diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab new file mode 100644 index 0000000000000000000000000000000000000000..442e5d37910e13c5333890cccf2725eb8f93e4f7 --- /dev/null +++ b/ci-scripts/Jenkinsfile-gitlab @@ -0,0 +1,106 @@ +// Comments + +pipeline { + agent { + label 'bellatrix' + } + options { + disableConcurrentBuilds() + timestamps() + gitLabConnection('OAI GitLab') + //gitlabBuilds(builds: ["Build", "Test"]) + gitlabBuilds(builds: ["Local Build"]) + } + + stages { + stage ("Verify Guidelines") { + steps { + echo "Git URL is ${GIT_URL}" + echo "GitLab Act is ${env.gitlabActionType}" + script { + if ("MERGE".equals(env.gitlabActionType)) { + // GitLab-Jenkins plugin integration is lacking to perform the merge by itself + // Doing it manually --> it may have merge conflicts + sh "./ci-scripts/doGitLabMerge.sh --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}" + + // Running astyle options on the list of modified files by the merge request + // For the moment, there is no fail criteria. Just a notification of number of files that do not follow + sh "./ci-scripts/checkCodingFormattingRules.sh --src-branch ${env.gitlabSourceBranch} --target-branch ${env.gitlabTargetBranch}" + def res=readFile('./oai_rules_result.txt').trim(); + if ("0".equals(res)) { + def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): All Changed files in Merge Request follow OAI Formatting Rules" + addGitLabMRComment comment: message + } else { + def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some Changed files in Merge Request DO NOT follow OAI Formatting Rules" + addGitLabMRComment comment: message + } + } else { + echo "Git Branch is ${GIT_BRANCH}" + echo "Git Commit is ${GIT_COMMIT}" + + // Running astyle options on all C/H files in the repository + // For the moment, there is no fail criteria. Just a notification of number of files that do not follow + sh "./ci-scripts/checkCodingFormattingRules.sh" + } + } + } + } + stage ("Local Build") { + steps { + gitlabCommitStatus(name: "Local Build") { + sh "./ci-scripts/buildLocally.sh --workspace $WORKSPACE" + } + } + post { + always { + script { + if(fileExists('archives/local_build_logs.zip')) { + archiveArtifacts artifacts: 'archives/local_build_logs.zip' + } + if ("MERGE".equals(env.gitlabActionType)) { + sh "./ci-scripts/reportBuildLocally.sh --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger merge-request --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}" + } else { + sh "./ci-scripts/reportBuildLocally.sh --git-url ${GIT_URL} --job-name ${JOB_NAME} --build-id ${BUILD_ID} --trigger push --branch ${GIT_BRANCH} --commit ${GIT_COMMIT}" + } + if(fileExists('build_results.html')) { + archiveArtifacts artifacts: 'build_results.html' + } + } + } + } + } + } + post { + always { + script { + echo "End of script" + } + } + success { + script { + def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ")" + if ("MERGE".equals(env.gitlabActionType)) { + echo "This is a MERGE event" + addGitLabMRComment comment: message + def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")" + slackSend channel: 'ci-enb', color: 'good', message: message2 + } else { + slackSend channel: 'ci-enb', color: 'good', message: message + } + } + } + failure { + script { + def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ")" + if ("MERGE".equals(env.gitlabActionType)) { + echo "This is a MERGE event" + addGitLabMRComment comment: message + def message2 = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")" + slackSend channel: 'ci-enb', color: 'danger', message: message2 + } else { + slackSend channel: 'ci-enb', color: 'danger', message: message + } + } + } + } +} diff --git a/ci-scripts/astyle-options.txt b/ci-scripts/astyle-options.txt new file mode 100644 index 0000000000000000000000000000000000000000..7f28bbb1f01d0a7c3bcae4c6614d9a38ed5a5db1 --- /dev/null +++ b/ci-scripts/astyle-options.txt @@ -0,0 +1,20 @@ +# OAI is using a style that is similar to the Google style +--style=google +# long options can be written without the preceding '--' +# Convert tabs to spaces +convert-tabs +# Indentation is 2 spaces +indent=spaces=2 +# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block. +indent-switches +# Indent C++ comments beginning in column one. +indent-col1-comments +# Pad empty lines around header blocks +break-blocks +delete-empty-lines +# Attach a pointer or reference operator (*, &, or ^) to the variable name (right) +align-pointer=name +# The code line length is 200 characters/columns +max-code-length=200 +break-after-logical +lineend=linux diff --git a/ci-scripts/buildLocally.sh b/ci-scripts/buildLocally.sh new file mode 100755 index 0000000000000000000000000000000000000000..67019508327a32e2cdf00c7f17d24c24d6918879 --- /dev/null +++ b/ci-scripts/buildLocally.sh @@ -0,0 +1,153 @@ +#!/bin/bash + +function usage { + echo "OAI Local Build Check script" + echo " Original Author: Raphael Defosseux" + echo "" + echo "Usage:" + echo "------" + echo " buildLocally.sh [OPTIONS]" + echo "" + echo "Options:" + echo "--------" + echo " --workspace #### OR -ws ####" + echo " Specify the workspace" + echo "" + echo " --help OR -h" + echo " Print this help message." + echo "" +} + +if [ $# -ne 2 ] && [ $# -ne 1 ] +then + echo "Syntax Error: not the correct number of arguments" + echo "" + usage + exit 1 +fi + +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -h|--help) + shift + usage + exit 0 + ;; + -ws|--workspace) + JENKINS_WKSP="$2" + shift + shift + ;; + *) + echo "Syntax Error: unknown option: $key" + echo "" + usage + exit 1 +esac +done + +cd $JENKINS_WKSP +STATUS=0 + +############################################################ +# Creating a tmp folder to store results and artifacts +############################################################ +if [ ! -d $JENKINS_WKSP/archives ] +then + mkdir $JENKINS_WKSP/archives +fi + +source oaienv +cd $JENKINS_WKSP/cmake_targets + +############################################################ +# Building eNb with USRP option +############################################################ +ARCHIVES_LOC=$JENKINS_WKSP/archives/enb_usrp +if [ ! -d $ARCHIVES_LOC ] +then + mkdir $ARCHIVES_LOC +fi +./build_oai --eNB -w USRP -c + +# Generated log files: +if [ -f $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target lte-softmodem" $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/lte-softmodem.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target params_libconfig" $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/params_libconfig.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target coding" $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/coding.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target oai_usrpdevif" $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/oai_usrpdevif.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi + +############################################################ +# Building basic simulator +############################################################ +ARCHIVES_LOC=$JENKINS_WKSP/archives/basic_sim +if [ ! -d $ARCHIVES_LOC ] +then + mkdir $ARCHIVES_LOC +fi +cd $JENKINS_WKSP/cmake_targets +./build_oai --basic-simulator -c + +# Generated log files: +if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt ] +then + LOCAL_STAT=`egrep -c "Built target lte-softmodem" $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_enb.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt ] +then + LOCAL_STAT=`egrep -c "Built target lte-uesoftmodem" $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/basic_simulator_ue.txt $ARCHIVES_LOC +else + STATUS=-1 +fi +if [ -f $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt ] +then + LOCAL_STAT=`egrep -c "Built target conf2uedata" $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt` + if [ $LOCAL_STAT -eq 0 ]; then STATUS=-1; fi + cp $JENKINS_WKSP/cmake_targets/log/conf2uedata.Rel14.txt $ARCHIVES_LOC +else + STATUS=-1 +fi + +############################################################ +# Creating a zip for Jenkins archiving +############################################################ +cd $JENKINS_WKSP/archives/ +zip -r local_build_logs.zip basic_sim enb_usrp + +exit $STATUS diff --git a/ci-scripts/checkCodingFormattingRules.sh b/ci-scripts/checkCodingFormattingRules.sh new file mode 100755 index 0000000000000000000000000000000000000000..20657b7fd0ade53a3f4e67a5264e3a95fb545afa --- /dev/null +++ b/ci-scripts/checkCodingFormattingRules.sh @@ -0,0 +1,121 @@ +#!/bin/bash + +function usage { + echo "OAI Coding / Formatting Guideline Check script" + echo " Original Author: Raphael Defosseux" + echo "" + echo " Requirement: astyle shall be installed" + echo "" + echo " By default (no options) the complete repository will be checked" + echo " In case of merge request, provided source and target branch," + echo " the script will check only the modified files" + echo "" + echo "Usage:" + echo "------" + echo " checkCodingFormattingRules.sh [OPTIONS]" + echo "" + echo "Options:" + echo "--------" + echo " --src-branch #### OR -sb ####" + echo " Specify the source branch of the merge request." + echo "" + echo " --target-branch #### OR -tb ####" + echo " Specify the target branch of the merge request (usually develop)." + echo "" + echo " --help OR -h" + echo " Print this help message." + echo "" +} + +if [ $# -ne 4 ] && [ $# -ne 1 ] && [ $# -ne 0 ] +then + echo "Syntax Error: not the correct number of arguments" + echo "" + usage + exit 1 +fi + +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 ` + echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT" + echo $NB_FILES_TO_FORMAT > ./oai_rules_result.txt + exit 0 +fi + +checker=0 +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -h|--help) + shift + usage + exit 0 + ;; + -sb|--src-branch) + SOURCE_BRANCH="$2" + let "checker|=0x1" + shift + shift + ;; + -tb|--target-branch) + TARGET_BRANCH="$2" + let "checker|=0x2" + shift + shift + ;; + *) + echo "Syntax Error: unknown option: $key" + echo "" + usage + exit 1 +esac + +done + + +if [ $checker -ne 3 ] +then + echo "Source Branch is : $SOURCE_BRANCH" + echo "Target Branch is : $TARGET_BRANCH" + echo "" + echo "Syntax Error: missing option" + echo "" + usage + exit 1 +fi + +# Merge request scenario + +MERGE_COMMMIT=`git log -n1 | grep commit | sed -e "s@commit @@"` +TARGET_INIT_COMMIT=`cat .git/refs/remotes/origin/$TARGET_BRANCH` + +echo " ---- Checking the modified files by the merge request ----" +echo "" +echo "Source Branch is : $SOURCE_BRANCH" +echo "Target Branch is : $TARGET_BRANCH" +echo "Merged Commit is : $MERGE_COMMMIT" +echo "Target Init is : $TARGET_INIT_COMMIT" + +# Retrieve the list of modified files since the latest develop commit +MODIFIED_FILES=`git log $TARGET_INIT_COMMIT..$MERGE_COMMMIT --oneline --name-status | egrep "^M|^A" | sed -e "s@^M\t*@@" -e "s@^A\t*@@" | sort | uniq` +NB_TO_FORMAT=0 +for FULLFILE in $MODIFIED_FILES +do + echo $FULLFILE + filename=$(basename -- "$FULLFILE") + EXT="${filename##*.}" + if [ $EXT = "c" ] || [ $EXT = "h" ] || [ $EXT = "cpp" ] || [ $EXT = "hpp" ] + then + TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt $FULLFILE | grep -c Formatted ` + NB_TO_FORMAT=$((NB_TO_FORMAT + TO_FORMAT)) + fi +done +echo "Nb Files that do NOT follow OAI rules: $NB_TO_FORMAT" +echo $NB_TO_FORMAT > ./oai_rules_result.txt + +exit 0 diff --git a/ci-scripts/doGitLabMerge.sh b/ci-scripts/doGitLabMerge.sh new file mode 100755 index 0000000000000000000000000000000000000000..cc6f38c81063b3f7dc370d428fe4f8205f4eb950 --- /dev/null +++ b/ci-scripts/doGitLabMerge.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +function usage { + echo "OAI GitLab merge request applying script" + echo " Original Author: Raphael Defosseux" + echo "" + echo "Usage:" + echo "------" + echo "" + echo " doGitLabMerge.sh [OPTIONS] [MANDATORY_OPTIONS]" + echo "" + echo "Mandatory Options:" + echo "------------------" + echo "" + echo " --src-branch #### OR -sb ####" + echo " Specify the source branch of the merge request." + echo "" + echo " --src-commit #### OR -sc ####" + echo " Specify the source commit ID (SHA-1) of the merge request." + echo "" + echo " --target-branch #### OR -tb ####" + echo " Specify the target branch of the merge request (usually develop)." + echo "" + echo " --target-commit #### OR -tc ####" + echo " Specify the target commit ID (SHA-1) of the merge request." + echo "" + echo "Options:" + echo "--------" + echo " --help OR -h" + echo " Print this help message." + echo "" +} + +if [ $# -ne 8 ] && [ $# -ne 1 ] +then + echo "Syntax Error: not the correct number of arguments" + echo "" + usage + exit 1 +fi + +checker=0 +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -h|--help) + shift + usage + exit 0 + ;; + -sb|--src-branch) + SOURCE_BRANCH="$2" + let "checker|=0x1" + shift + shift + ;; + -sc|--src-commit) + SOURCE_COMMIT_ID="$2" + let "checker|=0x2" + shift + shift + ;; + -tb|--target-branch) + TARGET_BRANCH="$2" + let "checker|=0x4" + shift + shift + ;; + -tc|--target-commit) + TARGET_COMMIT_ID="$2" + let "checker|=0x8" + shift + shift + ;; + *) + echo "Syntax Error: unknown option: $key" + echo "" + usage + exit 1 +esac + +done + +echo "Source Branch is : $SOURCE_BRANCH" +echo "Source Commit ID is : $SOURCE_COMMIT_ID" +echo "Target Branch is : $TARGET_BRANCH" +echo "Target Commit ID is : $TARGET_COMMIT_ID" + +if [ $checker -ne 15 ] +then + echo "" + echo "Syntax Error: missing option" + echo "" + usage + exit 1 +fi + +git config user.email "jenkins@openairinterface.org" +git config user.name "OAI Jenkins" + +git checkout -f $SOURCE_COMMIT_ID + +git merge --ff $TARGET_COMMIT_ID -m "Temporary merge for CI" + +exit 0 + + diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh new file mode 100755 index 0000000000000000000000000000000000000000..d3dd1f52a0af51f53379caba8c71def2c6282b4b --- /dev/null +++ b/ci-scripts/reportBuildLocally.sh @@ -0,0 +1,535 @@ +#!/bin/bash + +function usage { + echo "OAI Local Build Report script" + echo " Original Author: Raphael Defosseux" + echo "" + echo "Usage:" + echo "------" + echo "" + echo " reportBuildLocally.sh [OPTIONS]" + echo "" + echo "Options:" + echo "--------" + echo "" + echo " --help OR -h" + echo " Print this help message." + echo "" + echo "Job Options:" + echo "------------" + echo "" + echo " --git-url #### OR -gu ####" + echo " Specify the URL of the GIT Repository." + echo "" + echo " --job-name #### OR -jn ####" + echo " Specify the name of the Jenkins job." + echo "" + echo " --build-id #### OR -id ####" + echo " Specify the build ID of the Jenkins job." + echo "" + echo " --trigger merge-request OR -mr" + echo " --trigger push OR -pu" + echo " Specify trigger action of the Jenkins job. Either a merge-request event or a push event." + echo "" + echo "Merge-Request Options:" + echo "----------------------" + echo "" + echo " --src-branch #### OR -sb ####" + echo " Specify the source branch of the merge request." + echo "" + echo " --src-commit #### OR -sc ####" + echo " Specify the source commit ID (SHA-1) of the merge request." + echo "" + echo " --target-branch #### OR -tb ####" + echo " Specify the target branch of the merge request (usually develop)." + echo "" + echo " --target-commit #### OR -tc ####" + echo " Specify the target commit ID (SHA-1) of the merge request." + echo "" + echo "Push Options:" + echo "----------------------" + echo "" + echo " --branch #### OR -br ####" + echo " Specify the branch of the push event." + echo "" + echo " --commit #### OR -co ####" + echo " Specify the commit ID (SHA-1) of the push event." + echo "" + echo "" +} + +function trigger_usage { + echo "OAI Local Build Report script" + echo " Original Author: Raphael Defosseux" + echo "" + echo " --trigger merge-request OR -mr" + echo " --trigger push OR -pu" + echo " Specify trigger action of the Jenkins job. Either a merge-request event or a push event." + echo "" +} + +jb_checker=0 +mr_checker=0 +pu_checker=0 +MR_TRIG=0 +PU_TRIG=0 +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -h|--help) + shift + usage + exit 0 + ;; + -gu|--git-url) + GIT_URL="$2" + let "jb_checker|=0x1" + shift + shift + ;; + -jn|--job-name) + JOB_NAME="$2" + let "jb_checker|=0x2" + shift + shift + ;; + -id|--build-id) + BUILD_ID="$2" + let "jb_checker|=0x4" + shift + shift + ;; + --trigger) + TRIG="$2" + case $TRIG in + merge-request) + MR_TRIG=1 + ;; + push) + PU_TRIG=1 + ;; + *) + echo "" + echo "Syntax Error: Invalid Trigger option -> $TRIG" + echo "" + trigger_usage + exit + ;; + esac + let "jb_checker|=0x8" + shift + shift + ;; + -mr) + MR_TRIG=1 + let "jb_checker|=0x8" + shift + ;; + -pu) + PU_TRIG=1 + let "jb_checker|=0x8" + shift + ;; + -sb|--src-branch) + SOURCE_BRANCH="$2" + let "mr_checker|=0x1" + shift + shift + ;; + -sc|--src-commit) + SOURCE_COMMIT_ID="$2" + let "mr_checker|=0x2" + shift + shift + ;; + -tb|--target-branch) + TARGET_BRANCH="$2" + let "mr_checker|=0x4" + shift + shift + ;; + -tc|--target-commit) + TARGET_COMMIT_ID="$2" + let "mr_checker|=0x8" + shift + shift + ;; + -br|--branch) + SOURCE_BRANCH="$2" + let "pu_checker|=0x1" + shift + shift + ;; + -co|--commit) + SOURCE_COMMIT_ID="$2" + let "pu_checker|=0x2" + shift + shift + ;; + *) + echo "Syntax Error: unknown option: $key" + echo "" + usage + exit 1 + ;; +esac + +done + +if [ $jb_checker -ne 15 ] +then + echo "" + echo "Syntax Error: missing job information." + # TODO : list missing info + echo "" + exit 1 +fi + +if [ $PU_TRIG -eq 1 ] && [ $MR_TRIG -eq 1 ] +then + echo "" + echo "Syntax Error: trigger action incoherent." + echo "" + trigger_usage + exit 1 +fi + +if [ $PU_TRIG -eq 1 ] +then + if [ $pu_checker -ne 3 ] + then + echo "" + echo "Syntax Error: missing push information." + # TODO : list missing info + echo "" + exit 1 + fi +fi + +if [ $MR_TRIG -eq 1 ] +then + if [ $mr_checker -ne 15 ] + then + echo "" + echo "Syntax Error: missing merge-request information." + # TODO : list missing info + echo "" + exit 1 + fi +fi + +echo "<!DOCTYPE html>" > ./build_results.html +echo "<html class=\"no-js\" lang=\"en-US\">" >> ./build_results.html +echo "<head>" >> ./build_results.html +echo " <title>Build Results for $JOB_NAME job build #$BUILD_ID</title>" >> ./build_results.html +echo "</head>" >> ./build_results.html +echo "<body>" >> ./build_results.html +echo " <h1>Job Summary -- Job: $JOB_NAME -- Build-ID: $BUILD_ID</h1>" >> ./build_results.html +echo " <table border = \"1\">" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >GIT Repository</td>" >> ./build_results.html +echo " <td>$GIT_URL</td>" >> ./build_results.html +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >Job Trigger</td>" >> ./build_results.html +if [ $PU_TRIG -eq 1 ]; then echo " <td>Push Event</td>" >> ./build_results.html; fi +if [ $MR_TRIG -eq 1 ]; then echo " <td>Merge-Request</td>" >> ./build_results.html; fi +echo " </tr>" >> ./build_results.html +if [ $PU_TRIG -eq 1 ] +then + echo " <tr>" >> ./build_results.html + echo " <td bgcolor = \"lightcyan\" >Branch</td>" >> ./build_results.html + echo " <td>$SOURCE_BRANCH</td>" >> ./build_results.html + echo " </tr>" >> ./build_results.html + echo " <tr>" >> ./build_results.html + echo " <td bgcolor = \"lightcyan\" >Commit ID</td>" >> ./build_results.html + echo " <td>$SOURCE_COMMIT_ID</td>" >> ./build_results.html + echo " </tr>" >> ./build_results.html +fi +if [ $MR_TRIG -eq 1 ] +then + echo " <tr>" >> ./build_results.html + echo " <td bgcolor = \"lightcyan\" >Source Branch</td>" >> ./build_results.html + echo " <td>$SOURCE_BRANCH</td>" >> ./build_results.html + echo " </tr>" >> ./build_results.html + echo " <tr>" >> ./build_results.html + echo " <td bgcolor = \"lightcyan\" >Source Commit ID</td>" >> ./build_results.html + echo " <td>$SOURCE_COMMIT_ID</td>" >> ./build_results.html + echo " </tr>" >> ./build_results.html + echo " <tr>" >> ./build_results.html + echo " <td bgcolor = \"lightcyan\" >Target Branch</td>" >> ./build_results.html + echo " <td>$TARGET_BRANCH</td>" >> ./build_results.html + echo " </tr>" >> ./build_results.html + echo " <tr>" >> ./build_results.html + echo " <td bgcolor = \"lightcyan\" >Target Commit ID</td>" >> ./build_results.html + echo " <td>$TARGET_COMMIT_ID</td>" >> ./build_results.html + echo " </tr>" >> ./build_results.html +fi +echo " </table>" >> ./build_results.html +echo " <h2>Build Summary</h2>" >> ./build_results.html + +if [ -f ./oai_rules_result.txt ] +then + echo " <h3>OAI Coding / Formatting Guidelines Check</h3>" >> ./build_results.html + echo " <table border = "1">" >> ./build_results.html + echo " <tr>" >> ./build_results.html + echo " <td bgcolor = \"lightcyan\" >Result:</td>" >> ./build_results.html + NB_FILES=`cat ./oai_rules_result.txt` + if [ $NB_FILES = "0" ] + then + if [ $PU_TRIG -eq 1 ]; then echo " <td bgcolor = \"green\">All files in repository follow OAI rules. </td>" >> ./build_results.html; fi + if [ $MR_TRIG -eq 1 ]; then echo " <td bgcolor = \"green\">All modified files in Merge-Request follow OAI rules.</td>" >> ./build_results.html; fi + else + if [ $PU_TRIG -eq 1 ]; then echo " <td bgcolor = \"orange\">$NB_FILES files in repository DO NOT follow OAI rules. </td>" >> ./build_results.html; fi + if [ $MR_TRIG -eq 1 ]; then echo " <td bgcolor = \"orange\">$NB_FILES modified files in Merge-Request DO NOT follow OAI rules.</td>" >> ./build_results.html; fi + fi + echo " </tr>" >> ./build_results.html + echo " </table>" >> ./build_results.html +fi + +echo " <h3>OAI Build eNb -- USRP option</h3>" >> ./build_results.html +echo " <table border = "1">" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <th>Element</th>" >> ./build_results.html +echo " <th>Status</th>" >> ./build_results.html +echo " <th>Nb Errors</th>" >> ./build_results.html +echo " <th>Nb Warnings</th>" >> ./build_results.html +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >LTE SoftModem - Release 14</th>" >> ./build_results.html +if [ -f ./archives/enb_usrp/lte-softmodem.Rel14.txt ] +then + STATUS=`egrep -c "Built target lte-softmodem" ./archives/enb_usrp/lte-softmodem.Rel14.txt` + if [ $STATUS -eq 1 ] + then + echo " <td bgcolor = \"green\" >OK</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >KO</th>" >> ./build_results.html + fi + STATUS=`egrep -c "error:" ./archives/enb_usrp/lte-softmodem.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >$STATUS</th>" >> ./build_results.html + fi + STATUS=`egrep -c "warning:" ./archives/enb_usrp/lte-softmodem.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"orange\" >$STATUS</th>" >> ./build_results.html + fi +else + echo " <td bgcolor = \"lightgray\" >Unknown</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html +fi +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >Coding - Release 14</th>" >> ./build_results.html +if [ -f ./archives/enb_usrp/coding.Rel14.txt ] +then + STATUS=`egrep -c "Built target coding" ./archives/enb_usrp/coding.Rel14.txt` + if [ $STATUS -eq 1 ] + then + echo " <td bgcolor = \"green\" >OK</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >KO</th>" >> ./build_results.html + fi + STATUS=`egrep -c "error:" ./archives/enb_usrp/coding.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >$STATUS</th>" >> ./build_results.html + fi + STATUS=`egrep -c "warning:" ./archives/enb_usrp/coding.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"orange\" >$STATUS</th>" >> ./build_results.html + fi +else + echo " <td bgcolor = \"lightgray\" >Unknown</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html +fi +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >OAI USRP device if - Release 14</th>" >> ./build_results.html +if [ -f ./archives/enb_usrp/oai_usrpdevif.Rel14.txt ] +then + STATUS=`egrep -c "Built target oai_usrpdevif" ./archives/enb_usrp/oai_usrpdevif.Rel14.txt` + if [ $STATUS -eq 1 ] + then + echo " <td bgcolor = \"green\" >OK</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >KO</th>" >> ./build_results.html + fi + STATUS=`egrep -c "error:" ./archives/enb_usrp/oai_usrpdevif.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >$STATUS</th>" >> ./build_results.html + fi + STATUS=`egrep -c "warning:" ./archives/enb_usrp/oai_usrpdevif.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"orange\" >$STATUS</th>" >> ./build_results.html + fi +else + echo " <td bgcolor = \"lightgray\" >Unknown</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html +fi +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >Parameters Lib Config - Release 14</th>" >> ./build_results.html +if [ -f ./archives/enb_usrp/params_libconfig.Rel14.txt ] +then + STATUS=`egrep -c "Built target params_libconfig" ./archives/enb_usrp/params_libconfig.Rel14.txt` + if [ $STATUS -eq 1 ] + then + echo " <td bgcolor = \"green\" >OK</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >KO</th>" >> ./build_results.html + fi + STATUS=`egrep -c "error:" ./archives/enb_usrp/params_libconfig.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >$STATUS</th>" >> ./build_results.html + fi + STATUS=`egrep -c "warning:" ./archives/enb_usrp/params_libconfig.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"orange\" >$STATUS</th>" >> ./build_results.html + fi +else + echo " <td bgcolor = \"lightgray\" >Unknown</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html +fi +echo " </tr>" >> ./build_results.html +echo " </table>" >> ./build_results.html + +# conf2uedata.Rel14.txt +# archives/basic_sim + +echo " <h3>OAI Build basic simulator option</h3>" >> ./build_results.html +echo " <table border = "1">" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <th>Element</th>" >> ./build_results.html +echo " <th>Status</th>" >> ./build_results.html +echo " <th>Nb Errors</th>" >> ./build_results.html +echo " <th>Nb Warnings</th>" >> ./build_results.html +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >Basic Simulator eNb - Release 14</th>" >> ./build_results.html +if [ -f ./archives/basic_sim/basic_simulator_enb.txt ] +then + STATUS=`egrep -c "Built target lte-softmodem" ./archives/basic_sim/basic_simulator_enb.txt` + if [ $STATUS -eq 1 ] + then + echo " <td bgcolor = \"green\" >OK</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >KO</th>" >> ./build_results.html + fi + STATUS=`egrep -c "error:" ./archives/basic_sim/basic_simulator_enb.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >$STATUS</th>" >> ./build_results.html + fi + STATUS=`egrep -c "warning:" ./archives/basic_sim/basic_simulator_enb.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"orange\" >$STATUS</th>" >> ./build_results.html + fi +else + echo " <td bgcolor = \"lightgray\" >Unknown</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html +fi +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >Basic Simulator UE - Release 14</th>" >> ./build_results.html +if [ -f ./archives/basic_sim/basic_simulator_ue.txt ] +then + STATUS=`egrep -c "Built target lte-uesoftmodem" ./archives/basic_sim/basic_simulator_ue.txt` + if [ $STATUS -eq 1 ] + then + echo " <td bgcolor = \"green\" >OK</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >KO</th>" >> ./build_results.html + fi + STATUS=`egrep -c "error:" ./archives/basic_sim/basic_simulator_ue.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >$STATUS</th>" >> ./build_results.html + fi + STATUS=`egrep -c "warning:" ./archives/basic_sim/basic_simulator_ue.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"orange\" >$STATUS</th>" >> ./build_results.html + fi +else + echo " <td bgcolor = \"lightgray\" >Unknown</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html +fi +echo " </tr>" >> ./build_results.html +echo " <tr>" >> ./build_results.html +echo " <td bgcolor = \"lightcyan\" >Conf 2 UE data - Release 14</th>" >> ./build_results.html +if [ -f ./archives/basic_sim/conf2uedata.Rel14.txt ] +then + STATUS=`egrep -c "Built target conf2uedata" ./archives/basic_sim/conf2uedata.Rel14.txt` + if [ $STATUS -eq 1 ] + then + echo " <td bgcolor = \"green\" >OK</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >KO</th>" >> ./build_results.html + fi + STATUS=`egrep -c "error:" ./archives/basic_sim/conf2uedata.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"red\" >$STATUS</th>" >> ./build_results.html + fi + STATUS=`egrep -c "warning:" ./archives/basic_sim/conf2uedata.Rel14.txt` + if [ $STATUS -eq 0 ] + then + echo " <td bgcolor = \"green\" >$STATUS</th>" >> ./build_results.html + else + echo " <td bgcolor = \"orange\" >$STATUS</th>" >> ./build_results.html + fi +else + echo " <td bgcolor = \"lightgray\" >Unknown</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html + echo " <td bgcolor = \"lightgray\" >--</th>" >> ./build_results.html +fi +echo " </tr>" >> ./build_results.html +echo " </table>" >> ./build_results.html + +echo "</body>" >> ./build_results.html +echo "</html>" >> ./build_results.html + +exit 0 diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c0b864182e63bf447d0ad7b7f21b9befd4e6c739..4d154fc34e9daa33786f82c1e0589f8b26283a64 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -113,6 +113,14 @@ macro(add_list_string_option name val helpstr) add_definitions("-D${name}=\"${value}\"") endif() endmacro(add_list_string_option) + +function(make_version VERSION_VALUE) + math(EXPR RESULT "0") + foreach (ARG ${ARGN}) + math(EXPR RESULT "${RESULT} * 16 + ${ARG}") + endforeach() + set(${VERSION_VALUE} "${RESULT}" PARENT_SCOPE) +endfunction() #################################################### # compilation flags ############################################# @@ -162,7 +170,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC ") # add autotools definitions that were maybe used! set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP" + "${CMAKE_C_FLAGS} -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP -D'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -std=c++11 " @@ -243,6 +251,8 @@ add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace") add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace") add_boolean_option(DISABLE_LOG_X False "Deactivate all LOG_* macros") add_boolean_option(USRP_REC_PLAY False "Enable USRP record playback mode") +add_boolean_option(UE_NAS_USE_TUN False "Enable UE NAS TUN device instead of ue_ip.ko") +add_boolean_option(BASIC_SIMULATOR False "Has to be True when building the basic simulator, False otherwise") add_boolean_option(DEBUG_CONSOLE False "makes debugging easier, disables stdout/stderr buffering") @@ -284,16 +294,21 @@ set(protobuf_generated_dir ${OPENAIR_BIN_DIR}) add_list2_option(RRC_ASN1_VERSION "Rel14" "ASN.1 version of RRC interface" "Rel8" "Rel10" "Rel14" "CBA") if (${RRC_ASN1_VERSION} STREQUAL "Rel8") - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn) + make_version(RRC_VERSION 8 6 0) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn) elseif (${RRC_ASN1_VERSION} STREQUAL "CBA") - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn) + make_version(RRC_VERSION 10 2 0) + add_definitions(-DCBA) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn) elseif (${RRC_ASN1_VERSION} STREQUAL "Rel10") - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn) + make_version(RRC_VERSION 10 2 0) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn) else() - set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn) + make_version(RRC_VERSION 14 3 0) + set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn) endif (${RRC_ASN1_VERSION} STREQUAL "Rel8") - -set (RRC_FULL_DIR ${asn1_generated_dir}/${RRC_ASN1_VERSION}) +add_definitions(-DRRC_VERSION=${RRC_VERSION}) +set (RRC_FULL_DIR ${asn1_generated_dir}/RRC_${RRC_ASN1_VERSION}) if(NOT EXISTS ${asn1c_call}) message( FATAL_ERROR "The script ${asn1c_call} must be present" ) endif(NOT EXISTS ${asn1c_call}) @@ -315,8 +330,8 @@ file(GLOB rrc_h ${RRC_FULL_DIR}/*.h) set(rrc_h ${rrc_h} ${RRC_FULL_DIR}/asn1_constants.h) set_source_files_properties(${rrc_source} PROPERTIES COMPILE_FLAGS -w) # suppress warnings from generated code add_library(RRC_LIB ${rrc_h} ${rrc_source} - ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1_msg.c - ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c) + ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg.c + ${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c) include_directories ("${RRC_FULL_DIR}") # add the command to generate the source code @@ -332,18 +347,20 @@ add_custom_command ( # Same limitation as described in RRC: unknown generated file list # so we generate it at cmake time ############## -add_list1_option(S1AP_VERSION R10 "S1AP Asn.1 grammar version" R8 R9 R10) +add_list1_option(S1AP_RELEASE R10 "S1AP ASN.1 grammar version" R8 R9 R10) set(S1AP_DIR ${OPENAIR3_DIR}/S1AP) -if (${S1AP_VERSION} STREQUAL "R10") - set (ASN1RELDIR R10.5) - add_definitions("-DUPDATE_RELEASE_9 -DUPDATE_RELEASE_10") -elseif (${S1AP_VERSION} STREQUAL "R9") - set (ASN1RELDIR R9.8) - add_definitions("-DUPDATE_RELEASE_9") -else(${S1AP_VERSION} STREQUAL "R8") +if (${S1AP_RELEASE} STREQUAL "R8") + make_version(S1AP_VERSION 8 10 0) set (ASN1RELDIR R8.10) -endif(${S1AP_VERSION} STREQUAL "R10") +elseif (${S1AP_RELEASE} STREQUAL "R9") + make_version(S1AP_VERSION 9 8 0) + set (ASN1RELDIR R9.8) +elseif (${S1AP_RELEASE} STREQUAL "R10") + make_version(S1AP_VERSION 10 5 0) + set (ASN1RELDIR R10.5) +endif(${S1AP_RELEASE} STREQUAL "R8") +add_definitions(-DS1AP_VERSION=${S1AP_VERSION}) set(S1AP_ASN_DIR ${S1AP_DIR}/MESSAGES/ASN1/${ASN1RELDIR}) set(S1AP_ASN_FILES ${S1AP_ASN_DIR}/S1AP-CommonDataTypes.asn @@ -351,7 +368,7 @@ set(S1AP_ASN_FILES ${S1AP_ASN_DIR}/S1AP-IEs.asn ${S1AP_ASN_DIR}/S1AP-PDU.asn ) -set(S1AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) +set(S1AP_C_DIR ${asn1_generated_dir}/S1AP_${ASN1RELDIR}) #message("calling ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}") execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES} RESULT_VARIABLE ret) @@ -363,7 +380,7 @@ execute_process(COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1A if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "asn1tostruct.py: error") endif (NOT ${ret} STREQUAL 0) -execute_process(COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} +execute_process(COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_RELEASE} RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${fix_asn1c_call}: error") @@ -384,7 +401,7 @@ add_custom_command ( OUTPUT ${S1AP_OAI_generated} COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES} COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR} - COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} + COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_RELEASE} DEPENDS ${S1AP_ASN_FILES} ) add_library(S1AP_LIB @@ -418,13 +435,16 @@ add_library(S1AP_ENB # Same limitation as described in RRC/S1AP: unknown generated file list # so we generate it at cmake time ############## -add_list1_option(X2AP_VERSION R11 "X2AP Asn.1 grammar version" R10 R11) +add_list1_option(X2AP_RELEASE R11 "X2AP ASN.1 grammar version" R10 R11) set(X2AP_DIR ${OPENAIR2_DIR}/X2AP) -if (${X2AP_VERSION} STREQUAL "R11") - set (ASN1RELDIR R11.2) -elseif (${X2AP_VERSION} STREQUAL "R10") +if (${X2AP_RELEASE} STREQUAL "R10") + make_version(S1AP_VERSION 10 0 0) set (ASN1RELDIR R.UNKNOWN) -endif(${X2AP_VERSION} STREQUAL "R11") +elseif (${X2AP_RELEASE} STREQUAL "R11") + make_version(S1AP_VERSION 11 2 0) + set (ASN1RELDIR R11.2) +endif(${X2AP_RELEASE} STREQUAL "R10") +add_definitions(-DX2AP_VERSION=${X2AP_VERSION}) set(X2AP_ASN_DIR ${X2AP_DIR}/MESSAGES/ASN1/${ASN1RELDIR}) set(X2AP_ASN_FILES ${X2AP_ASN_DIR}/X2AP-CommonDataTypes.asn @@ -434,7 +454,7 @@ set(X2AP_ASN_FILES ${X2AP_ASN_DIR}/X2AP-Containers.asn ) -set(X2AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) +set(X2AP_C_DIR ${asn1_generated_dir}/X2AP_${ASN1RELDIR}) #message("calling ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}") execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES} RESULT_VARIABLE ret) @@ -446,7 +466,7 @@ execute_process(COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2 if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "asn1tostruct.py: error") endif (NOT ${ret} STREQUAL 0) -execute_process(COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} +execute_process(COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_RELEASE} RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${fix_asn1c_call}: error") @@ -467,7 +487,7 @@ add_custom_command ( OUTPUT ${X2AP_OAI_generated} COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES} COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR} - COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} + COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_RELEASE} DEPENDS ${X2AP_ASN_FILES} ) @@ -633,14 +653,26 @@ add_library(oai_mobipass MODULE ${TPLIB_MOBIPASS_SOURCE} ) get_target_property(mobipas_cflags oai_mobipass COMPILE_FLAGS) set_target_properties(oai_mobipass PROPERTIES COMPILE_FLAGS "${mobipass_cflags} -fvisibility=hidden") +# 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(oai_tcp_bridge MODULE ${HWLIB_TCP_BRIDGE_SOURCE} ) +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") -#get_target_property(tcp_bridge_cflags oai_tcp_bridge COMPILE_FLAGS) -#set_target_properties(oai_tcp_bridge PROPERTIES COMPILE_FLAGS "${tcp_bridge_cflags} -fvisibility=hidden") -set_target_properties(oai_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") ########################################################## @@ -705,12 +737,6 @@ add_boolean_option(DEBUG_PHY False "Enable PHY layer debugging opt add_boolean_option(DEBUG_PHY_PROC False "Enable debugging of PHY layer procedures") add_boolean_option(DEBUG_DLSCH False "Enable debugging of DLSCH physical layer channel") -########################## -# 802.21 options -########################## -add_boolean_option(ENABLE_RAL False "ENABLE 802.21 INTERFACE") -add_boolean_option(USE_3GPP_ADDR_AS_LINK_ADDR False "As per attribute name") - ########################## # NAS LAYER OPTIONS ########################## @@ -779,7 +805,7 @@ include_directories("${OPENAIR_BIN_DIR}") # add directories to find all include files # the internal rule is to use generic names such as defs.h # but to make it uniq name as adding the relative path in the include directtive -# example: #include "RRC/LITE/defs.h" +# example: #include "RRC/LTE/rrc_defs.h" #find_path (include_dirs_all *.h ${OPENAIR_DIR}) #find_path (include_dirs_all *.h PATHS /usr/include NO_CMAKE_PATH) #include_directories("${include_dirs_all}") @@ -813,11 +839,8 @@ include_directories("${OPENAIR2_DIR}/LAYER2/RLC/AM_v9.3.0") include_directories("${OPENAIR2_DIR}/LAYER2/RLC/UM_v9.3.0") include_directories("${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0") include_directories("${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0") -include_directories("${OPENAIR2_DIR}/RRC/LITE/MESSAGES") -include_directories("${OPENAIR2_DIR}/RRC/LITE") -include_directories("${OPENAIR3_DIR}/RAL-LTE/INTERFACE-802.21/INCLUDE") -include_directories("${OPENAIR3_DIR}/RAL-LTE/LTE_RAL_ENB/INCLUDE") -include_directories("${OPENAIR3_DIR}/RAL-LTE/LTE_RAL_UE/INCLUDE") +include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES") +include_directories("${OPENAIR2_DIR}/RRC/LTE") include_directories("${OPENAIR_DIR}/common/utils") include_directories("${OPENAIR_DIR}/common/utils/itti") include_directories("${OPENAIR3_DIR}/NAS/COMMON") @@ -854,7 +877,7 @@ include_directories("${OPENAIR2_DIR}/UTIL/OTG") include_directories("${OPENAIR2_DIR}/UTIL/CLI") include_directories("${OPENAIR2_DIR}/UTIL/OPT") include_directories("${OPENAIR2_DIR}/UTIL/OMV") -include_directories("${OPENAIR2_DIR}/RRC/LITE/MESSAGES") +include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES") include_directories("${OPENAIR3_DIR}/GTPV1-U/nw-gtpv1u/shared") include_directories("${OPENAIR3_DIR}/GTPV1-U/nw-gtpv1u/include") include_directories("${OPENAIR_DIR}") @@ -1025,9 +1048,9 @@ endif() include_directories(${OPENAIR_DIR}/common/utils/msc) set(UTIL_SRC - ${OPENAIR2_DIR}/UTIL/CLI/cli.c - ${OPENAIR2_DIR}/UTIL/CLI/cli_cmd.c - ${OPENAIR2_DIR}/UTIL/CLI/cli_server.c +# ${OPENAIR2_DIR}/UTIL/CLI/cli.c +# ${OPENAIR2_DIR}/UTIL/CLI/cli_cmd.c +# ${OPENAIR2_DIR}/UTIL/CLI/cli_server.c ${OPENAIR2_DIR}/UTIL/FIFO/pad_list.c ${OPENAIR2_DIR}/UTIL/LISTS/list.c ${OPENAIR2_DIR}/UTIL/LISTS/list2.c @@ -1035,32 +1058,32 @@ set(UTIL_SRC ${OPENAIR2_DIR}/UTIL/LOG/vcd_signal_dumper.c ${OPENAIR2_DIR}/UTIL/MATH/oml.c ${OPENAIR2_DIR}/UTIL/MEM/mem_block.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_create_dir.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_detect_file.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_generate_report.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_filename.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_XML.c - ${OPENAIR2_DIR}/UTIL/OCG/OCG_save_XML.c - ${OPENAIR2_DIR}/UTIL/OMG/common.c - ${OPENAIR2_DIR}/UTIL/OMG/grid.c - ${OPENAIR2_DIR}/UTIL/OMG/job.c - ${OPENAIR2_DIR}/UTIL/OMG/mobility_parser.c - ${OPENAIR2_DIR}/UTIL/OMG/omg.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_create_dir.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_detect_file.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_generate_report.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_filename.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_parse_XML.c +# ${OPENAIR2_DIR}/UTIL/OCG/OCG_save_XML.c +# ${OPENAIR2_DIR}/UTIL/OMG/common.c +# ${OPENAIR2_DIR}/UTIL/OMG/grid.c +# ${OPENAIR2_DIR}/UTIL/OMG/job.c +# ${OPENAIR2_DIR}/UTIL/OMG/mobility_parser.c +# ${OPENAIR2_DIR}/UTIL/OMG/omg.c #${OPENAIR2_DIR}/UTIL/OMG/omg_hashtable.c - ${OPENAIR2_DIR}/UTIL/OMG/rwalk.c - ${OPENAIR2_DIR}/UTIL/OMG/rwp.c - ${OPENAIR2_DIR}/UTIL/OMG/static.c - ${OPENAIR2_DIR}/UTIL/OMG/steadystaterwp.c - ${OPENAIR2_DIR}/UTIL/OMG/trace.c - ${OPENAIR2_DIR}/UTIL/OMG/trace_hashtable.c +# ${OPENAIR2_DIR}/UTIL/OMG/rwalk.c +# ${OPENAIR2_DIR}/UTIL/OMG/rwp.c +# ${OPENAIR2_DIR}/UTIL/OMG/static.c +# ${OPENAIR2_DIR}/UTIL/OMG/steadystaterwp.c +# ${OPENAIR2_DIR}/UTIL/OMG/trace.c +# ${OPENAIR2_DIR}/UTIL/OMG/trace_hashtable.c ${OPENAIR2_DIR}/UTIL/OPT/probe.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_tx.c - ${OPENAIR2_DIR}/UTIL/OTG/otg.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_kpi.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_models.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_form.c - ${OPENAIR2_DIR}/UTIL/OTG/otg_rx.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_tx.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_kpi.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_models.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_form.c +# ${OPENAIR2_DIR}/UTIL/OTG/otg_rx.c ) add_library(UTIL ${UTIL_SRC}) @@ -1094,30 +1117,27 @@ set(SECU_CN_SRC ) add_library(SECU_CN ${SECU_CN_SRC}) -# Scheduler +# Physical Channel Procedures Scheduling ################################" set(SCHED_SRC ${OPENAIR1_DIR}/SCHED/fapi_l1.c ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_eNb.c - ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_ue.c ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c - ${OPENAIR1_DIR}/SCHED/prach_procedures.c - ${OPENAIR1_DIR}/SCHED/ru_procedures.c -# ${OPENAIR1_DIR}/SCHED/phy_mac_stub.c - ${OPENAIR1_DIR}/SCHED/pucch_pc.c - ${OPENAIR1_DIR}/SCHED/pusch_pc.c - ${OPENAIR1_DIR}/SCHED/srs_pc.c ) add_library(SCHED_LIB ${SCHED_SRC}) -set(SCHED_SRC_UE - ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_ue.c - ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c +set(SCHED_SRC_RU ${OPENAIR1_DIR}/SCHED/ru_procedures.c ${OPENAIR1_DIR}/SCHED/prach_procedures.c - ${OPENAIR1_DIR}/SCHED/pucch_pc.c - ${OPENAIR1_DIR}/SCHED/pusch_pc.c - ${OPENAIR1_DIR}/SCHED/srs_pc.c +) +add_library(SCHED_RU_LIB ${SCHED_SRC_RU}) + +set(SCHED_SRC_UE + ${OPENAIR1_DIR}/SCHED_UE/phy_procedures_lte_ue.c + ${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c + ${OPENAIR1_DIR}/SCHED_UE/pucch_pc.c + ${OPENAIR1_DIR}/SCHED_UE/pusch_pc.c + ${OPENAIR1_DIR}/SCHED_UE/srs_pc.c ) add_library(SCHED_UE_LIB ${SCHED_SRC_UE}) @@ -1188,64 +1208,26 @@ set(PHY_TURBOIF ) add_library(coding MODULE ${PHY_TURBOSRC} ) -set(PHY_SRC +set(PHY_SRC_COMMON # depend on code generation from asn1c ${RRC_FULL_DIR}/asn1_constants.h # actual source - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pss.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots_mbsfn.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_coding.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_modulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_demodulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/power_control.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_decoding.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/uci_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools_common.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pbch.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/edci.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pcfich.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pch.c +# ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slss.c +# ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sldch.c +# ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slsch.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/group_hopping.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/srs_modulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/drs_modulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_modulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_demodulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_coding.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_decoding.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/rar_tools.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/print_stats.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/initial_sync.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_tools.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pcfich_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/power_control.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch_common.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/srs_modulation.c ${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c - ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c - ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_mbsfn.c - ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_ul.c - ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz.c - ${OPENAIR1_DIR}/PHY/MODULATION/beamforming.c - ${OPENAIR1_DIR}/PHY/MODULATION/compute_bf_weights.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/freq_equalization.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_time.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_timefreq.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_est_freq_offset.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ue_measurements.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_eNB_measurements.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/adjust_gain.c ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_cell_spec.c ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_uespec.c ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold.c @@ -1255,14 +1237,12 @@ set(PHY_SRC ${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c + ${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c ${OPENAIR1_DIR}/PHY/CODING/crc_byte.c ${PHY_TURBOIF} ${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching.c ${OPENAIR1_DIR}/PHY/CODING/viterbi.c ${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c - ${OPENAIR1_DIR}/PHY/INIT/lte_init.c - ${OPENAIR1_DIR}/PHY/INIT/lte_init_ru.c - ${OPENAIR1_DIR}/PHY/INIT/lte_init_ue.c ${OPENAIR1_DIR}/PHY/INIT/init_top.c ${OPENAIR1_DIR}/PHY/INIT/lte_parms.c ${OPENAIR1_DIR}/PHY/INIT/lte_param_init.c @@ -1280,9 +1260,7 @@ set(PHY_SRC ${OPENAIR1_DIR}/PHY/TOOLS/lut.c ) -set(PHY_SRC_UE - # depend on code generation from asn1c - ${RRC_FULL_DIR}/asn1_constants.h +set(PHY_SRC # actual source ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pss.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/sss.c @@ -1290,86 +1268,75 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pilots_mbsfn.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_coding.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_modulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_demodulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/power_control.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_decoding.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_scrambling.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/uci_tools.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pbch.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/edci.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pcfich.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pucch.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pch.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/group_hopping.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/srs_modulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/drs_modulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_modulation.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_demodulation.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_coding.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/ulsch_decoding.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/rar_tools.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/print_stats.c - ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/initial_sync.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/uci_tools.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/freq_equalization.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_eNB_measurements.c + ${OPENAIR1_DIR}/PHY/INIT/lte_init.c + ) + +set(PHY_SRC_RU + # actual source ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_tools.c - ${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c - ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c - ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_mbsfn.c ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_ul.c ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz.c ${OPENAIR1_DIR}/PHY/MODULATION/beamforming.c ${OPENAIR1_DIR}/PHY/MODULATION/compute_bf_weights.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/freq_equalization.c + ${OPENAIR1_DIR}/PHY/INIT/lte_init_ru.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach.c + + ) + +set(PHY_SRC_UE + # actual source + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/sss_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pbch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dci_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/phich_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pcfich_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pucch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/prach_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pmch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/pch_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/slss.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/sldch.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/slsch.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/drs_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/ulsch_coding.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c + ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/initial_sync.c + ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c + ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_mbsfn.c + ${OPENAIR1_DIR}/PHY/MODULATION/ul_7_5_kHz_ue.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_time.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_timefreq.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync.c + ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_est_freq_offset.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ue_measurements.c - ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_eNB_measurements.c ${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/adjust_gain.c - ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_cell_spec.c - ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_uespec.c - ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold.c - ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold_mbsfn.c - ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_mbsfn.c - ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_ul_ref.c - ${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c - ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c - ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c - ${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c - ${OPENAIR1_DIR}/PHY/CODING/crc_byte.c - ${PHY_TURBOIF} - ${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching.c - ${OPENAIR1_DIR}/PHY/CODING/viterbi.c - ${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c - ${OPENAIR1_DIR}/PHY/INIT/lte_init_ru.c ${OPENAIR1_DIR}/PHY/INIT/lte_init_ue.c - ${OPENAIR1_DIR}/PHY/INIT/init_top.c - ${OPENAIR1_DIR}/PHY/INIT/lte_parms.c - ${OPENAIR1_DIR}/PHY/INIT/lte_param_init.c - ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c - ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c - ${OPENAIR1_DIR}/PHY/TOOLS/lte_dfts.c - ${OPENAIR1_DIR}/PHY/TOOLS/log2_approx.c - ${OPENAIR1_DIR}/PHY/TOOLS/cmult_sv.c - ${OPENAIR1_DIR}/PHY/TOOLS/cmult_vv.c - ${OPENAIR1_DIR}/PHY/TOOLS/cdot_prod.c - ${OPENAIR1_DIR}/PHY/TOOLS/signal_energy.c - ${OPENAIR1_DIR}/PHY/TOOLS/dB_routines.c - ${OPENAIR1_DIR}/PHY/TOOLS/sqrt.c - ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c - ${OPENAIR1_DIR}/PHY/TOOLS/lut.c ) if (${SMBV}) @@ -1377,12 +1344,13 @@ if (${SMBV}) endif (${SMBV}) if (${COMPILATION_AVX2} STREQUAL "True") - set(PHY_SRC ${PHY_SRC} ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c) - set(PHY_SRC_UE ${PHY_SRC_UE} ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c) + set(PHY_SRC_UE ${PHY_SRC_UE} ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c) endif () +add_library(PHY_COMMON ${PHY_SRC_COMMON}) add_library(PHY ${PHY_SRC}) add_library(PHY_UE ${PHY_SRC_UE}) +add_library(PHY_RU ${PHY_SRC_RU}) #Layer 2 library ##################### @@ -1392,7 +1360,7 @@ set(RLC_DIR ${OPENAIR2_DIR}/LAYER2/RLC) set(RLC_UM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/UM_v9.3.0) set(RLC_AM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/AM_v9.3.0) set(RLC_TM_DIR ${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0) -set(RRC_DIR ${OPENAIR2_DIR}/RRC/LITE) +set(RRC_DIR ${OPENAIR2_DIR}/RRC/LTE) set(PDCP_DIR ${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0) set(L2_SRC ${OPENAIR2_DIR}/LAYER2/openair2_proc.c @@ -1482,14 +1450,15 @@ set(L2_SRC_UE ) set (MAC_SRC + #${PHY_INTERFACE_DIR}/phy_stub_UE.c ${PHY_INTERFACE_DIR}/IF_Module.c ${MAC_DIR}/main.c - ${MAC_DIR}/main_ue.c - ${MAC_DIR}/ue_procedures.c - ${MAC_DIR}/ra_procedures.c + #${MAC_DIR}/main_ue.c + #${MAC_DIR}/ue_procedures.c + #${MAC_DIR}/ra_procedures.c ${MAC_DIR}/l1_helpers.c ${MAC_DIR}/rar_tools.c - ${MAC_DIR}/rar_tools_ue.c + #${MAC_DIR}/rar_tools_ue.c ${MAC_DIR}/eNB_scheduler.c ${MAC_DIR}/eNB_scheduler_dlsch.c ${MAC_DIR}/eNB_scheduler_ulsch.c @@ -1497,12 +1466,14 @@ set (MAC_SRC ${MAC_DIR}/eNB_scheduler_bch.c ${MAC_DIR}/eNB_scheduler_primitives.c ${MAC_DIR}/eNB_scheduler_RA.c + ${MAC_DIR}/eNB_scheduler_phytest.c ${MAC_DIR}/pre_processor.c ${MAC_DIR}/config.c - ${MAC_DIR}/config_ue.c + #${MAC_DIR}/config_ue.c ) set (MAC_SRC_UE + ${PHY_INTERFACE_DIR}/phy_stub_UE.c ${MAC_DIR}/main_ue.c ${MAC_DIR}/ue_procedures.c ${MAC_DIR}/ra_procedures.c @@ -1528,38 +1499,11 @@ add_library(L2_UE ${MAC_SRC_UE} ) - include_directories(${NFAPI_USER_DIR}) # L3 Libs ########################## -set(RAL_LTE_DIR ${OPENAIR3_DIR}/RAL-LTE/) -if (${ENABLE_RAL}) - set(RAL_LTE_SRC - ${RRC_DIR}/rrc_UE_ral.c - ${RRC_DIR}/rrc_eNB_ral.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_action.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_main.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_mih_msg.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_parameters.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_process.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_rrc_msg.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_subscribe.c - ${RAL_LTE_DIR}LTE_RAL_ENB/SRC/lteRALenb_thresholds.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_action.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_main.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_mih_msg.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_parameters.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_process.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_rrc_msg.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_subscribe.c - ${RAL_LTE_DIR}LTE_RAL_UE/SRC/lteRALue_thresholds.c - ) - add_library(RAL ${RAL_LTE_SRC}) - set(RAL_LIB RAL) -endif() - # CN libs ########################## @@ -1906,8 +1850,8 @@ ${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/rangen_double.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_channel.c -${OPENAIR1_DIR}/SIMULATION/TOOLS/abstraction.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_tv_channel.c +${OPENAIR1_DIR}/SIMULATION/TOOLS/abstraction.c ${OPENAIR1_DIR}/SIMULATION/RF/rf.c ${OPENAIR1_DIR}/SIMULATION/RF/dac.c ${OPENAIR1_DIR}/SIMULATION/RF/adc.c @@ -2094,10 +2038,11 @@ add_executable(lte-softmodem ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c @@ -2111,7 +2056,8 @@ add_executable(lte-softmodem target_link_libraries (lte-softmodem -Wl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7 + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7 NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2132,12 +2078,13 @@ add_executable(lte-softmodem-nos1 ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c ${OPENAIR_DIR}/common/utils/system.c ${XFORMS_SOURCE} ${XFORMS_SOURCE_SOFTMODEM} @@ -2146,13 +2093,14 @@ add_executable(lte-softmodem-nos1 ${SHLIB_LOADER_SOURCES} ) target_link_libraries (lte-softmodem-nos1 - -Wl,--start-group - RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7 + -Wl,--start-grou + RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} + ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7 NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl ) target_link_libraries (lte-softmodem-nos1 ${LIBXML2_LIBRARIES}) -target_link_libraries (lte-softmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) +target_link_libraries (lte-softmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) target_link_libraries (lte-softmodem-nos1 ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-softmodem-nos1 ${T_LIB}) @@ -2167,10 +2115,11 @@ add_executable(lte-uesoftmodem ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c @@ -2183,8 +2132,9 @@ add_executable(lte-uesoftmodem target_link_libraries (lte-uesoftmodem -Wl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_UE LFDS L2_UE + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 + NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES}) @@ -2192,22 +2142,24 @@ target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${ target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (lte-uesoftmodem ${T_LIB}) -# lte-softmodem-nos1 is both eNB and UE implementation +# lte-uesoftmodem-nos1 is UE implementation ################################################### add_executable(lte-uesoftmodem-nos1 ${rrc_h} ${s1ap_h} - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c + ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c + ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${XFORMS_SOURCE} ${XFORMS_SOURCE_SOFTMODEM} @@ -2215,10 +2167,12 @@ add_executable(lte-uesoftmodem-nos1 ${CONFIG_SOURCES} ${SHLIB_LOADER_SOURCES} ) + target_link_libraries (lte-uesoftmodem-nos1 -Wl,--start-group - RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_UE_LIB PHY_UE LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} + RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 + NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl ) target_link_libraries (lte-uesoftmodem-nos1 ${LIBXML2_LIBRARIES}) @@ -2264,8 +2218,7 @@ add_executable(oaisim ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c - ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c +# ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c ${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c ${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c @@ -2288,8 +2241,8 @@ add_executable(oaisim target_include_directories(oaisim PUBLIC ${OPENAIR_TARGETS}/SIMU/USER) target_link_libraries (oaisim -Wl,-ldl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_UE_LIB PHY_UE LFDS L2 ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} - ${ASYNC_IF_LIB} ${FSPT_MSG_LIB} ${FLEXRAN_AGENT_LIB} ${PROTO_AGENT_LIB} LFDS7 + RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE ${MSC_LIB} LIB_NAS_UE SIMU SECU_OSA ${ITTI_LIB} ${MIH_LIB} + ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7 -Wl,--end-group z dl) target_link_libraries (oaisim ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES}) @@ -2309,10 +2262,10 @@ add_executable(oaisim_nos1 ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-ru.c + ${OPENAIR1_DIR}/SCHED/prach_procedures.c ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c - ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c - ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c +# ${OPENAIR_TARGETS}/SIMU/USER/oaisim_config.c ${OPENAIR_TARGETS}/SIMU/USER/sinr_sim.c ${OPENAIR_TARGETS}/SIMU/USER/cor_SF_sim.c ${OPENAIR_TARGETS}/SIMU/USER/oaisim_functions.c @@ -2331,11 +2284,8 @@ add_executable(oaisim_nos1 target_include_directories(oaisim_nos1 PUBLIC ${OPENAIR_TARGETS}/SIMU/USER) target_link_libraries (oaisim_nos1 -Wl,--start-group - RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_UE_LIB PHY_UE LFDS ${MSC_LIB} ${ITTI_LIB} SIMU L2_UE ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 - ${ASYNC_IF_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} - - -Wl,--end-group z dl ) - + RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS ${MSC_LIB} ${ITTI_LIB} SIMU L2_UE ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7 + -Wl,--end-group z dl ) target_link_libraries (oaisim_nos1 ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES}) target_link_libraries (oaisim_nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} @@ -2353,20 +2303,20 @@ target_link_libraries (oaisim_nos1 ${T_LIB}) #special case for dlim TM4, which uses its own version of phy_scope code add_executable(dlsim_tm4 - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/dlsim_tm4.c ${OPENAIR1_DIR}/PHY/TOOLS/lte_phy_scope_tm4.c ${T_SOURCE} ) target_link_libraries (dlsim_tm4 - -Wl,--start-group SIMU UTIL SCHED_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group + -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB PHY LFDS ${ITTI_LIB} -Wl,--end-group pthread m rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} ) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) add_executable(${myExe} - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c ${XFORMS_SOURCE} ${T_SOURCE} @@ -2375,7 +2325,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr ) target_link_libraries (${myExe} - -Wl,--start-group SIMU UTIL SCHED_LIB PHY LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group + -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY PHY_UE PHY_RU LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group pthread m rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} dl ) endforeach(myExe) @@ -2388,7 +2338,7 @@ add_executable(test_epc_generate_scenario ${OPENAIR2_DIR}/COMMON/messages_def.h ${OPENAIR2_DIR}/COMMON/messages_types.h ${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h - ${OPENAIR_BIN_DIR}/messages_xml.h +# ${OPENAIR_BIN_DIR}/messages_xml.h ) target_link_libraries (test_epc_generate_scenario -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} @@ -2412,7 +2362,7 @@ add_executable(test_epc_play_scenario ) target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c) target_link_libraries (test_epc_play_scenario - -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} + -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} ) @@ -2481,7 +2431,7 @@ endforeach() # castxml doesn't work with c11 (gcc 5 default) # force castxml and clang compilation with gnu89 standard # we can't use cXX standard as pthread_rwlock_t is gnu standard -list(APPEND itti_compiler_options "-std=gnu89") +list(APPEND itti_compiler_options "-std=gnu89;-D'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'") set (ITTI_H ${ITTI_DIR}/intertask_interface_types.h) if(EXISTS /usr/bin/gccxml) set(xml_command gccxml ${itti_compiler_options} -fxml=${OPENAIR_BIN_DIR}/messages.xml ${ITTI_H}) @@ -2569,7 +2519,7 @@ list(APPEND oai_nw_drv_src device.c common.c ioctl.c classifier.c tool.c) if(OAI_NW_DRIVER_USE_NETLINK) list(APPEND oai_nw_drv_src netlink.c) endif() -make_driver(oai_nw_drv ${OPENAIR2_DIR}/NETWORK_DRIVER/LITE ${oai_nw_drv_src}) +make_driver(oai_nw_drv ${OPENAIR2_DIR}/NETWORK_DRIVER/LTE ${oai_nw_drv_src}) # Exmimo board drivers ######################### diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 2586a731123d7ce6e773cdfd2b0c61c4fd9a07d7..60bf3951c27a3f92dd1269fd8469ca277cfbf4ef 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -67,6 +67,8 @@ UE_TIMING_TRACE="False" DISABLE_LOG_X="False" USRP_REC_PLAY="False" BUILD_ECLIPSE=0 +UE_NAS_USE_TUN="False" +BASIC_SIMULATOR=0 trap handle_ctrl_c INT function print_help() { @@ -160,6 +162,11 @@ Options Build eclipse project files. Paths are auto corrected by fixprj.sh --usrp-recplay Build for I/Q record-playback modes +--ue-nas-use-tun + Use TUN devices for the UEs instead of ue_ip.ko +--basic-simulator + Generates a basic [1 UE + 1 eNB + no channel] simulator. + See targets/ARCH/tcp_bridge/README.tcp_bridge_oai for documentation. Usage (first build): oaisim (eNB + UE): ./build_oai -I --oaisim -x --install-system-files Eurecom EXMIMO + COTS UE : ./build_oai -I --eNB -x --install-system-files @@ -355,6 +362,14 @@ function main() { USRP_REC_PLAY="True" echo_info "Enabling USRP record playback mode" shift 1;; + --ue-nas-use-tun) + UE_NAS_USE_TUN="True" + echo_info "Enabling UE NAS TUN device usage instead of ue_ip.ko" + shift 1;; + --basic-simulator) + BASIC_SIMULATOR=1 + echo_info "Compiling the basic simulator" + shift 1;; -h | --help) print_help exit 1;; @@ -715,6 +730,7 @@ function main() { echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file echo "set ( T_TRACER $T_TRACER )" >> $cmake_file + echo "set ( UE_NAS_USE_TUN $UE_NAS_USE_TUN )" >> $cmake_file echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file [ "$CLEAN" = "1" ] && rm -rf $DIR/$oaisim_build_dir/build mkdir -p $DIR/$oaisim_build_dir/build @@ -723,6 +739,12 @@ function main() { compilations \ $oaisim_build_dir $oaisim_exec \ $oaisim_exec $dbin/$oaisim_exec.$REL + compilations \ + $oaisim_build_dir $config_libconfig_shlib \ + lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so + compilations \ + $oaisim_build_dir coding \ + libcoding.so $dbin/libcoding.so if [ "$NOS1" != "1" ] ; then @@ -924,6 +946,124 @@ fi else echo_info "10. Bypassing the Tests ..." fi + + # basic simulator + ##################### + if [ "$BASIC_SIMULATOR" = "1" ]; then + echo_info "Build basic simulator" + [ "$CLEAN" = "1" ] && rm -rf $OPENAIR_DIR/cmake_targets/basic_simulator + [ "$CLEAN" = "1" ] && rm -rf $OPENAIR_DIR/cmake_targets/nas_sim_tools/build + mkdir -p $OPENAIR_DIR/cmake_targets/basic_simulator + mkdir -p $OPENAIR_DIR/cmake_targets/basic_simulator/enb + mkdir -p $OPENAIR_DIR/cmake_targets/basic_simulator/ue + mkdir -p $OPENAIR_DIR/cmake_targets/nas_sim_tools/build + + # enb + + cmake_file=$OPENAIR_DIR/cmake_targets/basic_simulator/enb/CMakeLists.txt + echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file + echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file + echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file + echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file + echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file + echo "set ( XFORMS $XFORMS )" >> $cmake_file + echo "set ( RF_BOARD \"OAI_USRP\")" >> $cmake_file + echo "set ( TRANSP_PRO \"None\")" >> $cmake_file + echo "set(PACKAGE_NAME \"simulator_enb\")" >> $cmake_file + echo "set (DEADLINE_SCHEDULER \"False\" )" >> $cmake_file + echo "set (CPU_AFFINITY \"False\" )" >> $cmake_file + echo "set ( T_TRACER \"True\" )" >> $cmake_file + echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)" >> $cmake_file + echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)" >> $cmake_file + echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file + echo "set (DISABLE_LOG_X $DISABLE_LOG_X)" >> $cmake_file + echo "set (USRP_REC_PLAY $USRP_REC_PLAY)" >> $cmake_file + echo "set (BASIC_SIMULATOR \"True\" )" >> $cmake_file + echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt)' >> $cmake_file + + echo_info "Build eNB" + echo_info "logs are in $dlog/basic_simulator_enb.txt" + set +e + { + cd $OPENAIR_DIR/cmake_targets/basic_simulator/enb + cmake . + make -j`nproc` lte-softmodem + make -j`nproc` coding params_libconfig tcp_bridge_oai + ln -sf libtcp_bridge_oai.so liboai_device.so + cd ../.. + } > $dlog/basic_simulator_enb.txt 2>&1 + set -e + if [ -s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/lte-softmodem -a \ + -s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/libcoding.so -a \ + -s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/libparams_libconfig.so -a \ + -s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/libtcp_bridge_oai.so ] ; then + echo_success "eNB compiled" + check_warnings "$dlog/basic_simulator_enb.txt" + else + echo_error "eNB compilation failed" + exit 1 + fi + + # ue + + echo_info "Compile conf2uedata" + cd $OPENAIR_DIR/cmake_targets/nas_sim_tools/build + eval $CMAKE_CMD + compilations \ + nas_sim_tools conf2uedata \ + conf2uedata $dbin/conf2uedata + + cmake_file=$OPENAIR_DIR/cmake_targets/basic_simulator/ue/CMakeLists.txt + echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file + echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file + echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file + echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file + echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file + echo "set ( XFORMS $XFORMS )" >> $cmake_file + echo "set ( RF_BOARD \"OAI_USRP\")" >> $cmake_file + echo "set ( TRANSP_PRO \"None\")" >> $cmake_file + echo "set(PACKAGE_NAME \"simulator_ue\")" >> $cmake_file + echo "set (DEADLINE_SCHEDULER \"False\" )" >> $cmake_file + echo "set (CPU_AFFINITY \"False\" )" >> $cmake_file + echo "set ( T_TRACER \"False\" )" >> $cmake_file + echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)" >> $cmake_file + echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)" >> $cmake_file + echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file + echo "set (DISABLE_LOG_X $DISABLE_LOG_X)" >> $cmake_file + echo "set (USRP_REC_PLAY $USRP_REC_PLAY)" >> $cmake_file + echo "set (LINUX True )" >> $cmake_file + echo "set (PDCP_USE_NETLINK True )" >> $cmake_file + echo "set (BASIC_SIMULATOR \"True\" )" >> $cmake_file + echo "set (UE_NAS_USE_TUN \"True\" )" >> $cmake_file + echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt)' >> $cmake_file + + echo_info "Build UE" + echo_info "logs are in $dlog/basic_simulator_ue.txt" + set +e + { + cd $OPENAIR_DIR/cmake_targets/basic_simulator/ue + cmake . + make -j`nproc` lte-uesoftmodem + make -j`nproc` coding params_libconfig tcp_bridge_oai + ln -sf libtcp_bridge_oai.so liboai_device.so + cd ../.. + } > $dlog/basic_simulator_ue.txt 2>&1 + set -e + if [ -s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/lte-uesoftmodem -a \ + -s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/libcoding.so -a \ + -s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/libparams_libconfig.so -a \ + -s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/libtcp_bridge_oai.so ] ; then + echo_success "UE compiled" + check_warnings "$dlog/basic_simulator_ue.txt" + else + echo_error "UE compilation failed" + exit 1 + fi + + echo_info "Generate UE SIM data" + $OPENAIR_DIR/targets/bin/conf2uedata -c $OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o $OPENAIR_DIR/cmake_targets/basic_simulator/ue + + fi } main "$@" diff --git a/cmake_targets/lte-simulators/CMakeLists.txt b/cmake_targets/lte-simulators/CMakeLists.txt index ca754449d7f9c6bbea10e1dcf726160df18a9f97..b7e83a92a03282f9dfae9b54633a8ea745763cee 100644 --- a/cmake_targets/lte-simulators/CMakeLists.txt +++ b/cmake_targets/lte-simulators/CMakeLists.txt @@ -8,5 +8,5 @@ set(DEBUG_PHY False) set(MU_RECIEVER False) set(NAS_UE False) set(MESSAGE_CHART_GENERATOR False) - +set(RRC_ASN1_VERSION "Rel14") include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 9b5c9320778eeef75cb0ebe231e59929490767d1..0270556b88724c30d6176eaaf2ce8438ef82b4bc 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -95,6 +95,7 @@ get_distribution_release() { check_supported_distribution() { local distribution=$(get_distribution_release) case "$distribution" in + "ubuntu18.04") return 0 ;; "ubuntu17.10") return 0 ;; "ubuntu17.04") return 0 ;; "ubuntu16.04") return 0 ;; @@ -267,7 +268,7 @@ check_install_usrp_uhd_driver(){ if [[ "$OS_DISTRO" == "ubuntu" ]]; then #first we remove old installation $SUDO apt-get remove -y uhd || true - $SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y + $SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y || true v=$(lsb_release -cs) $SUDO apt-add-repository --remove "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/$v $v main" #The new USRP repository @@ -488,19 +489,24 @@ check_install_oai_software() { $SUDO apt install -y software-properties-common case "$(get_distribution_release)" in "ubuntu14.04") - specific_packages="libtasn1-3-dev gccxml libgnutls-dev libatlas-dev" + specific_packages="libtasn1-3-dev gccxml 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 gccxml libgnutls-dev libatlas-dev" + specific_packages="libtasn1-6-dev gccxml libgnutls-dev libatlas-dev iproute libconfig8-dev" ;; "ubuntu17.04") - specific_packages="libtasn1-6-dev castxml libgnutls28-dev libatlas-dev" + specific_packages="libtasn1-6-dev castxml libgnutls28-dev libatlas-dev iproute libconfig8-dev" ;; "ubuntu17.10") - specific_packages="libtasn1-6-dev castxml libgnutls28-dev" + specific_packages="libtasn1-6-dev castxml libgnutls28-dev iproute libconfig8-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 castxml libgnutls28-dev iproute2 libconfig-dev" LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" ;; @@ -524,12 +530,10 @@ check_install_oai_software() { gtkwave \ guile-2.0-dev \ iperf \ - iproute \ iptables \ iptables-dev \ libatlas-base-dev \ libblas-dev \ - libconfig8-dev \ libffi-dev \ libforms-bin \ libforms-dev \ diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index a73a0737f25849fba1f59d820cc229f5547a063a..cfb0a214cfac14c337f894d67a5f64427d0f685e 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -130,6 +130,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { case TYPE_STRING: +printf("call config_lookup_string for '%s' %p\n", cfgpath, &(libconfig_privdata.cfg)); fflush(stdout); if ( config_lookup_string(&(libconfig_privdata.cfg),cfgpath, (const char **)&str)) { if ( cfgoptions[i].numelt > 0 && str != NULL && strlen(str) >= cfgoptions[i].numelt ) { fprintf(stderr,"[LIBCONFIG] %s: %s exceeds maximum length of %i bytes, value truncated\n", diff --git a/common/ran_context.h b/common/ran_context.h index 3b8ce6e09c7ea3917e2c616305d43eb1e9384873..343258cb1db374d951a327c2c5597d7edbbb5d15 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -35,12 +35,13 @@ #include <pthread.h> #include "COMMON/platform_constants.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "PHY/types.h" #include "PHY/impl_defs_top.h" #include "PHY/impl_defs_lte.h" -#include "RRC/LITE/defs.h" + #include "ENB_APP/enb_config.h" +#include "RRC/LTE/rrc_defs.h" #include "flexran_agent_defs.h" #include "gtpv1u.h" @@ -50,8 +51,8 @@ #include "gtpv1u_eNB_defs.h" #include "PHY/defs_L1_NB_IoT.h" -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" typedef struct { /// RAN context config file name char *config_file_name; diff --git a/common/utils/T/T.c b/common/utils/T/T.c index f1fce835385a7e524b2b223e2b6de0e043538be9..92e70c221b6fd052e5f5c4804de8bc3f2edc4fff 100644 --- a/common/utils/T/T.c +++ b/common/utils/T/T.c @@ -88,7 +88,7 @@ static void new_thread(void *(*f)(void *), void *data) /* defined in local_tracer.c */ void T_local_tracer_main(int remote_port, int wait_for_tracer, - int local_socket); + int local_socket, char *shm_file); /* We monitor the tracee and the local tracer processes. * When one dies we forcefully kill the other. @@ -113,6 +113,9 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) int s; int T_shm_fd; int child1, child2; + char shm_file[128]; + + sprintf(shm_file, "/%s%d", T_SHM_FILENAME, getpid()); if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair)) { perror("socketpair"); abort(); } @@ -122,7 +125,8 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) child1 = fork(); if (child1 == -1) abort(); if (child1 == 0) { close(socket_pair[1]); - T_local_tracer_main(remote_port, wait_for_tracer, socket_pair[0]); + T_local_tracer_main(remote_port, wait_for_tracer, socket_pair[0], + shm_file); exit(0); } close(socket_pair[0]); @@ -142,13 +146,13 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) T_socket = s; /* setup shared memory */ - T_shm_fd = shm_open(T_SHM_FILENAME, O_RDWR /*| O_SYNC*/, 0666); - shm_unlink(T_SHM_FILENAME); - if (T_shm_fd == -1) { perror(T_SHM_FILENAME); abort(); } + T_shm_fd = shm_open(shm_file, O_RDWR /*| O_SYNC*/, 0666); + shm_unlink(shm_file); + if (T_shm_fd == -1) { perror(shm_file); abort(); } T_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t), PROT_READ | PROT_WRITE, MAP_SHARED, T_shm_fd, 0); - if (T_cache == NULL) - { perror(T_SHM_FILENAME); abort(); } + if (T_cache == MAP_FAILED) + { perror(shm_file); abort(); } close(T_shm_fd); new_thread(T_receive_thread, NULL); diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 37668a830973dc668530ec685acabd0cf3ea1de5..cab246a6fff78017ab7e62df8c101f53212d8f8b 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -110,6 +110,16 @@ typedef struct { extern volatile int *T_freelist_head; extern T_cache_t *T_cache; +/* When running the basic simulator, we may fill the T cache too fast. + * Let's not crash if it's full, just wait. + */ +#if BASIC_SIMULATOR +# define T_BASIC_SIMULATOR_WAIT \ + while (T_cache[T_LOCAL_slot].busy) usleep(100) +#else +# define T_BASIC_SIMULATOR_WAIT /* */ +#endif + /* used at header of Tn, allocates buffer */ #define T_LOCAL_DATA \ char *T_LOCAL_buf; \ @@ -118,6 +128,7 @@ extern T_cache_t *T_cache; T_LOCAL_slot = __sync_fetch_and_add(T_freelist_head, 1) \ & (T_CACHE_SIZE - 1); \ (void)__sync_fetch_and_and(T_freelist_head, T_CACHE_SIZE - 1); \ + T_BASIC_SIMULATOR_WAIT; \ if (T_cache[T_LOCAL_slot].busy) { \ printf("%s:%d:%s: T cache is full - consider increasing its size\n", \ __FILE__, __LINE__, __FUNCTION__); \ diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index 6bdda0edacdb8f53ead52a6eea844037de309080..9961c1919e5d29cd40f120a5abedbc5f98363df6 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -8,10 +8,20 @@ #define T_MAX_ARGS 16 /* maximum size of a message - increase if needed */ -#define T_BUFFER_MAX (1024*64) +#if BASIC_SIMULATOR + /* let's have 100 RBs functional for the basic simulator */ +# define T_BUFFER_MAX (1024*64*2) +#else +# define T_BUFFER_MAX (1024*64) +#endif /* size of the local cache for messages (must be pow(2,something)) */ -#define T_CACHE_SIZE (8192 * 2) +#if BASIC_SIMULATOR + /* we don't need much space for the basic simulator */ +# define T_CACHE_SIZE 1024 +#else +# define T_CACHE_SIZE (8192 * 2) +#endif /* maximum number of bytes a message can contain */ #ifdef T_SEND_TIME @@ -32,7 +42,7 @@ typedef struct { #define VCD_NUM_FUNCTIONS 187 /* number of VCD variables (to be kept up to date! see in T_messages.txt) */ -#define VCD_NUM_VARIABLES 128 +#define VCD_NUM_VARIABLES 131 /* first VCD function (to be kept up to date! see in T_messages.txt) */ #define VCD_FIRST_FUNCTION ((uintptr_t)T_VCD_FUNCTION_RT_SLEEP) diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 8d531f9067708a301b395cb9ca4e2fb5d3bf1ec2..4d59a8d380f65c6d88efdeea2afa81640e81a7fa 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -1442,6 +1442,18 @@ ID = VCD_VARIABLE_UE0_TRX_WRITE_NS_MISSING DESC = VCD variable UE0_TRX_WRITE_NS_MISSING GROUP = ALL:VCD:UE:VCD_VARIABLE FORMAT = ulong,value +ID = VCD_VARIABLE_CPUID_ENB_THREAD_RXTX + DESC = VCD variable CPUID_ENB_THREAD_RXTX + GROUP = ALL:VCD:ENB:VCD_VARIABLE + FORMAT = ulong,value +ID = VCD_VARIABLE_CPUID_RU_THREAD + DESC = VCD variable CPUID_RU_THREAD + GROUP = ALL:VCD:ENB:VCD_VARIABLE + FORMAT = ulong,value +ID = VCD_VARIABLE_CPUID_RU_THREAD_TX + DESC = VCD variable CPUID_RU_THREAD_TX + GROUP = ALL:VCD:ENB:VCD_VARIABLE + FORMAT = ulong,value #functions diff --git a/common/utils/T/local_tracer.c b/common/utils/T/local_tracer.c index 6d0ecddd45913d1c58a813008091feaf0a2913f9..43680b40998b41ab43334c33d01756e5258c02cf 100644 --- a/common/utils/T/local_tracer.c +++ b/common/utils/T/local_tracer.c @@ -300,6 +300,20 @@ 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 /* BASIC_SIMULATOR */ + f->memusage += size+4; /* warn every 100MB */ if (f->memusage > f->last_warning_memusage && @@ -326,17 +340,17 @@ static void wait_message(void) while (T_local_cache[T_busylist_head].busy == 0) usleep(1000); } -static void init_shm(void) +static void init_shm(char *shm_file) { int i; - int s = shm_open(T_SHM_FILENAME, O_RDWR | O_CREAT /*| O_SYNC*/, 0666); - if (s == -1) { perror(T_SHM_FILENAME); abort(); } + int s = shm_open(shm_file, O_RDWR | O_CREAT /*| O_SYNC*/, 0666); + if (s == -1) { perror(shm_file); abort(); } if (ftruncate(s, T_CACHE_SIZE * sizeof(T_cache_t))) - { perror(T_SHM_FILENAME); abort(); } + { perror(shm_file); abort(); } T_local_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t), PROT_READ | PROT_WRITE, MAP_SHARED, s, 0); - if (T_local_cache == NULL) - { perror(T_SHM_FILENAME); abort(); } + if (T_local_cache == MAP_FAILED) + { perror(shm_file); abort(); } close(s); /* let's garbage the memory to catch some potential problems @@ -347,7 +361,7 @@ static void init_shm(void) } void T_local_tracer_main(int remote_port, int wait_for_tracer, - int local_socket) + int local_socket, char *shm_file) { int s; int port = remote_port; @@ -357,7 +371,7 @@ void T_local_tracer_main(int remote_port, int wait_for_tracer, /* write on a socket fails if the other end is closed and we get SIGPIPE */ if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort(); - init_shm(); + init_shm(shm_file); s = local_socket; if (dont_wait) { diff --git a/common/utils/T/tracer/enb.c b/common/utils/T/tracer/enb.c index f607743d1592f1473ad172ad9684a7ba17730104..a30366faf1eb8e645d5efba1cf664985cc60c255 100644 --- a/common/utils/T/tracer/enb.c +++ b/common/utils/T/tracer/enb.c @@ -12,7 +12,6 @@ #include "gui/gui.h" #include "filter/filter.h" #include "utils.h" -#include "../T_defs.h" #include "event_selector.h" #include "openair_logo.h" #include "config.h" @@ -875,6 +874,8 @@ int main(int n, char **v) if (pthread_mutex_init(&enb_data.lock, NULL)) abort(); setup_event_selector(g, database, is_on, is_on_changed, &enb_data); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + restart: clear_remote_config(); enb_data.socket = connect_to(ip, port); @@ -884,9 +885,8 @@ restart: /* read messages */ while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(enb_data.socket, v, database); + e = get_event(enb_data.socket, &ebuf, database); if (e.type == -1) goto restart; if (pthread_mutex_lock(&enb_data.lock)) abort(); handle_event(h, e); diff --git a/common/utils/T/tracer/event.c b/common/utils/T/tracer/event.c index 0917c010b3852a95a6e0fa6f56e48315c1d19b2b..f5d12e472c0ee09384ff5a1166421dfae4692dca 100644 --- a/common/utils/T/tracer/event.c +++ b/common/utils/T/tracer/event.c @@ -6,7 +6,7 @@ #include <stdlib.h> #include <string.h> -event get_event(int socket, char *event_buffer, void *database) +event get_event(int socket, OBUF *event_buffer, void *database) { #ifdef T_SEND_TIME struct timespec t; @@ -29,17 +29,23 @@ again: #endif if (fullread(socket, &type, sizeof(int)) == -1) goto read_error; length -= sizeof(int); - if (fullread(socket, event_buffer, length) == -1) goto read_error; + if (event_buffer->omaxsize < length) { + event_buffer->omaxsize = (length + 65535) & ~65535; + event_buffer->obuf = realloc(event_buffer->obuf, event_buffer->omaxsize); + if (event_buffer->obuf == NULL) { printf("out of memory\n"); exit(1); } + } + if (fullread(socket, event_buffer->obuf, length) == -1) goto read_error; + event_buffer->osize = length; - if (type == -1) append_received_config_chunk(event_buffer, length); + if (type == -1) append_received_config_chunk(event_buffer->obuf, length); if (type == -2) verify_config(); if (type == -1 || type == -2) goto again; #ifdef T_SEND_TIME - return new_event(t, type, length, event_buffer, database); + return new_event(t, type, length, event_buffer->obuf, database); #else - return new_event(type, length, event_buffer, database); + return new_event(type, length, event_buffer->obuf, database); #endif read_error: diff --git a/common/utils/T/tracer/event.h b/common/utils/T/tracer/event.h index 6272baf1a8f13216959db18951b606690315d46e..0170ab6680c6aac3c4b656ec803177c8e4ee7b6a 100644 --- a/common/utils/T/tracer/event.h +++ b/common/utils/T/tracer/event.h @@ -1,6 +1,7 @@ #ifndef _EVENT_H_ #define _EVENT_H_ +#include "utils.h" #include "../T_defs.h" #ifdef T_SEND_TIME #include <time.h> @@ -37,7 +38,7 @@ typedef struct { int ecount; } event; -event get_event(int s, char *v, void *d); +event get_event(int s, OBUF *v, void *d); #ifdef T_SEND_TIME event new_event(struct timespec sending_time, int type, diff --git a/common/utils/T/tracer/extract.c b/common/utils/T/tracer/extract.c index b9fca959eddf6a8428aee25b5aabf37cd51419b5..2aec38831fe2c528cd12cbaa3814e75813eb3bfe 100644 --- a/common/utils/T/tracer/extract.c +++ b/common/utils/T/tracer/extract.c @@ -99,10 +99,11 @@ int main(int n, char **v) found = 0; + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(fd, v, database); + e = get_event(fd, &ebuf, database); if (e.type == -1) break; if (e.type != input_event_id) continue; for (i = 0; i < filter_count; i++) diff --git a/common/utils/T/tracer/extract_config.c b/common/utils/T/tracer/extract_config.c index f35d765cec5b3366b88eca9bd9bc85d2697a18e4..a26c52aeda2a8ec31cf4748a0fc07a825d18a477 100644 --- a/common/utils/T/tracer/extract_config.c +++ b/common/utils/T/tracer/extract_config.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "utils.h" #include "../T_defs.h" void usage(void) @@ -35,14 +36,22 @@ int main(int n, char **v) in = fopen(input_filename, "r"); if (in == NULL) { perror(input_filename); abort(); } + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + while (1) { int type; int32_t length; - char v[T_BUFFER_MAX]; + char *v; int vpos = 0; /* read event from file */ if (fread(&length, 4, 1, in) != 1) break; + if (ebuf.omaxsize < length) { + ebuf.omaxsize = (length + 65535) & ~65535; + ebuf.obuf = realloc(ebuf.obuf, ebuf.omaxsize); + if (ebuf.obuf == NULL) { printf("out of memory\n"); exit(1); } + } + v = ebuf.obuf; memcpy(v+vpos, &length, 4); vpos += 4; #ifdef T_SEND_TIME diff --git a/common/utils/T/tracer/extract_input_subframe.c b/common/utils/T/tracer/extract_input_subframe.c index 02c5f3d56506d2889dc037918c1ec71ca1086d25..d7423182018df7a9f33a8d7c3202a6d810a3ed9f 100644 --- a/common/utils/T/tracer/extract_input_subframe.c +++ b/common/utils/T/tracer/extract_input_subframe.c @@ -104,11 +104,12 @@ err: fd = open(file, O_RDONLY); if (fd == -1) { perror(file); exit(1); } + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + /* get wanted frame/subframe */ while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(fd, v, database); + e = get_event(fd, &ebuf, database); if (e.type == -1) break; if (e.type != input_event_id) continue; if (verbose) diff --git a/common/utils/T/tracer/extract_output_subframe.c b/common/utils/T/tracer/extract_output_subframe.c index b82ad0e7665d259358e08b27f7c1816659ca3b3b..d24393553cee537e16f25cc600e74780fc808bba 100644 --- a/common/utils/T/tracer/extract_output_subframe.c +++ b/common/utils/T/tracer/extract_output_subframe.c @@ -100,10 +100,12 @@ err: int last_frame = -1; int last_subframe = -1; int subframe_written = 0; + + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(fd, v, database); + e = get_event(fd, &ebuf, database); if (e.type == -1) break; if (e.type != output_event_id) continue; if (verbose) diff --git a/common/utils/T/tracer/hacks/dump_nack_signal.c b/common/utils/T/tracer/hacks/dump_nack_signal.c index 1627bdd14e925ad68797d16614be9e57bc23447e..bb8f1a9477bda7894ba8465a068b2825db5e6737 100644 --- a/common/utils/T/tracer/hacks/dump_nack_signal.c +++ b/common/utils/T/tracer/hacks/dump_nack_signal.c @@ -73,17 +73,22 @@ int main(int n, char **v) socket_send(socket, is_on, number_of_events * sizeof(int)) == -1) abort(); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + char dump[10][T_BUFFER_MAX]; event dump_ev[10]; FILE *z = fopen("/tmp/dd", "w"); if (z == NULL) abort(); while (1) { - char v[T_BUFFER_MAX]; + char *v; event e; - e = get_event(socket, v, database); + e = get_event(socket, &ebuf, database); + v = ebuf.obuf; if (e.type == -1) break; if (e.type == ev_input) { int sf = e.e[2].i; - memcpy(dump[sf], v, T_BUFFER_MAX); + if (ebuf.osize > T_BUFFER_MAX) + { printf("event size too big\n"); exit(1); } + memcpy(dump[sf], ebuf.obuf, ebuf.osize); dump_ev[sf] = e; printf("input %d/%d\n", e.e[1].i, sf); if (fwrite(dump_ev[sf].e[4].b, dump_ev[sf].e[4].bsize, 1, z) != 1) abort(); diff --git a/common/utils/T/tracer/hacks/time_meas.c b/common/utils/T/tracer/hacks/time_meas.c index 04d4fa5acfcd026816c0345bc7513aa5759e0064..6bd29503011fb92e306dd10a7dd6539ebd0ee0f9 100644 --- a/common/utils/T/tracer/hacks/time_meas.c +++ b/common/utils/T/tracer/hacks/time_meas.c @@ -84,11 +84,12 @@ int main(int n, char **v) socket_send(socket, is_on, number_of_events * sizeof(int)) == -1) abort(); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + while (1) { - char v[T_BUFFER_MAX]; event e; int on_off; - e = get_event(socket, v, database); + e = get_event(socket, &ebuf, database); if (e.type == -1) break; if (e.type != ev_fun) { printf("unhandled event %d\n", e.type); continue; } diff --git a/common/utils/T/tracer/macpdu2wireshark.c b/common/utils/T/tracer/macpdu2wireshark.c index be0bbd382142bf82f171401bac34f91a7e4d4f67..954f668aa420c0cd0070f58757df721727199e2a 100644 --- a/common/utils/T/tracer/macpdu2wireshark.c +++ b/common/utils/T/tracer/macpdu2wireshark.c @@ -246,11 +246,12 @@ int main(int n, char **v) new_thread(receiver, &d); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + /* read messages */ while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(in, v, database); + e = get_event(in, &ebuf, database); if (e.type == -1) break; if (!(e.type == ul_id || e.type == dl_id)) continue; handle_event(h, e); diff --git a/common/utils/T/tracer/record.c b/common/utils/T/tracer/record.c index b1a1bc60de8cb8bdd0b69604f414f7d5aa7b0802..a565884e52b071ff9da15974b04fa81427cfa943 100644 --- a/common/utils/T/tracer/record.c +++ b/common/utils/T/tracer/record.c @@ -123,14 +123,22 @@ int main(int n, char **v) if (signal(SIGINT, force_stop) == SIG_ERR) abort(); if (signal(SIGTSTP, force_stop) == SIG_ERR) abort(); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + /* read messages */ while (run) { int type; int32_t length; - char v[T_BUFFER_MAX]; + char *v; int vpos = 0; if (fullread(socket, &length, 4) == -1) goto read_error; + if (ebuf.omaxsize < length) { + ebuf.omaxsize = (length + 65535) & ~65535; + ebuf.obuf = realloc(ebuf.obuf, ebuf.omaxsize); + if (ebuf.obuf == NULL) { printf("out of memory\n"); exit(1); } + } + v = ebuf.obuf; memcpy(v+vpos, &length, 4); vpos += 4; #ifdef T_SEND_TIME diff --git a/common/utils/T/tracer/replay.c b/common/utils/T/tracer/replay.c index be7e8d60c69fefcdd562ec79c5dea01c384b92c0..c199a668d58f7dfde3fc07378aaf112267d7afea 100644 --- a/common/utils/T/tracer/replay.c +++ b/common/utils/T/tracer/replay.c @@ -136,14 +136,22 @@ int main(int n, char **v) new_thread(get_message_thread, &socket); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + while (1) { int type; int32_t length; - char v[T_BUFFER_MAX]; + char *v; int vpos = 0; /* read event from file */ if (fread(&length, 4, 1, in) != 1) break; + if (ebuf.omaxsize < length) { + ebuf.omaxsize = (length + 65535) & ~65535; + ebuf.obuf = realloc(ebuf.obuf, ebuf.omaxsize); + if (ebuf.obuf == NULL) { printf("out of memory\n"); exit(1); } + } + v = ebuf.obuf; memcpy(v+vpos, &length, 4); vpos += 4; #ifdef T_SEND_TIME diff --git a/common/utils/T/tracer/textlog.c b/common/utils/T/tracer/textlog.c index 32bf1ed791ce10060fb48b62d7f4b69c94b23ba9..bb773b42150b9fcc15b7378405818a4b14db0e42 100644 --- a/common/utils/T/tracer/textlog.c +++ b/common/utils/T/tracer/textlog.c @@ -10,7 +10,6 @@ #include "view/view.h" #include "gui/gui.h" #include "utils.h" -#include "../T_defs.h" #include "event_selector.h" #include "config.h" @@ -182,11 +181,12 @@ int main(int n, char **v) /* send the first message - activate selected traces */ is_on_changed(&textlog_data); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + /* read messages */ while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(textlog_data.socket, v, database); + e = get_event(textlog_data.socket, &ebuf, database); if (e.type == -1) abort(); handle_event(h, e); } diff --git a/common/utils/T/tracer/to_vcd.c b/common/utils/T/tracer/to_vcd.c index 82cd3393d7e9e26e59305cb3928a209d879bfdc4..097fdce93217af2d6b6bc48a204bc120c421775f 100644 --- a/common/utils/T/tracer/to_vcd.c +++ b/common/utils/T/tracer/to_vcd.c @@ -287,11 +287,12 @@ int main(int n, char **v) if (signal(SIGINT, force_stop) == SIG_ERR) abort(); if (signal(SIGTSTP, force_stop) == SIG_ERR) abort(); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + /* read messages */ while (run) { - char v[T_BUFFER_MAX]; event e; - e = get_event(socket, v, database); + e = get_event(socket, &ebuf, database); if (e.type == -1) { printf("disconnected? let's quit gently\n"); break; } handle_event(h, e); } diff --git a/common/utils/T/tracer/ue.c b/common/utils/T/tracer/ue.c index 5709a4e79e06c82f2baa3a90b8cea683c768471c..6a7d03c897357c5e0d2cbbe07239fcb2bf2ebcfc 100644 --- a/common/utils/T/tracer/ue.c +++ b/common/utils/T/tracer/ue.c @@ -12,7 +12,6 @@ #include "gui/gui.h" #include "filter/filter.h" #include "utils.h" -#include "../T_defs.h" #include "event_selector.h" #include "openair_logo.h" #include "config.h" @@ -854,6 +853,8 @@ int main(int n, char **v) if (pthread_mutex_init(&ue_data.lock, NULL)) abort(); setup_event_selector(g, database, is_on, is_on_changed, &ue_data); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + restart: clear_remote_config(); ue_data.socket = connect_to(ip, port); @@ -863,9 +864,8 @@ restart: /* read messages */ while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(ue_data.socket, v, database); + e = get_event(ue_data.socket, &ebuf, database); if (e.type == -1) goto restart; if (pthread_mutex_lock(&ue_data.lock)) abort(); handle_event(h, e); diff --git a/common/utils/T/tracer/vcd.c b/common/utils/T/tracer/vcd.c index 0ad2756c2a49d218314aa4b586ba6a7bac0765ab..d4faa5fd8477d4698fd59721b910fca1dd6d26b6 100644 --- a/common/utils/T/tracer/vcd.c +++ b/common/utils/T/tracer/vcd.c @@ -10,7 +10,6 @@ #include "view/view.h" #include "gui/gui.h" #include "utils.h" -#include "../T_defs.h" #include "event_selector.h" #include "config.h" @@ -188,11 +187,12 @@ int main(int n, char **v) /* send the first message - activate selected traces */ is_on_changed(&vcd_data); + OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; + /* read messages */ while (1) { - char v[T_BUFFER_MAX]; event e; - e = get_event(vcd_data.socket, v, database); + e = get_event(vcd_data.socket, &ebuf, database); if (e.type == -1) abort(); handle_event(h, e); } diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index 1d38a3692b358d4cd52ef951cf9108cee905d188..21a3304e202b6910ce27145b5c807c72b4552912 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -72,6 +72,9 @@ const int itti_debug = (ITTI_DEBUG_ISSUES | ITTI_DEBUG_MP_STATISTICS); /* Global message size */ #define MESSAGE_SIZE(mESSAGEiD) (sizeof(MessageHeader) + itti_desc.messages_info[mESSAGEiD].size) + +extern int emulate_rf; + typedef enum task_state_s { TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX, } task_state_t; @@ -342,14 +345,16 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me destination_task_id, itti_get_task_name(destination_task_id)); } else { - /* We cannot send a message if the task is not running */ - AssertFatal (itti_desc.threads[destination_thread_id].task_state == TASK_STATE_READY, - "Task %s Cannot send message %s (%d) to thread %d, it is not in ready state (%d)!\n", - itti_get_task_name(origin_task_id), - itti_desc.messages_info[message_id].name, - message_id, - destination_thread_id, - itti_desc.threads[destination_thread_id].task_state); + if(!emulate_rf){ + /* We cannot send a message if the task is not running */ + AssertFatal (itti_desc.threads[destination_thread_id].task_state == TASK_STATE_READY, + "Task %s Cannot send message %s (%d) to thread %d, it is not in ready state (%d)!\n", + itti_get_task_name(origin_task_id), + itti_desc.messages_info[message_id].name, + message_id, + destination_thread_id, + itti_desc.threads[destination_thread_id].task_state); + } /* Allocate new list element */ new = (message_list_t *) itti_malloc (origin_task_id, destination_task_id, sizeof(struct message_list_s)); diff --git a/common/utils/load_module_shlib.c b/common/utils/load_module_shlib.c index fecdc2a58c624139f24bb44189b220dbf1f0d1d5..656f6a885224abaf3e6565368bd99d5f95225620 100644 --- a/common/utils/load_module_shlib.c +++ b/common/utils/load_module_shlib.c @@ -37,7 +37,7 @@ #include <errno.h> #include <sys/ioctl.h> #include <dlfcn.h> -#include "openair1/PHY/defs.h" +#include "openair1/PHY/defs_common.h" #define LOAD_MODULE_SHLIB_MAIN #include "common/config/config_userapi.h" diff --git a/d2d_emulator_setup.txt b/d2d_emulator_setup.txt new file mode 100644 index 0000000000000000000000000000000000000000..ef904066bc28d55eb345f9957e8751498c31e95e --- /dev/null +++ b/d2d_emulator_setup.txt @@ -0,0 +1,107 @@ +Scenario 1 : Off-network UE2UE link +SynchREF UE (UE1) + +UE1(eth0 - 10.10.10.1)--------UE2(eno1 - 10.10.10.2) + +Here's an example of /etc/network/interfaces configuration for UE1 +auto eth0 + iface eth0 inet static + address 10.10.10.1 + netmask 255.255.255.0 + gateway 10.10.10.1 + +Prepare the environment: + - git clone https://gitlab.eurecom.fr/matzakos/LTE-D2D.git #branch: master +This branch contains all the current development for DDPS + - UE MAC<-> UE MAC for Scenario 1 + - eNB MAC<->UE MAC (NFAPI Transport) + - RRC Extensions for “on-network†cases + +NFAPI configuration (required even for Scenario 1 target) + - git clone https://github.com/cisco/open-nFAPI.git + - cd open-nfapi + - patch -p1 --dry-run < $OPENAIR_HOME/open-nfapi.oai.patch +Validate that there are no errors + - patch -p1 < $OPENAIR_HOME/open-nfapi.oai.patch + +OAI build/execute + - export NFAPI_DIR=XXX (place where NFAPI was installed) + - cd cmake_targets + - ./build_oai --UE + (if necessary, use ./build_oai -I --UE to install required packages) + - cd lte_build_oai/build/ + - cp ../../../targets/bin/.ue* . + - cp ../../../targets/bin/.usim* . + - sudo insmod ../../../targets/bin/ue_ip.ko + +UE1: + - sudo ifconfig oip0 10.0.0.1 + - sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.3 -j MARK --set-mark 3 + - (if necessary) sudo route add default gw 10.10.10.1 eth0 +UE2: + - sudo ifconfig oip0 10.0.0.2 + - sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.3 -j MARK --set-mark 3 + - (if necessary) sudo route add default gw 10.10.10.1 eno1 + +UE1 and UE2: Get and build vencore_app from d2d-l3-stub (branch: l3_stub) + - gcc -I . vencore_app.c -o vencore_app -lpthread + +-------------------------------- +TEST ONE-TO-MANY +Run UE1 then UE2, for example: +UE1: sudo ./lte-softmodem-stub -U --emul-iface eth0 +UE2: sudo ./lte-softmodem-stub -U --emul-iface eno1 + +Test with Ping +- Sender - UE1: ping -I oip0 224.0.0.3 +- Receiver - UE2: using wireshark + +Test with Iperf +- Sender - UE1: iperf -c 224.0.0.3 -u -b 0.1M --bind 10.0.0.1 -t 100 +- Receiver - UE2: sudo ./mcreceive 224.0.0.3 5001 + +Filter the incomming packets according to GroupL2Id: receiver (one-to-many) can discard the packets if it doesn't belong to this group. +For the moment, both sender and receiver use the same set of Ids (hardcoded) + +UE1 (sender) + - sudo ./lte-softmodem-stub -U --emul-iface eth0 + - ./vencore_app #send the sourceL2Id, groupL2Id to OAI + - ping -I oip0 224.0.0.3 + UE2(receiver) + - sudo ./lte-softmodem-stub -U --emul-iface eno1 + #we can see the incomming packets from OAI log, however, cannot see from Wireshark -> they are discarded at MAC layer + - ./vencore_app #we can see the packets appearing in Wireshark + + -------------------------------------- +TEST PC5-S (UE1 -sender, UE2 - receiver) and PC5-U for ONE-TO-ONE scenario +Configure UE1/UE2 +UE1: + - sudo ifconfig oip0 10.0.0.1 + - sudo iptables -A POSTROUTING -t mangle -o oip0 -d 10.0.0.2 -j MARK --set-mark 3 + - sudo route add default gw 10.10.10.1 eth0 +UE2: + - sudo ifconfig oip0 10.0.0.2 + - sudo iptables -A POSTROUTING -t mangle -o oip0 -d 10.0.0.1 -j MARK --set-mark 3 + - sudo route add default gw 10.10.10.1 eno1 + +step 1: +- UE1: sudo ./lte-softmodem-stub -U --emul-iface eth0 +step 2: +- UE2: sudo ./lte-softmodem-stub -U --emul-iface eno1 +- UE2: ./vencore_app -r #listen to incomming message from PC5-S +step 3: +- UE1: ./vencore_app -s #send a message via PC5-S (e.g., DirectCommunicationRequest) + +Generate unicast traffic +UE1: ping -I oip0 10.0.0.2 + + + -------------------------------------- +TEST PC5-D +step 1: +- UE1: sudo ./lte-softmodem-stub -U --emul-iface eth0 +- UE1: ./vencore_app -d #send a PC5-Discovery-Announcement via PC5D +step 2: +- UE2: sudo ./lte-softmodem-stub -U --emul-iface eno1 +- UE2: ./vencore_app -d #send a PC5-Discovery-Announcement via PC5D + diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index c63d504e43d569f2cf9c3045aa2dca1c3b7056d8..dee4e8d310023fba1c22cc073800c1c2c1f2003c 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -32,6 +32,7 @@ #include "nfapi.h" #include "nfapi_pnf.h" #include "common/ran_context.h" +#include "openair2/PHY_INTERFACE/phy_stub_UE.h" //#include "openair1/PHY/vars.h" extern RAN_CONTEXT_t RC; @@ -47,7 +48,10 @@ extern RAN_CONTEXT_t RC; #include "fapi_stub.h" //#include "fapi_l1.h" #include "UTIL/LOG/log.h" -#include "openair2/LAYER2/MAC/proto.h" +#include "openair2/LAYER2/MAC/mac_proto.h" + +#include "PHY/INIT/phy_init.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" #define NUM_P5_PHY 2 @@ -61,8 +65,10 @@ extern pthread_mutex_t nfapi_sync_mutex; extern int nfapi_sync_var; extern int sync_var; +char uecap_xer_in; extern void init_eNB_afterRU(void); +extern void init_UE_stub(int nb_inst,int,int); extern void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, int frame, int subframe, eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu); extern void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nfapi_ul_config_request_pdu_t *ul_config_pdu, uint16_t frame,uint8_t subframe,uint8_t srs_present); extern void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t codeword_index, uint8_t *sdu); @@ -508,9 +514,31 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap pnf_info* pnf = (pnf_info*)(config->user_data); uint8_t num_tlv = 0; - struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + //struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; + + // Panos: In the case of nfapi_mode = 3 (UE = PNF) we should not have dependency on any eNB var. So we aim + // to keep only the necessary just to keep the nfapi FSM rolling by sending a dummy response. + LTE_DL_FRAME_PARMS *fp; + if (nfapi_mode!=3) { + struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; + fp = &eNB->frame_parms; + } + else{ + fp = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); + } + + +#if 0 + //DJP + auto found = std::find_if(pnf->phys.begin(), pnf->phys.end(), [&](phy_info& item) + { return item.id == req->header.phy_id; }); + if(found != pnf->phys.end()) + { + phy_info& phy_info = (*found); + } +#endif + //DJP phy_info* phy_info = pnf->phys; if(req->nfapi_config.timing_window.tl.tag == NFAPI_NFAPI_TIMING_WINDOW_TAG) { @@ -667,6 +695,7 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap num_tlv++; } + if(nfapi_mode!=3) { printf("[PNF] CONFIG_REQUEST[num_tlv:%d] TLVs processed:%d\n", req->num_tlv, num_tlv); printf("[PNF] Simulating PHY CONFIG - DJP\n"); @@ -678,6 +707,7 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap phy_config_request(&phy_config); dump_frame_parms(fp); + } phy_info->remote_port = req->nfapi_config.p7_vnf_port.value; @@ -695,6 +725,8 @@ int config_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfap nfapi_resp.error_code = 0; // DJP - some value resp->error_code; nfapi_pnf_config_resp(config, &nfapi_resp); printf("[PNF] Sent NFAPI_CONFIG_RESPONSE phy_id:%d\n", phy_info->id); + if(nfapi_mode ==3) + free(fp); return 0; } @@ -1081,6 +1113,7 @@ int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi } if(phy_info->timing_info_mode & 0x2) { + //printf("Panos-D: start_request () Enabling timing_info_mode_aperiodic \n"); p7_config->timing_info_mode_aperiodic = 1; } @@ -1090,77 +1123,110 @@ int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi p7_config->tx_req = &pnf_phy_tx_req; p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; - memset(&dummy_dl_config_req, 0, sizeof(dummy_dl_config_req)); - dummy_dl_config_req.dl_config_request_body.tl.tag=NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - dummy_dl_config_req.dl_config_request_body.number_pdcch_ofdm_symbols=1; - dummy_dl_config_req.dl_config_request_body.number_dci=0; - dummy_dl_config_req.dl_config_request_body.number_pdu=0; - dummy_dl_config_req.dl_config_request_body.number_pdsch_rnti=0; - dummy_dl_config_req.dl_config_request_body.transmission_power_pcfich=6000; - dummy_dl_config_req.dl_config_request_body.dl_config_pdu_list=0; + if (nfapi_mode==3) { + p7_config->dl_config_req = &memcpy_dl_config_req; + p7_config->ul_config_req = &memcpy_ul_config_req; + p7_config->hi_dci0_req = &memcpy_hi_dci0_req; + p7_config->tx_req = &memcpy_tx_req; + } + else { + p7_config->dl_config_req = &pnf_phy_dl_config_req; + p7_config->ul_config_req = &pnf_phy_ul_config_req; + p7_config->hi_dci0_req = &pnf_phy_hi_dci0_req; + p7_config->tx_req = &pnf_phy_tx_req; + } + p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; - memset(&dummy_tx_req, 0, sizeof(dummy_tx_req)); - dummy_tx_req.tx_request_body.number_of_pdus=0; - dummy_tx_req.tx_request_body.tl.tag=NFAPI_TX_REQUEST_BODY_TAG; + memset(&dummy_dl_config_req, 0, sizeof(dummy_dl_config_req)); + dummy_dl_config_req.dl_config_request_body.tl.tag=NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + dummy_dl_config_req.dl_config_request_body.number_pdcch_ofdm_symbols=1; + dummy_dl_config_req.dl_config_request_body.number_dci=0; + dummy_dl_config_req.dl_config_request_body.number_pdu=0; + dummy_dl_config_req.dl_config_request_body.number_pdsch_rnti=0; + dummy_dl_config_req.dl_config_request_body.transmission_power_pcfich=6000; + dummy_dl_config_req.dl_config_request_body.dl_config_pdu_list=0; - dummy_subframe.dl_config_req = &dummy_dl_config_req; - dummy_subframe.tx_req = 0;//&dummy_tx_req; + memset(&dummy_tx_req, 0, sizeof(dummy_tx_req)); + dummy_tx_req.tx_request_body.number_of_pdus=0; + dummy_tx_req.tx_request_body.tl.tag=NFAPI_TX_REQUEST_BODY_TAG; - dummy_subframe.ul_config_req=0; - dummy_subframe.hi_dci0_req=0; - dummy_subframe.lbt_dl_config_req=0; + dummy_subframe.dl_config_req = &dummy_dl_config_req; + dummy_subframe.tx_req = 0;//&dummy_tx_req; - p7_config->dummy_subframe = dummy_subframe; + dummy_subframe.ul_config_req=0; + dummy_subframe.hi_dci0_req=0; + dummy_subframe.lbt_dl_config_req=0; - p7_config->vendor_ext = &pnf_phy_vendor_ext; + p7_config->dummy_subframe = dummy_subframe; - p7_config->allocate_p7_vendor_ext = &pnf_phy_allocate_p7_vendor_ext; - p7_config->deallocate_p7_vendor_ext = &pnf_phy_deallocate_p7_vendor_ext; + p7_config->vendor_ext = &pnf_phy_vendor_ext; - p7_config->codec_config.unpack_p7_vendor_extension = &pnf_phy_unpack_p7_vendor_extension; - p7_config->codec_config.pack_p7_vendor_extension = &pnf_phy_pack_p7_vendor_extension; - p7_config->codec_config.unpack_vendor_extension_tlv = &pnf_phy_unpack_vendor_extension_tlv; - p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv; + p7_config->allocate_p7_vendor_ext = &pnf_phy_allocate_p7_vendor_ext; + p7_config->deallocate_p7_vendor_ext = &pnf_phy_deallocate_p7_vendor_ext; - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__); - pthread_t p7_thread; - pthread_create(&p7_thread, NULL, &pnf_p7_thread_start, p7_config); + p7_config->codec_config.unpack_p7_vendor_extension = &pnf_phy_unpack_p7_vendor_extension; + p7_config->codec_config.pack_p7_vendor_extension = &pnf_phy_pack_p7_vendor_extension; + p7_config->codec_config.unpack_vendor_extension_tlv = &pnf_phy_unpack_vendor_extension_tlv; + p7_config->codec_config.pack_vendor_extension_tlv = &pnf_phy_pack_vendor_extention_tlv; - //((pnf_phy_user_data_t*)(phy_info->fapi->user_data))->p7_config = p7_config; + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Creating P7 thread %s\n", __FUNCTION__); + pthread_t p7_thread; + pthread_create(&p7_thread, NULL, &pnf_p7_thread_start, p7_config); - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__); - l1_north_init_eNB(); + //((pnf_phy_user_data_t*)(phy_info->fapi->user_data))->p7_config = p7_config; - NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] DJP - HACK - Set p7_config global ready for subframe ind%s\n", __FUNCTION__); - p7_config_g = p7_config; + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Calling l1_north_init_eNB() %s\n", __FUNCTION__); + l1_north_init_eNB(); - // Need to wait for main thread to create RU structures - while(config_sync_var<0) { - usleep(5000000); - printf("[PNF] waiting for OAI to be configured (eNB/RU)\n"); - } - printf("[PNF] OAI eNB/RU configured\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] DJP - HACK - Set p7_config global ready for subframe ind%s\n", __FUNCTION__); + p7_config_g = p7_config; - printf("[PNF] About to call init_eNB_afterRU()\n"); - init_eNB_afterRU(); + //NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] Panos-D: start_request, BUFFER SIZE: %d", p7_config_g->subframe_buffer_size); + //printf("Panos-D: start_request, bUFFER SIZE: %d", p7_config_g->subframe_buffer_size); - // Signal to main thread that it can carry on - otherwise RU will startup too quickly and it is not initialised - pthread_mutex_lock(&nfapi_sync_mutex); - nfapi_sync_var=0; - pthread_cond_broadcast(&nfapi_sync_cond); - pthread_mutex_unlock(&nfapi_sync_mutex); + // Need to wait for main thread to create RU structures + while(config_sync_var<0) + { + usleep(5000000); + printf("[PNF] waiting for OAI to be configured (eNB/RU)\n"); + } + printf("[PNF] OAI eNB/RU configured\n"); - while(sync_var<0) { - usleep(5000000); - printf("[PNF] waiting for OAI to be started\n"); - } + //printf("[PNF] About to call phy_init_RU() for RC.ru[0]:%p\n", RC.ru[0]); + //phy_init_RU(RC.ru[0]); - printf("[PNF] Sending PNF_START_RESP\n"); - nfapi_send_pnf_start_resp(config, p7_config->phy_id); + printf("[PNF] About to call init_eNB_afterRU()\n"); - printf("[PNF] Sending first P7 subframe ind\n"); - nfapi_pnf_p7_subframe_ind(p7_config, p7_config->phy_id, 0); // DJP - SFN_SF set to zero - correct??? - printf("[PNF] Sent first P7 subframe ind\n"); + // Panos: Instead + /*if (nfapi_mode == 3) { + init_UE_stub(1,0,uecap_xer_in); + }*/ + //else{ + if (nfapi_mode != 3) { + // Panos + init_eNB_afterRU(); + } + + // Signal to main thread that it can carry on - otherwise RU will startup too quickly and it is not initialised + { + pthread_mutex_lock(&nfapi_sync_mutex); + nfapi_sync_var=0; + pthread_cond_broadcast(&nfapi_sync_cond); + pthread_mutex_unlock(&nfapi_sync_mutex); + } + + while(sync_var<0) + { + usleep(5000000); + printf("[PNF] waiting for OAI to be started\n"); + } + + printf("[PNF] Sending PNF_START_RESP\n"); + nfapi_send_pnf_start_resp(config, p7_config->phy_id); + + printf("[PNF] Sending first P7 subframe ind\n"); + nfapi_pnf_p7_subframe_ind(p7_config, p7_config->phy_id, 0); // DJP - SFN_SF set to zero - correct??? + printf("[PNF] Sent first P7 subframe ind\n"); return 0; } @@ -1464,7 +1530,9 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, printf("%s() PNF\n\n\n\n\n\n", __FUNCTION__); + if(nfapi_mode!=3) { nfapi_mode = 1; // PNF! + } nfapi_pnf_config_t* config = nfapi_pnf_config_create(); diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 07c3f1aa91fda58261b36dd8c90df3cbaf12d781..74e999528c51fc7d40f4eea48d56cd069a7ced04 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -37,7 +37,8 @@ #include "vendor_ext.h" #include "nfapi_vnf.h" - +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" #include "common/ran_context.h" extern RAN_CONTEXT_t RC; @@ -201,8 +202,8 @@ void oai_create_enb(void) { eNB->CC_id = bodge_counter; eNB->abstraction_flag = 0; eNB->single_thread_flag = 0;//single_thread_flag; - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; + eNB->td = ulsch_decoding_data_all;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; + eNB->te = dlsch_encoding_all;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; RC.nb_CC[bodge_counter] = 1; diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index 13041767522935fb74a90cfe9748517d303588dd..3c469c942bc028c81f8cbbf1492850891be06604 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -1247,9 +1247,14 @@ void vnf_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PNF:SFN/SF:%d VNF:SFN/SF:%d deltaSFNSF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind.last_sfn_sf), NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), vnf_pnf_sfnsf_delta); - if (vnf_pnf_sfnsf_delta>1 || vnf_pnf_sfnsf_delta < -1) + + // Panos: Careful here!!! + //if (vnf_pnf_sfnsf_delta>1 || vnf_pnf_sfnsf_delta < -1) + if (vnf_pnf_sfnsf_delta>0 || vnf_pnf_sfnsf_delta < 0) { NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SF DELTA between PNF and VNF delta:%d VNF:%d PNF:%d\n\n\n\n\n\n\n\n\n", __FUNCTION__, vnf_pnf_sfnsf_delta, NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), NFAPI_SFNSF2DEC(ind.last_sfn_sf)); + // Panos: Careful here!!! + vnf_p7->p7_connections[0].sfn_sf = ind.last_sfn_sf; } } } diff --git a/openair1/PHY/CODING/3gpplte.c b/openair1/PHY/CODING/3gpplte.c index 61acdb2ad9d3040dca9ed68d4264cc0fe0e332c4..ae476a118f0ab99f777e7ad2270fedfcb467a815 100644 --- a/openair1/PHY/CODING/3gpplte.c +++ b/openair1/PHY/CODING/3gpplte.c @@ -29,7 +29,7 @@ #endif #include <stdint.h> #include <stdio.h> -#include "PHY/CODING/defs.h" +#include "PHY/CODING/coding_defs.h" #include "extern_3GPPinterleaver.h" //#define DEBUG_TURBO_ENCODER 1 diff --git a/openair1/PHY/CODING/3gpplte_sse.c b/openair1/PHY/CODING/3gpplte_sse.c index 8150f02da89abd7ed2e5351de2cf25057c238263..e2eb7eb52af2897cfcbf02a5b3407e492cc681d6 100644 --- a/openair1/PHY/CODING/3gpplte_sse.c +++ b/openair1/PHY/CODING/3gpplte_sse.c @@ -26,10 +26,10 @@ date: 09.2012 */ #ifndef TC_MAIN -#include "defs.h" +#include "coding_defs.h" #include "extern_3GPPinterleaver.h" #else -#include "vars.h" +#include "coding_vars.h" #include <stdint.h> #endif #include <stdio.h> diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder.c b/openair1/PHY/CODING/3gpplte_turbo_decoder.c index c0e4ca12db42a30e768718336467da778dac3aa3..572127a5e0bd4118a4082d94e51c402743a33689 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder.c @@ -27,8 +27,8 @@ */ -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c index ef0ca48df465971ed2b89b66068f366a4937a519..a541c223934e00d2d3cf31eaf01d10a748b3dd3a 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c @@ -42,8 +42,9 @@ #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/impl_defs_top.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "extern_3GPPinterleaver.h" #else diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c index ae3ce531d037cce540522aa6454a20ab96733132..7daa86b8bb296218b17955532c96267c2688c24d 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c @@ -41,8 +41,9 @@ #include "PHY/sse_intrin.h" #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/impl_defs_top.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "extern_3GPPinterleaver.h" #else diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c index 5b7174e98964b9c9fec7e450fb892778755e57ff..f22ec21ff0ac25bfb876a8bac56c22b02129ca2c 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c @@ -39,8 +39,8 @@ #include "PHY/sse_intrin.h" #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/CODING/defs.h" +#include "PHY/defs_common.h" +#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "extern_3GPPinterleaver.h" #else diff --git a/openair1/PHY/CODING/ccoding_byte.c b/openair1/PHY/CODING/ccoding_byte.c index 8511a5ea0f7103cfcf252a9ededf4103ab8e4977..db91e68dc8f020c63b1d610cfbfb6d1f93ebaa3a 100644 --- a/openair1/PHY/CODING/ccoding_byte.c +++ b/openair1/PHY/CODING/ccoding_byte.c @@ -24,7 +24,7 @@ author: raymond.knopp@eurecom.fr, based on similar code for 3GPP convolutional code (UMTS) by P. Humblet (2000) date: 10.2004 */ -#include "defs.h" +#include "coding_defs.h" unsigned short gdot11[] = { 0133, 0171 }; // {A,B} diff --git a/openair1/PHY/CODING/ccoding_byte_lte.c b/openair1/PHY/CODING/ccoding_byte_lte.c index 6eb654827bc874c9d27a405d2975b014a572a32d..870e9ba4700c15e16c42d4b18e3a975ef757e51e 100644 --- a/openair1/PHY/CODING/ccoding_byte_lte.c +++ b/openair1/PHY/CODING/ccoding_byte_lte.c @@ -24,7 +24,7 @@ author: raymond.knopp@eurecom.fr date: 21.10.2009 */ -#include "defs.h" +#include "coding_defs.h" //#define DEBUG_CCODE 1 diff --git a/openair1/PHY/CODING/defs.h b/openair1/PHY/CODING/coding_defs.h similarity index 96% rename from openair1/PHY/CODING/defs.h rename to openair1/PHY/CODING/coding_defs.h index 40e19964dfa1abc0d847f84bfc2560ee3f2ea96f..d2975f3f9360dc09a55eb7329e625694895dfb5d 100644 --- a/openair1/PHY/CODING/defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -29,7 +29,7 @@ #include <stdint.h> -#include "PHY/defs.h" +#include "PHY/defs_common.h" #define CRC24_A 0 #define CRC24_B 1 @@ -75,20 +75,7 @@ int32_t lte_segmentation(uint8_t *input_buffer, uint32_t *Kminus, uint32_t *F); -/** \fn int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs) - \brief this functions calculates the delta MCS in dB based on the lte_segmentation function -\param tbs transport block size -\param nb_rb number of required rb -\param control_only a flag for the type of data -\param ncp cyclic prefix -\param use_srs a flag indicating the use of srs in the current SF -\returns ue_tx_power estimated ue tx power = delat_ mcs + bw_factor -*/ -int16_t estimate_ue_tx_power(uint32_t tbs, - uint32_t nb_rb, - uint8_t control_only, - lte_prefix_type_t ncp, - uint8_t use_srs); + /** \fn uint32_t sub_block_interleaving_turbo(uint32_t D, uint8_t *d,uint8_t *w) \brief This is the subblock interleaving algorithm from 36-212 (Release 8, 8.6 2009-03), pages 15-16. diff --git a/openair1/PHY/CODING/extern.h b/openair1/PHY/CODING/coding_extern.h similarity index 100% rename from openair1/PHY/CODING/extern.h rename to openair1/PHY/CODING/coding_extern.h diff --git a/openair1/PHY/CODING/coding_load.c b/openair1/PHY/CODING/coding_load.c index 31f71e6b31965e7777cba5fb9b4a2f260c56da51..76ab04f2207734355d209e71e5338567303a92f8 100644 --- a/openair1/PHY/CODING/coding_load.c +++ b/openair1/PHY/CODING/coding_load.c @@ -33,8 +33,8 @@ #include <sys/types.h> -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" #include "common/utils/load_module_shlib.h" #include "common/utils/telnetsrv/telnetsrv.h" diff --git a/openair1/PHY/CODING/vars.h b/openair1/PHY/CODING/coding_vars.h similarity index 100% rename from openair1/PHY/CODING/vars.h rename to openair1/PHY/CODING/coding_vars.h diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 21427de19b88c1568ac96b4a08b40b4d0813f1f2..0e1f0e065f36b8ade81d103fb2ccc70915a09751 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -31,7 +31,7 @@ */ -#include "defs.h" +#include "coding_defs.h" /*ref 36-212 v8.6.0 , pp 8-9 */ diff --git a/openair1/PHY/CODING/lte_rate_matching.c b/openair1/PHY/CODING/lte_rate_matching.c index 41c3c5e5a91b314c62c2d9a701c1802def0b306c..af5d1a169e950fa0a35b7237c47ad5390a195288 100644 --- a/openair1/PHY/CODING/lte_rate_matching.c +++ b/openair1/PHY/CODING/lte_rate_matching.c @@ -28,8 +28,8 @@ #include <stdio.h> #include <stdlib.h> #endif -#include "PHY/defs.h" -#include "assertions.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_common.h" //#define cmin(a,b) ((a)<(b) ? (a) : (b)) diff --git a/openair1/PHY/CODING/lte_segmentation.c b/openair1/PHY/CODING/lte_segmentation.c index 3ae65e20900e95323efee6563cbc9d7dd705b856..ba79b0171e4e31dac4d411e07b4ab22b66263cbf 100644 --- a/openair1/PHY/CODING/lte_segmentation.c +++ b/openair1/PHY/CODING/lte_segmentation.c @@ -24,8 +24,9 @@ author: raymond.knopp@eurecom.fr date: 21.10.2009 */ -#include "PHY/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_common.h" +#include "PHY/CODING/coding_defs.h" //#define DEBUG_SEGMENTATION diff --git a/openair1/PHY/CODING/viterbi_lte.c b/openair1/PHY/CODING/viterbi_lte.c index 5e11cb3453ab9dd2f425a175389acfd0edcca432..553192a4a8ee723ff3afb12292f53cb10c4463ac 100644 --- a/openair1/PHY/CODING/viterbi_lte.c +++ b/openair1/PHY/CODING/viterbi_lte.c @@ -29,8 +29,8 @@ */ #ifndef TEST_DEBUG -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" #else #include <stdio.h> #include <stdlib.h> diff --git a/openair1/PHY/INIT/defs_NB_IoT.h b/openair1/PHY/INIT/defs_NB_IoT.h index 8a83cbd03843e44686809823570832a8ef03c2e2..b49936770f2411068e60729d838c61f09f62539a 100644 --- a/openair1/PHY/INIT/defs_NB_IoT.h +++ b/openair1/PHY/INIT/defs_NB_IoT.h @@ -33,7 +33,7 @@ //#include "TDD-Config.h" //#include "MBSFN-SubframeConfigList.h" //#include "MobilityControlInfo.h" -//#if defined(Rel10) || defined(Rel14) +//#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //#include "SCellToAddMod-r10.h" //#endif diff --git a/openair1/PHY/INIT/extern.h b/openair1/PHY/INIT/init_extern.h similarity index 100% rename from openair1/PHY/INIT/extern.h rename to openair1/PHY/INIT/init_extern.h diff --git a/openair1/PHY/INIT/init_top.c b/openair1/PHY/INIT/init_top.c index 7bb745da83a50451a75973da3dcac7d69e565534..2e8ec365130d05ffdb9708aa99ee085f1ff7128f 100644 --- a/openair1/PHY/INIT/init_top.c +++ b/openair1/PHY/INIT/init_top.c @@ -20,13 +20,50 @@ */ /*!\brief Initilization and reconfiguration routines for LTE PHY */ -#ifndef USER_MODE -#define __NO_VERSION__ -#endif +#include "phy_init.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" + +void generate_64qam_table(void) +{ + + int a,b,c,index; + + + for (a=-1; a<=1; a+=2) + for (b=-1; b<=1; b+=2) + for (c=-1; c<=1; c+=2) { + index = (1+a)*2 + (1+b) + (1+c)/2; + qam64_table[index] = -a*(QAM64_n1 + b*(QAM64_n2 + (c*QAM64_n3))); // 0 1 2 + } +} + +void generate_16qam_table(void) +{ + + int a,b,index; + + for (a=-1; a<=1; a+=2) + for (b=-1; b<=1; b+=2) { + index = (1+a) + (1+b)/2; + qam16_table[index] = -a*(QAM16_n1 + (b*QAM16_n2)); + } +} + +void generate_qpsk_table(void) +{ + + int a,index; + + for (a=-1; a<=1; a+=2) { + index = (1+a)/2; + qpsk_table[index] = -a*QPSK; + } +} -#include "defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/extern.h" void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) { diff --git a/openair1/PHY/INIT/vars.h b/openair1/PHY/INIT/init_vars.h similarity index 100% rename from openair1/PHY/INIT/vars.h rename to openair1/PHY/INIT/init_vars.h diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index d22fb3e1fc468bbad997948a8810872cc99d35e0..8760d3c9d64cbabac3365e76bc86d73c37b38d57 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -19,14 +19,17 @@ * contact@openairinterface.org */ -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "PHY/defs_eNB.h" +#include "phy_init.h" +#include "SCHED/sched_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "SIMULATION/TOOLS/sim.h" #include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" #include "TDD-Config.h" -#include "LAYER2/MAC/extern.h" #include "MBSFN-SubframeConfigList.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "assertions.h" @@ -179,7 +182,7 @@ void phy_config_request(PHY_Config_t *phy_config) { fp->frame_type, RC.eNB[Mod_id][CC_id]->X_u); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) fp->prach_emtc_config_common.prach_Config_enabled=1; fp->prach_emtc_config_common.rootSequenceIndex = cfg->emtc_config.prach_catm_root_sequence_index.value; @@ -721,23 +724,6 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id, -void phy_config_cba_rnti (module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, rnti_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups) -{ - // uint8_t i; - - if (eNB_flag == 0 ) { - //LOG_D(PHY,"[UE %d] configure cba group %d with rnti %x, num active cba grp %d\n", index, index, cba_rnti, num_active_cba_groups); - PHY_vars_UE_g[Mod_id][CC_id]->ulsch[index]->num_active_cba_groups=num_active_cba_groups; - PHY_vars_UE_g[Mod_id][CC_id]->ulsch[index]->cba_rnti[cba_group_id]=cba_rnti; - } else { - //for (i=index; i < NUMBER_OF_UE_MAX; i+=num_active_cba_groups){ - // LOG_D(PHY,"[eNB %d] configure cba group %d with rnti %x for UE %d, num active cba grp %d\n",Mod_id, i%num_active_cba_groups, cba_rnti, i, num_active_cba_groups); - RC.eNB[Mod_id][CC_id]->ulsch[index]->num_active_cba_groups=num_active_cba_groups; - RC.eNB[Mod_id][CC_id]->ulsch[index]->cba_rnti[cba_group_id] = cba_rnti; - //} - } -} - int phy_init_lte_eNB(PHY_VARS_eNB *eNB, unsigned char is_secondary_eNB, unsigned char abstraction_flag) @@ -749,7 +735,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, LTE_eNB_PUSCH** const pusch_vars = eNB->pusch_vars; LTE_eNB_SRS* const srs_vars = eNB->srs_vars; LTE_eNB_PRACH* const prach_vars = &eNB->prach_vars; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LTE_eNB_PRACH* const prach_vars_br = &eNB->prach_vars_br; #endif int i, UE_id; @@ -845,7 +831,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, prach_vars->rxsigF[0] = (int16_t**)malloc16_clear(64*sizeof(int16_t*)); // PRACH BR -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) prach_vars_br->prachF = (int16_t*)malloc16_clear( 1024*2*sizeof(int32_t) ); // assume maximum of 64 RX antennas for PRACH receiver @@ -913,7 +899,7 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) LTE_eNB_PUSCH** const pusch_vars = eNB->pusch_vars; LTE_eNB_SRS* const srs_vars = eNB->srs_vars; LTE_eNB_PRACH* const prach_vars = &eNB->prach_vars; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LTE_eNB_PRACH* const prach_vars_br = &eNB->prach_vars_br; #endif int i, UE_id; @@ -946,7 +932,7 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) for (i = 0; i < 64; i++) free_and_zero(prach_vars->prach_ifft[0][i]); free_and_zero(prach_vars->prach_ifft[0]); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) for (int ce_level = 0; ce_level < 4; ce_level++) { for (i = 0; i < 64; i++) free_and_zero(prach_vars_br->prach_ifft[ce_level][i]); free_and_zero(prach_vars_br->prach_ifft[ce_level]); diff --git a/openair1/PHY/INIT/lte_init_ru.c b/openair1/PHY/INIT/lte_init_ru.c index 91681930748052dd38dd69a74cd7a782e1d6cf6d..b06e4c40af772f457fafa47852b7a7aba38747ef 100644 --- a/openair1/PHY/INIT/lte_init_ru.c +++ b/openair1/PHY/INIT/lte_init_ru.c @@ -19,14 +19,13 @@ * contact@openairinterface.org */ -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "phy_init.h" +#include "SCHED/sched_eNB.h" +#include "PHY/phy_extern.h" +#include "SIMULATION/TOOLS/sim.h" #include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" #include "TDD-Config.h" -#include "LAYER2/MAC/extern.h" #include "MBSFN-SubframeConfigList.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "assertions.h" @@ -99,7 +98,7 @@ int phy_init_RU(RU_t *ru) { for (i=0; i<ru->nb_rx; i++) { ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) ); LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,ru->prach_rxsigF[i]); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) for (j=0;j<4;j++) { ru->prach_rxsigF_br[j][i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) ); LOG_D(PHY,"[INIT] prach_vars_br->rxsigF[%d] = %p\n",i,ru->prach_rxsigF_br[j][i]); @@ -177,7 +176,7 @@ void phy_free_RU(RU_t *ru) for (i = 0; i < ru->nb_rx; i++) { free_and_zero(ru->prach_rxsigF[i]); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) for (j = 0; j < 4; j++) free_and_zero(ru->prach_rxsigF_br[j][i]); #endif } diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index 9fa86ca60e4fd1c2a5f331d33bd1aae7f63b5b57..b9c1504dd5ec37499e1d9e00040d4da6ec6106b7 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -19,21 +19,23 @@ * contact@openairinterface.org */ -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "phy_init.h" +#include "SCHED_UE/sched_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SIMULATION/TOOLS/sim.h" #include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" #include "TDD-Config.h" -#include "LAYER2/MAC/extern.h" #include "MBSFN-SubframeConfigList.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "assertions.h" #include <math.h> - +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10}; +extern uint8_t nfapi_mode; void phy_config_sib1_ue(uint8_t Mod_id,int CC_id, uint8_t eNB_id, @@ -340,7 +342,7 @@ void phy_config_meas_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) void phy_config_dedicated_scell_ue(uint8_t Mod_id, uint8_t eNB_index, SCellToAddMod_r10_t *sCellToAddMod_r10, @@ -563,14 +565,17 @@ void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, phy_vars_ue->decode_SIB = 0; phy_vars_ue->decode_MIB = 0; } - //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; - if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234) - phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; - else - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; - LOG_I(PHY,"C-RNTI %x %x \n", phy_vars_ue->pdcch_vars[0][eNB_id]->crnti, - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti); + if(nfapi_mode!=3){ + //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; + if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234) + phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; + else + phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; + + LOG_I(PHY,"C-RNTI %x %x \n", phy_vars_ue->pdcch_vars[0][eNB_id]->crnti, + phy_vars_ue->pdcch_vars[1][eNB_id]->crnti); + } } @@ -651,7 +656,7 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, int th_id; LOG_D(PHY,"Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); - LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST); + @@ -853,6 +858,9 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + + (*pdcch_vars_th)[th_id][eNB_id]->dciFormat = 0; + (*pdcch_vars_th)[th_id][eNB_id]->agregationLevel = 0xFF; } for (i=0; i<fp->nb_antennas_rx; i++) { diff --git a/openair1/PHY/INIT/lte_param_init.c b/openair1/PHY/INIT/lte_param_init.c index 6cf05769e52e4ca2b4dfc4a0bba6ac5d4848239f..0830058a8fb4bda41bb692a4e29b9aa460fb7104 100644 --- a/openair1/PHY/INIT/lte_param_init.c +++ b/openair1/PHY/INIT/lte_param_init.c @@ -25,10 +25,14 @@ #include <execinfo.h> #include <signal.h> -#include "SIMULATION/TOOLS/defs.h" +#include "SIMULATION/TOOLS/sim.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern.h" +#include "phy_init.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" extern PHY_VARS_eNB *eNB; extern PHY_VARS_UE *UE; diff --git a/openair1/PHY/INIT/lte_parms.c b/openair1/PHY/INIT/lte_parms.c index 2f2bd95617ebcffa60092376e9778935bd3ce877..e7c4ced5d37351977dc61f7d21e9c85ff8516905 100644 --- a/openair1/PHY/INIT/lte_parms.c +++ b/openair1/PHY/INIT/lte_parms.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "phy_init.h" #include "log.h" uint16_t dl_S_table_normal[10]={3,9,10,11,12,3,9,10,11,6}; diff --git a/openair1/PHY/INIT/defs.h b/openair1/PHY/INIT/phy_init.h similarity index 99% rename from openair1/PHY/INIT/defs.h rename to openair1/PHY/INIT/phy_init.h index be3e5c160b61a7ad71562befd3f2da89cd3a8fb0..8da34fc51cb9bc9ef43349e3fcf750f37e3afdc4 100644 --- a/openair1/PHY/INIT/defs.h +++ b/openair1/PHY/INIT/phy_init.h @@ -22,8 +22,8 @@ #ifndef __INIT_DEFS__H__ #define __INIT_DEFS__H__ -#include "PHY/defs.h" - +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "SystemInformationBlockType2.h" //#include "RadioResourceConfigCommonSIB.h" @@ -32,7 +32,7 @@ #include "PHICH-Config.h" #include "MBSFN-SubframeConfigList.h" #include "MobilityControlInfo.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #include "SCellToAddMod-r10.h" #endif /** @addtogroup _PHY_STRUCTURES_ @@ -349,7 +349,7 @@ void lte_param_init(PHY_VARS_eNB **eNBp, uint32_t perfect_ce); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) void phy_config_dedicated_scell_ue(uint8_t Mod_id, uint8_t eNB_index, SCellToAddMod_r10_t *sCellToAddMod_r10, diff --git a/openair1/PHY/LTE_ESTIMATION/adjust_gain.c b/openair1/PHY/LTE_ESTIMATION/adjust_gain.c index 7272b7247d93f451754d41eadfa5edfaf2b51057..27e6c106863e98a5d317bfad32926583536205bc 100644 --- a/openair1/PHY/LTE_ESTIMATION/adjust_gain.c +++ b/openair1/PHY/LTE_ESTIMATION/adjust_gain.c @@ -20,8 +20,8 @@ */ #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" void phy_adjust_gain (PHY_VARS_UE *ue, uint32_t rx_power_fil_dB, uint8_t eNB_id) diff --git a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c index 2c318d85e401d529bb78f5bdda5ffc6c74be5c05..3fd58a4989701d795401ae296b3a4241e159136a 100644 --- a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c +++ b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" // This is 512/(1:256) in __m128i format diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c index 18444076f315de40ee4ef925e31ccd93043b1d37..2b7873cc29658acfcd83a9a83b278a22eb77be95 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c @@ -20,10 +20,11 @@ */ #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "openair2/LAYER2/MAC/mac_proto.h" #define DEBUG_PHY @@ -84,6 +85,11 @@ void lte_adjust_synch(LTE_DL_FRAME_PARMS *frame_parms, { diff = max_pos_fil - (frame_parms->nb_prefix_samples>>3); +#if BASIC_SIMULATOR + /* a hack without which the UE does not connect (to be fixed somehow) */ + diff = 0; +#endif + if ( abs(diff) < SYNCH_HYST ) ue->rx_offset = 0; else @@ -134,128 +140,3 @@ void lte_adjust_synch(LTE_DL_FRAME_PARMS *frame_parms, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_OUT); } } - - -int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, - LTE_eNB_SRS *lte_eNB_srs, - unsigned int *eNB_id, - unsigned char clear, - unsigned char number_of_cards, - short coef) - -{ - - static int max_pos_fil2 = 0; - int temp, i, aa, max_pos = 0,ind; - int max_val=0; - short Re,Im,ncoef; -#ifdef DEBUG_PHY - char fname[100],vname[100]; -#endif - - ncoef = 32768 - coef; - - for (ind=0; ind<number_of_cards; ind++) { - - if (ind==0) - max_val=0; - - - for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { - // do ifft of channel estimate - switch(frame_parms->N_RB_DL) { - case 6: - dft128((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - case 25: - dft512((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - case 50: - dft1024((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - case 100: - dft2048((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], - (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], - 1); - break; - } -#ifdef DEBUG_PHY - sprintf(fname,"srs_ch_estimates_time_%d%d.m",ind,aa); - sprintf(vname,"srs_time_%d%d",ind,aa); - write_output(fname,vname,lte_eNB_srs->srs_ch_estimates_time[aa],frame_parms->ofdm_symbol_size*2,2,1); -#endif - } - - // we only use channel estimates from tx antenna 0 here - // remember we fixed the SRS to use only every second subcarriers - for (i = 0; i < frame_parms->ofdm_symbol_size/2; i++) { - temp = 0; - - for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { - Re = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[(i<<1)]; - Im = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[1+(i<<1)]; - temp += (Re*Re/2) + (Im*Im/2); - } - - if (temp > max_val) { - max_pos = i; - max_val = temp; - *eNB_id = ind; - } - } - } - - // filter position to reduce jitter - if (clear == 1) - max_pos_fil2 = max_pos; - else - max_pos_fil2 = ((max_pos_fil2 * coef) + (max_pos * ncoef)) >> 15; - - return(max_pos_fil2); -} - - -int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id) -{ - int temp, i, aa, max_pos=0, max_val=0; - short Re,Im; - - LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - LTE_eNB_PUSCH *eNB_pusch_vars = eNB->pusch_vars[UE_id]; - int32_t **ul_ch_estimates_time= eNB_pusch_vars->drs_ch_estimates_time; - uint8_t cyclic_shift = 0; - int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); - - AssertFatal(frame_parms->ofdm_symbol_size > 127,"frame_parms->ofdm_symbol_size %d<128\n",frame_parms->ofdm_symbol_size); - AssertFatal(frame_parms->nb_antennas_rx >0 && frame_parms->nb_antennas_rx<3,"frame_parms->nb_antennas_rx %d not in [0,1]\n", - frame_parms->nb_antennas_rx); - for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { - temp = 0; - - for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { - Re = ((int16_t*)ul_ch_estimates_time[aa])[(i<<1)]; - Im = ((int16_t*)ul_ch_estimates_time[aa])[1+(i<<1)]; - temp += (Re*Re/2) + (Im*Im/2); - } - - if (temp > max_val) { - max_pos = i; - max_val = temp; - } - } - - if (max_pos>frame_parms->ofdm_symbol_size/2) - max_pos = max_pos-frame_parms->ofdm_symbol_size; - - //#ifdef DEBUG_PHY - LOG_D(PHY,"frame %d: max_pos = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,sync_pos); - //#endif //DEBUG_PHY - - return max_pos - sync_pos; -} diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c new file mode 100644 index 0000000000000000000000000000000000000000..3bf4c40adeab61602225124d9d53d8f3ff73e851 --- /dev/null +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c @@ -0,0 +1,153 @@ +/* + * 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 "PHY/types.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" + +#include "UTIL/LOG/vcd_signal_dumper.h" + +#define DEBUG_PHY + +int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms, + LTE_eNB_SRS *lte_eNB_srs, + unsigned int *eNB_id, + unsigned char clear, + unsigned char number_of_cards, + short coef) + +{ + + static int max_pos_fil2 = 0; + int temp, i, aa, max_pos = 0,ind; + int max_val=0; + short Re,Im,ncoef; +#ifdef DEBUG_PHY + char fname[100],vname[100]; +#endif + + ncoef = 32768 - coef; + + for (ind=0; ind<number_of_cards; ind++) { + + if (ind==0) + max_val=0; + + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + // do ifft of channel estimate + switch(frame_parms->N_RB_DL) { + case 6: + dft128((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + case 25: + dft512((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + case 50: + dft1024((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + case 100: + dft2048((int16_t*) <e_eNB_srs->srs_ch_estimates[aa][0], + (int16_t*) lte_eNB_srs->srs_ch_estimates_time[aa], + 1); + break; + } +#ifdef DEBUG_PHY + sprintf(fname,"srs_ch_estimates_time_%d%d.m",ind,aa); + sprintf(vname,"srs_time_%d%d",ind,aa); + write_output(fname,vname,lte_eNB_srs->srs_ch_estimates_time[aa],frame_parms->ofdm_symbol_size*2,2,1); +#endif + } + + // we only use channel estimates from tx antenna 0 here + // remember we fixed the SRS to use only every second subcarriers + for (i = 0; i < frame_parms->ofdm_symbol_size/2; i++) { + temp = 0; + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[(i<<1)]; + Im = ((int16_t*)lte_eNB_srs->srs_ch_estimates_time[aa])[1+(i<<1)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + *eNB_id = ind; + } + } + } + + // filter position to reduce jitter + if (clear == 1) + max_pos_fil2 = max_pos; + else + max_pos_fil2 = ((max_pos_fil2 * coef) + (max_pos * ncoef)) >> 15; + + return(max_pos_fil2); +} + + +int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id) +{ + int temp, i, aa, max_pos=0, max_val=0; + short Re,Im; + + LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; + LTE_eNB_PUSCH *eNB_pusch_vars = eNB->pusch_vars[UE_id]; + int32_t **ul_ch_estimates_time= eNB_pusch_vars->drs_ch_estimates_time; + uint8_t cyclic_shift = 0; + int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); + + AssertFatal(frame_parms->ofdm_symbol_size > 127,"frame_parms->ofdm_symbol_size %d<128\n",frame_parms->ofdm_symbol_size); + AssertFatal(frame_parms->nb_antennas_rx >0 && frame_parms->nb_antennas_rx<3,"frame_parms->nb_antennas_rx %d not in [0,1]\n", + frame_parms->nb_antennas_rx); + for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { + temp = 0; + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)ul_ch_estimates_time[aa])[(i<<1)]; + Im = ((int16_t*)ul_ch_estimates_time[aa])[1+(i<<1)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + } + } + + if (max_pos>frame_parms->ofdm_symbol_size/2) + max_pos = max_pos-frame_parms->ofdm_symbol_size; + + //#ifdef DEBUG_PHY + LOG_D(PHY,"frame %d: max_pos = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,sync_pos); + //#endif //DEBUG_PHY + + return max_pos - sync_pos; +} + diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..06ef4a5d1a16fd68083c4f03b973ed5a215ef079 --- /dev/null +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_ue.c @@ -0,0 +1,138 @@ +/* + * 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 "PHY/types.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/impl_defs_top.h" +#include "openair2/LAYER2/MAC/mac_proto.h" + +#include "UTIL/LOG/vcd_signal_dumper.h" + +#define DEBUG_PHY + +// Adjust location synchronization point to account for drift +// The adjustment is performed once per frame based on the +// last channel estimate of the receiver + +void lte_adjust_synch(LTE_DL_FRAME_PARMS *frame_parms, + PHY_VARS_UE *ue, + unsigned char eNB_id, + uint8_t subframe, + unsigned char clear, + short coef) +{ + + static int max_pos_fil = 0; + static int count_max_pos_ok = 0; + static int first_time = 1; + int temp = 0, i, aa, max_val = 0, max_pos = 0; + int diff; + short Re,Im,ncoef; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_IN); + + ncoef = 32767 - coef; + +#ifdef DEBUG_PHY + LOG_D(PHY,"AbsSubframe %d.%d: rx_offset (before) = %d\n",ue->proc.proc_rxtx[0].frame_rx%1024,subframe,ue->rx_offset); +#endif //DEBUG_PHY + + + // we only use channel estimates from tx antenna 0 here + for (i = 0; i < frame_parms->nb_prefix_samples; i++) { + temp = 0; + + for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id][aa])[(i<<2)]; + Im = ((int16_t*)ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates_time[eNB_id][aa])[1+(i<<2)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + } + } + + // filter position to reduce jitter + if (clear == 1) + max_pos_fil = max_pos; + else + max_pos_fil = ((max_pos_fil * coef) + (max_pos * ncoef)) >> 15; + + // do not filter to have proactive timing adjustment + max_pos_fil = max_pos; + + if(subframe == 6) + { + diff = max_pos_fil - (frame_parms->nb_prefix_samples>>3); + + if ( abs(diff) < SYNCH_HYST ) + ue->rx_offset = 0; + else + ue->rx_offset = diff; + + if(abs(diff)<5) + count_max_pos_ok ++; + else + count_max_pos_ok = 0; + + if(count_max_pos_ok > 10 && first_time == 1) + { + first_time = 0; + ue->time_sync_cell = 1; + if (ue->mac_enabled==1) { + LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id); + //mac_resynch(); + dl_phy_sync_success(ue->Mod_id,ue->proc.proc_rxtx[0].frame_rx,0,1);//ue->common_vars.eNb_id); + ue->UE_mode[0] = PRACH; + } + else { + ue->UE_mode[0] = PUSCH; + } + } + + if ( ue->rx_offset < 0 ) + ue->rx_offset += FRAME_LENGTH_COMPLEX_SAMPLES; + + if ( ue->rx_offset >= FRAME_LENGTH_COMPLEX_SAMPLES ) + ue->rx_offset -= FRAME_LENGTH_COMPLEX_SAMPLES; + + + + #ifdef DEBUG_PHY + LOG_D(PHY,"AbsSubframe %d.%d: ThreadId %d diff =%i rx_offset (final) = %i : clear %d,max_pos = %d,max_pos_fil = %d (peak %d) max_val %d target_pos %d \n", + ue->proc.proc_rxtx[ue->current_thread_id[subframe]].frame_rx, + subframe, + ue->current_thread_id[subframe], + diff, + ue->rx_offset, + clear, + max_pos, + max_pos_fil, + temp,max_val, + (frame_parms->nb_prefix_samples>>3)); + #endif //DEBUG_PHY + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ADJUST_SYNCH, VCD_FUNCTION_OUT); + } +} diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c index 55d2cf6c5c5f2aae5eb34b045f394fdfeea08f24..8d1fb20d6b79b828130666254a629c9cd255b355 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c @@ -20,8 +20,10 @@ */ #include <string.h> -#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" +#include "lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + #include "filt16_32.h" //#define DEBUG_BF_CH diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c index a4b29bb25ec407efbbb4ec696bada4557bbd1ec1..a72563f7e6d58754111b3657ea50ec7fa7230576 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c @@ -20,12 +20,13 @@ */ #include <string.h> -#include "defs.h" -#include "SCHED/defs.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" #include "filt96_32.h" #include "T.h" //#define DEBUG_CH +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "SCHED_UE/sched_UE.h" int lte_dl_channel_estimation(PHY_VARS_UE *ue, uint8_t eNB_id, diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c index 17d44b22f8815442a5c10921410e685b02d64f1a..c4fc80a8c11635868e1a7d97590ff048553500ef 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_mbsfn_channel_estimation.c @@ -20,8 +20,9 @@ */ #include <string.h> -#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" +#include "lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_CH int lte_dl_mbsfn_channel_estimation(PHY_VARS_UE *ue, diff --git a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c index 42409cbaae6c4d9e53029483543adf79430eb14b..b416ff9e79ba3148552b8f57c1931ebfdad4b9a4 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c index cce1e06df4bce134e149558b4b64c8a4b3f95de5..ed82aeb09e36c602ee2b8d71d2db425176b19b60 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_est_freq_offset.c @@ -25,7 +25,7 @@ date: 19.11.2009 */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" //#define DEBUG_PHY #if defined(__x86_64__) || defined(__i386__) diff --git a/openair1/PHY/LTE_ESTIMATION/defs.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h similarity index 99% rename from openair1/PHY/LTE_ESTIMATION/defs.h rename to openair1/PHY/LTE_ESTIMATION/lte_estimation.h index a7b5d14701874da4fb4894dca2382bfd7102708b..4512fc0d9be15bf9d52efaf1f68248725fc0d8ba 100644 --- a/openair1/PHY/LTE_ESTIMATION/defs.h +++ b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h @@ -22,7 +22,9 @@ #ifndef __LTE_ESTIMATION_DEFS__H__ #define __LTE_ESTIMATION_DEFS__H__ -#include "PHY/defs.h" + +#include "PHY/defs_UE.h" +#include "PHY/defs_eNB.h" /** @addtogroup _PHY_PARAMETER_ESTIMATION_BLOCKS_ * @{ */ diff --git a/openair1/PHY/LTE_ESTIMATION/extern.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation_extern.h similarity index 100% rename from openair1/PHY/LTE_ESTIMATION/extern.h rename to openair1/PHY/LTE_ESTIMATION/lte_estimation_extern.h diff --git a/openair1/PHY/LTE_ESTIMATION/vars.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation_vars.h similarity index 100% rename from openair1/PHY/LTE_ESTIMATION/vars.h rename to openair1/PHY/LTE_ESTIMATION/lte_estimation_vars.h diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index 39a877f47b2bd4c57fa587cd48578f993457fd44..b72ba71d0c4780e262abce878d7e9f16df0ba03a 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -26,19 +26,15 @@ */ //#include <string.h> -#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include <math.h> -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" -#endif -//#define DEBUG_PHY + +#include "LAYER2/MAC/mac.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" + int* sync_corr_ue0 = NULL; int* sync_corr_ue1 = NULL; @@ -487,8 +483,6 @@ int lte_sync_time(int **rxdata, ///rx data in time domain } -//#define DEBUG_PHY - int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain LTE_DL_FRAME_PARMS *frame_parms, uint32_t length, diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c index d428f8e6e6d9f927da6dbc7be5a0ffd77ebbf501..fd7b8d601ab9db9811c99a7df8b6b75cd0e2a9e0 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c @@ -36,8 +36,8 @@ */ //#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #if defined(__x86_64__) || defined(__i386__) #include "pss6144.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c index ce6cd869599087d1b4a1258d4d894bc1fbaec717..199fc2d846def40512bf97215c6e43928d082cfc 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c @@ -21,10 +21,8 @@ // this function fills the PHY_vars->PHY_measurement structure -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "log.h" #include "PHY/sse_intrin.h" @@ -454,397 +452,339 @@ void ue_rrc_measurements(PHY_VARS_UE *ue, } -void lte_ue_measurements(PHY_VARS_UE *ue, - unsigned int subframe_offset, - unsigned char N0_symbol, - unsigned char abstraction_flag, - unsigned char rank_adaptation, - uint8_t subframe) +void 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 Hhermitian * H matrix + 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; - int aarx,aatx,eNB_id=0; //,gain_offset=0; - //int rx_power[NUMBER_OF_CONNECTED_eNB_MAX]; - int i; - unsigned int limit,subband; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch0_128,*dl_ch1_128; -#elif defined(__arm__) - int16x8_t *dl_ch0_128, *dl_ch1_128; -#endif - int *dl_ch0,*dl_ch1; - - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int nb_subbands,subband_size,last_subband_size; - int N_RB_DL = frame_parms->N_RB_DL; + ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; + for (rb=0; rb<3*nb_rb; rb++) { - int rank_tm3_tm4; + 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*)&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); - ue->measurements.nb_antennas_rx = frame_parms->nb_antennas_rx; +#ifdef DEBUG_RANK_EST + 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]); +#endif + dl_ch0_128+=1; + dl_ch1_128+=1; + ch0conj_ch1_128+=1; + } + _mm_empty(); + _m_empty(); +} - switch (N_RB_DL) { - case 6: - nb_subbands = 6; - subband_size = 12; - last_subband_size = 0; - break; +void construct_HhH_elements(int *ch0conj_ch0, //00_00 + int *ch1conj_ch1,//01_01 + int *ch2conj_ch2,//11_11 + int *ch3conj_ch3,//10_10 + int *ch0conj_ch1,//00_01 + int *ch1conj_ch0,//01_00 + int *ch2conj_ch3,//10_11 + int *ch3conj_ch2,//11_10 + 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 short rb; + __m128i *ch0conj_ch0_128, *ch1conj_ch1_128, *ch2conj_ch2_128, *ch3conj_ch3_128; + __m128i *ch0conj_ch1_128, *ch1conj_ch0_128, *ch2conj_ch3_128, *ch3conj_ch2_128; + __m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128; - default: - case 25: - nb_subbands = 7; - subband_size = 4*12; - last_subband_size = 12; - break; + ch0conj_ch0_128 = (__m128i *)ch0conj_ch0; + ch1conj_ch1_128 = (__m128i *)ch1conj_ch1; + ch2conj_ch2_128 = (__m128i *)ch2conj_ch2; + ch3conj_ch3_128 = (__m128i *)ch3conj_ch3; + ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; + ch1conj_ch0_128 = (__m128i *)ch1conj_ch0; + ch2conj_ch3_128 = (__m128i *)ch2conj_ch3; + ch3conj_ch2_128 = (__m128i *)ch3conj_ch2; + 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; - case 50: - nb_subbands = 9; - subband_size = 6*12; - last_subband_size = 2*12; - break; + for (rb=0; rb<3*nb_rb; rb++) { - case 100: - nb_subbands = 13; - subband_size = 8*12; - last_subband_size = 4*12; - break; - } + after_mf_00_128[0] =_mm_adds_epi16(ch0conj_ch0_128[0],ch3conj_ch3_128[0]);// _mm_adds_epi32(ch0conj_ch0_128[0], ch3conj_ch3_128[0]); //00_00 + 10_10 + after_mf_11_128[0] =_mm_adds_epi16(ch1conj_ch1_128[0], ch2conj_ch2_128[0]); //01_01 + 11_11 + after_mf_01_128[0] =_mm_adds_epi16(ch0conj_ch1_128[0], ch2conj_ch3_128[0]);//00_01 + 10_11 + after_mf_10_128[0] =_mm_adds_epi16(ch1conj_ch0_128[0], ch3conj_ch2_128[0]);//01_00 + 11_10 - // signal measurements - for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) { - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { - ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = - (signal_energy_nodc(&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][(aatx<<1) + aarx][0], - (N_RB_DL*12))); - //- ue->measurements.n0_power[aarx]; +#ifdef DEBUG_RANK_EST + printf(" \n construct_HhH_elements \n"); + print_shorts("ch0conj_ch0_128:",(int16_t*)&ch0conj_ch0_128[0]); + print_shorts("ch1conj_ch1_128:",(int16_t*)&ch1conj_ch1_128[0]); + print_shorts("ch2conj_ch2_128:",(int16_t*)&ch2conj_ch2_128[0]); + print_shorts("ch3conj_ch3_128:",(int16_t*)&ch3conj_ch3_128[0]); + print_shorts("ch0conj_ch1_128:",(int16_t*)&ch0conj_ch1_128[0]); + print_shorts("ch1conj_ch0_128:",(int16_t*)&ch1conj_ch0_128[0]); + print_shorts("ch2conj_ch3_128:",(int16_t*)&ch2conj_ch3_128[0]); + print_shorts("ch3conj_ch2_128:",(int16_t*)&ch3conj_ch2_128[0]); + 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 - if (ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]<0) - ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = 0; //ue->measurements.n0_power[aarx]; + ch0conj_ch0_128+=1; + ch1conj_ch1_128+=1; + ch2conj_ch2_128+=1; + ch3conj_ch3_128+=1; + ch0conj_ch1_128+=1; + ch1conj_ch0_128+=1; + ch2conj_ch3_128+=1; + ch3conj_ch2_128+=1; - ue->measurements.rx_spatial_power_dB[eNB_id][aatx][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]); + after_mf_00_128+=1; + after_mf_01_128+=1; + after_mf_10_128+=1; + after_mf_11_128+=1; + } + _mm_empty(); + _m_empty(); +} - if (aatx==0) - ue->measurements.rx_power[eNB_id][aarx] = ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; - else - ue->measurements.rx_power[eNB_id][aarx] += ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; - } //aatx - ue->measurements.rx_power_dB[eNB_id][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_power[eNB_id][aarx]); +void squared_matrix_element(int32_t *Hh_h_00, + int32_t *Hh_h_00_sq, + unsigned short nb_rb) +{ + unsigned short rb; + __m128i *Hh_h_00_128,*Hh_h_00_sq_128; - if (aarx==0) - ue->measurements.rx_power_tot[eNB_id] = ue->measurements.rx_power[eNB_id][aarx]; - else - ue->measurements.rx_power_tot[eNB_id] += ue->measurements.rx_power[eNB_id][aarx]; - } //aarx + Hh_h_00_128 = (__m128i *)Hh_h_00; + Hh_h_00_sq_128 = (__m128i *)Hh_h_00_sq; - ue->measurements.rx_power_tot_dB[eNB_id] = (unsigned short) dB_fixed(ue->measurements.rx_power_tot[eNB_id]); + for (rb=0; rb<3*nb_rb; rb++) { - } //eNB_id + Hh_h_00_sq_128[0] = _mm_madd_epi16(Hh_h_00_128[0],Hh_h_00_128[0]); - eNB_id=0; - if (ue->transmission_mode[0]==4 || ue->transmission_mode[0]==3){ - if (rank_adaptation == 1) - rank_tm3_tm4 = rank_estimation_tm3_tm4(&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][0][4], - &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][2][4], - &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][1][4], - &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][3][4], - N_RB_DL); - else - rank_tm3_tm4=1; #ifdef DEBUG_RANK_EST - printf("rank tm3 or tm4 %d\n", rank_tm3_tm4); + printf("\n Computing squared_matrix_element \n"); + print_shorts("Hh_h_00_128:",(int16_t*)&Hh_h_00_128[0]); + print_ints("Hh_h_00_sq_128:",(int32_t*)&Hh_h_00_sq_128[0]); #endif + + Hh_h_00_sq_128+=1; + Hh_h_00_128+=1; } + _mm_empty(); + _m_empty(); +} - if (ue->transmission_mode[eNB_id]!=4 && ue->transmission_mode[eNB_id]!=3) - ue->measurements.rank[eNB_id] = 0; - else - ue->measurements.rank[eNB_id] = rank_tm3_tm4; - // printf ("tx mode %d\n", ue->transmission_mode[eNB_id]); - // printf ("rank %d\n", ue->PHY_measurements.rank[eNB_id]); - // filter to remove jitter - if (ue->init_averaging == 0) { - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) - ue->measurements.rx_power_avg[eNB_id] = (int) - (((k1*((long long int)(ue->measurements.rx_power_avg[eNB_id]))) + - (k2*((long long int)(ue->measurements.rx_power_tot[eNB_id]))))>>10); - //LOG_I(PHY,"Noise Power Computation: k1 %d k2 %d n0 avg %d n0 tot %d\n", k1, k2, ue->measurements.n0_power_avg, - // ue->measurements.n0_power_tot); - ue->measurements.n0_power_avg = (int) - (((k1*((long long int) (ue->measurements.n0_power_avg))) + - (k2*((long long int) (ue->measurements.n0_power_tot))))>>10); - } else { - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) - ue->measurements.rx_power_avg[eNB_id] = ue->measurements.rx_power_tot[eNB_id]; +void det_HhH(int32_t *after_mf_00, + int32_t *after_mf_01, + int32_t *after_mf_10, + int32_t *after_mf_11, + int32_t *det_fin, + unsigned short nb_rb) - ue->measurements.n0_power_avg = ue->measurements.n0_power_tot; - ue->init_averaging = 0; - } +{ + 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; + __m128i *det_fin_128, det_128; - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { - ue->measurements.rx_power_avg_dB[eNB_id] = dB_fixed( ue->measurements.rx_power_avg[eNB_id]); - ue->measurements.wideband_cqi_tot[eNB_id] = dB_fixed2(ue->measurements.rx_power_tot[eNB_id],ue->measurements.n0_power_tot); - ue->measurements.wideband_cqi_avg[eNB_id] = dB_fixed2(ue->measurements.rx_power_avg[eNB_id],ue->measurements.n0_power_avg); - ue->measurements.rx_rssi_dBm[eNB_id] = ue->measurements.rx_power_avg_dB[eNB_id] - ue->rx_total_gain_dB; -#ifdef DEBUG_MEAS_UE - LOG_I(PHY,"[eNB %d] Subframe %d, RSSI %d dBm, RSSI (digital) %d dB, WBandCQI %d dB, rxPwrAvg %d, n0PwrAvg %d\n", - eNB_id, - subframe, - ue->measurements.rx_rssi_dBm[eNB_id], - ue->measurements.rx_power_avg_dB[eNB_id], - ue->measurements.wideband_cqi_avg[eNB_id], - ue->measurements.rx_power_avg[eNB_id], - ue->measurements.n0_power_tot); -#endif - } + 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; - ue->measurements.n0_power_avg_dB = dB_fixed( ue->measurements.n0_power_avg); + det_fin_128 = (__m128i *)det_fin; - for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { - if (frame_parms->nb_antenna_ports_eNB!=1) { - // cqi/pmi information + for (rb=0; rb<3*nb_rb; rb++) { - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - dl_ch1 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; + ad_re_128 = _mm_madd_epi16(after_mf_00_128[0],after_mf_11_128[0]); + bc_re_128 = _mm_madd_epi16(after_mf_01_128[0],after_mf_01_128[0]); + det_128 = _mm_sub_epi32(ad_re_128, bc_re_128); + det_fin_128[0] = _mm_abs_epi32(det_128); - for (subband=0; subband<nb_subbands; subband++) { +#ifdef DEBUG_RANK_EST + printf("\n Computing denominator \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]); + print_ints("ad_re_128:",(int32_t*)&ad_re_128); + print_ints("bc_re_128:",(int32_t*)&bc_re_128); + print_ints("det_fin_128:",(int32_t*)&det_fin_128[0]); +#endif - // cqi - if (aarx==0) - ue->measurements.subband_cqi_tot[eNB_id][subband]=0; + 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(); +} - if ((subband<(nb_subbands-1))||(N_RB_DL==6)) { - /*for (i=0;i<48;i++) - msg("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - */ - ue->measurements.subband_cqi[eNB_id][aarx][subband] = - (signal_energy_nodc(dl_ch0,subband_size) + signal_energy_nodc(dl_ch1,subband_size)); +void numer(int32_t *Hh_h_00_sq, + int32_t *Hh_h_01_sq, + int32_t *Hh_h_10_sq, + int32_t *Hh_h_11_sq, + int32_t *num_fin, + unsigned short nb_rb) - if ( ue->measurements.subband_cqi[eNB_id][aarx][subband] < 0) - ue->measurements.subband_cqi[eNB_id][aarx][subband]=0; +{ + unsigned short rb; + __m128i *h_h_00_sq_128, *h_h_01_sq_128, *h_h_10_sq_128, *h_h_11_sq_128; + __m128i *num_fin_128, sq_a_plus_sq_d_128, sq_b_plus_sq_c_128; - /* - else - ue->measurements.subband_cqi[eNB_id][aarx][subband]-=ue->measurements.n0_power[aarx]; - */ + h_h_00_sq_128 = (__m128i *)Hh_h_00_sq; + h_h_01_sq_128 = (__m128i *)Hh_h_01_sq; + h_h_10_sq_128 = (__m128i *)Hh_h_10_sq; + h_h_11_sq_128 = (__m128i *)Hh_h_11_sq; - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } else { // this is for the last subband which is smaller in size - // for (i=0;i<12;i++) - // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,last_subband_size) + - signal_energy_nodc(dl_ch1,last_subband_size)); // - ue->measurements.n0_power[aarx]; - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } + num_fin_128 = (__m128i *)num_fin; - dl_ch1+=subband_size; - dl_ch0+=subband_size; - // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); - } + for (rb=0; rb<3*nb_rb; rb++) { - } + sq_a_plus_sq_d_128 = _mm_add_epi32(h_h_00_sq_128[0],h_h_11_sq_128[0]); + sq_b_plus_sq_c_128 = _mm_add_epi32(h_h_01_sq_128[0],h_h_10_sq_128[0]); + num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128); - for (subband=0; subband<nb_subbands; subband++) { - ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); - // msg("subband_cqi_tot[%d][%d] => %d dB (n0 %d)\n",eNB_id,subband,ue->measurements.subband_cqi_tot_dB[eNB_id][subband],ue->measurements.n0_power_tot); - } +#ifdef DEBUG_RANK_EST + printf("\n Computing numerator \n"); + print_ints("h_h_00_sq_128:",(int32_t*)&h_h_00_sq_128[0]); + print_ints("h_h_01_sq_128:",(int32_t*)&h_h_01_sq_128[0]); + print_ints("h_h_10_sq_128:",(int32_t*)&h_h_10_sq_128[0]); + print_ints("h_h_11_sq_128:",(int32_t*)&h_h_11_sq_128[0]); + print_shorts("sq_a_plus_sq_d_128:",(int16_t*)&sq_a_plus_sq_d_128); + print_shorts("sq_b_plus_sq_c_128:",(int16_t*)&sq_b_plus_sq_c_128); + print_shorts("num_fin_128:",(int16_t*)&num_fin_128[0]); +#endif - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - //printf("aarx=%d", aarx); - // skip the first 4 RE due to interpolation filter length of 5 (not possible to skip 5 due to 128i alignment, must be multiple of 128bit) + num_fin_128+=1; + h_h_00_sq_128+=1; + h_h_01_sq_128+=1; + h_h_10_sq_128+=1; + h_h_11_sq_128+=1; + } + _mm_empty(); + _m_empty(); +} -#if defined(__x86_64__) || defined(__i386__) - __m128i pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1 /* ,mmtmpPMI2,mmtmpPMI3 */ ; +void dlsch_channel_level_TM34_meas(int *ch00, + int *ch01, + int *ch10, + int *ch11, + int *avg_0, + int *avg_1, + unsigned short nb_rb) +{ - dl_ch0_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - dl_ch1_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; -#elif defined(__arm__) - int32x4_t pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1,mmtmpPMI0b,mmtmpPMI1b; +#if defined(__x86_64__)||defined(__i386__) - dl_ch0_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - dl_ch1_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; + short rb; + unsigned char nre=12; + __m128i *ch00_128, *ch01_128, *ch10_128, *ch11_128; + __m128i avg_0_row0_128D, avg_1_row0_128D, avg_0_row1_128D, avg_1_row1_128D; + __m128i ch00_128_tmp, ch01_128_tmp, ch10_128_tmp, ch11_128_tmp; -#endif - for (subband=0; subband<nb_subbands; subband++) { + avg_0[0] = 0; + avg_0[1] = 0; + avg_1[0] = 0; + avg_1[1] = 0; + ch00_128 = (__m128i *)ch00; + ch01_128 = (__m128i *)ch01; + ch10_128 = (__m128i *)ch10; + ch11_128 = (__m128i *)ch11; - // pmi -#if defined(__x86_64__) || defined(__i386__) + avg_0_row0_128D = _mm_setzero_si128(); + avg_1_row0_128D = _mm_setzero_si128(); + avg_0_row1_128D = _mm_setzero_si128(); + avg_1_row1_128D = _mm_setzero_si128(); - pmi128_re = _mm_xor_si128(pmi128_re,pmi128_re); - pmi128_im = _mm_xor_si128(pmi128_im,pmi128_im); -#elif defined(__arm__) + for (rb=0; rb<3*nb_rb; rb++) { + ch00_128_tmp = _mm_load_si128(&ch00_128[0]); + ch01_128_tmp = _mm_load_si128(&ch01_128[0]); + ch10_128_tmp = _mm_load_si128(&ch10_128[0]); + ch11_128_tmp = _mm_load_si128(&ch11_128[0]); - pmi128_re = vdupq_n_s32(0); - pmi128_im = vdupq_n_s32(0); -#endif - // limit is the number of groups of 4 REs in a subband (12 = 4 RBs, 3 = 1 RB) - // for 5 MHz channelization, there are 7 subbands, 6 of size 4 RBs and 1 of size 1 RB - if ((N_RB_DL==6) || (subband<(nb_subbands-1))) - limit = subband_size>>2; - else - limit = last_subband_size>>2; + avg_0_row0_128D = _mm_add_epi32(avg_0_row0_128D,_mm_madd_epi16(ch00_128_tmp,ch00_128_tmp)); + avg_1_row0_128D = _mm_add_epi32(avg_1_row0_128D,_mm_madd_epi16(ch01_128_tmp,ch01_128_tmp)); + avg_0_row1_128D = _mm_add_epi32(avg_0_row1_128D,_mm_madd_epi16(ch10_128_tmp,ch10_128_tmp)); + avg_1_row1_128D = _mm_add_epi32(avg_1_row1_128D,_mm_madd_epi16(ch11_128_tmp,ch11_128_tmp)); - for (i=0; i<limit; i++) { + ch00_128+=1; + ch01_128+=1; + ch10_128+=1; + ch11_128+=1; + } -#if defined(__x86_64__) || defined(__i386__) - mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); - mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); + avg_0[0] = (((int*)&avg_0_row0_128D)[0])/(nb_rb*nre) + + (((int*)&avg_0_row0_128D)[1])/(nb_rb*nre) + + (((int*)&avg_0_row0_128D)[2])/(nb_rb*nre) + + (((int*)&avg_0_row0_128D)[3])/(nb_rb*nre); - // For each RE in subband perform ch0 * conj(ch1) - // multiply by conjugated channel - // print_ints("ch0",&dl_ch0_128[0]); - // print_ints("ch1",&dl_ch1_128[0]); + avg_1[0] = (((int*)&avg_1_row0_128D)[0])/(nb_rb*nre) + + (((int*)&avg_1_row0_128D)[1])/(nb_rb*nre) + + (((int*)&avg_1_row0_128D)[2])/(nb_rb*nre) + + (((int*)&avg_1_row0_128D)[3])/(nb_rb*nre); - mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]); - // print_ints("re",&mmtmpPMI0); - mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[0],_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate[0]); - // print_ints("_mm_sign_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[0]); - // print_ints("mm_madd_epi16",&mmtmpPMI1); - // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) - pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); - // print_ints(" pmi128_re 0",&pmi128_re); - pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); - // print_ints(" pmi128_im 0 ",&pmi128_im); + avg_0[1] = (((int*)&avg_0_row1_128D)[0])/(nb_rb*nre) + + (((int*)&avg_0_row1_128D)[1])/(nb_rb*nre) + + (((int*)&avg_0_row1_128D)[2])/(nb_rb*nre) + + (((int*)&avg_0_row1_128D)[3])/(nb_rb*nre); - /* mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); - mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); + avg_1[1] = (((int*)&avg_1_row1_128D)[0])/(nb_rb*nre) + + (((int*)&avg_1_row1_128D)[1])/(nb_rb*nre) + + (((int*)&avg_1_row1_128D)[2])/(nb_rb*nre) + + (((int*)&avg_1_row1_128D)[3])/(nb_rb*nre); - mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[1],dl_ch1_128[1]); - // print_ints("re",&mmtmpPMI0); - mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[1],_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); - // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate); - // print_ints("_mm_sign_epi16",&mmtmpPMI1); - mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[1]); - // print_ints("mm_madd_epi16",&mmtmpPMI1); - // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) - pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); - // print_ints(" pmi128_re 1",&pmi128_re); - pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); - //print_ints(" pmi128_im 1 ",&pmi128_im);*/ + avg_0[0] = avg_0[0] + avg_0[1]; + avg_1[0] = avg_1[0] + avg_1[1]; + avg_0[0] = min (avg_0[0], avg_1[0]); + avg_1[0] = avg_0[0]; + + _mm_empty(); + _m_empty(); #elif defined(__arm__) - mmtmpPMI0 = vmull_s16(((int16x4_t*)dl_ch0_128)[0], ((int16x4_t*)dl_ch1_128)[0]); - mmtmpPMI1 = vmull_s16(((int16x4_t*)dl_ch0_128)[1], ((int16x4_t*)dl_ch1_128)[1]); - pmi128_re = vqaddq_s32(pmi128_re,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0),vget_high_s32(mmtmpPMI0)),vpadd_s32(vget_low_s32(mmtmpPMI1),vget_high_s32(mmtmpPMI1)))); +#endif +} - mmtmpPMI0b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[0],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[0]); - mmtmpPMI1b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[1],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[1]); - pmi128_im = vqaddq_s32(pmi128_im,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0b),vget_high_s32(mmtmpPMI0b)),vpadd_s32(vget_low_s32(mmtmpPMI1b),vget_high_s32(mmtmpPMI1b)))); +uint8_t rank_estimation_tm3_tm4 (int *dl_ch_estimates_00, // please respect the order of channel estimates + int *dl_ch_estimates_01, + int *dl_ch_estimates_10, + int *dl_ch_estimates_11, + unsigned short nb_rb) +{ -#endif - dl_ch0_128++; - dl_ch1_128++; - } - - ue->measurements.subband_pmi_re[eNB_id][subband][aarx] = (((int *)&pmi128_re)[0] + ((int *)&pmi128_re)[1] + ((int *)&pmi128_re)[2] + ((int *)&pmi128_re)[3])>>2; - ue->measurements.subband_pmi_im[eNB_id][subband][aarx] = (((int *)&pmi128_im)[0] + ((int *)&pmi128_im)[1] + ((int *)&pmi128_im)[2] + ((int *)&pmi128_im)[3])>>2; - ue->measurements.wideband_pmi_re[eNB_id][aarx] += ue->measurements.subband_pmi_re[eNB_id][subband][aarx]; - ue->measurements.wideband_pmi_im[eNB_id][aarx] += ue->measurements.subband_pmi_im[eNB_id][subband][aarx]; - } // subband loop - } // rx antenna loop - } // if frame_parms->mode1_flag == 0 - else { - // cqi information only for mode 1 - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - - for (subband=0; subband<7; subband++) { - - // cqi - if (aarx==0) - ue->measurements.subband_cqi_tot[eNB_id][subband]=0; - - if (subband<6) { - // for (i=0;i<48;i++) - // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = - (signal_energy_nodc(dl_ch0,48) ) - ue->measurements.n0_power[aarx]; - - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } else { - // for (i=0;i<12;i++) - // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); - ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,12) ) - ue->measurements.n0_power[aarx]; - ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; - ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], - ue->measurements.n0_power[aarx]); - } - - dl_ch1+=48; - // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); - } - } - - for (subband=0; subband<nb_subbands; subband++) { - ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); - } - } - - //ue->measurements.rank[eNB_id] = 0; - - for (i=0; i<nb_subbands; i++) { - ue->measurements.selected_rx_antennas[eNB_id][i] = 0; - - if (frame_parms->nb_antennas_rx>1) { - if (ue->measurements.subband_cqi_dB[eNB_id][0][i] >= ue->measurements.subband_cqi_dB[eNB_id][1][i]) - ue->measurements.selected_rx_antennas[eNB_id][i] = 0; - else - ue->measurements.selected_rx_antennas[eNB_id][i] = 1; - } else - ue->measurements.selected_rx_antennas[eNB_id][i] = 0; - } - - // if(eNB_id==0) - // printf("in lte_ue_measurements: selected rx_antenna[eNB_id==0]:%u\n", ue->measurements.selected_rx_antennas[eNB_id][i]); - } // eNB_id loop - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - - -void lte_ue_measurements_emul(PHY_VARS_UE *ue,uint8_t subframe,uint8_t eNB_id) -{ - - LOG_D(PHY,"EMUL UE lte_ue_measurements_emul subframe %d, eNB_id %d\n",subframe,eNB_id); -} - - -uint8_t rank_estimation_tm3_tm4 (int *dl_ch_estimates_00, // please respect the order of channel estimates - int *dl_ch_estimates_01, - int *dl_ch_estimates_10, - int *dl_ch_estimates_11, - unsigned short nb_rb) -{ - - int i=0; - int rank=0; - int N_RB=nb_rb; - int *ch00_rank, *ch01_rank, *ch10_rank, *ch11_rank; + int i=0; + int rank=0; + int N_RB=nb_rb; + int *ch00_rank, *ch01_rank, *ch10_rank, *ch11_rank; int32_t shift; int avg_0[2]; @@ -1058,328 +998,390 @@ uint8_t rank_estimation_tm3_tm4 (int *dl_ch_estimates_00, // please respect the return(rank); } -void 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 Hhermitian * H matrix - 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*)&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); -#ifdef DEBUG_RANK_EST - 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]); +void lte_ue_measurements(PHY_VARS_UE *ue, + unsigned int subframe_offset, + unsigned char N0_symbol, + unsigned char abstraction_flag, + unsigned char rank_adaptation, + uint8_t subframe) +{ + + + int aarx,aatx,eNB_id=0; //,gain_offset=0; + //int rx_power[NUMBER_OF_CONNECTED_eNB_MAX]; + int i; + unsigned int limit,subband; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch0_128,*dl_ch1_128; +#elif defined(__arm__) + int16x8_t *dl_ch0_128, *dl_ch1_128; #endif + int *dl_ch0,*dl_ch1; - dl_ch0_128+=1; - dl_ch1_128+=1; - ch0conj_ch1_128+=1; - } - _mm_empty(); - _m_empty(); -} + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int nb_subbands,subband_size,last_subband_size; + int N_RB_DL = frame_parms->N_RB_DL; -void construct_HhH_elements(int *ch0conj_ch0, //00_00 - int *ch1conj_ch1,//01_01 - int *ch2conj_ch2,//11_11 - int *ch3conj_ch3,//10_10 - int *ch0conj_ch1,//00_01 - int *ch1conj_ch0,//01_00 - int *ch2conj_ch3,//10_11 - int *ch3conj_ch2,//11_10 - 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 short rb; - __m128i *ch0conj_ch0_128, *ch1conj_ch1_128, *ch2conj_ch2_128, *ch3conj_ch3_128; - __m128i *ch0conj_ch1_128, *ch1conj_ch0_128, *ch2conj_ch3_128, *ch3conj_ch2_128; - __m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128; - ch0conj_ch0_128 = (__m128i *)ch0conj_ch0; - ch1conj_ch1_128 = (__m128i *)ch1conj_ch1; - ch2conj_ch2_128 = (__m128i *)ch2conj_ch2; - ch3conj_ch3_128 = (__m128i *)ch3conj_ch3; - ch0conj_ch1_128 = (__m128i *)ch0conj_ch1; - ch1conj_ch0_128 = (__m128i *)ch1conj_ch0; - ch2conj_ch3_128 = (__m128i *)ch2conj_ch3; - ch3conj_ch2_128 = (__m128i *)ch3conj_ch2; - 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; + int rank_tm3_tm4; - for (rb=0; rb<3*nb_rb; rb++) { - after_mf_00_128[0] =_mm_adds_epi16(ch0conj_ch0_128[0],ch3conj_ch3_128[0]);// _mm_adds_epi32(ch0conj_ch0_128[0], ch3conj_ch3_128[0]); //00_00 + 10_10 - after_mf_11_128[0] =_mm_adds_epi16(ch1conj_ch1_128[0], ch2conj_ch2_128[0]); //01_01 + 11_11 - after_mf_01_128[0] =_mm_adds_epi16(ch0conj_ch1_128[0], ch2conj_ch3_128[0]);//00_01 + 10_11 - after_mf_10_128[0] =_mm_adds_epi16(ch1conj_ch0_128[0], ch3conj_ch2_128[0]);//01_00 + 11_10 + ue->measurements.nb_antennas_rx = frame_parms->nb_antennas_rx; -#ifdef DEBUG_RANK_EST - printf(" \n construct_HhH_elements \n"); - print_shorts("ch0conj_ch0_128:",(int16_t*)&ch0conj_ch0_128[0]); - print_shorts("ch1conj_ch1_128:",(int16_t*)&ch1conj_ch1_128[0]); - print_shorts("ch2conj_ch2_128:",(int16_t*)&ch2conj_ch2_128[0]); - print_shorts("ch3conj_ch3_128:",(int16_t*)&ch3conj_ch3_128[0]); - print_shorts("ch0conj_ch1_128:",(int16_t*)&ch0conj_ch1_128[0]); - print_shorts("ch1conj_ch0_128:",(int16_t*)&ch1conj_ch0_128[0]); - print_shorts("ch2conj_ch3_128:",(int16_t*)&ch2conj_ch3_128[0]); - print_shorts("ch3conj_ch2_128:",(int16_t*)&ch3conj_ch2_128[0]); - 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 - ch0conj_ch0_128+=1; - ch1conj_ch1_128+=1; - ch2conj_ch2_128+=1; - ch3conj_ch3_128+=1; - ch0conj_ch1_128+=1; - ch1conj_ch0_128+=1; - ch2conj_ch3_128+=1; - ch3conj_ch2_128+=1; + switch (N_RB_DL) { + case 6: + nb_subbands = 6; + subband_size = 12; + last_subband_size = 0; + break; - after_mf_00_128+=1; - after_mf_01_128+=1; - after_mf_10_128+=1; - after_mf_11_128+=1; + default: + case 25: + nb_subbands = 7; + subband_size = 4*12; + last_subband_size = 12; + break; + + case 50: + nb_subbands = 9; + subband_size = 6*12; + last_subband_size = 2*12; + break; + + case 100: + nb_subbands = 13; + subband_size = 8*12; + last_subband_size = 4*12; + break; } - _mm_empty(); - _m_empty(); -} + // signal measurements + for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) { + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { + ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = + (signal_energy_nodc(&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][(aatx<<1) + aarx][0], + (N_RB_DL*12))); + //- ue->measurements.n0_power[aarx]; -void squared_matrix_element(int32_t *Hh_h_00, - int32_t *Hh_h_00_sq, - unsigned short nb_rb) -{ - unsigned short rb; - __m128i *Hh_h_00_128,*Hh_h_00_sq_128; + if (ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]<0) + ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] = 0; //ue->measurements.n0_power[aarx]; - Hh_h_00_128 = (__m128i *)Hh_h_00; - Hh_h_00_sq_128 = (__m128i *)Hh_h_00_sq; + ue->measurements.rx_spatial_power_dB[eNB_id][aatx][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]); - for (rb=0; rb<3*nb_rb; rb++) { + if (aatx==0) + ue->measurements.rx_power[eNB_id][aarx] = ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; + else + ue->measurements.rx_power[eNB_id][aarx] += ue->measurements.rx_spatial_power[eNB_id][aatx][aarx]; + } //aatx - Hh_h_00_sq_128[0] = _mm_madd_epi16(Hh_h_00_128[0],Hh_h_00_128[0]); + ue->measurements.rx_power_dB[eNB_id][aarx] = (unsigned short) dB_fixed(ue->measurements.rx_power[eNB_id][aarx]); + + if (aarx==0) + ue->measurements.rx_power_tot[eNB_id] = ue->measurements.rx_power[eNB_id][aarx]; + else + ue->measurements.rx_power_tot[eNB_id] += ue->measurements.rx_power[eNB_id][aarx]; + } //aarx + + ue->measurements.rx_power_tot_dB[eNB_id] = (unsigned short) dB_fixed(ue->measurements.rx_power_tot[eNB_id]); + } //eNB_id + + eNB_id=0; + if (ue->transmission_mode[0]==4 || ue->transmission_mode[0]==3){ + if (rank_adaptation == 1) + rank_tm3_tm4 = rank_estimation_tm3_tm4(&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][0][4], + &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][2][4], + &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][1][4], + &ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][3][4], + N_RB_DL); + else + rank_tm3_tm4=1; #ifdef DEBUG_RANK_EST - printf("\n Computing squared_matrix_element \n"); - print_shorts("Hh_h_00_128:",(int16_t*)&Hh_h_00_128[0]); - print_ints("Hh_h_00_sq_128:",(int32_t*)&Hh_h_00_sq_128[0]); + printf("rank tm3 or tm4 %d\n", rank_tm3_tm4); #endif + } - Hh_h_00_sq_128+=1; - Hh_h_00_128+=1; + if (ue->transmission_mode[eNB_id]!=4 && ue->transmission_mode[eNB_id]!=3) + ue->measurements.rank[eNB_id] = 0; + else + ue->measurements.rank[eNB_id] = rank_tm3_tm4; + // printf ("tx mode %d\n", ue->transmission_mode[eNB_id]); + // printf ("rank %d\n", ue->PHY_measurements.rank[eNB_id]); + + // filter to remove jitter + if (ue->init_averaging == 0) { + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) + ue->measurements.rx_power_avg[eNB_id] = (int) + (((k1*((long long int)(ue->measurements.rx_power_avg[eNB_id]))) + + (k2*((long long int)(ue->measurements.rx_power_tot[eNB_id]))))>>10); + + //LOG_I(PHY,"Noise Power Computation: k1 %d k2 %d n0 avg %d n0 tot %d\n", k1, k2, ue->measurements.n0_power_avg, + // ue->measurements.n0_power_tot); + ue->measurements.n0_power_avg = (int) + (((k1*((long long int) (ue->measurements.n0_power_avg))) + + (k2*((long long int) (ue->measurements.n0_power_tot))))>>10); + } else { + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) + ue->measurements.rx_power_avg[eNB_id] = ue->measurements.rx_power_tot[eNB_id]; + + ue->measurements.n0_power_avg = ue->measurements.n0_power_tot; + ue->init_averaging = 0; } - _mm_empty(); - _m_empty(); -} + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { + ue->measurements.rx_power_avg_dB[eNB_id] = dB_fixed( ue->measurements.rx_power_avg[eNB_id]); + ue->measurements.wideband_cqi_tot[eNB_id] = dB_fixed2(ue->measurements.rx_power_tot[eNB_id],ue->measurements.n0_power_tot); + ue->measurements.wideband_cqi_avg[eNB_id] = dB_fixed2(ue->measurements.rx_power_avg[eNB_id],ue->measurements.n0_power_avg); + ue->measurements.rx_rssi_dBm[eNB_id] = ue->measurements.rx_power_avg_dB[eNB_id] - ue->rx_total_gain_dB; +#ifdef DEBUG_MEAS_UE + LOG_I(PHY,"[eNB %d] Subframe %d, RSSI %d dBm, RSSI (digital) %d dB, WBandCQI %d dB, rxPwrAvg %d, n0PwrAvg %d\n", + eNB_id, + subframe, + ue->measurements.rx_rssi_dBm[eNB_id], + ue->measurements.rx_power_avg_dB[eNB_id], + ue->measurements.wideband_cqi_avg[eNB_id], + ue->measurements.rx_power_avg[eNB_id], + ue->measurements.n0_power_tot); +#endif + } + ue->measurements.n0_power_avg_dB = dB_fixed( ue->measurements.n0_power_avg); -void det_HhH(int32_t *after_mf_00, - int32_t *after_mf_01, - int32_t *after_mf_10, - int32_t *after_mf_11, - int32_t *det_fin, - unsigned short nb_rb) + for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) { + if (frame_parms->nb_antenna_ports_eNB!=1) { + // cqi/pmi information -{ - 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; - __m128i *det_fin_128, det_128; + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; + dl_ch1 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; - 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 (subband=0; subband<nb_subbands; subband++) { - det_fin_128 = (__m128i *)det_fin; + // cqi + if (aarx==0) + ue->measurements.subband_cqi_tot[eNB_id][subband]=0; - for (rb=0; rb<3*nb_rb; rb++) { + if ((subband<(nb_subbands-1))||(N_RB_DL==6)) { + /*for (i=0;i<48;i++) + msg("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + */ + ue->measurements.subband_cqi[eNB_id][aarx][subband] = + (signal_energy_nodc(dl_ch0,subband_size) + signal_energy_nodc(dl_ch1,subband_size)); - ad_re_128 = _mm_madd_epi16(after_mf_00_128[0],after_mf_11_128[0]); - bc_re_128 = _mm_madd_epi16(after_mf_01_128[0],after_mf_01_128[0]); - det_128 = _mm_sub_epi32(ad_re_128, bc_re_128); - det_fin_128[0] = _mm_abs_epi32(det_128); + if ( ue->measurements.subband_cqi[eNB_id][aarx][subband] < 0) + ue->measurements.subband_cqi[eNB_id][aarx][subband]=0; -#ifdef DEBUG_RANK_EST - printf("\n Computing denominator \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]); - print_ints("ad_re_128:",(int32_t*)&ad_re_128); - print_ints("bc_re_128:",(int32_t*)&bc_re_128); - print_ints("det_fin_128:",(int32_t*)&det_fin_128[0]); -#endif + /* + else + ue->measurements.subband_cqi[eNB_id][aarx][subband]-=ue->measurements.n0_power[aarx]; + */ + + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } else { // this is for the last subband which is smaller in size + // for (i=0;i<12;i++) + // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,last_subband_size) + + signal_energy_nodc(dl_ch1,last_subband_size)); // - ue->measurements.n0_power[aarx]; + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } + + dl_ch1+=subband_size; + dl_ch0+=subband_size; + // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); + } + + } - 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(); -} + for (subband=0; subband<nb_subbands; subband++) { + ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); + // msg("subband_cqi_tot[%d][%d] => %d dB (n0 %d)\n",eNB_id,subband,ue->measurements.subband_cqi_tot_dB[eNB_id][subband],ue->measurements.n0_power_tot); + } -void numer(int32_t *Hh_h_00_sq, - int32_t *Hh_h_01_sq, - int32_t *Hh_h_10_sq, - int32_t *Hh_h_11_sq, - int32_t *num_fin, - unsigned short nb_rb) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + //printf("aarx=%d", aarx); + // skip the first 4 RE due to interpolation filter length of 5 (not possible to skip 5 due to 128i alignment, must be multiple of 128bit) -{ - unsigned short rb; - __m128i *h_h_00_sq_128, *h_h_01_sq_128, *h_h_10_sq_128, *h_h_11_sq_128; - __m128i *num_fin_128, sq_a_plus_sq_d_128, sq_b_plus_sq_c_128; +#if defined(__x86_64__) || defined(__i386__) + __m128i pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1 /* ,mmtmpPMI2,mmtmpPMI3 */ ; - h_h_00_sq_128 = (__m128i *)Hh_h_00_sq; - h_h_01_sq_128 = (__m128i *)Hh_h_01_sq; - h_h_10_sq_128 = (__m128i *)Hh_h_10_sq; - h_h_11_sq_128 = (__m128i *)Hh_h_11_sq; + dl_ch0_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; + dl_ch1_128 = (__m128i *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; +#elif defined(__arm__) + int32x4_t pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1,mmtmpPMI0b,mmtmpPMI1b; - num_fin_128 = (__m128i *)num_fin; + dl_ch0_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; + dl_ch1_128 = (int16x8_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][2+aarx][4]; - for (rb=0; rb<3*nb_rb; rb++) { +#endif + for (subband=0; subband<nb_subbands; subband++) { - sq_a_plus_sq_d_128 = _mm_add_epi32(h_h_00_sq_128[0],h_h_11_sq_128[0]); - sq_b_plus_sq_c_128 = _mm_add_epi32(h_h_01_sq_128[0],h_h_10_sq_128[0]); - num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128); -#ifdef DEBUG_RANK_EST - printf("\n Computing numerator \n"); - print_ints("h_h_00_sq_128:",(int32_t*)&h_h_00_sq_128[0]); - print_ints("h_h_01_sq_128:",(int32_t*)&h_h_01_sq_128[0]); - print_ints("h_h_10_sq_128:",(int32_t*)&h_h_10_sq_128[0]); - print_ints("h_h_11_sq_128:",(int32_t*)&h_h_11_sq_128[0]); - print_shorts("sq_a_plus_sq_d_128:",(int16_t*)&sq_a_plus_sq_d_128); - print_shorts("sq_b_plus_sq_c_128:",(int16_t*)&sq_b_plus_sq_c_128); - print_shorts("num_fin_128:",(int16_t*)&num_fin_128[0]); + // pmi +#if defined(__x86_64__) || defined(__i386__) + + pmi128_re = _mm_xor_si128(pmi128_re,pmi128_re); + pmi128_im = _mm_xor_si128(pmi128_im,pmi128_im); +#elif defined(__arm__) + + pmi128_re = vdupq_n_s32(0); + pmi128_im = vdupq_n_s32(0); #endif + // limit is the number of groups of 4 REs in a subband (12 = 4 RBs, 3 = 1 RB) + // for 5 MHz channelization, there are 7 subbands, 6 of size 4 RBs and 1 of size 1 RB + if ((N_RB_DL==6) || (subband<(nb_subbands-1))) + limit = subband_size>>2; + else + limit = last_subband_size>>2; - num_fin_128+=1; - h_h_00_sq_128+=1; - h_h_01_sq_128+=1; - h_h_10_sq_128+=1; - h_h_11_sq_128+=1; - } - _mm_empty(); - _m_empty(); -} + for (i=0; i<limit; i++) { +#if defined(__x86_64__) || defined(__i386__) + mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); + mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); + // For each RE in subband perform ch0 * conj(ch1) + // multiply by conjugated channel + // print_ints("ch0",&dl_ch0_128[0]); + // print_ints("ch1",&dl_ch1_128[0]); + mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]); + // print_ints("re",&mmtmpPMI0); + mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[0],_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate[0]); + // print_ints("_mm_sign_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[0]); + // print_ints("mm_madd_epi16",&mmtmpPMI1); + // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) + pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); + // print_ints(" pmi128_re 0",&pmi128_re); + pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); + // print_ints(" pmi128_im 0 ",&pmi128_im); + /* mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0); + mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1); -void dlsch_channel_level_TM34_meas(int *ch00, - int *ch01, - int *ch10, - int *ch11, - int *avg_0, - int *avg_1, - unsigned short nb_rb) -{ + mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[1],dl_ch1_128[1]); + // print_ints("re",&mmtmpPMI0); + mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[1],_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflelo_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1)); + // print_ints("_mm_shufflehi_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate); + // print_ints("_mm_sign_epi16",&mmtmpPMI1); + mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[1]); + // print_ints("mm_madd_epi16",&mmtmpPMI1); + // mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit) + pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0); + // print_ints(" pmi128_re 1",&pmi128_re); + pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1); + //print_ints(" pmi128_im 1 ",&pmi128_im);*/ -#if defined(__x86_64__)||defined(__i386__) +#elif defined(__arm__) - short rb; - unsigned char nre=12; - __m128i *ch00_128, *ch01_128, *ch10_128, *ch11_128; - __m128i avg_0_row0_128D, avg_1_row0_128D, avg_0_row1_128D, avg_1_row1_128D; - __m128i ch00_128_tmp, ch01_128_tmp, ch10_128_tmp, ch11_128_tmp; + mmtmpPMI0 = vmull_s16(((int16x4_t*)dl_ch0_128)[0], ((int16x4_t*)dl_ch1_128)[0]); + mmtmpPMI1 = vmull_s16(((int16x4_t*)dl_ch0_128)[1], ((int16x4_t*)dl_ch1_128)[1]); + pmi128_re = vqaddq_s32(pmi128_re,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0),vget_high_s32(mmtmpPMI0)),vpadd_s32(vget_low_s32(mmtmpPMI1),vget_high_s32(mmtmpPMI1)))); - avg_0[0] = 0; - avg_0[1] = 0; - avg_1[0] = 0; - avg_1[1] = 0; + mmtmpPMI0b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[0],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[0]); + mmtmpPMI1b = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)dl_ch0_128)[1],*(int16x4_t*)conjugate)), ((int16x4_t*)dl_ch1_128)[1]); + pmi128_im = vqaddq_s32(pmi128_im,vcombine_s32(vpadd_s32(vget_low_s32(mmtmpPMI0b),vget_high_s32(mmtmpPMI0b)),vpadd_s32(vget_low_s32(mmtmpPMI1b),vget_high_s32(mmtmpPMI1b)))); - ch00_128 = (__m128i *)ch00; - ch01_128 = (__m128i *)ch01; - ch10_128 = (__m128i *)ch10; - ch11_128 = (__m128i *)ch11; +#endif + dl_ch0_128++; + dl_ch1_128++; + } - avg_0_row0_128D = _mm_setzero_si128(); - avg_1_row0_128D = _mm_setzero_si128(); - avg_0_row1_128D = _mm_setzero_si128(); - avg_1_row1_128D = _mm_setzero_si128(); + ue->measurements.subband_pmi_re[eNB_id][subband][aarx] = (((int *)&pmi128_re)[0] + ((int *)&pmi128_re)[1] + ((int *)&pmi128_re)[2] + ((int *)&pmi128_re)[3])>>2; + ue->measurements.subband_pmi_im[eNB_id][subband][aarx] = (((int *)&pmi128_im)[0] + ((int *)&pmi128_im)[1] + ((int *)&pmi128_im)[2] + ((int *)&pmi128_im)[3])>>2; + ue->measurements.wideband_pmi_re[eNB_id][aarx] += ue->measurements.subband_pmi_re[eNB_id][subband][aarx]; + ue->measurements.wideband_pmi_im[eNB_id][aarx] += ue->measurements.subband_pmi_im[eNB_id][subband][aarx]; + } // subband loop + } // rx antenna loop + } // if frame_parms->mode1_flag == 0 + else { + // cqi information only for mode 1 + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + dl_ch0 = &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][aarx][4]; - for (rb=0; rb<3*nb_rb; rb++) { - ch00_128_tmp = _mm_load_si128(&ch00_128[0]); - ch01_128_tmp = _mm_load_si128(&ch01_128[0]); - ch10_128_tmp = _mm_load_si128(&ch10_128[0]); - ch11_128_tmp = _mm_load_si128(&ch11_128[0]); + for (subband=0; subband<7; subband++) { - avg_0_row0_128D = _mm_add_epi32(avg_0_row0_128D,_mm_madd_epi16(ch00_128_tmp,ch00_128_tmp)); - avg_1_row0_128D = _mm_add_epi32(avg_1_row0_128D,_mm_madd_epi16(ch01_128_tmp,ch01_128_tmp)); - avg_0_row1_128D = _mm_add_epi32(avg_0_row1_128D,_mm_madd_epi16(ch10_128_tmp,ch10_128_tmp)); - avg_1_row1_128D = _mm_add_epi32(avg_1_row1_128D,_mm_madd_epi16(ch11_128_tmp,ch11_128_tmp)); + // cqi + if (aarx==0) + ue->measurements.subband_cqi_tot[eNB_id][subband]=0; - ch00_128+=1; - ch01_128+=1; - ch10_128+=1; - ch11_128+=1; - } + if (subband<6) { + // for (i=0;i<48;i++) + // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + ue->measurements.subband_cqi[eNB_id][aarx][subband] = + (signal_energy_nodc(dl_ch0,48) ) - ue->measurements.n0_power[aarx]; - avg_0[0] = (((int*)&avg_0_row0_128D)[0])/(nb_rb*nre) + - (((int*)&avg_0_row0_128D)[1])/(nb_rb*nre) + - (((int*)&avg_0_row0_128D)[2])/(nb_rb*nre) + - (((int*)&avg_0_row0_128D)[3])/(nb_rb*nre); + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } else { + // for (i=0;i<12;i++) + // printf("subband %d (%d) : %d,%d\n",subband,i,((short *)dl_ch0)[2*i],((short *)dl_ch0)[1+(2*i)]); + ue->measurements.subband_cqi[eNB_id][aarx][subband] = (signal_energy_nodc(dl_ch0,12) ) - ue->measurements.n0_power[aarx]; + ue->measurements.subband_cqi_tot[eNB_id][subband] += ue->measurements.subband_cqi[eNB_id][aarx][subband]; + ue->measurements.subband_cqi_dB[eNB_id][aarx][subband] = dB_fixed2(ue->measurements.subband_cqi[eNB_id][aarx][subband], + ue->measurements.n0_power[aarx]); + } - avg_1[0] = (((int*)&avg_1_row0_128D)[0])/(nb_rb*nre) + - (((int*)&avg_1_row0_128D)[1])/(nb_rb*nre) + - (((int*)&avg_1_row0_128D)[2])/(nb_rb*nre) + - (((int*)&avg_1_row0_128D)[3])/(nb_rb*nre); + dl_ch1+=48; + // msg("subband_cqi[%d][%d][%d] => %d (%d dB)\n",eNB_id,aarx,subband,ue->measurements.subband_cqi[eNB_id][aarx][subband],ue->measurements.subband_cqi_dB[eNB_id][aarx][subband]); + } + } - avg_0[1] = (((int*)&avg_0_row1_128D)[0])/(nb_rb*nre) + - (((int*)&avg_0_row1_128D)[1])/(nb_rb*nre) + - (((int*)&avg_0_row1_128D)[2])/(nb_rb*nre) + - (((int*)&avg_0_row1_128D)[3])/(nb_rb*nre); + for (subband=0; subband<nb_subbands; subband++) { + ue->measurements.subband_cqi_tot_dB[eNB_id][subband] = dB_fixed2(ue->measurements.subband_cqi_tot[eNB_id][subband],ue->measurements.n0_power_tot); + } + } - avg_1[1] = (((int*)&avg_1_row1_128D)[0])/(nb_rb*nre) + - (((int*)&avg_1_row1_128D)[1])/(nb_rb*nre) + - (((int*)&avg_1_row1_128D)[2])/(nb_rb*nre) + - (((int*)&avg_1_row1_128D)[3])/(nb_rb*nre); + //ue->measurements.rank[eNB_id] = 0; - avg_0[0] = avg_0[0] + avg_0[1]; - avg_1[0] = avg_1[0] + avg_1[1]; - avg_0[0] = min (avg_0[0], avg_1[0]); - avg_1[0] = avg_0[0]; + for (i=0; i<nb_subbands; i++) { + ue->measurements.selected_rx_antennas[eNB_id][i] = 0; + + if (frame_parms->nb_antennas_rx>1) { + if (ue->measurements.subband_cqi_dB[eNB_id][0][i] >= ue->measurements.subband_cqi_dB[eNB_id][1][i]) + ue->measurements.selected_rx_antennas[eNB_id][i] = 0; + else + ue->measurements.selected_rx_antennas[eNB_id][i] = 1; + } else + ue->measurements.selected_rx_antennas[eNB_id][i] = 0; + } + // if(eNB_id==0) + // printf("in lte_ue_measurements: selected rx_antenna[eNB_id==0]:%u\n", ue->measurements.selected_rx_antennas[eNB_id][i]); + } // eNB_id loop + +#if defined(__x86_64__) || defined(__i386__) _mm_empty(); _m_empty(); +#endif +} -#elif defined(__arm__) -#endif +void lte_ue_measurements_emul(PHY_VARS_UE *ue,uint8_t subframe,uint8_t eNB_id) +{ + + LOG_D(PHY,"EMUL UE lte_ue_measurements_emul subframe %d, eNB_id %d\n",subframe,eNB_id); } + + + diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 9ef23f23d06ebcaee853c03d4d110de305ee4130..74ef6798c78c57baaada40d1044b137988a60774 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -19,13 +19,14 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" //#define DEBUG_CH #include "UTIL/LOG/log.h" - +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" #include "T.h" +#include "lte_estimation.h" // round(exp(sqrt(-1)*(pi/2)*[0:1:N-1]/N)*pow2(15)) static int16_t ru_90[2*128] = {32767, 0,32766, 402,32758, 804,32746, 1206,32729, 1608,32706, 2009,32679, 2411,32647, 2811,32610, 3212,32568, 3612,32522, 4011,32470, 4410,32413, 4808,32352, 5205,32286, 5602,32214, 5998,32138, 6393,32058, 6787,31972, 7180,31881, 7571,31786, 7962,31686, 8351,31581, 8740,31471, 9127,31357, 9512,31238, 9896,31114, 10279,30986, 10660,30853, 11039,30715, 11417,30572, 11793,30425, 12167,30274, 12540,30118, 12910,29957, 13279,29792, 13646,29622, 14010,29448, 14373,29269, 14733,29086, 15091,28899, 15447,28707, 15800,28511, 16151,28311, 16500,28106, 16846,27897, 17190,27684, 17531,27467, 17869,27246, 18205,27020, 18538,26791, 18868,26557, 19195,26320, 19520,26078, 19841,25833, 20160,25583, 20475,25330, 20788,25073, 21097,24812, 21403,24548, 21706,24279, 22006,24008, 22302,23732, 22595,23453, 22884,23170, 23170,22884, 23453,22595, 23732,22302, 24008,22006, 24279,21706, 24548,21403, 24812,21097, 25073,20788, 25330,20475, 25583,20160, 25833,19841, 26078,19520, 26320,19195, 26557,18868, 26791,18538, 27020,18205, 27246,17869, 27467,17531, 27684,17190, 27897,16846, 28106,16500, 28311,16151, 28511,15800, 28707,15447, 28899,15091, 29086,14733, 29269,14373, 29448,14010, 29622,13646, 29792,13279, 29957,12910, 30118,12540, 30274,12167, 30425,11793, 30572,11417, 30715,11039, 30853,10660, 30986,10279, 31114,9896, 31238,9512, 31357,9127, 31471,8740, 31581,8351, 31686,7962, 31786,7571, 31881,7180, 31972,6787, 32058,6393, 32138,5998, 32214,5602, 32286,5205, 32352,4808, 32413,4410, 32470,4011, 32522,3612, 32568,3212, 32610,2811, 32647,2411, 32679,2009, 32706,1608, 32729,1206, 32746,804, 32758,402, 32766}; diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c b/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c index 5bf69578d194269b656266e0245d38fbd2a39b56..56d8aaf1dfce1826cedefec58e856a64620aabd7 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_cell_spec.c @@ -22,8 +22,9 @@ #include <stdio.h> #include <stdlib.h> -#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_top.h" //extern unsigned int lte_gold_table[3][20][2][14]; //#define DEBUG_DL_CELL_SPEC diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c index 35e5fe6affa62885f33bde299fe1d63a7375d475..54f52ef40b9d3990abbf044d48aed421cdb31f78 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c @@ -24,8 +24,10 @@ #include <stdio.h> #include <stdlib.h> -#include "defs.h" -#include "PHY/defs.h" +#include "lte_refsig.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_top.h" //extern unsigned int lte_gold_table[10][3][42]; //#define DEBUG_DL_MBSFN diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c b/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c index a7db8fd5aa321848cb1a4b903b5fb2b1cc780842..fc03299f2b60bda1ff969d5307c478b51f9fa686 100644 --- a/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c +++ b/openair1/PHY/LTE_REFSIG/lte_dl_uespec.c @@ -33,9 +33,11 @@ #include <stdio.h> #include <stdlib.h> -#include "defs.h" -#include "PHY/defs.h" +#include "lte_refsig.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "log.h" +#include "PHY/impl_defs_top.h" //extern unsigned int lte_gold_table[3][20][2][14]; //#define DEBUG_DL_CELL_SPEC diff --git a/openair1/PHY/LTE_REFSIG/lte_gold.c b/openair1/PHY/LTE_REFSIG/lte_gold.c index c3a3f42456293460213b3bea994b8757b0be37a0..78fae8b8f3304a69a1d2c0d67cac522e08209135 100644 --- a/openair1/PHY/LTE_REFSIG/lte_gold.c +++ b/openair1/PHY/LTE_REFSIG/lte_gold.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "lte_refsig.h" /* c(n) = x1(n+Nc) + x2(n+Nc) mod 2 diff --git a/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c b/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c index 66d7fa8fb253c3cb3ed3d6220e475f0d526ab7b3..14def309b7bdb11043ef66712b0828d5546898d6 100644 --- a/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c +++ b/openair1/PHY/LTE_REFSIG/lte_gold_mbsfn.c @@ -42,7 +42,7 @@ //unsigned int lte_gold_table[10][3][42]; // need 165 bytes for sequence //slot index x pilot within slot x sequence*/ -#include "defs.h" +#include "lte_refsig.h" void lte_gold_mbsfn(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_mbsfn_table[10][3][42],uint16_t Nid_mbsfn) { diff --git a/openair1/PHY/LTE_REFSIG/defs.h b/openair1/PHY/LTE_REFSIG/lte_refsig.h similarity index 99% rename from openair1/PHY/LTE_REFSIG/defs.h rename to openair1/PHY/LTE_REFSIG/lte_refsig.h index 838406b4444222c2ca341f69ad85213fcd27018c..27788e5e1a92c2266b23cad399af48f2506a2580 100644 --- a/openair1/PHY/LTE_REFSIG/defs.h +++ b/openair1/PHY/LTE_REFSIG/lte_refsig.h @@ -23,7 +23,8 @@ /* Author R. Knopp / EURECOM / OpenAirInterface.org */ #ifndef __LTE_REFSIG_DEFS__H__ #define __LTE_REFSIG_DEFS__H__ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" /** @ingroup _PHY_REF_SIG * @{ diff --git a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c index 93ca7646e63cdaabfc0d229d2e8241cdf8480541..01b27205c21b619bc273b8ef43309073de21a7e1 100644 --- a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c +++ b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c @@ -24,7 +24,8 @@ #include <stdlib.h> #include <math.h> #endif -#include "defs.h" +#include "lte_refsig.h" +#include "PHY/defs_eNB.h" uint16_t dftsizes[33] = {12,24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,864,900,960,972,1080,1152,1200}; diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index ded49d1c73a8c53d0574dfdc8f43aa46a3e001e0..d8a13bbbfdbc0abfc760aa4853aba0eeba25362d 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -32,16 +32,19 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "SIMULATION/TOOLS/sim.h" // for taus #include "PHY/sse_intrin.h" - +#include "transport_proto.h" +#include "transport_common_proto.h" #include "assertions.h" #include "T.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_TRANSPORT/transport_extern.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_DCI_ENCODING 1 //#define DEBUG_DCI_DECODING 1 @@ -52,109 +55,6 @@ //extern uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; //extern uint16_t pcfich_reg[4]; -uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi) -{ - - uint16_t i; - uint16_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - uint16_t mprime; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - if ((lprime>0) && (frame_parms->Ncp==0) ) - return(0); - - // printf("check_phich_reg : mi %d\n",mi); - - // compute REG based on symbol - if ((lprime == 0)|| - ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4))) - mprime = kprime/6; - else - mprime = kprime>>2; - - // check if PCFICH uses mprime - if ((lprime==0) && - ((mprime == pcfich_reg[0]) || - (mprime == pcfich_reg[1]) || - (mprime == pcfich_reg[2]) || - (mprime == pcfich_reg[3]))) { -#ifdef DEBUG_DCI_ENCODING - printf("[PHY] REG %d allocated to PCFICH\n",mprime); -#endif - return(1); - } - - // handle Special subframe case for TDD !!! - - // printf("Checking phich_reg %d\n",mprime); - if (mi > 0) { - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - if (frame_parms->Ncp == 1) { - Ngroup_PHICH<<=1; - } - - - - for (i=0; i<Ngroup_PHICH; i++) { - if ((mprime == frame_parms->phich_reg[i][0]) || - (mprime == frame_parms->phich_reg[i][1]) || - (mprime == frame_parms->phich_reg[i][2])) { -#ifdef DEBUG_DCI_ENCODING - printf("[PHY] REG %d (lprime %d) allocated to PHICH\n",mprime,lprime); -#endif - return(1); - } - } - } - - return(0); -} - -uint16_t extract_crc(uint8_t *dci,uint8_t dci_len) -{ - - uint16_t crc16; - // uint8_t i; - - /* - uint8_t crc; - crc = ((uint16_t *)dci)[DCI_LENGTH>>4]; - printf("crc1: %x, shift %d (DCI_LENGTH %d)\n",crc,DCI_LENGTH&0xf,DCI_LENGTH); - crc = (crc>>(DCI_LENGTH&0xf)); - // clear crc bits - ((uint16_t *)dci)[DCI_LENGTH>>4] &= (0xffff>>(16-(DCI_LENGTH&0xf))); - printf("crc2: %x, dci0 %x\n",crc,((int16_t *)dci)[DCI_LENGTH>>4]); - crc |= (((uint16_t *)dci)[1+(DCI_LENGTH>>4)])<<(16-(DCI_LENGTH&0xf)); - // clear crc bits - (((uint16_t *)dci)[1+(DCI_LENGTH>>4)]) = 0; - printf("extract_crc: crc %x\n",crc); - */ -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY,"dci_crc (%x,%x,%x), dci_len&0x7=%d\n",dci[dci_len>>3],dci[1+(dci_len>>3)],dci[2+(dci_len>>3)], - dci_len&0x7); -#endif - - if ((dci_len&0x7) > 0) { - ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]<<(dci_len&0x7) | dci[2+(dci_len>>3)]>>(8-(dci_len&0x7)); - ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]<<(dci_len&0x7) | dci[1+(dci_len>>3)]>>(8-(dci_len&0x7)); - } else { - ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]; - ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]; - } - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY,"dci_crc =>%x\n",crc16); -#endif - - // dci[(dci_len>>3)]&=(0xffff<<(dci_len&0xf)); - // dci[(dci_len>>3)+1] = 0; - // dci[(dci_len>>3)+2] = 0; - return((uint16_t)crc16); - -} - static uint8_t d[3*(MAX_DCI_SIZE_BITS + 16) + 96]; @@ -219,7 +119,7 @@ uint8_t *generate_dci0(uint8_t *dci, (aggregation_level==2) || (aggregation_level==4) || (aggregation_level==8) -#ifdef Rel14 // Added for EPDCCH/MPDCCH +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) // Added for EPDCCH/MPDCCH || (aggregation_level==16) || (aggregation_level==24) || @@ -271,15 +171,10 @@ uint8_t *generate_dci0(uint8_t *dci, uint32_t Y; -#define CCEBITS 72 -#define CCEPERSYMBOL 33 // This is for 1200 RE -#define CCEPERSYMBOL0 22 // This is for 1200 RE -#define DCI_BITS_MAX ((2*CCEPERSYMBOL+CCEPERSYMBOL0)*CCEBITS) -#define Msymb (DCI_BITS_MAX/2) -//#define Mquad (Msymb/4) -static uint32_t bitrev_cc_dci[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30}; -static int32_t wtemp[2][Msymb]; + + + void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi) { @@ -292,6 +187,8 @@ void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **w #ifdef RM_DEBUG int32_t nulled=0; #endif + uint32_t Msymb=(DCI_BITS_MAX/2); + int32_t wtemp[2][Msymb]; // printf("[PHY] PDCCH Interleaving Mquad %d (Nsymb %d)\n",Mquad,n_symbols_pdcch); if ((Mquad&0x1f) > 0) @@ -346,1853 +243,34 @@ void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **w } } -void pdcch_demapping(uint16_t *llr,uint16_t *wbar,LTE_DL_FRAME_PARMS *frame_parms,uint8_t num_pdcch_symbols,uint8_t mi) -{ - - uint32_t i, lprime; - uint16_t kprime,kprime_mod12,mprime,symbol_offset,tti_offset,tti_offset0; - int16_t re_offset,re_offset0; - - // This is the REG allocation algorithm from 36-211, second part of Section 6.8.5 - - int Msymb2; - - switch (frame_parms->N_RB_DL) { - case 100: - Msymb2 = Msymb; - break; - - case 75: - Msymb2 = 3*Msymb/4; - break; - - case 50: - Msymb2 = Msymb>>1; - break; - - case 25: - Msymb2 = Msymb>>2; - break; - - case 15: - Msymb2 = Msymb*15/100; - break; - - case 6: - Msymb2 = Msymb*6/100; - break; - - default: - Msymb2 = Msymb>>2; - break; - } - - mprime=0; - - - re_offset = 0; - re_offset0 = 0; // counter for symbol with pilots (extracted outside!) - - for (kprime=0; kprime<frame_parms->N_RB_DL*12; kprime++) { - for (lprime=0; lprime<num_pdcch_symbols; lprime++) { - - symbol_offset = (uint32_t)frame_parms->N_RB_DL*12*lprime; - - tti_offset = symbol_offset + re_offset; - tti_offset0 = symbol_offset + re_offset0; - - // if REG is allocated to PHICH, skip it - if (check_phich_reg(frame_parms,kprime,lprime,mi) == 1) { - // printf("dci_demapping : skipping REG %d (RE %d)\n",(lprime==0)?kprime/6 : kprime>>2,kprime); - if ((lprime == 0)&&((kprime%6)==0)) - re_offset0+=4; - } else { // not allocated to PHICH/PCFICH - // printf("dci_demapping: REG %d\n",(lprime==0)?kprime/6 : kprime>>2); - if (lprime == 0) { - // first symbol, or second symbol+4 TX antennas skip pilots - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 6)) { - // kprime represents REG - - for (i=0; i<4; i++) { - wbar[mprime] = llr[tti_offset0+i]; -#ifdef DEBUG_DCI_DECODING -// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset0+i,symbol_offset,re_offset0,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); -#endif - mprime++; - re_offset0++; - } - } - } else if ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4)) { - // LATER!!!! - } else { // no pilots in this symbol - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 4) || (kprime_mod12 == 8)) { - // kprime represents REG - for (i=0; i<4; i++) { - wbar[mprime] = llr[tti_offset+i]; -#ifdef DEBUG_DCI_DECODING -// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset+i,symbol_offset,re_offset+i,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); -#endif - mprime++; - } - } // is representative - } // no pilots case - } // not allocated to PHICH/PCFICH - - // Stop when all REGs are copied in - if (mprime>=Msymb2) - break; - } //lprime loop - - re_offset++; - - } // kprime loop -} - -static uint16_t wtemp_rx[Msymb]; -void pdcch_deinterleaving(LTE_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t *wbar,uint8_t number_pdcch_symbols,uint8_t mi) -{ - - uint16_t *wptr,*zptr,*wptr2; - - uint16_t Mquad=get_nquad(number_pdcch_symbols,frame_parms,mi); - uint32_t RCC = (Mquad>>5), ND; - uint32_t row,col,Kpi,index; - int32_t i,k; - - - // printf("Mquad %d, RCC %d\n",Mquad,RCC); - - AssertFatal(z!=NULL,"dci.c: pdcch_deinterleaving: FATAL z is Null\n"); - - // undo permutation - for (i=0; i<Mquad; i++) { - wptr = &wtemp_rx[((i+frame_parms->Nid_cell)%Mquad)<<2]; - wptr2 = &wbar[i<<2]; - - wptr[0] = wptr2[0]; - wptr[1] = wptr2[1]; - wptr[2] = wptr2[2]; - wptr[3] = wptr2[3]; - /* - printf("pdcch_deinterleaving (%p,%p): quad %d (%d) -> (%d,%d %d,%d %d,%d %d,%d)\n",wptr,wptr2,i,(i+frame_parms->Nid_cell)%Mquad, - ((char*)wptr2)[0], - ((char*)wptr2)[1], - ((char*)wptr2)[2], - ((char*)wptr2)[3], - ((char*)wptr2)[4], - ((char*)wptr2)[5], - ((char*)wptr2)[6], - ((char*)wptr2)[7]); - */ - - } - - if ((Mquad&0x1f) > 0) - RCC++; - - Kpi = (RCC<<5); - ND = Kpi - Mquad; - - k=0; - - for (col=0; col<32; col++) { - index = bitrev_cc_dci[col]; - - for (row=0; row<RCC; row++) { - // printf("row %d, index %d, Nd %d\n",row,index,ND); - if (index>=ND) { - - - - wptr = &wtemp_rx[k<<2]; - zptr = &z[(index-ND)<<2]; - - zptr[0] = wptr[0]; - zptr[1] = wptr[1]; - zptr[2] = wptr[2]; - zptr[3] = wptr[3]; - - /* - printf("deinterleaving ; k %d, index-Nd %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",k,(index-ND), - ((int8_t *)wptr)[0], - ((int8_t *)wptr)[1], - ((int8_t *)wptr)[2], - ((int8_t *)wptr)[3], - ((int8_t *)wptr)[4], - ((int8_t *)wptr)[5], - ((int8_t *)wptr)[6], - ((int8_t *)wptr)[7]); - */ - k++; - } - - index+=32; - - } - } - - for (i=0; i<Mquad; i++) { - zptr = &z[i<<2]; - /* - printf("deinterleaving ; quad %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",i, - ((int8_t *)zptr)[0], - ((int8_t *)zptr)[1], - ((int8_t *)zptr)[2], - ((int8_t *)zptr)[3], - ((int8_t *)zptr)[4], - ((int8_t *)zptr)[5], - ((int8_t *)zptr)[6], - ((int8_t *)zptr)[7]); - */ - } - -} - - -int32_t pdcch_qpsk_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho_i, - int16_t *pdcch_llr16, - int16_t *pdcch_llr8in, - uint8_t symbol) -{ - - int16_t *rxF=(int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rxF_i=(int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rho=(int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *llr128; - int32_t i; - char *pdcch_llr8; - int16_t *pdcch_llr; - pdcch_llr8 = (char *)&pdcch_llr8in[symbol*frame_parms->N_RB_DL*12]; - pdcch_llr = &pdcch_llr16[symbol*frame_parms->N_RB_DL*12]; - - // printf("dlsch_qpsk_qpsk: symbol %d\n",symbol); - - llr128 = (int16_t*)pdcch_llr; - - if (!llr128) { - printf("dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol); - return -1; - } - - qpsk_qpsk(rxF, - rxF_i, - llr128, - rho, - frame_parms->N_RB_DL*12); - - //prepare for Viterbi which accepts 8 bit, but prefers 4 bit, soft input. - for (i=0; i<(frame_parms->N_RB_DL*24); i++) { - if (*pdcch_llr>7) - *pdcch_llr8=7; - else if (*pdcch_llr<-8) - *pdcch_llr8=-8; - else - *pdcch_llr8 = (char)(*pdcch_llr); - - pdcch_llr++; - pdcch_llr8++; - } - - return(0); -} - - -int32_t pdcch_llr(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - char *pdcch_llr, - uint8_t symbol) -{ - - int16_t *rxF= (int16_t*) &rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int32_t i; - char *pdcch_llr8; - - pdcch_llr8 = &pdcch_llr[2*symbol*frame_parms->N_RB_DL*12]; - - if (!pdcch_llr8) { - printf("pdcch_qpsk_llr: llr is null, symbol %d\n",symbol); - return(-1); - } - - // printf("pdcch qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llr8-pdcch_llr); - - for (i=0; i<(frame_parms->N_RB_DL*((symbol==0) ? 16 : 24)); i++) { - - if (*rxF>31) - *pdcch_llr8=31; - else if (*rxF<-32) - *pdcch_llr8=-32; - else - *pdcch_llr8 = (char)(*rxF); - - // printf("%d %d => %d\n",i,*rxF,*pdcch_llr8); - rxF++; - pdcch_llr8++; - } - - return(0); - -} - -//__m128i avg128P; - -//compute average channel_level on each (TX,RX) antenna pair -void pdcch_channel_level(int32_t **dl_ch_estimates_ext, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t *avg, - uint8_t nb_rb) -{ - - int16_t rb; - uint8_t aatx,aarx; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128; - __m128i avg128P; -#elif defined(__arm__) - int16x8_t *dl_ch128; - int32x4_t *avg128P; -#endif - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - //clear average level -#if defined(__x86_64__) || defined(__i386__) - avg128P = _mm_setzero_si128(); - dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][0]; -#elif defined(__arm__) - -#endif - for (rb=0; rb<nb_rb; rb++) { - -#if defined(__x86_64__) || defined(__i386__) - avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); - avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); - avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); -#elif defined(__arm__) - -#endif - dl_ch128+=3; - /* - if (rb==0) { - print_shorts("dl_ch128",&dl_ch128[0]); - print_shorts("dl_ch128",&dl_ch128[1]); - print_shorts("dl_ch128",&dl_ch128[2]); - } - */ - } - - DevAssert( nb_rb ); - avg[(aatx<<1)+aarx] = (((int32_t*)&avg128P)[0] + - ((int32_t*)&avg128P)[1] + - ((int32_t*)&avg128P)[2] + - ((int32_t*)&avg128P)[3])/(nb_rb*12); - - // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - -#if defined(__x86_64) || defined(__i386__) -__m128i mmtmpPD0,mmtmpPD1,mmtmpPD2,mmtmpPD3; -#elif defined(__arm__) - -#endif -void pdcch_dual_stream_correlation(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - int32_t **dl_ch_estimates_ext, - int32_t **dl_ch_estimates_ext_i, - int32_t **dl_ch_rho_ext, - uint8_t output_shift) -{ - - uint16_t rb; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*dl_ch128i,*dl_ch_rho128; -#elif defined(__arm__) - -#endif - uint8_t aarx; - - // printf("dlsch_dual_stream_correlation: symbol %d\n",symbol); - - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128i = (__m128i *)&dl_ch_estimates_ext_i[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch_rho128 = (__m128i *)&dl_ch_rho_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - // multiply by conjugated channel -#if defined(__x86_64__) || defined(__i386__) - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128i[0]); - // print_ints("re",&mmtmpPD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[0]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpPD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpPD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - dl_ch_rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - //print_shorts("rx:",dl_ch128_2); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rho128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128i[1]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[1]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - - dl_ch_rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+1); - //print_shorts("ch:",dl_ch128+1); - //print_shorts("pack:",rho128+1); - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128i[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - dl_ch_rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+2); - //print_shorts("ch:",dl_ch128+2); - //print_shorts("pack:",rho128+2); - - dl_ch128+=3; - dl_ch128i+=3; - dl_ch_rho128+=3; - - -#elif defined(__arm__) - -#endif - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - - -void pdcch_detection_mrc_i(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho, - int32_t **rho_i, - uint8_t symbol) +void pdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + uint8_t *e, + uint32_t length) { - - uint8_t aatx; - -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; -#endif - int32_t i; - - if (frame_parms->nb_antennas_rx>1) { - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { - //if (frame_parms->mode1_flag && (aatx>0)) break; - -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#endif - // MRC on each re of rb on MF output - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); -#endif - } - } - -#if defined(__x86_64__) || defined(__i386__) - rho128_0 = (__m128i *) &rho[0][symbol*frame_parms->N_RB_DL*12]; - rho128_1 = (__m128i *) &rho[1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rho128_0 = (int16x8_t *) &rho[0][symbol*frame_parms->N_RB_DL*12]; - rho128_1 = (int16x8_t *) &rho[1][symbol*frame_parms->N_RB_DL*12]; -#endif - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1)); -#elif defined(__arm__) - rho128_0[i] = vhaddq_s16(rho128_0[i],rho128_1[i]); -#endif - } - -#if defined(__x86_64__) || defined(__i386__) - rho128_i0 = (__m128i *) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; - rho128_i1 = (__m128i *) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i0 = (__m128i *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i1 = (__m128i *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rho128_i0 = (int16x8_t*) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; - rho128_i1 = (int16x8_t*) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i0 = (int16x8_t *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_i1 = (int16x8_t *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; - -#endif - // MRC on each re of rb on MF and rho - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_i0[i],1),_mm_srai_epi16(rxdataF_comp128_i1[i],1)); - rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_i0[i] = vhaddq_s16(rxdataF_comp128_i0[i],rxdataF_comp128_i1[i]); - rho128_i0[i] = vhaddq_s16(rho128_i0[i],rho128_i1[i]); - -#endif - } - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - - -void pdcch_extract_rbs_single(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - uint8_t symbol, - uint32_t high_speed_flag, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - - uint16_t rb,nb_rb=0; - uint8_t i,j,aarx; - int32_t *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; - - - int nushiftmod3 = frame_parms->nushift%3; - uint8_t symbol_mod; - - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod); -#endif - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (high_speed_flag == 1) - dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; - else - dl_ch0 = &dl_ch_estimates[aarx][5]; - - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - - rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; - - if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - // For second half of RBs skip DC carrier - if (rb==(frame_parms->N_RB_DL>>1)) { - rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; - - //dl_ch0++; - } - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - - for (i=0; i<12; i++) { - - rxF_ext[i]=rxF[i]; - - } - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j++]=dl_ch0[i]; - // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } - } - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - rxF+=12; - } - } - } else { // Odd number of RBs - for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j++]=dl_ch0[i]; - // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } - } - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - rxF+=12; - } - } - - // Do middle RB (around DC) - // printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]); - - if (symbol_mod==0) { - j=0; - - for (i=0; i<6; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3))) { - 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 = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - if ((i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+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])); - } - } - - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - dl_ch0+=12; - rxF+=7; - rb++; - } else { - for (i=0; i<6; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - rxF_ext[i]=rxF[i]; - } - - rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - rxF_ext[i]=rxF[(1+i-6)]; - } - - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - dl_ch0+=12; - rxF+=7; - rb++; - } - - for (; rb<frame_parms->N_RB_DL; rb++) { - if (symbol_mod > 0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=(nushiftmod3)) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j++]=dl_ch0[i]; - } - } - - nb_rb++; - dl_ch0_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - rxF+=12; - } - } - } - } -} - -void pdcch_extract_rbs_dual(int32_t **rxdataF, - int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - uint8_t symbol, - uint32_t high_speed_flag, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - - uint16_t rb,nb_rb=0; - uint8_t i,aarx,j; - int32_t *dl_ch0,*dl_ch0_ext,*dl_ch1,*dl_ch1_ext,*rxF,*rxF_ext; - uint8_t symbol_mod; - int nushiftmod3 = frame_parms->nushift%3; - - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "extract_rbs_dual: symbol_mod %d\n",symbol_mod); -#endif - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (high_speed_flag==1) { - dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; - dl_ch1 = &dl_ch_estimates[2+aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; - } else { - dl_ch0 = &dl_ch_estimates[aarx][5]; - dl_ch1 = &dl_ch_estimates[2+aarx][5]; - } - - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(frame_parms->N_RB_DL*12)]; - - // printf("pdcch extract_rbs: rxF_ext pos %d\n",symbol*(frame_parms->N_RB_DL*12)); - rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; - - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; - - if ((frame_parms->N_RB_DL&1) == 0) // even number of RBs - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - // For second half of RBs skip DC carrier - if (rb==(frame_parms->N_RB_DL>>1)) { - rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; - // dl_ch0++; - //dl_ch1++; - } - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); - - /* - printf("rb %d\n",rb); - for (i=0;i<12;i++) - printf("(%d %d)",((int16_t *)dl_ch0)[i<<1],((int16_t*)dl_ch0)[1+(i<<1)]); - printf("\n"); - */ - for (i=0; i<12; i++) { - rxF_ext[i]=rxF[i]; - // printf("%d : (%d,%d)\n",(rxF+(2*i)-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))*2])/2, - // ((int16_t*)&rxF[i<<1])[0],((int16_t*)&rxF[i<<1])[0]); - } - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3) && - (i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j] =dl_ch0[i]; - dl_ch1_ext[j++]=dl_ch1[i]; - } - } - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - } - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } - - else { // Odd number of RBs - for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { - - // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); - - if (symbol_mod>0) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3) && - (i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j++]=dl_ch1[i]; - // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } - } - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } - } - - // Do middle RB (around DC) - - if (symbol_mod > 0) { - for (i=0; i<6; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - dl_ch1_ext[i]=dl_ch1[i]; - rxF_ext[i]=rxF[i]; - } - - rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - dl_ch0_ext[i]=dl_ch0[i]; - dl_ch1_ext[i]=dl_ch1[i]; - rxF_ext[i]=rxF[(1+i)]; - } - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=7; - rb++; - } else { - j=0; - - for (i=0; i<6; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3)) { - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j]=dl_ch1[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 = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; - - for (; i<12; i++) { - if ((i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j]=dl_ch1[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])); - } - } - - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - dl_ch0+=12; - dl_ch1+=12; - rxF+=7; - rb++; - } - - for (; rb<frame_parms->N_RB_DL; rb++) { - - if (symbol_mod>0) { - // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); - memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); - - for (i=0; i<12; i++) - rxF_ext[i]=rxF[i]; - - nb_rb++; - dl_ch0_ext+=12; - dl_ch1_ext+=12; - rxF_ext+=12; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=nushiftmod3+3) && - (i!=nushiftmod3+6) && - (i!=nushiftmod3+9)) { - rxF_ext[j]=rxF[i]; - // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - dl_ch0_ext[j]=dl_ch0[i]; - dl_ch1_ext[j++]=dl_ch1[i]; - } - } - - nb_rb++; - dl_ch0_ext+=8; - dl_ch1_ext+=8; - rxF_ext+=8; - - dl_ch0+=12; - dl_ch1+=12; - rxF+=12; - } - } - } - } -} - - -void pdcch_channel_compensation(int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - int32_t **rxdataF_comp, - int32_t **rho, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - uint8_t output_shift) -{ - - uint16_t rb; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; - __m128i *dl_ch128_2, *rho128; -#elif defined(__arm__) - -#endif - uint8_t aatx,aarx,pilots=0; - - - - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "PDCCH comp: symbol %d\n",symbol); -#endif - - if (symbol==0) - pilots=1; - - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { - //if (frame_parms->mode1_flag && aatx>0) break; //if mode1_flag is set then there is only one stream to extract, independent of nb_antenna_ports_eNB - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - -#if defined(__x86_64__) || defined(__i386__) - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpPD0); - - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[0]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpPD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpPD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[1]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - // multiply by conjugated channel - if (pilots == 0) { - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - } - - // print_shorts("rx:",rxdataF128+2); - // print_shorts("ch:",dl_ch128+2); - // print_shorts("pack:",rxdataF_comp128+2); - - if (pilots==0) { - dl_ch128+=3; - rxdataF128+=3; - rxdataF_comp128+=3; - } else { - dl_ch128+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } -#elif defined(__arm__) - -#endif - } - } - } - - - if (rho) { - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { -#if defined(__x86_64__) || defined(__i386__) - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128_2[0]); - // print_ints("re",&mmtmpD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[0]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - //print_shorts("rx:",dl_ch128_2); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rho128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128_2[1]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[1]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - - rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+1); - //print_shorts("ch:",dl_ch128+1); - //print_shorts("pack:",rho128+1); - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128_2[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+2); - //print_shorts("ch:",dl_ch128+2); - //print_shorts("pack:",rho128+2); - - dl_ch128+=3; - dl_ch128_2+=3; - rho128+=3; - -#elif defined(__arm_) - - -#endif - } - } - - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void pdcch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - uint8_t symbol) -{ - - uint8_t aatx; - -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; -#endif - int32_t i; - - if (frame_parms->nb_antennas_rx>1) { - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; -#endif - // MRC on each re of rb - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); -#endif - } - } - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - -void pdcch_siso(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - uint8_t l) -{ - - - uint8_t rb,re,jj,ii; - - jj=0; - ii=0; - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - for (re=0; re<12; re++) { - - rxdataF_comp[0][jj++] = rxdataF_comp[0][ii]; - ii++; - } - } -} - - -void pdcch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - uint8_t symbol) -{ - - - int16_t *rxF0,*rxF1; - uint8_t rb,re; - int32_t jj=(symbol*frame_parms->N_RB_DL*12); - - rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y - rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y - - for (rb=0; rb<frame_parms->N_RB_DL; rb++) { - - for (re=0; re<12; re+=2) { - - // Alamouti RX combining - - rxF0[0] = rxF0[0] + rxF1[2]; - rxF0[1] = rxF0[1] - rxF1[3]; - - rxF0[2] = rxF0[2] - rxF1[0]; - rxF0[3] = rxF0[3] + rxF1[1]; - - rxF0+=4; - rxF1+=4; - } - } - - -} - -int32_t avgP[4]; - -int32_t rx_pdcch(PHY_VARS_UE *ue, - uint32_t frame, - uint8_t subframe, - uint8_t eNB_id, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t is_secondary_ue) -{ - - LTE_UE_COMMON *common_vars = &ue->common_vars; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; - - uint8_t log2_maxh,aatx,aarx; -#ifdef MU_RECEIVER - uint8_t eNB_id_i=eNB_id+1;//add 1 to eNB_id to separate from wanted signal, chosen as the B/F'd pilots from the SeNB are shifted by 1 -#endif - int32_t avgs; - uint8_t n_pdcch_symbols; - uint8_t mi = get_mi(frame_parms,subframe); - - //printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d \n",subframe,eNB_id,pdcch_vars); - // procress ofdm symbol 0 - if (is_secondary_ue == 1) { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id+1], //add 1 to eNB_id to compensate for the shifted B/F'd pilots from the SeNB - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); -#ifdef MU_RECEIVER - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id_i - 1],//subtract 1 to eNB_id_i to compensate for the non-shifted pilots from the PeNB - pdcch_vars[eNB_id_i]->rxdataF_ext,//shift by two to simulate transmission from a second antenna - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext,//shift by two to simulate transmission from a second antenna - 0, - high_speed_flag, - frame_parms); -#endif //MU_RECEIVER - } else if (frame_parms->nb_antenna_ports_eNB>1) { - pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); - } else { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); - } - - - // compute channel level based on ofdm symbol 0 - pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, - frame_parms, - avgP, - frame_parms->N_RB_DL); - - avgs = 0; - - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) - avgs = cmax(avgs,avgP[(aarx<<1)+aatx]); - - log2_maxh = (log2_approx(avgs)/2) + 5; //+frame_parms->nb_antennas_rx; -#ifdef UE_DEBUG_TRACE - LOG_D(PHY,"subframe %d: pdcch log2_maxh = %d (%d,%d)\n",subframe,log2_maxh,avgP[0],avgs); -#endif - - T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(frame%1024), T_INT(subframe), - T_INT(avgP[0]), T_INT(avgP[1]), T_INT(avgP[2]), T_INT(avgP[3])); - - // compute LLRs for ofdm symbol 0 only - pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, - frame_parms, - 0, - log2_maxh); // log2_maxh+I0_shift - - -#ifdef DEBUG_PHY - - if (subframe==5) - write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); - -#endif - -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - //get MF output for interfering stream - pdcch_channel_compensation(pdcch_vars[eNB_id_i]->rxdataF_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id_i]->rho : NULL, - frame_parms, - 0, - log2_maxh); // log2_maxh+I0_shift -#ifdef DEBUG_PHY - write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif - pdcch_dual_stream_correlation(frame_parms, - 0, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - log2_maxh); - } - -#endif //MU_RECEIVER - - - if (frame_parms->nb_antennas_rx > 1) { -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - pdcch_detection_mrc_i(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->rho, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - 0); -#ifdef DEBUG_PHY - write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); - write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif - } else -#endif //MU_RECEIVER - pdcch_detection_mrc(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - 0); - } - - if (mimo_mode == SISO) - pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); - else - pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); - - -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - pdcch_qpsk_qpsk_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - pdcch_vars[eNB_id]->llr16, //subsequent function require 16 bit llr, but output must be 8 bit (actually clipped to 4, because of the Viterbi decoder) - pdcch_vars[eNB_id]->llr, - 0); - /* - #ifdef DEBUG_PHY - if (subframe==5) { - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - write_output("llr16_seq.m","llr16",&pdcch_vars[eNB_id]->llr16[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - } - #endif*/ - } else { -#endif //MU_RECEIVER - pdcch_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - (char *)pdcch_vars[eNB_id]->llr, - 0); - /*#ifdef DEBUG_PHY - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - #endif*/ - -#ifdef MU_RECEIVER - } - -#endif //MU_RECEIVER - - - // decode pcfich here and find out pdcch ofdm symbol number - n_pdcch_symbols = rx_pcfich(frame_parms, - subframe, - pdcch_vars[eNB_id], - mimo_mode); - - - if (n_pdcch_symbols>3) - n_pdcch_symbols=1; - -#if T_TRACER - T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), - T_INT(n_pdcch_symbols), - T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4)); -#endif - - -#ifdef DEBUG_DCI_DECODING - - LOG_I(PHY,"demapping: subframe %d, mi %d, tdd_config %d\n",subframe,get_mi(frame_parms,subframe),frame_parms->tdd_config); -#endif - - // process pdcch ofdm symbol 1 and 2 if necessary - for (int s=1; s<n_pdcch_symbols; s++){ - if (is_secondary_ue == 1) { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id+1], //add 1 to eNB_id to compensate for the shifted B/F'd pilots from the SeNB - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - s, - high_speed_flag, - frame_parms); -#ifdef MU_RECEIVER -pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id_i - 1],//subtract 1 to eNB_id_i to compensate for the non-shifted pilots from the PeNB - pdcch_vars[eNB_id_i]->rxdataF_ext,//shift by two to simulate transmission from a second antenna - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext,//shift by two to simulate transmission from a second antenna - s, - high_speed_flag, - frame_parms); -#endif //MU_RECEIVER - } else if (frame_parms->nb_antenna_ports_eNB>1) { - pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - s, - high_speed_flag, - frame_parms); - } else { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - s, - high_speed_flag, - frame_parms); - } - - - pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, - frame_parms, - s, - log2_maxh); // log2_maxh+I0_shift - - -#ifdef DEBUG_PHY - -if (subframe==5) - write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); - -#endif - -#ifdef MU_RECEIVER - -if (is_secondary_ue) { - //get MF output for interfering stream - pdcch_channel_compensation(pdcch_vars[eNB_id_i]->rxdataF_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id_i]->rho : NULL, - frame_parms, - s, - log2_maxh); // log2_maxh+I0_shift -#ifdef DEBUG_PHY -write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif -pdcch_dual_stream_correlation(frame_parms, - s, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - log2_maxh); -} - -#endif //MU_RECEIVER - - -if (frame_parms->nb_antennas_rx > 1) { -#ifdef MU_RECEIVER - - if (is_secondary_ue) { - pdcch_detection_mrc_i(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->rho, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - s); -#ifdef DEBUG_PHY -write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -write_output("rxF_comp_i.m","rxF_c_i",&pdcch_vars[eNB_id_i]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); -#endif - } else -#endif //MU_RECEIVER - pdcch_detection_mrc(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - s); - -} - -if (mimo_mode == SISO) - pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); -else - pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); - - -#ifdef MU_RECEIVER - -if (is_secondary_ue) { - pdcch_qpsk_qpsk_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - pdcch_vars[eNB_id_i]->rxdataF_comp, - pdcch_vars[eNB_id]->dl_ch_rho_ext, - pdcch_vars[eNB_id]->llr16, //subsequent function require 16 bit llr, but output must be 8 bit (actually clipped to 4, because of the Viterbi decoder) - pdcch_vars[eNB_id]->llr, - s); - /* - #ifdef DEBUG_PHY - if (subframe==5) { - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - write_output("llr16_seq.m","llr16",&pdcch_vars[eNB_id]->llr16[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - } - #endif*/ -} else { -#endif //MU_RECEIVER - pdcch_llr(frame_parms, - pdcch_vars[eNB_id]->rxdataF_comp, - (char *)pdcch_vars[eNB_id]->llr, - s); - /*#ifdef DEBUG_PHY - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - #endif*/ - -#ifdef MU_RECEIVER -} - -#endif //MU_RECEIVER - - } - - pdcch_demapping(pdcch_vars[eNB_id]->llr, - pdcch_vars[eNB_id]->wbar, - frame_parms, - n_pdcch_symbols, - get_mi(frame_parms,subframe)); - - pdcch_deinterleaving(frame_parms, - (uint16_t*)pdcch_vars[eNB_id]->e_rx, - pdcch_vars[eNB_id]->wbar, - n_pdcch_symbols, - mi); - - pdcch_unscrambling(frame_parms, - subframe, - pdcch_vars[eNB_id]->e_rx, - get_nCCE(n_pdcch_symbols,frame_parms,mi)*72); - - pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols; - - return(0); -} - - -void pdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - uint8_t *e, - uint32_t length) -{ - int i; - uint8_t reset; - uint32_t x1, x2, s=0; + int i; + uint8_t reset; + uint32_t x1, x2, s=0; //LOG_D(PHY, "%s(fp, subframe:%d, e, length:%d)\n", __FUNCTION__, subframe, length); reset = 1; - // x1 is set in lte_gold_generic - - x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 - - for (i=0; i<length; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - //printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - // printf("scrambling %d : e %d, c %d\n",i,e[i],((s>>(i&0x1f))&1)); - if (e[i] != 2) // <NIL> element is 2 - e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1); - } -} - -void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - int8_t* llr, - uint32_t length) -{ - - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in first call to lte_gold_generic + // x1 is set in lte_gold_generic x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 for (i=0; i<length; i++) { if ((i&0x1f)==0) { s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); + //printf("lte_gold[%d]=%x\n",i,s); reset = 0; } - - // printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); - if (((s>>(i%32))&1)==0) - llr[i] = -llr[i]; - // printf("%d\n",llr[i]); - - } -} - -/* -uint8_t get_num_pdcch_symbols(uint8_t num_dci, - DCI_ALLOC_t *dci_alloc, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe) -{ - - uint16_t numCCE = 0; - uint8_t i; - uint8_t nCCEmin = 0; - uint16_t CCE_max_used_index = 0; - uint16_t firstCCE_max = dci_alloc[0].firstCCE; - uint8_t L = dci_alloc[0].L; - - // check pdcch duration imposed by PHICH duration (Section 6.9 of 36-211) - if (frame_parms->Ncp==1) { // extended prefix - if ((frame_parms->frame_type == TDD) && - ((frame_parms->tdd_config<3)||(frame_parms->tdd_config==6)) && - ((subframe==1) || (subframe==6))) // subframes 1 and 6 (S-subframes) for 5ms switching periodicity are 2 symbols - nCCEmin = 2; - else { // 10ms switching periodicity is always 3 symbols, any DL-only subframe is 3 symbols - nCCEmin = 3; - } - } - - // compute numCCE - for (i=0; i<num_dci; i++) { - // printf("dci %d => %d\n",i,dci_alloc[i].L); - numCCE += (1<<(dci_alloc[i].L)); - - if(firstCCE_max < dci_alloc[i].firstCCE) { - firstCCE_max = dci_alloc[i].firstCCE; - L = dci_alloc[i].L; - } - } - CCE_max_used_index = firstCCE_max + (1<<L) - 1; - - //if ((9*numCCE) <= (frame_parms->N_RB_DL*2)) - if (CCE_max_used_index < get_nCCE(1, frame_parms, get_mi(frame_parms, subframe))) - return(cmax(1,nCCEmin)); - //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 4 : 5))) - else if (CCE_max_used_index < get_nCCE(2, frame_parms, get_mi(frame_parms, subframe))) - return(cmax(2,nCCEmin)); - //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 7 : 8))) - else if (CCE_max_used_index < get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))) - return(cmax(3,nCCEmin)); - else if (frame_parms->N_RB_DL<=10) { - if (frame_parms->Ncp == 0) { // normal CP - printf("numCCE %d, N_RB_DL = %d : should be returning 4 PDCCH symbols (%d,%d,%d)\n",numCCE,frame_parms->N_RB_DL, - get_nCCE(1, frame_parms, get_mi(frame_parms, subframe)), - get_nCCE(2, frame_parms, get_mi(frame_parms, subframe)), - get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))); - - if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 10 : 11))) - return(4); - } else { // extended CP - if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 9 : 10))) - return(4); - } + // printf("scrambling %d : e %d, c %d\n",i,e[i],((s>>(i&0x1f))&1)); + if (e[i] != 2) // <NIL> element is 2 + e[i] = (e[i]&1) ^ ((s>>(i&0x1f))&1); } - - - - // LOG_I(PHY," dci.c: get_num_pdcch_symbols subframe %d FATAL, illegal numCCE %d (num_dci %d)\n",subframe,numCCE,num_dci); - //for (i=0;i<num_dci;i++) { - // printf("dci_alloc[%d].L = %d\n",i,dci_alloc[i].L); - //} - //exit(-1); -exit(1); - return(0); } -*/ - uint8_t generate_dci_top(uint8_t num_pdcch_symbols, uint8_t num_dci, @@ -2211,8 +289,9 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, uint32_t gain_lin_QPSK,kprime,kprime_mod12,mprime,nsymb,symbol_offset,tti_offset; int16_t re_offset; uint8_t mi = get_mi(frame_parms,subframe); - static uint8_t e[DCI_BITS_MAX]; - static int32_t yseq0[Msymb],yseq1[Msymb],wbar0[Msymb],wbar1[Msymb]; + uint8_t e[DCI_BITS_MAX]; + uint32_t Msymb=(DCI_BITS_MAX/2); + int32_t yseq0[Msymb],yseq1[Msymb],wbar0[Msymb],wbar1[Msymb]; int32_t *y[2]; int32_t *wbar[2]; @@ -2276,7 +355,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, /* clear all bits, the above code may generate too much false detections * (not sure about this, to be checked somehow) */ - // memset(e, 0, DCI_BITS_MAX); + //memset(e, 0, DCI_BITS_MAX); e_ptr = e; @@ -2298,6 +377,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, #endif if (dci_alloc[i].firstCCE>=0) { +//printf("generate DCI .%d rnti %d length %d\n", subframe, dci_alloc[i].rnti, dci_alloc[i].dci_length); e_ptr = generate_dci0(dci_alloc[i].dci_pdu, e+(72*dci_alloc[i].firstCCE), dci_alloc[i].dci_length, @@ -2540,1706 +620,3 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, } - -void dci_decoding(uint8_t DCI_LENGTH, - uint8_t aggregation_level, - int8_t *e, - uint8_t *decoded_output) -{ - - uint8_t dummy_w_rx[3*(MAX_DCI_SIZE_BITS+16+64)]; - int8_t w_rx[3*(MAX_DCI_SIZE_BITS+16+32)],d_rx[96+(3*(MAX_DCI_SIZE_BITS+16))]; - - uint16_t RCC; - - uint16_t D=(DCI_LENGTH+16+64); - uint16_t coded_bits; -#ifdef DEBUG_DCI_DECODING - int32_t i; -#endif - - AssertFatal(aggregation_level<4, - "dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); - - coded_bits = 72 * (1<<aggregation_level); - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," Doing DCI decoding for %d bits, DCI_LENGTH %d,coded_bits %d, e %p\n",3*(DCI_LENGTH+16),DCI_LENGTH,coded_bits,e); -#endif - - // now do decoding - memset((void*)dummy_w_rx,0,3*D); - RCC = generate_dummy_w_cc(DCI_LENGTH+16, - dummy_w_rx); - - - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," Doing DCI Rate Matching RCC %d, w %p\n",RCC,w); -#endif - - lte_rate_matching_cc_rx(RCC,coded_bits,w_rx,dummy_w_rx,e); - - sub_block_deinterleaving_cc((uint32_t)(DCI_LENGTH+16), - &d_rx[96], - &w_rx[0]); - -#ifdef DEBUG_DCI_DECODING - - for (i=0; i<16+DCI_LENGTH; i++) - LOG_I(PHY," DCI %d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); - -#endif - memset(decoded_output,0,2+((16+DCI_LENGTH)>>3)); - -#ifdef DEBUG_DCI_DECODING - printf("Before Viterbi\n"); - - for (i=0; i<16+DCI_LENGTH; i++) - printf("%d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); - -#endif - //debug_printf("Doing DCI Viterbi \n"); - phy_viterbi_lte_sse2(d_rx+96,decoded_output,16+DCI_LENGTH); - //debug_printf("Done DCI Viterbi \n"); -} - - -static uint8_t dci_decoded_output[RX_NB_TH][(MAX_DCI_SIZE_BITS+64)/8]; - -uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) -{ - return(get_nquad(num_pdcch_symbols,frame_parms,mi)/9); -} - -uint16_t get_nquad(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) -{ - - uint16_t Nreg=0; - uint8_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - if (frame_parms->Ncp == 1) { - Ngroup_PHICH<<=1; - } - - Ngroup_PHICH*=mi; - - if ((num_pdcch_symbols>0) && (num_pdcch_symbols<4)) - switch (frame_parms->N_RB_DL) { - case 6: - Nreg=12+(num_pdcch_symbols-1)*18; - break; - - case 25: - Nreg=50+(num_pdcch_symbols-1)*75; - break; - - case 50: - Nreg=100+(num_pdcch_symbols-1)*150; - break; - - case 100: - Nreg=200+(num_pdcch_symbols-1)*300; - break; - - default: - return(0); - } - - // printf("Nreg %d (%d)\n",Nreg,Nreg - 4 - (3*Ngroup_PHICH)); - return(Nreg - 4 - (3*Ngroup_PHICH)); -} - -uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe) -{ - - // check for eNB only ! - return(get_nCCE(num_pdcch_symbols, - &RC.eNB[Mod_id][CC_id]->frame_parms, - get_mi(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe))); -} - - -int get_nCCE_offset_l1(int *CCE_table, - const unsigned char L, - const int nCCE, - const int common_dci, - const unsigned short rnti, - const unsigned char subframe) -{ - - int search_space_free,m,nb_candidates = 0,l,i; - unsigned int Yk; - /* - printf("CCE Allocation: "); - for (i=0;i<nCCE;i++) - printf("%d.",CCE_table[i]); - printf("\n"); - */ - if (common_dci == 1) { - // check CCE(0 ... L-1) - nb_candidates = (L==4) ? 4 : 2; - nb_candidates = min(nb_candidates,nCCE/L); - - // printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); - - for (m = nb_candidates-1 ; m >=0 ; m--) { - - search_space_free = 1; - for (l=0; l<L; l++) { - - // printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]); - if (CCE_table[(m*L) + l] == 1) { - search_space_free = 0; - break; - } - } - - if (search_space_free == 1) { - - // printf("returning %d\n",m*L); - - for (l=0; l<L; l++) - CCE_table[(m*L)+l]=1; - return(m*L); - } - } - - return(-1); - - } else { // Find first available in ue specific search space - // according to procedure in Section 9.1.1 of 36.213 (v. 8.6) - // compute Yk - Yk = (unsigned int)rnti; - - for (i=0; i<=subframe; i++) - Yk = (Yk*39827)%65537; - - Yk = Yk % (nCCE/L); - - - switch (L) { - case 1: - case 2: - nb_candidates = 6; - break; - - case 4: - case 8: - nb_candidates = 2; - break; - - default: - DevParam(L, nCCE, rnti); - break; - } - - - LOG_D(MAC,"rnti %x, Yk = %d, nCCE %d (nCCE/L %d),nb_cand %d\n",rnti,Yk,nCCE,nCCE/L,nb_candidates); - - for (m = 0 ; m < nb_candidates ; m++) { - search_space_free = 1; - - for (l=0; l<L; l++) { - int cce = (((Yk+m)%(nCCE/L))*L) + l; - if (cce >= nCCE || CCE_table[cce] == 1) { - search_space_free = 0; - break; - } - } - - if (search_space_free == 1) { - for (l=0; l<L; l++) - CCE_table[(((Yk+m)%(nCCE/L))*L)+l]=1; - - return(((Yk+m)%(nCCE/L))*L); - } - } - - return(-1); - } -} - - -void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars, - int do_common, - dci_detect_mode_t mode, - uint8_t subframe, - DCI_ALLOC_t *dci_alloc, - int16_t eNB_id, - uint8_t current_thread_id, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t mi, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint8_t L, - uint8_t format_si, - uint8_t format_p, - uint8_t format_ra, - uint8_t format_c, - uint8_t sizeof_bits, - uint8_t sizeof_bytes, - uint8_t *dci_cnt, - uint8_t *format0_found, - uint8_t *format_c_found, - uint32_t *CCEmap0, - uint32_t *CCEmap1, - uint32_t *CCEmap2) -{ - - uint16_t crc,CCEind,nCCE; - uint32_t *CCEmap=NULL,CCEmap_mask=0; - int L2=(1<<L); - unsigned int Yk,nb_candidates = 0,i,m; - unsigned int CCEmap_cand; - - nCCE = get_nCCE(pdcch_vars[eNB_id]->num_pdcch_symbols,frame_parms,mi); - - if (nCCE > get_nCCE(3,frame_parms,1)) { - LOG_D(PHY,"skip DCI decoding: nCCE=%d > get_nCCE(3,frame_parms,1)=%d\n", nCCE, get_nCCE(3,frame_parms,1)); - return; - } - - if (nCCE<L2) { - LOG_D(PHY,"skip DCI decoding: nCCE=%d < L2=%d\n", nCCE, L2); - return; - } - - if (mode == NO_DCI) { - LOG_D(PHY, "skip DCI decoding: expect no DCIs at subframe %d\n", subframe); - return; - } - - if (do_common == 1) { - nb_candidates = (L2==4) ? 4 : 2; - Yk=0; - } else { - // Find first available in ue specific search space - // according to procedure in Section 9.1.1 of 36.213 (v. 8.6) - // compute Yk - Yk = (unsigned int)pdcch_vars[eNB_id]->crnti; - - for (i=0; i<=subframe; i++) - Yk = (Yk*39827)%65537; - - Yk = Yk % (nCCE/L2); - - switch (L2) { - case 1: - case 2: - nb_candidates = 6; - break; - - case 4: - case 8: - nb_candidates = 2; - break; - - default: - DevParam(L2, do_common, eNB_id); - break; - } - } - - /* for (CCEind=0; - CCEind<nCCE2; - CCEind+=(1<<L)) {*/ - - if (nb_candidates*L2 > nCCE) - nb_candidates = nCCE/L2; - - for (m=0; m<nb_candidates; m++) { - - CCEind = (((Yk+m)%(nCCE/L2))*L2); - - if (CCEind<32) - CCEmap = CCEmap0; - else if (CCEind<64) - CCEmap = CCEmap1; - else if (CCEind<96) - CCEmap = CCEmap2; - else { - AssertFatal(1==0, - "Illegal CCEind %d (Yk %d, m %d, nCCE %d, L2 %d\n",CCEind,Yk,m,nCCE,L2); - } - - switch (L2) { - case 1: - CCEmap_mask = (1<<(CCEind&0x1f)); - break; - - case 2: - CCEmap_mask = (3<<(CCEind&0x1f)); - break; - - case 4: - CCEmap_mask = (0xf<<(CCEind&0x1f)); - break; - - case 8: - CCEmap_mask = (0xff<<(CCEind&0x1f)); - break; - - default: - AssertFatal(1==0, - "Illegal L2 value %d\n", L2 ); - } - - CCEmap_cand = (*CCEmap)&CCEmap_mask; - - // CCE is not allocated yet - - if (CCEmap_cand == 0) { - - if (do_common == 1) - LOG_D(PHY,"[DCI search nPdcch %d - common] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n", - pdcch_vars[eNB_id]->num_pdcch_symbols,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask); - else - LOG_D(PHY,"[DCI search nPdcch %d - ue spec %x] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x) format %d\n", - pdcch_vars[eNB_id]->num_pdcch_symbols,pdcch_vars[eNB_id]->crnti,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask,format_c); - - dci_decoding(sizeof_bits, - L, - &pdcch_vars[eNB_id]->e_rx[CCEind*72], - &dci_decoded_output[current_thread_id][0]); - /* - for (i=0;i<3+(sizeof_bits>>3);i++) - printf("dci_decoded_output[%d][%d] => %x\n",current_thread_id,i,dci_decoded_output[current_thread_id][i]); - */ - - crc = (crc16(&dci_decoded_output[current_thread_id][0],sizeof_bits)>>16) ^ extract_crc(&dci_decoded_output[current_thread_id][0],sizeof_bits); -#ifdef DEBUG_DCI_DECODING - printf("crc =>%x\n",crc); -#endif - - if (((L>1) && ((crc == si_rnti)|| - (crc == p_rnti)|| - (crc == ra_rnti)))|| - (crc == pdcch_vars[eNB_id]->crnti)) { - dci_alloc[*dci_cnt].dci_length = sizeof_bits; - dci_alloc[*dci_cnt].rnti = crc; - dci_alloc[*dci_cnt].L = L; - dci_alloc[*dci_cnt].firstCCE = CCEind; - - //printf("DCI FOUND !!! crc =>%x, sizeof_bits %d, sizeof_bytes %d \n",crc, sizeof_bits, sizeof_bytes); - if (sizeof_bytes<=4) { - dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0]; - dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1]; - dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3]; -#ifdef DEBUG_DCI_DECODING - printf("DCI => %x,%x,%x,%x\n",dci_decoded_output[current_thread_id][0], - dci_decoded_output[current_thread_id][1], - dci_decoded_output[current_thread_id][2], - dci_decoded_output[current_thread_id][3]); -#endif - } else { - dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0]; - dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[current_thread_id][1]; - dci_alloc[*dci_cnt].dci_pdu[5] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3]; - dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][4]; - dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][5]; - dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][6]; - dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][7]; -#ifdef DEBUG_DCI_DECODING - printf("DCI => %x,%x,%x,%x,%x,%x,%x,%x\n", - dci_decoded_output[current_thread_id][0],dci_decoded_output[current_thread_id][1],dci_decoded_output[current_thread_id][2],dci_decoded_output[current_thread_id][3], - dci_decoded_output[current_thread_id][4],dci_decoded_output[current_thread_id][5],dci_decoded_output[current_thread_id][6],dci_decoded_output[current_thread_id][7]); -#endif - } - - if (crc==si_rnti) { - dci_alloc[*dci_cnt].format = format_si; - *dci_cnt = *dci_cnt+1; - } else if (crc==p_rnti) { - dci_alloc[*dci_cnt].format = format_p; - *dci_cnt = *dci_cnt+1; - } else if (crc==ra_rnti) { - dci_alloc[*dci_cnt].format = format_ra; - // store first nCCE of group for PUCCH transmission of ACK/NAK - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - *dci_cnt = *dci_cnt+1; - } else if (crc==pdcch_vars[eNB_id]->crnti) { - - if ((mode&UL_DCI)&&(format_c == format0)&&((dci_decoded_output[current_thread_id][0]&0x80)==0)) {// check if pdu is format 0 or 1A - if (*format0_found == 0) { - dci_alloc[*dci_cnt].format = format0; - *format0_found = 1; - *dci_cnt = *dci_cnt+1; - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - } - } else if (format_c == format0) { // this is a format 1A DCI - dci_alloc[*dci_cnt].format = format1A; - *dci_cnt = *dci_cnt+1; - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - } else { - // store first nCCE of group for PUCCH transmission of ACK/NAK - if (*format_c_found == 0) { - dci_alloc[*dci_cnt].format = format_c; - *dci_cnt = *dci_cnt+1; - *format_c_found = 1; - pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; - } - } - } - - //LOG_I(PHY,"DCI decoding CRNTI [format: %d, nCCE[subframe: %d]: %d ], AggregationLevel %d \n",format_c, subframe, pdcch_vars[eNB_id]->nCCE[subframe],L2); - // memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_decoded_output,sizeof_bytes); - - - - switch (1<<L) { - case 1: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - - case 2: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - - case 4: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - - case 8: - *CCEmap|=(1<<(CCEind&0x1f)); - break; - } - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY,"[DCI search] Found DCI %d rnti %x Aggregation %d length %d format %s in CCE %d (CCEmap %x) candidate %d / %d \n", - *dci_cnt,crc,1<<L,sizeof_bits,dci_format_strings[dci_alloc[*dci_cnt-1].format],CCEind,*CCEmap,m,nb_candidates ); - dump_dci(frame_parms,&dci_alloc[*dci_cnt-1]); - -#endif - return; - } // rnti match - } // CCEmap_cand == 0 -/* - if ( agregationLevel != 0xFF && - (format_c == format0 && m==0 && si_rnti != SI_RNTI)) - { - //Only valid for OAI : Save some processing time when looking for DCI format0. From the log we see the DCI only on candidate 0. - return; - } -*/ - } // candidate loop -} - -uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue, - DCI_ALLOC_t *dci_alloc, - uint8_t DCIFormat, - uint8_t agregationLevel, - int16_t eNB_id, - uint8_t subframe) -{ - - uint8_t dci_cnt=0,old_dci_cnt=0; - uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; - LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t mi = get_mi(&ue->frame_parms,subframe); - uint16_t ra_rnti=99; - uint8_t format0_found=0,format_c_found=0; - uint8_t tmode = ue->transmission_mode[eNB_id]; - uint8_t frame_type = frame_parms->frame_type; - uint8_t format0_size_bits=0,format0_size_bytes=0; - uint8_t format1_size_bits=0,format1_size_bytes=0; - dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - - } else { - format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); - } - - break; - - case 25: - default: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); - } else { - format0_size_bits = sizeof_DCI0_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); - } - - break; - - case 50: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_10MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); - - } else { - format0_size_bits = sizeof_DCI0_10MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); - format1_size_bits = sizeof_DCI1_10MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); - } - - break; - - case 100: - if (frame_type == TDD) { - format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_20MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); - } else { - format0_size_bits = sizeof_DCI0_20MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); - format1_size_bits = sizeof_DCI1_20MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); - } - - break; - } - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - agregationLevel, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (DCIFormat == format1) - { - if ((tmode < 3) || (tmode == 7)) { - //printf("Crnti decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); - - // Now check UE_SPEC format 1 search spaces at aggregation 1 - - //printf("[DCI search] Format 1/1A aggregation 1\n"); - - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //printf("Crnti 1 decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); - - } - else if (DCIFormat == format1A) - { - AssertFatal(0,"Other Transmission mode not yet coded\n"); - } - } - else - { - LOG_W(PHY,"DCI format %d wrong or not yet implemented \n",DCIFormat); - } - - return(dci_cnt); - -} - -uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, - DCI_ALLOC_t *dci_alloc, - int do_common, - int16_t eNB_id, - uint8_t subframe) -{ - - uint8_t dci_cnt=0,old_dci_cnt=0; - uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; - LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t mi = get_mi(&ue->frame_parms,subframe); - uint16_t ra_rnti=99; - uint8_t format0_found=0,format_c_found=0; - uint8_t tmode = ue->transmission_mode[eNB_id]; - uint8_t frame_type = frame_parms->frame_type; - uint8_t format1A_size_bits=0,format1A_size_bytes=0; - uint8_t format1C_size_bits=0,format1C_size_bytes=0; - uint8_t format0_size_bits=0,format0_size_bytes=0; - uint8_t format1_size_bits=0,format1_size_bytes=0; - uint8_t format2_size_bits=0,format2_size_bytes=0; - uint8_t format2A_size_bits=0,format2A_size_bytes=0; - dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_1_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); - format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_1_5MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_1_5MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_1_5MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_1_5MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_1_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); - format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_1_5MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_1_5MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_FDD_t); - } - } - - break; - - case 25: - default: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_5MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_5MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_5MHz_t); - format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_5MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_5MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_5MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_5MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_5MHz_t); - format0_size_bits = sizeof_DCI0_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_5MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_5MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_4A_FDD_t); - } - } - - break; - - case 50: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_10MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_10MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_10MHz_t; - format1C_size_bytes = sizeof(DCI1C_10MHz_t); - format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_10MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_10MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_10MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_10MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_10MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_10MHz_t; - format1C_size_bytes = sizeof(DCI1C_10MHz_t); - format0_size_bits = sizeof_DCI0_10MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); - format1_size_bits = sizeof_DCI1_10MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_10MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_10MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_4A_FDD_t); - } - } - - break; - - case 100: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_20MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_20MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_20MHz_t; - format1C_size_bytes = sizeof(DCI1C_20MHz_t); - format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_20MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_20MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_20MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_20MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_20MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_20MHz_t; - format1C_size_bytes = sizeof(DCI1C_20MHz_t); - format0_size_bits = sizeof_DCI0_20MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); - format1_size_bits = sizeof_DCI1_20MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_20MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_20MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_4A_FDD_t); - } - } - - break; - } - - if (do_common == 1) { -#ifdef DEBUG_DCI_DECODING - printf("[DCI search] subframe %d: doing common search/format0 aggregation 4\n",subframe); -#endif - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // First check common search spaces at aggregation 4 (SI_RNTI, P_RNTI and RA_RNTI format 0/1A), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0) , - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format0, - format1A_size_bits, - format1A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 4 (SI_RNTI,P_RNTI and RA_RNTI and C-RNTI format 1C), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1C, - format1C, - format1C, - format1C, - format1C_size_bits, - format1C_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 8 (SI_RNTI,P_RNTI and RA_RNTI format 1A), - // and UE_SPEC format0 (PUSCH) too while we're at it - // printf("[DCI search] doing common search/format0 aggregation 3\n"); -#ifdef DEBUG_DCI_DECODING - printf("[DCI search] doing common search/format0 aggregation 8\n"); -#endif - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - P_RNTI, - ra_rnti, - 3, - format1A, - format1A, - format1A, - format0, - format1A_size_bits, - format1A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 8 (SI_RNTI and RA_RNTI and C-RNTI format 1C), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1C, - format1C, - format1C, - format1C, - format1C_size_bits, - format1C_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - - } - - if (ue->UE_mode[eNB_id] <= PRACH) - return(dci_cnt); - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 - // printf("[DCI search] Format 0/1A aggregation 8\n"); - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 1 dci_cnt %d\n",dci_cnt); - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 4 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - - //printf("[DCI search] Format 0 aggregation 2 dci_cnt %d\n",dci_cnt); - } - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 2 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 4 dci_cnt %d\n",dci_cnt); - } - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 1 - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 8 dci_cnt %d\n",dci_cnt); - - } - // These are for CRNTI based on transmission mode - if ((tmode < 3) || (tmode == 7)) { - // Now check UE_SPEC format 1 search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 1 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff) || - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1 search spaces at aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 2 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1 search spaces at aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 4 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 1 search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 8 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#endif //ALL_AGGREGATION - } else if (tmode == 3) { - - - // LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 1 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - // Now check UE_SPEC format 2A_2A search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - LOG_D(PHY," format 2A_2A search CCEmap0 %x, format0_found %d, format_c_found %d \n", CCEmap0, format0_found, format_c_found); - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2 search spaces at aggregation 2 - LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 2 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2_2A search spaces at aggregation 4 - // LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 4 \n"); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 2_2A search spaces at aggregation 8 - LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 8 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - } else if (tmode == 4) { - - // Now check UE_SPEC format 2_2A search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2 search spaces at aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2_2A search spaces at aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 2_2A search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - } else if ((tmode==5) || (tmode==6)) { // This is MU-MIMO - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 1 -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," MU-MIMO check UE_SPEC format 1E_2A_M10PRB\n"); -#endif - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - subframe, - dci_alloc, - eNB_id, - ue->current_thread_id[subframe], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#endif //ALL_AGGREGATION - - } - - return(dci_cnt); -} diff --git a/openair1/PHY/LTE_TRANSPORT/dci.h b/openair1/PHY/LTE_TRANSPORT/dci.h index 9381dd63fdd1a3d49b50e6ce4b27793c1a1074c1..c5654aa7428203ca04b4c709eaedae3612adf84d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci.h +++ b/openair1/PHY/LTE_TRANSPORT/dci.h @@ -30,8 +30,18 @@ * \warning */ +#ifndef __DCI__h__ +#define __DCI__h__ + #include <stdint.h> +#define CCEBITS 72 +#define CCEPERSYMBOL 33 // This is for 1200 RE +#define CCEPERSYMBOL0 22 // This is for 1200 RE +#define DCI_BITS_MAX ((2*CCEPERSYMBOL+CCEPERSYMBOL0)*CCEBITS) + +//#define Mquad (Msymb/4) + /// DCI Format Type 0 (5 MHz,TDD0, 27 bits) struct DCI0_5MHz_TDD0 { /// type = 0 => DCI Format 0, type = 1 => DCI Format 1A @@ -3014,3 +3024,5 @@ struct DCI_INFO_EXTRACTED { uint64_t ap_si_nl_id:3; }; typedef struct DCI_INFO_EXTRACTED DCI_INFO_EXTRACTED_t; + +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 4b73de6fcc72864fa1a55d7924819dab46cd5e14..048eb200683208c4f624cd497da72355c58084ef 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -30,776 +30,23 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" #ifdef DEBUG_DCI_TOOLS -#include "PHY/vars.h" +#include "PHY/phy_vars.h" #endif #include "assertions.h" #include "nfapi_interface.h" //#define DEBUG_HARQ -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" -//#define DEBUG_DCI - -uint32_t localRIV2alloc_LUT6[32]; -uint32_t distRIV2alloc_even_LUT6[32]; -uint32_t distRIV2alloc_odd_LUT6[32]; -uint16_t RIV2nb_rb_LUT6[32]; -uint16_t RIV2first_rb_LUT6[32]; -uint16_t RIV_max6=0; - -uint32_t localRIV2alloc_LUT25[512]; -uint32_t distRIV2alloc_even_LUT25[512]; -uint32_t distRIV2alloc_odd_LUT25[512]; -uint16_t RIV2nb_rb_LUT25[512]; -uint16_t RIV2first_rb_LUT25[512]; -uint16_t RIV_max25=0; - - -uint32_t localRIV2alloc_LUT50_0[1600]; -uint32_t localRIV2alloc_LUT50_1[1600]; -uint32_t distRIV2alloc_gap0_even_LUT50_0[1600]; -uint32_t distRIV2alloc_gap0_odd_LUT50_0[1600]; -uint32_t distRIV2alloc_gap0_even_LUT50_1[1600]; -uint32_t distRIV2alloc_gap0_odd_LUT50_1[1600]; -uint32_t distRIV2alloc_gap1_even_LUT50_0[1600]; -uint32_t distRIV2alloc_gap1_odd_LUT50_0[1600]; -uint32_t distRIV2alloc_gap1_even_LUT50_1[1600]; -uint32_t distRIV2alloc_gap1_odd_LUT50_1[1600]; -uint16_t RIV2nb_rb_LUT50[1600]; -uint16_t RIV2first_rb_LUT50[1600]; -uint16_t RIV_max50=0; - -uint32_t localRIV2alloc_LUT100_0[6000]; -uint32_t localRIV2alloc_LUT100_1[6000]; -uint32_t localRIV2alloc_LUT100_2[6000]; -uint32_t localRIV2alloc_LUT100_3[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_0[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_0[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_1[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_1[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_2[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_2[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_3[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_3[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_0[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_0[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_1[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_1[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_2[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_2[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_3[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_3[6000]; -uint16_t RIV2nb_rb_LUT100[6000]; -uint16_t RIV2first_rb_LUT100[6000]; -uint16_t RIV_max100=0; - - -extern uint32_t current_dlsch_cqi; - -// Table 8.6.3-3 36.213 -uint16_t beta_cqi[16] = {0, //reserved - 0, //reserved - 9, //1.125 - 10, //1.250 - 11, //1.375 - 13, //1.625 - 14, //1.750 - 16, //2.000 - 18, //2.250 - 20, //2.500 - 23, //2.875 - 25, //3.125 - 28, //3.500 - 32, //4.000 - 40, //5.000 - 50 - }; //6.250 - -// Table 8.6.3-2 36.213 -uint16_t beta_ri[16] = {10, //1.250 - 13, //1.625 - 16, //2.000 - 20, //2.500 - 25, //3.125 - 32, //4.000 - 40, //5.000 - 50, //6.250 - 64, //8.000 - 80, //10.000 - 101, //12.625 - 127, //15.875 - 160, //20.000 - 0, //reserved - 0, //reserved - 0 - }; //reserved - -// Table 8.6.3-2 36.213 -uint16_t beta_ack[16] = {16, //2.000 - 20, //2.500 - 25, //3.125 - 32, //4.000 - 40, //5.000 - 50, //6.250 - 64, //8.000 - 80, //10.000 - 101, //12.625 - 127, //15.875 - 160, //20.000 - 248, //31.000 - 400, //50.000 - 640, //80.000 - 808 - };//126.00 - -int8_t delta_PUSCH_abs[4] = {-4,-1,1,4}; -int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; - -int8_t *delta_PUCCH_lut = delta_PUSCH_acc; - -void conv_eMTC_rballoc(uint16_t resource_block_coding, - uint32_t N_RB_DL, - uint32_t *rb_alloc) { - - - int narrowband = resource_block_coding>>5; - int RIV = resource_block_coding&31; - int N_NB_DL = N_RB_DL/6; - int i0 = (N_RB_DL>>1) - (3*N_NB_DL); - int first_rb = (6*narrowband)+i0; - int alloc = localRIV2alloc_LUT6[RIV]; - int ind = first_rb>>5; - int ind_mod = first_rb&31; - - if (((N_RB_DL&1) > 0) && (narrowband>=(N_NB_DL>>1))) first_rb++; - rb_alloc[0] = 0; - rb_alloc[1] = 0; - rb_alloc[2] = 0; - rb_alloc[3] = 0; - rb_alloc[ind] = alloc<<ind_mod; - if (ind_mod > 26) rb_alloc[ind+1] = alloc>>(6-(ind_mod-26)); -} - -void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2) -{ - - uint32_t i,shift,subset; - rb_alloc2[0] = 0; - rb_alloc2[1] = 0; - rb_alloc2[2] = 0; - rb_alloc2[3] = 0; - - // printf("N_RB_DL %d, ra_header %d, rb_alloc %x\n",N_RB_DL,ra_header,rb_alloc); - - switch (N_RB_DL) { - - case 6: - rb_alloc2[0] = rb_alloc&0x3f; - break; - - case 25: - if (ra_header == 0) {// Type 0 Allocation - - for (i=12; i>0; i--) { - if ((rb_alloc&(1<<i)) != 0) - rb_alloc2[0] |= (3<<((2*(12-i)))); - - // printf("rb_alloc2 (type 0) %x\n",rb_alloc2); - } - - if ((rb_alloc&1) != 0) - rb_alloc2[0] |= (1<<24); - } else { - subset = rb_alloc&1; - shift = (rb_alloc>>1)&1; - - for (i=0; i<11; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - rb_alloc2[0] |= (1<<(2*i)); - - //printf("rb_alloc2 (type 1) %x\n",rb_alloc2); - } - - if ((shift == 0) && (subset == 1)) - rb_alloc2[0]<<=1; - else if ((shift == 1) && (subset == 0)) - rb_alloc2[0]<<=4; - else if ((shift == 1) && (subset == 1)) - rb_alloc2[0]<<=3; - } - - break; - - case 50: - AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=50\n"); - - for (i=16; i>0; i--) { - if ((rb_alloc&(1<<i)) != 0) - rb_alloc2[(3*(16-i))>>5] |= (7<<((3*(16-i))%32)); - } - - // bit mask across - if ((rb_alloc2[0]>>31)==1) - rb_alloc2[1] |= 1; - - if ((rb_alloc&1) != 0) - rb_alloc2[1] |= (3<<16); - break; - - case 100: - AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=100\n"); - for (i=0; i<25; i++) { - if ((rb_alloc&(1<<(24-i))) != 0) - rb_alloc2[(4*i)>>5] |= (0xf<<((4*i)%32)); - - // printf("rb_alloc2[%d] (type 0) %x (%d)\n",(4*i)>>5,rb_alloc2[(4*i)>>5],rb_alloc&(1<<i)); - } - - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", N_RB_DL); - DevParam (N_RB_DL, 0, 0); - break; - } - -} - - - -uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL) -{ - - uint32_t nprb=0,i; - - switch (N_RB_DL) { - case 6: - for (i=0; i<6; i++) { - if ((rb_alloc&(1<<i)) != 0) - nprb += 1; - } - - break; - - case 25: - if (ra_header == 0) {// Type 0 Allocation - - for (i=12; i>0; i--) { - if ((rb_alloc&(1<<i)) != 0) - nprb += 2; - } - - if ((rb_alloc&1) != 0) - nprb += 1; - } else { - for (i=0; i<11; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - nprb += 1; - } - } - - break; - - case 50: - if (ra_header == 0) {// Type 0 Allocation - - for (i=0; i<16; i++) { - if ((rb_alloc&(1<<(16-i))) != 0) - nprb += 3; - } - - if ((rb_alloc&1) != 0) - nprb += 2; - - } else { - for (i=0; i<17; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - nprb += 1; - } - } - - break; - - case 100: - if (ra_header == 0) {// Type 0 Allocation - - for (i=0; i<25; i++) { - if ((rb_alloc&(1<<(24-i))) != 0) - nprb += 4; - } - } else { - for (i=0; i<25; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - nprb += 1; - } - } - - break; - - default: - LOG_E(PHY,"Invalide N_RB_DL %d\n", N_RB_DL); - DevParam (N_RB_DL, 0, 0); - break; - } - - return(nprb); -} - -uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs) -{ - - uint16_t RIV; - - if (Lcrbs<=(1+(N_RB_DL>>1))) - RIV = (N_RB_DL*(Lcrbs-1)) + RBstart; - else - RIV = (N_RB_DL*(N_RB_DL+1-Lcrbs)) + (N_RB_DL-1-RBstart); - - return(RIV); -} - -// Convert a DCI Format 1C RIV to a Format 1A RIV -// This extracts the start and length in PRBs from the 1C rballoc and -// recomputes the RIV as if it were the 1A rballoc - -uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL) { - - int NpDLVRB,N_RB_step,LpCRBsm1,RBpstart; - - switch (N_RB_DL) { - - case 6: // N_RB_step = 2, NDLVRB = 6, NpDLVRB = 3 - NpDLVRB = 3; - N_RB_step = 2; - break; - case 25: // N_RB_step = 2, NDLVRB = 24, NpDLVRB = 12 - NpDLVRB = 12; - N_RB_step = 2; - break; - case 50: // N_RB_step = 4, NDLVRB = 46, NpDLVRB = 11 - NpDLVRB = 11; - N_RB_step = 4; - break; - case 100: // N_RB_step = 4, NDLVRB = 96, NpDLVRB = 24 - NpDLVRB = 24; - N_RB_step = 4; - break; - default: - NpDLVRB = 24; - N_RB_step = 4; - break; - } - - // This is the 1C part from 7.1.6.3 in 36.213 - LpCRBsm1 = rballoc/NpDLVRB; - // printf("LpCRBs = %d\n",LpCRBsm1+1); - - if (LpCRBsm1 <= (NpDLVRB/2)) { - RBpstart = rballoc % NpDLVRB; - } - else { - LpCRBsm1 = NpDLVRB-LpCRBsm1; - RBpstart = NpDLVRB-(rballoc%NpDLVRB); - } - // printf("RBpstart %d\n",RBpstart); - return(computeRIV(N_RB_DL,N_RB_step*RBpstart,N_RB_step*(LpCRBsm1+1))); - -} - -uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { - - int offset; - - switch (N_RB_DL) { - - case 6: - // N_RB_DL = tildeN_RB_DL = 6 - // Ngap = 4 , P=1, Nrow = 2, Nnull = 2 - - switch (vrb) { - case 0: // even: 0->0, 1->2, odd: 0->3, 1->5 - case 1: - return ((3*odd_slot) + 2*(vrb&3))%6; - break; - case 2: // even: 2->3, 3->5, odd: 2->0, 3->2 - case 3: - return ((3*odd_slot) + 2*(vrb&3) + 5)%6; - break; - case 4: // even: 4->1, odd: 4->4 - return ((3*odd_slot) + 1)%6; - case 5: // even: 5->4, odd: 5->1 - return ((3*odd_slot) + 4)%6; - break; - } - break; - - case 15: - if (vrb<12) { - if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11 - return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); - else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13 - return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); - } - if (vrb==12) - return (3+(7*odd_slot)) % 14; - if (vrb==13) - return (10+(7*odd_slot)) % 14; - return 14; - break; - - case 25: - return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); - break; - - case 50: // P=3 - if (Ngap==0) { - // Nrow=12,Nnull=2,NVRBDL=46,Ngap1= 27 - if (vrb>=23) - offset=4; - else - offset=0; - if (vrb<44) { - if ((vrb&3)>=2) - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; - else - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; - } - if (vrb==44) // even: 44->11, odd: 45->34 - return offset+((23*odd_slot) + 22-12+1); - if (vrb==45) // even: 45->10, odd: 45->33 - return offset+((23*odd_slot) + 22+12); - if (vrb==46) - return offset+46+((23*odd_slot) + 23-12+1) % 46; - if (vrb==47) - return offset+46+((23*odd_slot) + 23+12) % 46; - if (vrb==48) - return offset+46+((23*odd_slot) + 23-12+1) % 46; - if (vrb==49) - return offset+46+((23*odd_slot) + 23+12) % 46; - } - else { - // Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27 - if (vrb>=9) - offset=18; - else - offset=0; - - if (vrb<12) { - if ((vrb&3)>=2) - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; - else - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; - } - else { - return offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18); - } - } - break; - case 75: - // Ngap1 = 32, NVRBRL=64, P=4, Nrow= 16, Nnull=0 - if (Ngap ==0) { - return ((32*odd_slot) + 16*(vrb&3) + (vrb>>2))%64 + (vrb/64); - } else { - // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); - } - break; - case 100: - // Ngap1 = 48, NVRBDL=96, Nrow=24, Nnull=0 - if (Ngap ==0) { - return ((48*odd_slot) + 24*(vrb&3) + (vrb>>2))%96 + (vrb/96); - } else { - // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); - } - break; - default: - LOG_E(PHY,"Unknown N_RB_DL %d\n",N_RB_DL); - return 0; - } - return 0; - -} - - -void generate_RIV_tables() -{ - - // 6RBs localized RIV - uint8_t Lcrbs,RBstart; - uint16_t RIV; - uint32_t alloc0,allocdist0_0_even,allocdist0_0_odd,allocdist0_1_even,allocdist0_1_odd; - uint32_t alloc1,allocdist1_0_even,allocdist1_0_odd,allocdist1_1_even,allocdist1_1_odd; - uint32_t alloc2,allocdist2_0_even,allocdist2_0_odd,allocdist2_1_even,allocdist2_1_odd; - uint32_t alloc3,allocdist3_0_even,allocdist3_0_odd,allocdist3_1_even,allocdist3_1_odd; - uint32_t nVRB,nVRB_even_dist,nVRB_odd_dist; - - for (RBstart=0; RBstart<6; RBstart++) { - alloc0 = 0; - allocdist0_0_even = 0; - allocdist0_0_odd = 0; - for (Lcrbs=1; Lcrbs<=(6-RBstart); Lcrbs++) { - //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); - nVRB = Lcrbs-1+RBstart; - alloc0 |= (1<<nVRB); - allocdist0_0_even |= (1<<get_prb(6,0,nVRB,0)); - allocdist0_0_odd |= (1<<get_prb(6,1,nVRB,0)); - RIV=computeRIV(6,RBstart,Lcrbs); - - if (RIV>RIV_max6) - RIV_max6 = RIV; - - // printf("RIV %d (%d) : first_rb %d NBRB %d\n",RIV,localRIV2alloc_LUT25[RIV],RBstart,Lcrbs); - localRIV2alloc_LUT6[RIV] = alloc0; - distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even; - distRIV2alloc_odd_LUT6[RIV] = allocdist0_0_odd; - RIV2nb_rb_LUT6[RIV] = Lcrbs; - RIV2first_rb_LUT6[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<25; RBstart++) { - alloc0 = 0; - allocdist0_0_even = 0; - allocdist0_0_odd = 0; - for (Lcrbs=1; Lcrbs<=(25-RBstart); Lcrbs++) { - nVRB = Lcrbs-1+RBstart; - //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); - alloc0 |= (1<<nVRB); - allocdist0_0_even |= (1<<get_prb(25,0,nVRB,0)); - allocdist0_0_odd |= (1<<get_prb(25,1,nVRB,0)); - - //printf("alloc 0 %x, allocdist0_even %x, allocdist0_odd %x\n",alloc0,allocdist0_0_even,allocdist0_0_odd); - RIV=computeRIV(25,RBstart,Lcrbs); - - if (RIV>RIV_max25) - RIV_max25 = RIV;; - - - localRIV2alloc_LUT25[RIV] = alloc0; - distRIV2alloc_even_LUT25[RIV] = allocdist0_0_even; - distRIV2alloc_odd_LUT25[RIV] = allocdist0_0_odd; - RIV2nb_rb_LUT25[RIV] = Lcrbs; - RIV2first_rb_LUT25[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<50; RBstart++) { - alloc0 = 0; - alloc1 = 0; - allocdist0_0_even=0; - allocdist1_0_even=0; - allocdist0_0_odd=0; - allocdist1_0_odd=0; - allocdist0_1_even=0; - allocdist1_1_even=0; - allocdist0_1_odd=0; - allocdist1_1_odd=0; - - for (Lcrbs=1; Lcrbs<=(50-RBstart); Lcrbs++) { - - nVRB = Lcrbs-1+RBstart; - - - if (nVRB<32) - alloc0 |= (1<<nVRB); - else - alloc1 |= (1<<(nVRB-32)); - - // Distributed Gap1, even slot - nVRB_even_dist = get_prb(50,0,nVRB,0); - if (nVRB_even_dist<32) - allocdist0_0_even |= (1<<nVRB_even_dist); - else - allocdist1_0_even |= (1<<(nVRB_even_dist-32)); - - // Distributed Gap1, odd slot - nVRB_odd_dist = get_prb(50,1,nVRB,0); - if (nVRB_odd_dist<32) - allocdist0_0_odd |= (1<<nVRB_odd_dist); - else - allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); - - // Distributed Gap2, even slot - nVRB_even_dist = get_prb(50,0,nVRB,1); - if (nVRB_even_dist<32) - allocdist0_1_even |= (1<<nVRB_even_dist); - else - allocdist1_1_even |= (1<<(nVRB_even_dist-32)); - - // Distributed Gap2, odd slot - nVRB_odd_dist = get_prb(50,1,nVRB,1); - if (nVRB_odd_dist<32) - allocdist0_1_odd |= (1<<nVRB_odd_dist); - else - allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); - - RIV=computeRIV(50,RBstart,Lcrbs); - - if (RIV>RIV_max50) - RIV_max50 = RIV; - - // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); - localRIV2alloc_LUT50_0[RIV] = alloc0; - localRIV2alloc_LUT50_1[RIV] = alloc1; - distRIV2alloc_gap0_even_LUT50_0[RIV] = allocdist0_0_even; - distRIV2alloc_gap0_even_LUT50_1[RIV] = allocdist1_0_even; - distRIV2alloc_gap0_odd_LUT50_0[RIV] = allocdist0_0_odd; - distRIV2alloc_gap0_odd_LUT50_1[RIV] = allocdist1_0_odd; - distRIV2alloc_gap1_even_LUT50_0[RIV] = allocdist0_1_even; - distRIV2alloc_gap1_even_LUT50_1[RIV] = allocdist1_1_even; - distRIV2alloc_gap1_odd_LUT50_0[RIV] = allocdist0_1_odd; - distRIV2alloc_gap1_odd_LUT50_1[RIV] = allocdist1_1_odd; - RIV2nb_rb_LUT50[RIV] = Lcrbs; - RIV2first_rb_LUT50[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<100; RBstart++) { - alloc0 = 0; - alloc1 = 0; - alloc2 = 0; - alloc3 = 0; - allocdist0_0_even=0; - allocdist1_0_even=0; - allocdist2_0_even=0; - allocdist3_0_even=0; - allocdist0_0_odd=0; - allocdist1_0_odd=0; - allocdist2_0_odd=0; - allocdist3_0_odd=0; - allocdist0_1_even=0; - allocdist1_1_even=0; - allocdist2_1_even=0; - allocdist3_1_even=0; - allocdist0_1_odd=0; - allocdist1_1_odd=0; - allocdist2_1_odd=0; - allocdist3_1_odd=0; - - for (Lcrbs=1; Lcrbs<=(100-RBstart); Lcrbs++) { - - nVRB = Lcrbs-1+RBstart; - - if (nVRB<32) - alloc0 |= (1<<nVRB); - else if (nVRB<64) - alloc1 |= (1<<(nVRB-32)); - else if (nVRB<96) - alloc2 |= (1<<(nVRB-64)); - else - alloc3 |= (1<<(nVRB-96)); - - // Distributed Gap1, even slot - nVRB_even_dist = get_prb(100,0,nVRB,0); - -// if ((RBstart==0) && (Lcrbs<=8)) -// printf("nVRB %d => nVRB_even_dist %d\n",nVRB,nVRB_even_dist); - - - if (nVRB_even_dist<32) - allocdist0_0_even |= (1<<nVRB_even_dist); - else if (nVRB_even_dist<64) - allocdist1_0_even |= (1<<(nVRB_even_dist-32)); - else if (nVRB_even_dist<96) - allocdist2_0_even |= (1<<(nVRB_even_dist-64)); - else - allocdist3_0_even |= (1<<(nVRB_even_dist-96)); -/* if ((RBstart==0) && (Lcrbs<=8)) - printf("rballoc =>(%08x.%08x.%08x.%08x)\n", - allocdist0_0_even, - allocdist1_0_even, - allocdist2_0_even, - allocdist3_0_even - ); -*/ - // Distributed Gap1, odd slot - nVRB_odd_dist = get_prb(100,1,nVRB,0); - if (nVRB_odd_dist<32) - allocdist0_0_odd |= (1<<nVRB_odd_dist); - else if (nVRB_odd_dist<64) - allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); - else if (nVRB_odd_dist<96) - allocdist2_0_odd |= (1<<(nVRB_odd_dist-64)); - else - allocdist3_0_odd |= (1<<(nVRB_odd_dist-96)); - - - // Distributed Gap2, even slot - nVRB_even_dist = get_prb(100,0,nVRB,1); - if (nVRB_even_dist<32) - allocdist0_1_even |= (1<<nVRB_even_dist); - else if (nVRB_even_dist<64) - allocdist1_1_even |= (1<<(nVRB_even_dist-32)); - else if (nVRB_even_dist<96) - allocdist2_1_even |= (1<<(nVRB_even_dist-64)); - else - allocdist3_1_even |= (1<<(nVRB_even_dist-96)); - - - // Distributed Gap2, odd slot - nVRB_odd_dist = get_prb(100,1,nVRB,1); - if (nVRB_odd_dist<32) - allocdist0_1_odd |= (1<<nVRB_odd_dist); - else if (nVRB_odd_dist<64) - allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); - else if (nVRB_odd_dist<96) - allocdist2_1_odd |= (1<<(nVRB_odd_dist-64)); - else - allocdist3_1_odd |= (1<<(nVRB_odd_dist-96)); - - - RIV=computeRIV(100,RBstart,Lcrbs); - - if (RIV>RIV_max100) - RIV_max100 = RIV; - - // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); - localRIV2alloc_LUT100_0[RIV] = alloc0; - localRIV2alloc_LUT100_1[RIV] = alloc1; - localRIV2alloc_LUT100_2[RIV] = alloc2; - localRIV2alloc_LUT100_3[RIV] = alloc3; - distRIV2alloc_gap0_even_LUT100_0[RIV] = allocdist0_0_even; - distRIV2alloc_gap0_even_LUT100_1[RIV] = allocdist1_0_even; - distRIV2alloc_gap0_even_LUT100_2[RIV] = allocdist2_0_even; - distRIV2alloc_gap0_even_LUT100_3[RIV] = allocdist3_0_even; - distRIV2alloc_gap0_odd_LUT100_0[RIV] = allocdist0_0_odd; - distRIV2alloc_gap0_odd_LUT100_1[RIV] = allocdist1_0_odd; - distRIV2alloc_gap0_odd_LUT100_2[RIV] = allocdist2_0_odd; - distRIV2alloc_gap0_odd_LUT100_3[RIV] = allocdist3_0_odd; - distRIV2alloc_gap1_even_LUT100_0[RIV] = allocdist0_1_even; - distRIV2alloc_gap1_even_LUT100_1[RIV] = allocdist1_1_even; - distRIV2alloc_gap1_even_LUT100_2[RIV] = allocdist2_1_even; - distRIV2alloc_gap1_even_LUT100_3[RIV] = allocdist3_1_even; - distRIV2alloc_gap1_odd_LUT100_0[RIV] = allocdist0_1_odd; - distRIV2alloc_gap1_odd_LUT100_1[RIV] = allocdist1_1_odd; - distRIV2alloc_gap1_odd_LUT100_2[RIV] = allocdist2_1_odd; - distRIV2alloc_gap1_odd_LUT100_3[RIV] = allocdist3_1_odd; - - RIV2nb_rb_LUT100[RIV] = Lcrbs; - RIV2first_rb_LUT100[RIV] = RBstart; - } - } -} - -// Ngap = 3, N_VRB_DL=6, P=1, N_row=2, N_null=4*2-6=2 -// permutation for even slots : -// n_PRB'(0,2,4) = (0,1,2), n_PRB'(1,3,5) = (4,5,6) -// n_PRB''(0,1,2,3) = (0,2,4,6) -// => n_tilde_PRB(5) = (4) -// n_tilde_PRB(4) = (1) -// n_tilde_PRB(2,3) = (3,5) -// n_tilde_PRB(0,1) = (0,2) +#include "LAYER2/MAC/mac.h" +//#define DEBUG_DCI +#include "dci_tools_common_extern.h" +#include "transport_proto.h" int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) { @@ -840,25 +87,8 @@ int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) } -uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci) -{ - - return(localRIV2alloc_LUT25[rb_alloc_dci]); - -} -/* -uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti) -{ - unsigned char UE_id; - // find the UE_index corresponding to rnti - UE_id = find_ue(rnti,RC.eNB[Mod_id][CC_id]); - DevAssert( UE_id != (unsigned char)-1 ); - - return(RC.eNB[Mod_id][CC_id]->transmission_mode[UE_id]); -} -*/ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,nfapi_dl_config_dci_dl_pdu *pdu) { @@ -2183,6 +1413,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t #endif +//printf("DCI %d.%d rnti %d harq %d TBS %d\n", frame, subframe, rel8->rnti, rel8->harq_process, dlsch0_harq->TBS); #if T_TRACER if (dlsch0->active) T(T_ENB_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame), T_INT(subframe), @@ -2709,6385 +1940,4 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame ulsch->harq_processes[harq_pid]->round); } -int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) -{ - switch (dci->format) { - - case format0: // This is an UL SCH allocation so nothing here, inform MAC - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format0 (TDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 25: - LOG_D(PHY,"DCI format0 (TDD1-6, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 50: - LOG_D(PHY,"DCI format0 (TDD1-6, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 100: - LOG_D(PHY,"DCI format0 (TDD1-6, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else if (frame_parms->frame_type == FDD) - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format0 (FDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 25: - LOG_D(PHY,"DCI format0 (FDD, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 50: - LOG_D(PHY,"DCI format0 (FDD, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 100: - LOG_D(PHY,"DCI format0 (FDD, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1: - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) - - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1 (TDD 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 25: - LOG_D(PHY,"DCI format1 (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 50: - LOG_D(PHY,"DCI format1 (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 100: - LOG_D(PHY,"DCI format1 (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else if (frame_parms->frame_type == FDD) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1 (FDD, 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format1 (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format1 (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format1 (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1A: // This is DLSCH allocation for control traffic - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1A (TDD1-6, 1_5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 25: - LOG_D(PHY,"DCI format1A (TDD1-6, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %d (NB_RB %d)\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 50: - LOG_D(PHY,"DCI format1A (TDD1-6, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 100: - LOG_D(PHY,"DCI format1A (TDD1-6, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - } else if (frame_parms->frame_type == FDD) { - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1A(FDD, 1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format1A(FDD, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format1A(FDD, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format1A(FDD, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - - break; - - case format1C: // This is DLSCH allocation for control traffic - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1C (1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n", - ((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT6[conv_1C_RIV(((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,6)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 25: - LOG_D(PHY,"DCI format1C (5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[conv_1C_RIV(((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,25)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 50: - LOG_D(PHY,"DCI format1C (10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"Ngap %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->Ngap); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,50)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 100: - LOG_D(PHY,"DCI format1C (20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"Ngap %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->Ngap); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,100)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - break; - - case format2: - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } else if (frame_parms->frame_type == FDD) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - - LOG_D(PHY,"DCI format2 2 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, swap %d, TPMI %d, TPC %d\n", - - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - - case 6: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format2A: - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap - ); - break; - - case 25: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - case 50: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - case 100: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } else if (frame_parms->frame_type == FDD) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - - case 6: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1E_2A_M10PRB: - - LOG_D(PHY,"DCI format1E_2A_M10PRB, rnti %x (%8x): harq_pid %d, rah %d, rb_alloc %x, mcs %d, rv %d, tpmi %d, ndi %d, dl_power_offset %d\n", - dci->rnti, - ((uint32_t *)&dci->dci_pdu)[0], - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->harq_pid, - //((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->dl_power_off - ); - - break; - - default: - LOG_E(PHY,"dci_tools.c: dump_dci, unknown format %d\n",dci->format); - return(-1); - } - - return(0); -} - -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) -{ - uint8_t harq_pid=0; - uint32_t rballoc=0; - uint8_t vrb_type=0; - uint8_t mcs=0; - uint8_t rv=0; - uint8_t ndi=0; - uint8_t TPC=0; - - uint8_t dai=0; - - switch (N_RB_DL) { - case 6: - if (frame_type == TDD) { - vrb_type = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - break; - - case 25: - - if (frame_type == TDD) { - vrb_type = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai; - //printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_5MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - - break; - - case 50: - if (frame_type == TDD) { - vrb_type = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_10MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_10MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, vrb_type %d, rballoc %x,ndi %d, rv %d, TPC %d\n",mcs,vrb_type,rballoc,ndi,rv,TPC); - } - break; - - case 100: - if (frame_type == TDD) { - vrb_type = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_20MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_20MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - break; - } - - pdci_info_extarcted->vrb_type = vrb_type; - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rv1 = rv; - pdci_info_extarcted->ndi1 = ndi; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->harq_pid = harq_pid; - 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) -{ - - uint32_t rballoc=0; - uint8_t mcs=0; - - switch (N_RB_DL) { - case 6: - mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 25: - mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 50: - mcs = ((DCI1C_10MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_10MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 100: - mcs = ((DCI1C_20MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_20MHz_t *)dci_pdu)->rballoc,6); - break; - - default: - AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",N_RB_DL); - break; - } - - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rballoc = rballoc; -} - -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) -{ - - uint32_t rballoc=0; - uint8_t mcs=0; - uint8_t rah=0; - uint8_t rv=0; - uint8_t TPC=0; - uint8_t ndi=0; - uint8_t harq_pid=0; - - switch (N_RB_DL) { - case 6: - if (frame_type == TDD) { - mcs = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 25: - if (frame_type == TDD) { - mcs = ((DCI1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_5MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_5MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_5MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_5MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 50: - if (frame_type == TDD) { - mcs = ((DCI1_10MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_10MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_10MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_10MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_10MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_10MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_10MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_10MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_10MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_10MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_10MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_10MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_10MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 100: - if (frame_type == TDD) { - mcs = ((DCI1_20MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_20MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_20MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_20MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_20MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_20MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_20MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_20MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_20MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_20MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_20MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_20MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_20MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - } - - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rv1 = rv; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->ndi1 = ndi; - pdci_info_extarcted->harq_pid = harq_pid; - -} - -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) -{ - - uint32_t rballoc=0; - uint8_t rah=0; - uint8_t mcs1=0; - uint8_t mcs2=0; - uint8_t rv1=0; - uint8_t rv2=0; - uint8_t ndi1=0; - uint8_t ndi2=0; - uint8_t tbswap=0; - uint8_t tpmi=0; - uint8_t harq_pid=0; - uint8_t TPC=0; - - switch (N_RB_DL) { - - case 6: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 25: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 50: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 100: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - } - - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->mcs1 = mcs1; - pdci_info_extarcted->mcs2 = mcs2; - pdci_info_extarcted->rv1 = rv1; - pdci_info_extarcted->rv2 = rv2; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->tb_swap = tbswap; - pdci_info_extarcted->tpmi = tpmi; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->ndi1 = ndi1; - pdci_info_extarcted->ndi2 = ndi2; - -} - -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) -{ - - uint32_t rballoc=0; - uint8_t rah=0; - uint8_t mcs1=0; - uint8_t mcs2=0; - uint8_t rv1=0; - uint8_t rv2=0; - uint8_t ndi1=0; - uint8_t ndi2=0; - uint8_t tbswap=0; - uint8_t tpmi=0; - uint8_t harq_pid=0; - uint8_t TPC=0; - - AssertFatal( (nb_antenna_ports_eNB == 2) || (nb_antenna_ports_eNB == 4), "unsupported nb_antenna_ports_eNB %d\n", nb_antenna_ports_eNB); - switch (N_RB_DL) { - - case 6: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - - case 25: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - break; - - case 50: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - - case 100: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - } - - pdci_info_extarcted->mcs1 = mcs1; - pdci_info_extarcted->mcs2 = mcs2; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->rv1 = rv1; - pdci_info_extarcted->rv2 = rv2; - pdci_info_extarcted->ndi1 = ndi1; - pdci_info_extarcted->ndi2 = ndi2; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->tb_swap = tbswap; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->tpmi = tpmi; -} - -int check_dci_format1_1a_coherency(DCI_format_t dci_format, - uint8_t N_RB_DL, - uint16_t rnti, - uint16_t tc_rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint32_t frame, - uint8_t subframe, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_UE_HARQ_t *pdlsch0_harq) -{ - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t rah = pdci_info_extarcted->rah; -#ifdef DEBUG_DCI - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t ndi1 = pdci_info_extarcted->ndi1; -#endif - - uint8_t NPRB = 0; - long long int RIV_max = 0; - -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1-1A] AbsSubframe %d.%d dci_format %d\n", frame, subframe, dci_format); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rnti %x\n", rnti); - LOG_I(PHY,"[DCI-FORMAT-1-1A] harq_pid %d\n", harq_pid); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rah %d\n", rah); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rballoc %x\n", rballoc); - LOG_I(PHY,"[DCI-FORMAT-1-1A] mcs1 %d\n", mcs1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rv1 %d\n", rv1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] ndi1 %d\n", ndi1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] TPC %d\n", TPC); -#endif - - - // I- check dci content minimum coherency - if( ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) && harq_pid > 0) - { - return(0); - } - - if(harq_pid>=8) - { - // LOG_I(PHY,"bad harq id \n"); - return(0); - } - - if(dci_format == format1 && ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) ) - { - // LOG_I(PHY,"bad dci format \n"); - return(0); - } - - - if( mcs1 > 28) - { - if(pdlsch0_harq->round == 0) - { - // LOG_I(PHY,"bad dci mcs + round \n"); - return(0); - } - - if((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - // LOG_I(PHY,"bad dci mcs + rnti \n"); - return(0); - } - } - - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - NPRB = (TPC&1) + 2; - switch (N_RB_DL) { - case 6: - RIV_max = RIV_max6; - break; - case 25: - RIV_max = RIV_max25; - break; - case 50: - RIV_max = RIV_max50; - break; - case 100: - RIV_max = RIV_max100; - break; - } - } - else - { - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max6; - else - RIV_max = 0x3F; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max25; - else - RIV_max = 0x1FFF; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max50; - else - RIV_max = 0x1FFFF; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max100; - else - RIV_max = 0x1FFFFFF; - break; - } - } - - - if(dci_format == format1) - { - NPRB = conv_nprb(rah, rballoc, N_RB_DL); - } - - - if(rballoc > RIV_max) - { - // LOG_I(PHY,"bad dci rballoc rballoc %d RIV_max %lld \n",rballoc, RIV_max); - // DCI false detection - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - // LOG_I(PHY,"bad NPRB = 0 \n"); - return(0); - } - - // this a retransmission - if(pdlsch0_harq->round>0) - { - // compare old TBS to new TBS - if((mcs1<29) && (pdlsch0_harq->TBS != TBStable[get_I_TBS(mcs1)][NPRB-1])) - { - // this is an eNB issue - // retransmisison but old and new TBS are different !!! - // work around, consider it as a new transmission - LOG_E(PHY,"Format1A Retransmission but TBS are different: consider it as new transmission !!! \n"); - pdlsch0_harq->round = 0; - //return(0); // ?? to cross check - } - } - - return(1); -} - -int check_dci_format1c_coherency(uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - uint16_t rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - LTE_DL_UE_HARQ_t *pdlsch0_harq) -{ - uint32_t rballoc = pdci_info_extarcted->rballoc; - - uint8_t NPRB = 0; - uint32_t RIV_max = 0; - - // I- check dci content minimum coherency - - if((rnti!=si_rnti) && (rnti!=p_rnti) && (rnti!=ra_rnti)) - return(0); - - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - RIV_max = RIV_max6; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - RIV_max = RIV_max25; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - RIV_max = RIV_max50; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - RIV_max = RIV_max100; - break; - } - - if(rballoc > RIV_max) - { - // DCI false detection - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - return(0); - } - - return(1); -} - -int check_dci_format2_2a_coherency(DCI_format_t dci_format, - uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - uint16_t rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - LTE_DL_UE_HARQ_t *pdlsch0_harq, - LTE_DL_UE_HARQ_t *pdlsch1_harq) -{ - uint8_t rah = pdci_info_extarcted->rah; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t mcs2 = pdci_info_extarcted->mcs2; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t rv2 = pdci_info_extarcted->rv2; - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - -#ifdef DEBUG_DCI - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t ndi2 = pdci_info_extarcted->ndi2; -#endif - - uint8_t NPRB = 0; - long long RIV_max = 0; - -#ifdef DEBUG_DCI - LOG_I(PHY, "extarcted dci - dci_format %d \n", dci_format); - LOG_I(PHY, "extarcted dci - rnti %d \n", rnti); - LOG_I(PHY, "extarcted dci - rah %d \n", rah); - LOG_I(PHY, "extarcted dci - mcs1 %d \n", mcs1); - LOG_I(PHY, "extarcted dci - mcs2 %d \n", mcs2); - LOG_I(PHY, "extarcted dci - rv1 %d \n", rv1); - LOG_I(PHY, "extarcted dci - rv2 %d \n", rv2); - //LOG_I(PHY, "extarcted dci - ndi1 %d \n", ndi1); - //LOG_I(PHY, "extarcted dci - ndi2 %d \n", ndi2); - LOG_I(PHY, "extarcted dci - rballoc %x \n", rballoc); - LOG_I(PHY, "extarcted dci - harq pid %d \n", harq_pid); - LOG_I(PHY, "extarcted dci - round0 %d \n", pdlsch0_harq->round); - LOG_I(PHY, "extarcted dci - round1 %d \n", pdlsch1_harq->round); -#endif - - // I- check dci content minimum coherency - if(harq_pid>=8) - { - // LOG_I(PHY,"bad harq pid\n"); - return(0); - } - - if( (rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti) ) - { - // LOG_I(PHY,"bad rnti\n"); - return(0); - } - - - if( mcs1 > 28) - { - if(pdlsch0_harq->round == 0) - { - // LOG_I(PHY,"bad mcs1\n"); - return(0); - } - } - - if( mcs2 > 28) - { - if(pdlsch1_harq->round == 0) - { - // LOG_I(PHY,"bad mcs2\n"); - return(0); - } - } - - - if((pdlsch0_harq->round == 0) && (rv1 > 0) && (mcs1 != 0)) - { - // DCI false detection - // LOG_I(PHY,"bad rv1\n"); - return(0); - } - - if((pdlsch1_harq->round == 0) && (rv2 > 0) && (mcs2 != 0)) - { - // DCI false detection - // LOG_I(PHY,"bad rv2\n"); - return(0); - } - - - switch (N_RB_DL) { - case 6: - if (rah == 0) - { - //RBG = 1; - RIV_max = 0x3F; - } - else - { - RIV_max = RIV_max6; - } - break; - case 25: - if (rah == 0) - { - //RBG = 2; - RIV_max = 0x1FFF; - } - else - { - RIV_max = RIV_max25; - } - break; - case 50: - if (rah == 0) - { - //RBG = 3; - RIV_max = 0x1FFFF; - } - else - { - RIV_max = RIV_max50; - } - break; - case 100: - if (rah == 0) - { - //RBG = 4; - RIV_max = 0x1FFFFFF; - } - else - { - RIV_max = RIV_max100; - } - break; - } - - NPRB = conv_nprb(rah, - rballoc, - N_RB_DL); - - - - if( (rballoc > RIV_max) && (rah == 1) ) - { - // DCI false detection - // LOG_I(PHY,"bad rballoc %d RIV_max %lld\n", rballoc, RIV_max); - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - // LOG_I(PHY,"bad NPRB\n"); - return(0); - } - - return(1); -} - -void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - LTE_DL_UE_HARQ_t *dlsch0_harq, - uint8_t nb_rb_alloc, - uint8_t subframe) -{ - uint32_t pbch_pss_sss_re; - uint32_t crs_re; - uint32_t granted_re; - uint32_t data_re; - uint32_t llr_offset; - uint8_t symbol; - uint8_t symbol_mod; - - pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; - - LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); - - //dlsch0_harq->rb_alloc_even; - //dlsch0_harq->rb_alloc_odd; - - for(symbol=pdcch_vars->num_pdcch_symbols; symbol<frame_parms->symbols_per_tti; symbol++) - { - symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; - if((symbol_mod == 0) || symbol_mod == (4-frame_parms->Ncp)) - { - if (frame_parms->nb_antennas_tx == 2) - crs_re = 4; - else - crs_re = 2; - } - else - { - crs_re = 0; - } - - granted_re = nb_rb_alloc * (12-crs_re); - pbch_pss_sss_re = adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,subframe,symbol); - pbch_pss_sss_re = (double)pbch_pss_sss_re * ((double)(12-crs_re)/12); - data_re = granted_re - pbch_pss_sss_re; - llr_offset = data_re * dlsch0_harq->Qm * 2; - - pdsch_vars->llr_length[symbol] = data_re; - if(symbol < (frame_parms->symbols_per_tti-1)) - pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; - - LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); - LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); - LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); - LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); - - - - LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, - pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); - } -} -void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, - uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - uint8_t subframe, - uint16_t rnti, - uint16_t tc_rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - LTE_DL_UE_HARQ_t *pdlsch0_harq, - LTE_UE_DLSCH_t *pdlsch0) -{ - - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint8_t vrb_type = pdci_info_extarcted->vrb_type; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t rah = pdci_info_extarcted->rah; - uint8_t dai = pdci_info_extarcted->dai; - - - uint8_t NPRB = 0; - uint8_t NPRB4TBS = 0; - - if(dci_format == format1A) - { - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc]; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc]; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc]; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc]; - break; - } - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - NPRB4TBS = (TPC&1) + 2; - } - else - { - NPRB4TBS = NPRB; - /* - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - break; - } - - */ - } - } - else // format1 - { - NPRB = conv_nprb(rah, rballoc, N_RB_DL); - NPRB4TBS=NPRB; - } - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->active = 1; - pdlsch0->rnti = rnti; - if(dci_format == format1A) - pdlsch0->harq_ack[subframe].vDAI_DL = dai+1; - - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - pdlsch0_harq->round = 0; - pdlsch0_harq->status = ACTIVE; - } - else //CRNTI - { - if (rnti == tc_rnti) { - //fix for standalone Contention Resolution Id - pdlsch0_harq->DCINdi = (uint8_t)-1; - LOG_D(PHY,"UE (%x/%d): Format1A DCI: C-RNTI is temporary. Set NDI = %d and to be ignored\n", - rnti,harq_pid,pdlsch0_harq->DCINdi); - } - - // NDI has been toggled or this is the first transmission - if ((ndi1!=pdlsch0_harq->DCINdi) || (pdlsch0_harq->first_tx==1)) - { - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 0; - pdlsch0_harq->status = ACTIVE; - - }else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if (pdlsch0_harq->status == SCH_IDLE) - //packet was actually decoded in previous transmission (ACK was missed by eNB) - //However, the round is not a good check as it might have been decoded in a retransmission prior to this one. - { - // LOG_D(PHY,"skip pdsch decoding and report ack\n"); - // skip pdsch decoding and report ack - //pdlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[subframe].ack = 1; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch0->harq_ack[subframe].send_harq_status = 1; - - //pdlsch0_harq->first_tx = 0; - } - else //normal retransmission - { - // nothing special to do - } - } - else - { - pdlsch0_harq->status = ACTIVE; - } - } - - pdlsch0_harq->DCINdi = ndi1; - pdlsch0_harq->mcs = mcs1; - pdlsch0_harq->rvidx = rv1; - pdlsch0_harq->nb_rb = NPRB; - - pdlsch0_harq->codeword = 0; - pdlsch0_harq->Nl = 1; - pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; - pdlsch0_harq->dl_power_off = 1; //no power offset - pdlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC &3]; - - // compute resource allocation - if(dci_format == format1A) - { - switch (N_RB_DL) { - case 6: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT6[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; - } - break; - - case 25: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT25[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; - } - break; - - case 50: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT50_1[rballoc]; - } else { // DISTRIBUTED - if ((rballoc&(1<<10)) == 0) { - rballoc = rballoc&(~(1<<10)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - else { - rballoc = rballoc&(~(1<<10)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - } - break; - - case 100: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = localRIV2alloc_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = localRIV2alloc_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = localRIV2alloc_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = localRIV2alloc_LUT100_3[rballoc]; - } else { - if ((rballoc&(1<<10)) == 0) { //Gap 1 - rballoc = rballoc&(~(1<<12)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; - } - else { //Gap 2 - rballoc = rballoc&(~(1<<12)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; - } - } - break; - } - } - else // format1 - { - conv_rballoc(rah,rballoc,frame_parms->N_RB_DL,pdlsch0_harq->rb_alloc_even); - pdlsch0_harq->rb_alloc_odd[0]= pdlsch0_harq->rb_alloc_even[0]; - pdlsch0_harq->rb_alloc_odd[1]= pdlsch0_harq->rb_alloc_even[1]; - pdlsch0_harq->rb_alloc_odd[2]= pdlsch0_harq->rb_alloc_even[2]; - pdlsch0_harq->rb_alloc_odd[3]= pdlsch0_harq->rb_alloc_even[3]; - } - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - pdlsch0_harq->TBS = TBStable[mcs1][NPRB4TBS-1]; - pdlsch0_harq->Qm = 2; - } - else - { - if(mcs1 < 29) - { - pdlsch0_harq->TBS = TBStable[get_I_TBS(mcs1)][NPRB4TBS-1]; - pdlsch0_harq->Qm = get_Qm(mcs1); - } - } - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - pdlsch0_harq, - NPRB, - subframe); -} - -void prepare_dl_decoding_format1C(uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - uint32_t rnti, - uint32_t si_rnti, - uint32_t ra_rnti, - uint32_t p_rnti, - uint32_t frame, - uint8_t subframe, - LTE_DL_UE_HARQ_t *pdlsch0_harq, - LTE_UE_DLSCH_t *pdlsch0) -{ - - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t Ngap = pdci_info_extarcted->Ngap; - - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 1; - pdlsch0_harq->vrb_type = DISTRIBUTED; - - if (rnti==si_rnti) { // rule from Section 5.3.1 of 36.321 - if (((frame&1) == 0) && (subframe == 5)) - pdlsch0_harq->rvidx = (((3*((frame>>1)&3))+1)>>1)&3; // SIB1 - else - pdlsch0_harq->rvidx = (((3*(subframe&3))+1)>>1)&3; // other SIBs - } - else if ((rnti==p_rnti) || (rnti==ra_rnti)) { // Section 7.1.7.3 - pdlsch0_harq->rvidx = 0; - } - - - pdlsch0_harq->Nl = 1; - pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; - pdlsch0_harq->dl_power_off = 1; //no power offset - - pdlsch0_harq->codeword = 0; - pdlsch0_harq->mcs = mcs1; - pdlsch0_harq->TBS = TBStable1C[mcs1]; - pdlsch0_harq->Qm = 2; - - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->active = 1; - pdlsch0->rnti = rnti; - - switch (N_RB_DL) { - case 6: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; - - break; - - case 25: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; - break; - - case 50: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT50[rballoc]; - if (Ngap == 0) { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT50_1[rballoc]; - } - break; - - case 100: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT100[rballoc]; - if (Ngap==0) { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; - } - break; - - default: - AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",frame_parms->N_RB_DL); - break; - } - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - pdlsch0_harq, - pdlsch0_harq->nb_rb, - subframe); - -} - -void compute_precoding_info_2cw(uint8_t tpmi, uint8_t tbswap, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch0_harq, LTE_DL_UE_HARQ_t *dlsch1_harq) -{ - -switch (tpmi) { - case 0: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); - break; - case 1: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); - break; - case 2: // PUSCH precoding - dlsch0_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - dlsch1_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - if (tbswap==0){ - dlsch0_harq->pmi_alloc = pmi_alloc; - dlsch1_harq->pmi_alloc = pmi_alloc^0x1555; - } else { - dlsch1_harq->pmi_alloc = pmi_alloc; - dlsch0_harq->pmi_alloc = pmi_alloc^0x1555; - } -#ifdef DEBUG_HARQ - printf ("\n \n compute_precoding_info_2cw pmi_alloc_new = %d\n", dlsch0_harq->pmi_alloc); - #endif - break; - default: - break; - } -} - -void compute_precoding_info_1cw(uint8_t tpmi, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch_harq) -{ - -switch (tpmi) { - case 0 : - dlsch_harq->mimo_mode = ALAMOUTI; - break; - case 1: - dlsch_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,0, 0); - break; - case 2: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); - break; - case 3: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); - break; - case 4: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); - break; - case 5: - dlsch_harq->mimo_mode = PUSCH_PRECODING0; - dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,0); - break; - case 6: - dlsch_harq->mimo_mode = PUSCH_PRECODING1; - dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,1); - break; - } - #ifdef DEBUG_HARQ - printf ("[DCI UE] I am calling from the UE side pmi_alloc_new = %d with tpmi %d\n", dlsch_harq->pmi_alloc, tpmi); - #endif - } - -void compute_precoding_info_format2A(uint8_t tpmi, - uint8_t nb_antenna_ports_eNB, - uint8_t tb0_active, - uint8_t tb1_active, - LTE_DL_UE_HARQ_t *dlsch0_harq, - LTE_DL_UE_HARQ_t *dlsch1_harq) -{ - - dlsch0_harq->dl_power_off = 0; - dlsch1_harq->dl_power_off = 0; - - if (nb_antenna_ports_eNB == 2) { - if ((tb0_active==1) && (tb1_active==1)) { - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - } else { - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - } - } else if (nb_antenna_ports_eNB == 4) { // 4 antenna case - if ((tb0_active==1) && (tb1_active==1)) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 1: // one-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 3: // - LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n"); - break; - } - } else if (tb0_active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - break; - - case 1: // two-layers on TB 0 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } else if (tb1_active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - break; - - case 1: // two-layers on TB 0 - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } - } - // printf("Format 2A: NPRB=%d (rballoc %x,mcs1 %d, mcs2 %d, frame_type %d N_RB_DL %d,active %d/%d)\n",NPRB,rballoc,mcs1,mcs2,frame_parms->frame_type,frame_parms->N_RB_DL,dlsch0->active,dlsch1->active); - //printf("UE (%x/%d): Subframe %d Format2A DCI: ndi1 %d, old_ndi1 %d, ndi2 %d, old_ndi2 %d (first tx1 %d, first tx2 %d) harq_status1 %d, harq_status2 %d\n",dlsch0->rnti,harq_pid,subframe,ndi,dlsch0_harq->DCINdi, - // dlsch0_harq->first_tx,dlsch1_harq->first_tx,dlsch0_harq->status,dlsch1_harq->status); - //printf("TBS0 %d, TBS1 %d\n",dlsch0_harq->TBS,dlsch1_harq->TBS); - -} - -void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - uint16_t rnti, - uint8_t subframe, - LTE_DL_UE_HARQ_t *dlsch0_harq, - LTE_DL_UE_HARQ_t *dlsch1_harq, - LTE_UE_DLSCH_t *pdlsch0, - LTE_UE_DLSCH_t *pdlsch1) -{ - - uint8_t rah = pdci_info_extarcted->rah; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t mcs2 = pdci_info_extarcted->mcs2; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t rv2 = pdci_info_extarcted->rv2; - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t tbswap = pdci_info_extarcted->tb_swap; - uint8_t tpmi = pdci_info_extarcted->tpmi; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t ndi2 = pdci_info_extarcted->ndi2; - - uint8_t TB0_active = 1; - uint8_t TB1_active = 1; - - // printf("inside prepare pdlsch1->pmi_alloc %d \n",pdlsch1->pmi_alloc); - - - if ((rv1 == 1) && (mcs1 == 0)) { - TB0_active=0; - } - if ((rv2 == 1) && (mcs2 == 0)) { - TB1_active=0; - } - -#ifdef DEBUG_HARQ - printf("[DCI UE]: TB0 status %d , TB1 status %d\n", TB0_active, TB1_active); -#endif - - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - dlsch0_harq->DCINdi = ndi1; - dlsch1_harq->DCINdi = ndi2; - - dlsch0_harq->codeword = 0; - dlsch1_harq->codeword = 1; - dlsch0_harq->Nl = 1; - dlsch1_harq->Nl = 1; - dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; - dlsch1_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch1->current_harq_pid = harq_pid; - pdlsch1->harq_ack[subframe].harq_id = harq_pid; - - // assume two CW are active - dlsch0_harq->status = ACTIVE; - dlsch1_harq->status = ACTIVE; - pdlsch0->active = 1; - pdlsch1->active = 1; - pdlsch0->rnti = rnti; - pdlsch1->rnti = rnti; - - - if (TB0_active && TB1_active && tbswap==1) { - dlsch0_harq->codeword = 1; - dlsch1_harq->codeword = 0; - } - - - if (!TB0_active && TB1_active){ - dlsch1_harq->codeword = 0; - } - - if (TB0_active && !TB1_active){ - dlsch0_harq->codeword = 0; - } - - - if (TB0_active==0) { - dlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - #ifdef DEBUG_HARQ - printf("[DCI UE]: TB0 is deactivated, retransmit TB1 transmit in TM6\n"); - #endif - } - - if (TB1_active==0) { - dlsch1_harq->status = SCH_IDLE; - pdlsch1->active = 0; - } - -#ifdef DEBUG_HARQ - printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); -#endif - - // compute resource allocation - if (TB0_active == 1){ - - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc_even); - - dlsch0_harq->rb_alloc_odd[0]= dlsch0_harq->rb_alloc_even[0]; - dlsch0_harq->rb_alloc_odd[1]= dlsch0_harq->rb_alloc_even[1]; - dlsch0_harq->rb_alloc_odd[2]= dlsch0_harq->rb_alloc_even[2]; - dlsch0_harq->rb_alloc_odd[3]= dlsch0_harq->rb_alloc_even[3]; - - if (TB1_active == 1){ - dlsch1_harq->rb_alloc_even[0]= dlsch0_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_even[1]= dlsch0_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_even[2]= dlsch0_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_even[3]= dlsch0_harq->rb_alloc_even[3]; - dlsch1_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_odd[0]; - dlsch1_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_odd[1]; - dlsch1_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_odd[2]; - dlsch1_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_odd[3]; - - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - //dlsch0_harq->Nl = 1; - //dlsch1_harq->Nl = 1; - } - } else if ((TB0_active == 0) && (TB1_active == 1)){ - - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch1_harq->rb_alloc_even); - - dlsch1_harq->rb_alloc_odd[0]= dlsch1_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_odd[1]= dlsch1_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_odd[2]= dlsch1_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_odd[3]= dlsch1_harq->rb_alloc_even[3]; - dlsch1_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - } - - - // compute precoding matrix + mimo mode - if(dci_format == format2) - { - if ((TB0_active) && (TB1_active)){ //two CW active - compute_precoding_info_2cw(tpmi, tbswap, pdlsch0->pmi_alloc,frame_parms, dlsch0_harq, dlsch1_harq); - - // printf("[DCI UE 1]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - } else if ((TB0_active) && (!TB1_active)) { // only CW 0 active - compute_precoding_info_1cw(tpmi, pdlsch0->pmi_alloc, frame_parms, dlsch0_harq); - } else { - compute_precoding_info_1cw(tpmi, pdlsch1->pmi_alloc, frame_parms, dlsch1_harq); - // printf("I am doing compute_precoding_info_1cw with tpmi %d \n", tpmi); - } - //printf(" UE DCI harq0 MIMO mode = %d\n", dlsch0_harq->mimo_mode); - if ((frame_parms->nb_antenna_ports_eNB == 1) && (TB0_active)) - dlsch0_harq->mimo_mode = SISO; - } - else - { - compute_precoding_info_format2A( tpmi, - frame_parms->nb_antenna_ports_eNB, - TB0_active, - TB1_active, - dlsch0_harq, - dlsch1_harq); - } - // printf("[DCI UE 2]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - // reset round + compute Qm - if (TB0_active) { - // printf("TB0 ndi1 =%d, dlsch0_harq->DCINdi =%d, dlsch0_harq->first_tx = %d\n", ndi1, dlsch0_harq->DCINdi, dlsch0_harq->first_tx); - if ((ndi1!=dlsch0_harq->DCINdi) || (dlsch0_harq->first_tx==1)) { - dlsch0_harq->round = 0; - dlsch0_harq->status = ACTIVE; - dlsch0_harq->DCINdi = ndi1; - - //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW0 subframe %d (pid %d, round %d)\n", - // subframe,harq_pid,dlsch0_harq->round); - if ( dlsch0_harq->first_tx==1) { - // LOG_D(PHY,"Format 2 DCI First TX0: Clearing flag\n"); - dlsch0_harq->first_tx = 0; - } - } - /*else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if(dlsch0_harq->status == SCH_IDLE) { - // skip pdsch decoding and report ack - //dlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[subframe].ack = 1; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch0->harq_ack[subframe].send_harq_status = 1; - }*/ - - // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest - // PDCCH for the same trasport block using Imcs in [0 .. 28] - if(dlsch0_harq->mcs <= 28) - { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - LOG_D(PHY,"[UE] DLSCH: New TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); - } - else - { - LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); - } - //if(dlsch0_harq->Nl == 2) - //dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1]; - if (mcs1 <= 28) - dlsch0_harq->Qm = get_Qm(mcs1); - else if (mcs1<=31) - dlsch0_harq->Qm = (mcs1-28)<<1; - } - - // printf("[DCI UE 3]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - - if (TB1_active) { - // printf("TB1 ndi2 =%d, dlsch1_harq->DCINdi =%d, dlsch1_harq->first_tx = %d\n", ndi2, dlsch1_harq->DCINdi, dlsch1_harq->first_tx); - if ((ndi2!=dlsch1_harq->DCINdi) || (dlsch1_harq->first_tx==1)) { - dlsch1_harq->round = 0; - dlsch1_harq->status = ACTIVE; - dlsch1_harq->DCINdi = ndi2; - //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW1 subframe %d (pid %d, round %d)\n", - // subframe,harq_pid,dlsch0_harq->round); - if (dlsch1_harq->first_tx==1) { - // LOG_D(PHY,"Format 2 DCI First TX1: Clearing flag\n"); - dlsch1_harq->first_tx = 0; - } - } - /*else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if(dlsch1_harq->status == SCH_IDLE) { - // skip pdsch decoding and report ack - //dlsch1_harq->status = SCH_IDLE; - pdlsch1->active = 0; - pdlsch1->harq_ack[subframe].ack = 1; - pdlsch1->harq_ack[subframe].harq_id = harq_pid; - pdlsch1->harq_ack[subframe].send_harq_status = 1; - } - }*/ - - // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest - // PDCCH for the same trasport block using Imcs in [0 .. 28] - if(dlsch1_harq->mcs <= 28) - { - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; - LOG_D(PHY,"[UE] DLSCH: New TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); - } - else - { - LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", - subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); - } - if (mcs2 <= 28) - dlsch1_harq->Qm = get_Qm(mcs2); - else if (mcs1<=31) - dlsch1_harq->Qm = (mcs2-28)<<1; - } - - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - dlsch0_harq, - dlsch0_harq->nb_rb, - subframe); - - - /* #ifdef DEBUG_HARQ - printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - printf("[DCI UE]: TB0_active %d , TB1_active %d\n", TB0_active, TB1_active); - if (dlsch0 != NULL && dlsch1 != NULL) - printf("[DCI UE] dlsch0_harq status = %d, dlsch1_harq status = %d\n", dlsch0_harq->status, dlsch1_harq->status); - else if (dlsch0 == NULL && dlsch1 != NULL) - printf("[DCI UE] dlsch0_harq NULL dlsch1_harq status = %d\n", dlsch1_harq->status); - else if (dlsch0 != NULL && dlsch1 == NULL) - printf("[DCI UE] dlsch1_harq NULL dlsch0_harq status = %d\n", dlsch0_harq->status); - #endif*/ -} - -int generate_ue_dlsch_params_from_dci(int frame, - uint8_t subframe, - void *dci_pdu, - uint16_t rnti, - DCI_format_t dci_format, - LTE_UE_PDCCH *pdcch_vars, - LTE_UE_PDSCH *pdsch_vars, - LTE_UE_DLSCH_t **dlsch, - LTE_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint8_t beamforming_mode, - uint16_t tc_rnti) -{ - - uint8_t harq_pid=0; - uint8_t frame_type=frame_parms->frame_type; - uint8_t tpmi=0; - LTE_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; - LTE_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; - - DCI_INFO_EXTRACTED_t dci_info_extarcted; - uint8_t status=0; - - if (!dlsch[0]) return -1; - - #ifdef DEBUG_DCI - LOG_D(PHY,"dci_tools.c: Filling ue dlsch params -> rnti %x, SFN/SF %d/%d, dci_format %s\n", - rnti, - frame%1024, - subframe, - (dci_format==format0? "Format 0":( - dci_format==format1? "format 1":( - dci_format==format1A? "format 1A":( - dci_format==format1B? "format 1B":( - dci_format==format1C? "format 1C":( - dci_format==format1D? "format 1D":( - dci_format==format1E_2A_M10PRB? "format 1E_2A_M10PRB":( - dci_format==format2? "format 2":( - dci_format==format2A? "format 2A":( - dci_format==format2B? "format 2B":( - dci_format==format2C? "format 2C":( - dci_format==format2D? "format 2D":( - dci_format==format3? "format 3": "UNKNOWN" - )))))))))))))); - #endif - - memset(&dci_info_extarcted,0,sizeof(dci_info_extarcted)); - switch (dci_format) { - - case format0: // This is an ULSCH allocation so nothing here, inform MAC - LOG_E(PHY,"format0 not possible\n"); - return(-1); - break; - - case format1A: - { - // extract dci infomation -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d extarct dci info \n", frame, subframe); -#endif - extract_dci1A_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - - // check dci content - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d check dci coherency \n", frame, subframe); -#endif - status = check_dci_format1_1a_coherency(format1A, - frame_parms->N_RB_DL, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti,frame,subframe, - &dci_info_extarcted, - dlsch0_harq); - if(status == 0) - { - printf("bad DCI 1A !!! \n"); - return(-1); - } - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); -#endif - prepare_dl_decoding_format1_1A(format1A, - frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - subframe, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch0); - - - - break; - } - case format1C: - { - // extract dci infomation -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] extact dci information \n"); -#endif - extract_dci1C_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - - // check dci content -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] check dci content \n"); -#endif - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; - - status = check_dci_format1c_coherency(frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq); - if(status == 0) - return(-1); - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] prepare downlink decoding \n"); -#endif - prepare_dl_decoding_format1C(frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - si_rnti, - ra_rnti, - p_rnti, - frame, - subframe, - dlsch0_harq, - dlsch0); - - break; - } - - case format1: - { - // extract dci infomation -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d extarct dci info \n", frame, subframe); -#endif - extract_dci1_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - // check dci content - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; - -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d check dci coherency \n", frame, subframe); -#endif - status = check_dci_format1_1a_coherency(format1, - frame_parms->N_RB_DL, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti,frame,subframe, - &dci_info_extarcted, - dlsch0_harq); - if(status == 0) - { - printf("bad DCI 1 !!! \n"); - return(-1); - } - - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); -#endif - prepare_dl_decoding_format1_1A(format1, - frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - subframe, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch0); - break; - } - - case format2: - { - // extract dci infomation - //LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame, subframe); - extract_dci2_info(frame_parms->N_RB_DL, - frame_type, - frame_parms->nb_antenna_ports_eNB, - dci_pdu, - &dci_info_extarcted); - - - // check dci content - dlsch[0]->active = 1; - dlsch[1]->active = 1; - - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - - dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; - dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; - // printf("before coherency dlsch[1]->pmi_alloc %d\n",dlsch[1]->pmi_alloc); - // printf("before coherency dlsch1->pmi_alloc %d\n",dlsch1->pmi_alloc); - // printf("before coherency dlsch1_harq->pmi_alloc %d\n",dlsch1_harq->pmi_alloc); - - //LOG_I(PHY,"[DCI-format2] check dci content \n"); - status = check_dci_format2_2a_coherency(format2, - frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch1_harq); - if(status == 0) - return(-1); - - - // dci is correct ==> update internal structure and prepare dl decoding - //LOG_I(PHY,"[DCI-format2] update internal structure and prepare dl decoding \n"); - prepare_dl_decoding_format2_2A(format2, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - subframe, - dlsch0_harq, - dlsch1_harq, - dlsch0, - dlsch1); - } - break; - - case format2A: - { - // extract dci infomation - LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame%1024, subframe); - extract_dci2A_info(frame_parms->N_RB_DL, - frame_type, - frame_parms->nb_antenna_ports_eNB, - dci_pdu, - &dci_info_extarcted); - - // check dci content - //LOG_I(PHY,"[DCI-format2A] check dci content \n"); - //LOG_I(PHY,"[DCI-format2A] tb_swap %d harq_pid %d\n", dci_info_extarcted.tb_swap, dci_info_extarcted.harq_pid); - //dlsch[0]->active = 0; - //dlsch[1]->active = 0; - - if (dci_info_extarcted.tb_swap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } else { - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; - dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; - - //LOG_I(PHY,"[DCI-format2A] check dci content \n"); - status = check_dci_format2_2a_coherency(format2A, - frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch1_harq); - if(status == 0) - return(-1); - - // dci is correct ==> update internal structure and prepare dl decoding - //LOG_I(PHY,"[DCI-format2A] update internal structure and prepare dl decoding \n"); - prepare_dl_decoding_format2_2A(format2A, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - subframe, - dlsch0_harq, - dlsch1_harq, - dlsch0, - dlsch1); - } - break; - - case format1E_2A_M10PRB: - if (!dlsch[0]) return -1; - - harq_pid = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->harq_pid; - - if (harq_pid>=8) { - LOG_E(PHY,"Format 1E_2A_M10PRB: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - dlsch[0]->current_harq_pid = harq_pid; - dlsch[0]->harq_ack[subframe].harq_id = harq_pid; - - /* - tbswap = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tb_swap; - if (tbswap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } - else{ - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - */ - dlsch0 = dlsch[0]; - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - // Needs to be checked - dlsch0_harq->codeword=0; - conv_rballoc(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc,frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc_even); - - dlsch0_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_even[0]; - dlsch0_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_even[1]; - dlsch0_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_even[2]; - dlsch0_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_even[3]; - /* - dlsch1_harq->rb_alloc_even[0] = dlsch0_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_even[1] = dlsch0_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_even[2] = dlsch0_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_even[3] = dlsch0_harq->rb_alloc_even[3]; - */ - dlsch0_harq->nb_rb = conv_nprb(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc, - frame_parms->N_RB_DL); - //dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->TPC&3]; - - - - /* - if (dlsch0_harq->mcs>20) { - printf("dci_tools.c: mcs > 20 disabled for now (asked %d)\n",dlsch0_harq->mcs); - return(-1); - } - */ - - //dlsch1_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs2; - dlsch0_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv; - //dlsch1_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv2; - - // check if either TB is disabled (see 36-213 V8.6 p. 26) - - if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { - dlsch0_harq->status = DISABLED; - } - - //if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { - //dlsch1_harq->status = DISABLED; - //} - dlsch0_harq->Nl = 1; - - //dlsch0->layer_index = tbswap; - //dlsch1->layer_index = 1-tbswap; - - - // Fix this - tpmi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tpmi; - // printf("ue: tpmi %d\n",tpmi); - - switch (tpmi) { - case 0 : - dlsch0_harq->mimo_mode = ALAMOUTI; - break; - - case 1: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0,0); - break; - - case 2: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); - break; - - case 3: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); - - break; - - case 4: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); - break; - - case 5: - dlsch0_harq->mimo_mode = PUSCH_PRECODING0; - // pmi stored from ulsch allocation routine - dlsch0_harq->pmi_alloc = dlsch0->pmi_alloc; - //LOG_I(PHY,"XXX using PMI %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc)); - break; - - - case 6: - dlsch0_harq->mimo_mode = PUSCH_PRECODING1; - LOG_E(PHY,"Unsupported TPMI\n"); - return(-1); - break; - } - - - if (frame_parms->nb_antenna_ports_eNB == 1) - dlsch0_harq->mimo_mode = SISO; - - - if ((dlsch0_harq->DCINdi != ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi) || - (dlsch0_harq->first_tx==1)) { - - dlsch0_harq->round = 0; - dlsch0_harq->first_tx = 0; - dlsch0_harq->status = ACTIVE; - } - /* - else if (dlsch0_harq->status == SCH_IDLE) { // we got same ndi for a previously decoded process, - // this happens if either another harq process in the same - // is NAK or an ACK was not received - - dlsch0->harq_ack[subframe].ack = 1; - dlsch0->harq_ack[subframe].harq_id = harq_pid; - dlsch0->harq_ack[subframe].send_harq_status = 1; - dlsch0->active = 0; - return(0); - } - */ - - dlsch0_harq->DCINdi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi; - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - - if (dlsch0_harq->nb_rb>1) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - } else - dlsch0_harq->TBS =0; - - dlsch0->rnti = rnti; - //dlsch1->rnti = rnti; - - dlsch0->active = 1; - //dlsch1->active = 1; - - dlsch0_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; - //dlsch1_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; - - - break; - - default: - LOG_E(PHY,"format %d not yet implemented\n",dci_format); - return(-1); - break; - } - -#ifdef UE_DEBUG_TRACE - - if (dlsch[0] && (dlsch[0]->rnti != 0xffff)) { - LOG_I(PHY,"dci_format:%d Abssubframe: %d.%d \n",dci_format,frame%1024,subframe); - LOG_I(PHY,"PDSCH dlsch0 UE: rnti %x\n",dlsch[0]->rnti); - LOG_D(PHY,"PDSCH dlsch0 UE: NBRB %d\n",dlsch0_harq->nb_rb); - LOG_D(PHY,"PDSCH dlsch0 UE: rballoc %x\n",dlsch0_harq->rb_alloc_even[0]); - LOG_I(PHY,"PDSCH dlsch0 UE: harq_pid %d\n",dci_info_extarcted.harq_pid); - LOG_I(PHY,"PDSCH dlsch0 UE: g %d\n",dlsch[0]->g_pucch); - LOG_D(PHY,"PDSCH dlsch0 UE: round %d\n",dlsch0_harq->round); - LOG_D(PHY,"PDSCH dlsch0 UE: DCINdi %d\n",dlsch0_harq->DCINdi); - LOG_D(PHY,"PDSCH dlsch0 UE: rvidx %d\n",dlsch0_harq->rvidx); - LOG_D(PHY,"PDSCH dlsch0 UE: TBS %d\n",dlsch0_harq->TBS); - LOG_D(PHY,"PDSCH dlsch0 UE: mcs %d\n",dlsch0_harq->mcs); - LOG_D(PHY,"PDSCH dlsch0 UE: pwr_off %d\n",dlsch0_harq->dl_power_off); - } -#endif - -#if T_TRACER - if( (dlsch[0]->rnti != si_rnti) && (dlsch[0]->rnti != ra_rnti) && (dlsch[0]->rnti != p_rnti)) - { - T(T_UE_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame%1024), T_INT(subframe), - T_INT(dlsch[0]->rnti), T_INT(dci_format), - T_INT(harq_pid), - T_INT(dlsch0_harq->mcs), - T_INT(dlsch0_harq->TBS)); - } -#endif - - - // compute DL power control parameters - if (dlsch0_harq != NULL){ - computeRhoA_UE(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[0],dlsch0_harq->dl_power_off); - } - - if (dlsch1_harq != NULL) { - computeRhoA_UE(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[1],dlsch1_harq->dl_power_off); - } - - - return(0); -} - - -uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) -{ - uint8_t ret = 255; - - if (frame_parms->frame_type == FDD) { - ret = (((frame*10)+subframe)&7); - } else { - - switch (frame_parms->tdd_config) { - - case 1: - if ((subframe==2) || - (subframe==3) || - (subframe==7) || - (subframe==8)) - switch (subframe) { - case 2: - case 3: - ret = (subframe-2); - break; - - case 7: - case 8: - ret = (subframe-5); - break; - - default: - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - break; - } - - break; - - case 2: - if ((subframe!=2) && (subframe!=7)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret=255; - } - else ret = (subframe/7); - break; - - case 3: - if ((subframe<2) || (subframe>4)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - } - else ret = (subframe-2); - break; - - case 4: - if ((subframe<2) || (subframe>3)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - } - else ret = (subframe-2); - break; - - case 5: - if (subframe!=2) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); - ret = (255); - } - else ret = (subframe-2); - break; - - default: - LOG_E(PHY,"subframe2_harq_pid, Unsupported TDD mode %d\n",frame_parms->tdd_config); - ret = (255); - } - } - - AssertFatal(ret!=255, - "invalid harq_pid(%d) at SFN/SF = %d/%d\n", (int8_t)ret, frame, subframe); - return ret; -} - -uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) -{ - uint8_t ul_subframe = 255; - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_subframe = ((n+6)%10); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - ((n==0)||(n==1)||(n==5)||(n==6))) - ul_subframe = ((n+7)%10); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - (n==9)) // tdd_config 6 SF 9 - ul_subframe = ((n+5)%10); - else - ul_subframe = ((n+4)%10); - - AssertFatal(frame_parms->frame_type == FDD || subframe_select(frame_parms,ul_subframe) == SF_UL,"illegal ul_subframe %d (n %d)\n",ul_subframe,n); - - LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe); - return ul_subframe; -} - -uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) -{ - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==7)||(n==2))) // tdd_config 0,1 SF 1,5 - return((n==7)? 1 : 6); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - ((n==7)||(n==8)||(n==2)||(n==3))) - return((n+3)%10); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - (n==4)) // tdd_config 6 SF 9 - return(9); - else - return((n+6)%10); -} - -uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) -{ - uint32_t ul_frame; - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_frame = (frame + (n==1 ? 0 : 1)); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - ((n==0)||(n==1)||(n==5)||(n==6))) - ul_frame = (frame + (n>=5 ? 1 : 0)); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - (n==9)) // tdd_config 6 SF 9 - ul_frame = (frame+1); - else - ul_frame = (frame+(n>=6 ? 1 : 0)); - - LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame); - return ul_frame % 1024; -} - -int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb) -{ - int nb_subbands = 0; - int32_t pmi_alloc_new = 0, pmi_new = 0, pmi_old = 0; - int i; - - switch (nb_rb) { - case 6: - nb_subbands = 6; - break; - default: - case 25: - nb_subbands = 7; - break; - case 50: - nb_subbands = 9; - break; - case 100: - nb_subbands = 13; - break; - } - - for (i = 0; i < nb_subbands; i++) { - pmi_old = (pmi_alloc >> i)&1; - - if (pmi_old == 0) - if (tpmi == 5) - pmi_new = 0; - else - pmi_new = 1; - else - if (tpmi == 5) - pmi_new = 2; - else - pmi_new = 3; - - pmi_alloc_new|=pmi_new<<(2*i); - - } -#ifdef DEBUG_HARQ -printf(" [DCI UE] pmi_alloc_old %d, pmi_alloc_new %d pmi_old %d , pmi_new %d\n", pmi_alloc, pmi_alloc_new,pmi_old, pmi_new ); -#endif -return(pmi_alloc_new); - -} - -uint16_t quantize_subband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,int nb_rb) -{ - - int i, aarx; - uint16_t pmiq=0; - uint32_t pmivect = 0; - uint8_t rank = meas->rank[eNB_id]; - int pmi_re,pmi_im; - int nb_subbands=0; - - - switch (nb_rb) { - case 6: - nb_subbands = 6; - break; - default: - case 25: - nb_subbands = 7; - break; - case 50: - nb_subbands = 9; - break; - case 100: - nb_subbands = 13; - break; - } - - - for (i=0; i<nb_subbands; i++) { - pmi_re = 0; - pmi_im = 0; - - if (rank == 0) { - for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { - pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; - pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; - } - - // pmi_re = meas->subband_pmi_re[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; - // pmi_im = meas->subband_pmi_im[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; - - // printf("pmi => (%d,%d)\n",pmi_re,pmi_im); - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - // printf("subband %d, pmi%d \n",i,pmiq); - pmivect |= (pmiq<<(2*i)); - } - - else if (rank==1) { - for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { - pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; - //printf("meas->subband_pmi_re[eNB_id][i][%d]=%d\n", aarx, meas->subband_pmi_re[eNB_id][i][aarx]); - pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; - //printf("meas->subband_pmi_im[eNB_id][i][%d]=%d\n",aarx, meas->subband_pmi_im[eNB_id][i][aarx]); - } - if (pmi_re >= pmi_im) // this is not orthogonal - // this is orthogonal - //if (((pmi_re >= pmi_im) && (pmi_re >= -pmi_im)) || ((pmi_re <= pmi_im) && (pmi_re >= -pmi_im))) - pmiq = PMI_2A_R1_11; - else - pmiq = PMI_2A_R1_1j; - - // printf("subband %d, pmi_re %d, pmi_im %d, pmiq %d \n",i,pmi_re,pmi_im,pmiq); - // printf("subband %d, pmi%d \n",i,pmiq); - //According to Section 7.2.4 of 36.213 - - pmivect |= ((pmiq-1)<<(i)); //shift 1 since only one bit - } - else { - LOG_E(PHY,"PMI feedback for rank>1 not supported!\n"); - pmivect = 0; - } - - } -#ifdef DEBUG_HARQ - printf( "quantize_subband_pmi pmivect %d \n", pmivect); -#endif - return(pmivect); -} - -uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands) -{ - - uint8_t i; - uint16_t pmiq=0; - uint16_t pmivect = 0; - uint8_t rank = meas->rank[eNB_id]; - int pmi_re,pmi_im; - - for (i=0; i<nb_subbands; i++) { - - if (rank == 0) { - pmi_re = meas->subband_pmi_re[eNB_id][i][a_id]; - pmi_im = meas->subband_pmi_im[eNB_id][i][a_id]; - - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - pmivect |= (pmiq<<(2*i)); - } else { - // This needs to be done properly!!! - pmivect = 0; - } - } - - return(pmivect); -} - -uint16_t quantize_wideband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) -{ - - uint16_t pmiq=0; - uint8_t rank = meas->rank[eNB_id]; - //int pmi; - int pmi_re,pmi_im; - - if (rank == 1) { - //pmi = - pmi_re = meas->wideband_pmi_re[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; - pmi_im = meas->wideband_pmi_im[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; - - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - } else { - // This needs to be done properly! - pmiq = PMI_2A_11; - } - - - return(pmiq); -} -/* - uint8_t sinr2cqi(int sinr) { - if (sinr<-3) - return(0); - if (sinr>14) - return(10); - else - return(3+(sinr>>1)); - } -*/ - -uint8_t sinr2cqi(double sinr,uint8_t trans_mode) -{ - // int flag_LA=0; - - uint8_t retValue = 0; - - if(flag_LA==0) { - // Ideal Channel Estimation - if (sinr<=-4.89) - retValue = (0); - else if (sinr < -3.53) - retValue = (3); - else if (sinr <= -1.93) - retValue = (4); - else if (sinr <= -0.43) - retValue = (5); - else if (sinr <= 1.11) - retValue = (6); - else if (sinr <= 3.26) - retValue = (7); - else if (sinr <= 5.0) - retValue = (8); - else if (sinr <= 7.0) - retValue = (9); - else if (sinr <= 9.0) - retValue = (10); - else if (sinr <= 11.0) - retValue = (11); - else if (sinr <= 13.0) - retValue = (12); - else if (sinr <= 15.5) - retValue = (13); - else if (sinr <= 17.5) - retValue = (14); - else - retValue = (15); - } else { - int h=0; - int trans_mode_tmp; - - if (trans_mode ==5) - trans_mode_tmp=2; - else if(trans_mode ==6) - trans_mode_tmp=3; - else - trans_mode_tmp = trans_mode-1; - - for(h=0; h<16; h++) { - if(sinr<=sinr_to_cqi[trans_mode_tmp][h]) - retValue = (h); - } - } - - LOG_D(PHY, "sinr=%f trans_mode=%d cqi=%d\n", sinr, trans_mode, retValue); - return retValue; -} -//uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) { -// -// uint8_t i; -//// uint16_t cqivect = 0; -// uint32_t cqivect = 0; -// -//// char diff_cqi; -// int diff_cqi=0; -// -// for (i=0;i<NUMBER_OF_SUBBANDS;i++) { -// -// diff_cqi = -sinr2cqi(meas->wideband_cqi_dB[eNB_id][0]) + sinr2cqi(meas->subband_cqi_dB[eNB_id][0][i]); -// -// // Note, this is Table 7.2.1-2 from 36.213 -// if (diff_cqi<=-1) -// diff_cqi = 3; -// else if (diff_cqi>2) -// diff_cqi = 2; -// cqivect |= (diff_cqi<<(2*i)); -// -// } -// -// return(cqivect); -//} - - -uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t trans_mode,int nb_subbands) -{ - - uint8_t i; - - uint32_t cqivect = 0,offset=0; - - - int diff_cqi=0; - - for (i=0; i<nb_subbands; i++) { - - diff_cqi = -sinr2cqi(meas->wideband_cqi_avg[eNB_id],trans_mode) + sinr2cqi(meas->subband_cqi_tot_dB[eNB_id][i],trans_mode); - - // Note, this is Table 7.2.1-2 from 36.213 - if (diff_cqi<=-1) - offset = 3; - else if (diff_cqi>=2) - offset = 2; - else - offset=(uint32_t)diff_cqi; - - cqivect |= (offset<<(2*i)); - - } - - return(cqivect); -} - -void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t harq_pid,int N_RB_DL,uint16_t rnti, uint8_t trans_mode, double sinr_eff) -{ - - // printf("[PHY][UE] Filling CQI for eNB %d, meas->wideband_cqi_tot[%d] %d\n", - // eNB_id,eNB_id,meas->wideband_cqi_tot[eNB_id]); - double sinr_tmp; - uint8_t *o = ulsch->o; - UCI_format_t uci_format = ulsch->uci_format; - - if(flag_LA==1) - sinr_tmp = sinr_eff; - else - sinr_tmp = (double) meas->wideband_cqi_avg[eNB_id]; - - - - //LOG_I(PHY,"[UE][UCI] Filling CQI format %d for eNB %d N_RB_DL %d\n",uci_format,eNB_id,N_RB_DL); - - switch (N_RB_DL) { - - case 6: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti = rnti; - LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - case 25: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - case 50: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - case 100: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - AssertFatal(1==0,"unsupported CQI mode !!!"); - break; - - } - - break; - - } - - -} - -void reset_cba_uci(void *o) -{ - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = 0; //fixme - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = 0x0; -} - - -uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank) -{ - - uint8_t i,wideband_pmi2; - uint32_t pmi_ex = 0; - - if (frame_parms->N_RB_DL!=25) { - LOG_E(PHY,"pmi_extend not yet implemented for anything else than 25PRB\n"); - return(-1); - } - - if (rank==0) { - wideband_pmi2=wideband_pmi&3; - for (i=0; i<14; i+=2) - pmi_ex|=(wideband_pmi2<<i); - } - else if (rank==1) { - wideband_pmi2=wideband_pmi&1; - for (i=0; i<7; i++) - pmi_ex|=(wideband_pmi2<<i); - } - else { - LOG_E(PHY,"unsupported rank\n"); - return(-1); - } - - return(pmi_ex); -} - - -int generate_ue_ulsch_params_from_dci(void *dci_pdu, - uint16_t rnti, - uint8_t subframe, - DCI_format_t dci_format, - PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t eNB_id, - uint8_t use_srs) -{ - - uint8_t harq_pid; - uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - ANFBmode_t AckNackFBMode; - LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - LTE_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[subframe]][0]; - PHY_MEASUREMENTS *meas = &ue->measurements; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - // uint32_t current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; - - if(frame_parms->frame_type == TDD) - { - AckNackFBMode = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; - } - else - { - AckNackFBMode = 1; // 1: multiplexing for FDD - } - - uint32_t cqi_req; - uint32_t dai=3; - uint32_t cshift; - uint32_t TPC; - uint32_t ndi; - uint32_t mcs; - uint32_t rballoc,RIV_max; - uint16_t* RIV2first_rb_LUT; - uint16_t* RIV2nb_rb_LUT; - - // uint32_t hopping; - // uint32_t type; - - if (dci_format == format0) { - - if (!ulsch) - return -1; - - if (rnti == ra_rnti) - harq_pid = 0; - else - harq_pid = subframe2harq_pid(frame_parms, - pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,subframe), - pdcch_alloc2ul_subframe(frame_parms,subframe)); - LOG_D(PHY,"Frame %d, Subframe %d: Programming ULSCH for (%d.%d) => harq_pid %d\n", - proc->frame_rx,subframe, - pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,subframe), - pdcch_alloc2ul_subframe(frame_parms,subframe), harq_pid); - - if (harq_pid == 255) { - LOG_E(PHY, "frame %d, subframe %d, rnti %x, format %d: illegal harq_pid!\n", - proc->frame_rx, subframe, rnti, dci_format); - return(-1); - } - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max6; - RIV2first_rb_LUT = RIV2first_rb_LUT6; - RIV2nb_rb_LUT = RIV2nb_rb_LUT6; - - break; - - case 25: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_5MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max25; - RIV2first_rb_LUT = RIV2first_rb_LUT25; - RIV2nb_rb_LUT = RIV2nb_rb_LUT25; - // printf("***********rballoc %d, first_rb %d, nb_rb %d (dci %p)\n",rballoc,ulsch->harq_processes[harq_pid]->first_rb,ulsch->harq_processes[harq_pid]->nb_rb,dci_pdu); - break; - - case 50: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_10MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max50; - RIV2first_rb_LUT = RIV2first_rb_LUT50; - RIV2nb_rb_LUT = RIV2nb_rb_LUT50; - - break; - - case 100: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_20MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max100; - RIV2first_rb_LUT = RIV2first_rb_LUT100; - RIV2nb_rb_LUT = RIV2nb_rb_LUT100; - - // printf("rb_alloc (20 MHz dci) %d\n",rballoc); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - if (rballoc > RIV_max) { - LOG_E(PHY,"frame %d, subframe %d, rnti %x, format %d: FATAL ERROR: generate_ue_ulsch_params_from_dci, rb_alloc[%d] > RIV_max[%d]\n", - proc->frame_rx, subframe, rnti, dci_format,rballoc,RIV_max); - LOG_E(PHY,"Wrong DCI0 detection, do not transmit PUSCH for HARQID: %d\n",harq_pid); - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - return(-1); - } - - - // indicate that this process is to be serviced in subframe n+4 - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1; //+=1 this indicates the number of dci / cba group: not supported in the data struct - else - { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - //LOG_I(PHY,"[HARQ-UL harqId: %d] DCI0 ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - - } - - ulsch->harq_processes[harq_pid]->TPC = TPC; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; - - if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", - ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, - delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); - ulsch->f_pusch += delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; - } else { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ABS) %d, adjusting to %d (TPC %d)\n", - ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, - delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); - ulsch->f_pusch = delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; - } - - if (ulsch->harq_processes[harq_pid]->first_tx==1) { - // ulsch->harq_processes[harq_pid]->Ndi = 1; - ulsch->harq_processes[harq_pid]->first_tx=0; - ulsch->harq_processes[harq_pid]->DCINdi= ndi; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - if (ulsch->harq_processes[harq_pid]->DCINdi!=ndi) { // new SDU opportunity - // ulsch->harq_processes[harq_pid]->Ndi = 1; - ulsch->harq_processes[harq_pid]->DCINdi= ndi; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - // ulsch->harq_processes[harq_pid]->Ndi = 0; - //ulsch->harq_processes[harq_pid]->round++; // This is done in phich RX - - //#ifdef DEBUG_PHICH - //LOG_I(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d Adaptative Retrans, NDI not toggled => Nack. maxHARQ_Tx %d \n", - // ue->Mod_id,harq_pid, - // proc->frame_rx, - // subframe, - // ulsch->Mlimit); - //#endif -/* - if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich - { - // ulsch->harq_processes[harq_pid]->round++; already done on phich_rx - // ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; - // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); - - if (ulsch->harq_processes[harq_pid]->round >= ulsch->Mlimit) //UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) - { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - ulsch->harq_processes[harq_pid]->round = 0; - ulsch->harq_processes[harq_pid]->status = IDLE; - //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - } - else - { - // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - uint8_t rv_table[4] = {0, 2, 3, 1}; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); - } - } -*/ - } - } - - ulsch->harq_processes[harq_pid]->n_DMRS = cshift; - - //printf("nb_rb %d, first_rb %d (RIV %d)\n",ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb,rballoc); - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - // ulsch->cba_rnti[0]=rnti; - } else { - ulsch->rnti = rnti; - } - - // printf("[PHY][UE] DCI format 0: harq_pid %d nb_rb %d, rballoc %d\n",harq_pid,ulsch->harq_processes[harq_pid]->nb_rb, - // ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc); - //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) - if(cshift == 0) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; - else if(cshift == 1) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; - else if(cshift == 2) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; - else if(cshift == 3) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; - else if(cshift == 4) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; - else if(cshift == 5) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; - else if(cshift == 6) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; - else if(cshift == 7) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - - - //reserved for cooperative communication - /* - if(ulsch->n_DMRS2 == 6) - ulsch->cooperation_flag = 2; - else - ulsch->cooperation_flag = 0; - */ - - if ((ulsch->harq_processes[harq_pid]->nb_rb>0) && (ulsch->harq_processes[harq_pid]->nb_rb < 25)) - ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb-1]; - - // if (ulsch->harq_processes[harq_pid]->Ndi == 1) - // ulsch->harq_processes[harq_pid]->status = ACTIVE; - - - if (cqi_req == 1) { - - if( (AntennaInfoDedicated__transmissionMode_tm3 == transmission_mode) || (AntennaInfoDedicated__transmissionMode_tm4 == transmission_mode) ) - { - ulsch->O_RI = 1; - } - else - { - ulsch->O_RI = 0; - } - //ulsch->O_RI = 0; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table - - switch(transmission_mode) { - // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling - case 1: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 2: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 3: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 4: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 5: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 6: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 7: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - default: - LOG_E(PHY,"Incorrect Transmission Mode \n"); - break; - } - } else { - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - } - - print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); - - ulsch->bundling = 1-AckNackFBMode; - - if (frame_parms->frame_type == FDD) { - //int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); - int dl_subframe = subframe; - - if (ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_ack[dl_subframe].send_harq_status>0) { // we have downlink transmission - ulsch->harq_processes[harq_pid]->O_ACK = 1; - } else { - ulsch->harq_processes[harq_pid]->O_ACK = 0; - } - /*LOG_I(PHY,"DCI 0 Processing: dl_subframe %d send_harq_status Odd %d send_harq_status Even %d harq_pid %d O_ACK %d\n", dl_subframe, - ue->dlsch[0][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, - ue->dlsch[1][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, - harq_pid, - ulsch->harq_processes[harq_pid]->O_ACK);*/ - - } else { - if (ulsch->bundling) - ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; - else - ulsch->harq_processes[harq_pid]->O_ACK = (dai >= 2)? 2 : (dai+1)&3; //(dai+1)&3; - - // ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; - } - - dlsch[0]->harq_ack[subframe].vDAI_UL = dai+1; - - - LOG_D(PHY, "[PUSCH %d] Format0 DCI %s, CQI_req=%d, cshift=%d, TPC=%d, DAI=%d, vDAI_UL[sf#%d]=%d, NDI=%d, MCS=%d, RBalloc=%d, first_rb=%d, harq_pid=%d, nb_rb=%d, subframe_scheduling_flag=%d" - " ulsch->bundling %d, O_ACK %d \n", - harq_pid, - (frame_parms->frame_type == TDD? "TDD" : "FDD"), - cqi_req, cshift, TPC, dai, subframe, dlsch[0]->harq_ack[subframe].vDAI_UL, ndi, mcs, rballoc, - ulsch->harq_processes[harq_pid]->first_rb, harq_pid, ulsch->harq_processes[harq_pid]->nb_rb, - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, - ulsch->bundling, - ulsch->harq_processes[harq_pid]->O_ACK); - - LOG_D(PHY,"Setting beta_offset_cqi_times8 to %d, index %d\n", - beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index], - ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index); - - ulsch->beta_offset_cqi_times8 = beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index];//18; - ulsch->beta_offset_ri_times8 = beta_ri[ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index];//10; - ulsch->beta_offset_harqack_times8 = beta_ack[ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index];//16; - - ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); - ulsch->srs_active = use_srs; - - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; - else - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - ulsch->harq_processes[harq_pid]->rvidx = 0; - - // ulsch->harq_processes[harq_pid]->calibration_flag =0; - if (mcs < 29) { - ulsch->harq_processes[harq_pid]->mcs = mcs; - // ulsch->harq_processes[harq_pid]->round = 0; - } else { - ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; - if (ulsch->harq_processes[harq_pid]->round == 0) { - LOG_W(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); - } else { - LOG_D(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); - } - //LOG_E(PHY,"Fatal: mcs(%d) > 28!!! and round == 0\n", mcs); - } - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - - /* - else if (ulsch->harq_processes[harq_pid]->mcs == 29) { - ulsch->harq_processes[harq_pid]->mcs = 4; - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - // ulsch->harq_processes[harq_pid]->calibration_flag =1; - // printf("Auto-Calibration (UE): mcs %d, TBS %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->TBS,ulsch->harq_processes[harq_pid]->nb_rb); - }*/ - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->Nsymb_pusch; - - // a Ndi=1 automatically acknowledges previous PUSCH transmission - if (ue->ulsch_Msg3_active[eNB_id] == 1) - ue->ulsch_Msg3_active[eNB_id] = 0; - - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d), nb_rb %d, first_rb %d, mcs %d, round %d, rv %d, ulsch_ue_Msg3_active %d, cqi_req %d => O %d\n", - ue->Mod_id,harq_pid, - proc->frame_rx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift,ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb, - ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->round,ulsch->harq_processes[harq_pid]->rvidx, ue->ulsch_Msg3_active[eNB_id],cqi_req,ulsch->O); - - // ulsch->n_DMRS2 = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - -#ifdef UE_DEBUG_TRACE - - LOG_D(PHY,"Format 0 DCI : ulsch (ue): AbsSubframe %d.%d\n",proc->frame_rx%1024,subframe); - LOG_D(PHY,"Format 0 DCI : ulsch (ue): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): rballoc %d\n",rballoc); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): harq_pid %d\n",harq_pid); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_tx %d\n",ulsch->harq_processes[harq_pid]->first_tx); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): DCINdi %d\n",ulsch->harq_processes[harq_pid]->DCINdi); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): round %d\n",ulsch->harq_processes[harq_pid]->round); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): O %d\n",ulsch->O); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): cqiReq %d\n",cqi_req); - //if (frame_parms->frame_type == TDD) - // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK/DAI %d/%d\n",ulsch->harq_processes[harq_pid]->O_ACK,dai); - //else - // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK %d\n",ulsch->harq_processes[harq_pid]->O_ACK); - - LOG_D(PHY,"Format 0 DCI :ulsch (ue): Nsymb_pusch %d\n",ulsch->Nsymb_pusch); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): phich status %d\n",ulsch->harq_processes[harq_pid]->status); -#else - UNUSED_VARIABLE(dai); -#endif - return(0); - } else { - LOG_E(PHY,"frame %d, subframe %d: FATAL ERROR, generate_ue_ulsch_params_from_dci, Illegal dci_format %d\n", - proc->frame_rx, subframe,dci_format); - return(-1); - } - -} - -/* -int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - void *dci_pdu, - uint16_t rnti, - DCI_format_t dci_format, - uint8_t UE_id, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t use_srs) -{ - - uint8_t harq_pid; - uint32_t rb_alloc; - uint8_t transmission_mode=eNB->transmission_mode[UE_id]; - ANFBmode_t AckNackFBMode = eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode; - LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id]; - LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - int subframe = proc->subframe_tx; - - uint32_t cqi_req = 0; - uint32_t dai = 0; - uint32_t cshift = 0; - uint32_t TPC = 0; - uint32_t mcs = 0; - uint32_t rballoc = UINT32_MAX; - uint32_t RIV_max = 0; - // uint32_t hopping; - // uint32_t type; - -#ifdef DEBUG_DCI - printf("filling eNB ulsch params for rnti %x, dci format %d, dci %x, subframe %d\n", - rnti,dci_format,*(uint32_t*)dci_pdu,subframe); -#endif - - if (dci_format == format0) { - - harq_pid = subframe2harq_pid(frame_parms, - pdcch_alloc2ul_frame(frame_parms, - proc->frame_tx, - subframe), - pdcch_alloc2ul_subframe(frame_parms,subframe)); - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; - // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max6; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT6[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT6[rballoc]; - - break; - - case 25: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max25; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT25[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT25[rballoc]; - - break; - - case 50: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max50; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT50[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT50[rballoc]; - - break; - - case 100: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max100; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT100[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT100[rballoc]; - - //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - rb_alloc = rballoc; - AssertFatal(rb_alloc>RIV_max, - "Format 0: rb_alloc (%d) > RIV_max (%d)\n",rb_alloc,RIV_max); -#ifdef DEBUG_DCI - printf("generate_eNB_ulsch_params_from_dci: subframe %d, rnti %x,harq_pid %d,cqi_req %d\n",subframe,rnti,harq_pid,cqi_req); -#endif - - ulsch->harq_processes[harq_pid]->dci_alloc = 1; - ulsch->harq_processes[harq_pid]->rar_alloc = 0; - ulsch->harq_processes[harq_pid]->TPC = TPC; - ulsch->harq_processes[harq_pid]->n_DMRS = cshift; - - - if (cqi_req == 1) { - // 36.213 7.2.1 (release 10) says: - // "RI is only reported for transmission modes 3 and 4, - // as well as transmission modes 8 and 9 with PMI/RI reporting" - // This is for aperiodic reporting. - // TODO: deal with TM 8&9 correctly when they are implemented. - // TODO: deal with periodic reporting if we implement it. - // - if (transmission_mode == 3 || transmission_mode == 4) - ulsch->harq_processes[harq_pid]->O_RI = 1; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table - else - ulsch->harq_processes[harq_pid]->O_RI = 0; - - switch(transmission_mode) { - // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling - case 1: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 2: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 3: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 4: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 5: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 6: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 7: - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - break; - - default: - LOG_E(PHY,"Incorrect Transmission Mode \n"); - break; - } - } else { - ulsch->harq_processes[harq_pid]->O_RI = 0; - ulsch->harq_processes[harq_pid]->Or2 = 0; - ulsch->harq_processes[harq_pid]->Or1 = 0; - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - ulsch->bundling = 1-AckNackFBMode; - - if (frame_parms->frame_type == FDD) { - int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); - - if (eNB->dlsch[UE_id][0]->subframe_tx[dl_subframe]>0) { // we have downlink transmission - ulsch->harq_processes[harq_pid]->O_ACK = 1; - } else { - ulsch->harq_processes[harq_pid]->O_ACK = 0; - } - } else { - if (ulsch->bundling) - ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; - else - ulsch->harq_processes[harq_pid]->O_ACK = (dai+1)&3; - - ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; - } - - ulsch->beta_offset_cqi_times8 = beta_cqi[eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index];//18; - ulsch->beta_offset_ri_times8 = beta_ri[eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index];//10; - ulsch->beta_offset_harqack_times8 = beta_ack[eNB->pusch_config_dedicated[UE_id].betaOffset_ACK_Index];//16; - - ulsch->harq_processes[harq_pid]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); - ulsch->harq_processes[harq_pid]->srs_active = use_srs; - - //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) - if(cshift == 0) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; - else if(cshift == 1) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; - else if(cshift == 2) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; - else if(cshift == 3) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; - else if(cshift == 4) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; - else if(cshift == 5) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; - else if(cshift == 6) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; - else if(cshift == 7) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - - - LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d)\n", - eNB->Mod_id,harq_pid,proc->frame_tx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift); - - - - if (ulsch->harq_processes[harq_pid]->round == 0) { - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; - else - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = mcs; - // ulsch->harq_processes[harq_pid]->calibration_flag = 0; - //if (ulsch->harq_processes[harq_pid]->mcs) - // - //if (ulsch->harq_processes[harq_pid]->mcs == 29) { - //ulsch->harq_processes[harq_pid]->mcs = 4; - // ulsch->harq_processes[harq_pid]->calibration_flag = 1; - // printf("Auto-Calibration (eNB): mcs %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->nb_rb); - //} - - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->harq_processes[harq_pid]->Nsymb_pusch; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - if (mcs>28) - ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; - else { - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = mcs; - } - - // ulsch->harq_processes[harq_pid]->round++; - } - - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->cba_rnti[0] = rnti; - } else { - ulsch->rnti = rnti; - } - - //ulsch->n_DMRS2 = cshift; - -#ifdef DEBUG_DCI - printf("ulsch (eNB): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - printf("ulsch (eNB): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); - printf("ulsch (eNB): harq_pid %d\n",harq_pid); - printf("ulsch (eNB): round %d\n",ulsch->harq_processes[harq_pid]->round); - printf("ulsch (eNB): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - printf("ulsch (eNB): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - printf("ulsch (eNB): Or1 %d\n",ulsch->harq_processes[harq_pid]->Or1); - printf("ulsch (eNB): Nsymb_pusch %d\n",ulsch->harq_processes[harq_pid]->Nsymb_pusch); - printf("ulsch (eNB): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); -#else - UNUSED_VARIABLE(dai); -#endif - return(0); - } else { - LOG_E(PHY,"generate_eNB_ulsch_params_from_dci, Illegal dci_format %d\n",dci_format); - return(-1); - } - -} -*/ - -double sinr_eff_cqi_calc(PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe) -{ - uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - PHY_MEASUREMENTS *meas = &ue->measurements; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int32_t **dl_channel_est = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id]; - double *s_dB; - s_dB = ue->sinr_CQI_dB; - // LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - //for the calculation of SINR_eff for CQI calculation - int count,a_rx,a_tx; - double abs_channel=0; - double channelx=0; - double channely=0; - double channelx_i=0; - double channely_i=0; - uint16_t q = quantize_subband_pmi(meas,eNB_id,7); - uint8_t qq; - - switch(transmission_mode) { - case 1: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - s_dB[count] = 10*log10(pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2], - 2)) - meas->n0_power_avg_dB; - } - } - } - - break; - - case 2: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - abs_channel=0; - - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - abs_channel += (pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2],2)); - } - } - - s_dB[count] = 10*log10(abs_channel/2) - meas->n0_power_avg_dB; - } - - break; - - case 5: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - channelx=0; - channely=0; - channelx_i=0; - channely_i=0; - qq = (q>>(((count/12)>>2)<<1))&3; - - //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - switch(qq) { - case 0: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 1: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 2: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 3: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - default: - printf("Problem in SINR Calculation for TM5 \n"); - break; - }//switch(qq) - }//a_rx - }//a_tx - - s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - 10 * log10 ((pow(channelx_i,2) + pow(channely_i,2))/2) - meas->n0_power_avg_dB; - }//count - - break; - - case 6: - for (count=0; count<frame_parms->N_RB_DL*12; count++) { - channelx=0; - channely=0; - qq = (q>>(((count/12)>>2)<<1))&3; - - //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); - for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { - switch(qq) { - case 0: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 1: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 2: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 3: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - default: - printf("Problem in SINR Calculation for TM6 \n"); - break; - }//switch(qq) - }//a_rx - }//a_tx - - s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - meas->n0_power_avg_dB; - }//count - - break; - - default: - printf("Problem in SINR Calculation for CQI \n"); - break; - } - - int ii; - double sinr_eff = 0; - double sinr_eff_qpsk=0; - double sinr_eff_qam16=0; - double sinr_eff_qam64=0; - double x = 0; - double I_qpsk=0; - double I_qam16=0; - double I_qam64=0; - double I_qpsk_avg=0; - double I_qam16_avg=0; - double I_qam64_avg=0; - double qpsk_max=12.2; - double qam16_max=19.2; - double qam64_max=25.2; - double sinr_min = -20; - int offset=0; - - - for (offset = 0; offset <= 24; offset++) { - for(ii=0; ii<12; ii++) { - //x is the sinr_dB in dB - x = s_dB[(offset*12)+ii]; - - if(x<sinr_min) { - I_qpsk +=0; - I_qam16 +=0; - I_qam64 +=0; - } else { - if(x>qpsk_max) - I_qpsk += 1; - else - I_qpsk += (q_qpsk[0]*pow(x,7) + q_qpsk[1]*pow(x,6) + q_qpsk[2]*pow(x,5) + q_qpsk[3]*pow(x,4) + q_qpsk[4]*pow(x,3) + q_qpsk[5]*pow(x,2) + q_qpsk[6]*x + q_qpsk[7]); - - if(x>qam16_max) - I_qam16 += 1; - else - I_qam16 += (q_qam16[0]*pow(x,7) + q_qam16[1]*pow(x,6) + q_qam16[2]*pow(x,5) + q_qam16[3]*pow(x,4) + q_qam16[4]*pow(x,3) + q_qam16[5]*pow(x,2) + q_qam16[6]*x + q_qam16[7]); - - if(x>qam64_max) - I_qam64 += 1; - else - I_qam64 += (q_qam64[0]*pow(x,7) + q_qam64[1]*pow(x,6) + q_qam64[2]*pow(x,5) + q_qam64[3]*pow(x,4) + q_qam64[4]*pow(x,3) + q_qam64[5]*pow(x,2) + q_qam64[6]*x + q_qam64[7]); - - } - } - } - - // averaging of accumulated MI - I_qpsk_avg = I_qpsk/(12*frame_parms->N_RB_DL); - I_qam16_avg = I_qam16/(12*frame_parms->N_RB_DL); - I_qam64_avg = I_qam64/(12*frame_parms->N_RB_DL); - - // I->SINR_effective Mapping - - sinr_eff_qpsk = (p_qpsk[0]*pow(I_qpsk_avg,7) + p_qpsk[1]*pow(I_qpsk_avg,6) + p_qpsk[2]*pow(I_qpsk_avg,5) + p_qpsk[3]*pow(I_qpsk_avg,4) + p_qpsk[4]*pow(I_qpsk_avg,3) + p_qpsk[5]*pow(I_qpsk_avg, - 2) + p_qpsk[6]*I_qpsk_avg + p_qpsk[7]); - - sinr_eff_qam16 = (p_qam16[0]*pow(I_qam16_avg,7) + p_qam16[1]*pow(I_qam16_avg,6) + p_qam16[2]*pow(I_qam16_avg,5) + p_qam16[3]*pow(I_qam16_avg,4) + p_qam16[4]*pow(I_qam16_avg, - 3) + p_qam16[5]*pow(I_qam16_avg,2) + p_qam16[6]*I_qam16_avg + p_qam16[7]); - - sinr_eff_qam64 = (p_qam64[0]*pow(I_qam64_avg,7) + p_qam64[1]*pow(I_qam64_avg,6) + p_qam64[2]*pow(I_qam64_avg,5) + p_qam64[3]*pow(I_qam64_avg,4) + p_qam64[4]*pow(I_qam64_avg, - 3) + p_qam64[5]*pow(I_qam64_avg,2) + p_qam64[6]*I_qam64_avg + p_qam64[7]); - sinr_eff = cmax3(sinr_eff_qpsk,sinr_eff_qam16,sinr_eff_qam64); - - //printf("SINR_Eff = %e\n",sinr_eff); - - return(sinr_eff); -} -// - - - -#ifdef DEBUG_DLSCH_TOOLS -main() -{ - - int i; - uint8_t rah; - uint32_t rballoc; - - generate_RIV_tables(); - - rah = 0; - rballoc = 0x1fff; - printf("rballoc 0 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rah = 1; - - rballoc = 0x1678; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - - rballoc = 0xfffc; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xfffd; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xffff; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xfffe; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); -} - -#endif diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c new file mode 100644 index 0000000000000000000000000000000000000000..8f0f8a6cab6fc308be46b61e562c149de5f74f66 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c @@ -0,0 +1,2276 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/dci_tools.c + * \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler. + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#ifdef DEBUG_DCI_TOOLS +#include "PHY/phy_vars.h" +#endif +#include "assertions.h" +#include "nfapi_interface.h" +#include "transport_common_proto.h" +#include "SCHED/sched_common.h" +//#define DEBUG_HARQ + + +#include "LAYER2/MAC/mac.h" + +//#define DEBUG_DCI + +uint32_t localRIV2alloc_LUT6[32]; +uint32_t distRIV2alloc_even_LUT6[32]; +uint32_t distRIV2alloc_odd_LUT6[32]; +uint16_t RIV2nb_rb_LUT6[32]; +uint16_t RIV2first_rb_LUT6[32]; +uint16_t RIV_max6=0; + +uint32_t localRIV2alloc_LUT25[512]; +uint32_t distRIV2alloc_even_LUT25[512]; +uint32_t distRIV2alloc_odd_LUT25[512]; +uint16_t RIV2nb_rb_LUT25[512]; +uint16_t RIV2first_rb_LUT25[512]; +uint16_t RIV_max25=0; + + +uint32_t localRIV2alloc_LUT50_0[1600]; +uint32_t localRIV2alloc_LUT50_1[1600]; +uint32_t distRIV2alloc_gap0_even_LUT50_0[1600]; +uint32_t distRIV2alloc_gap0_odd_LUT50_0[1600]; +uint32_t distRIV2alloc_gap0_even_LUT50_1[1600]; +uint32_t distRIV2alloc_gap0_odd_LUT50_1[1600]; +uint32_t distRIV2alloc_gap1_even_LUT50_0[1600]; +uint32_t distRIV2alloc_gap1_odd_LUT50_0[1600]; +uint32_t distRIV2alloc_gap1_even_LUT50_1[1600]; +uint32_t distRIV2alloc_gap1_odd_LUT50_1[1600]; +uint16_t RIV2nb_rb_LUT50[1600]; +uint16_t RIV2first_rb_LUT50[1600]; +uint16_t RIV_max50=0; + +uint32_t localRIV2alloc_LUT100_0[6000]; +uint32_t localRIV2alloc_LUT100_1[6000]; +uint32_t localRIV2alloc_LUT100_2[6000]; +uint32_t localRIV2alloc_LUT100_3[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_0[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_0[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_1[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_1[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_2[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_2[6000]; +uint32_t distRIV2alloc_gap0_even_LUT100_3[6000]; +uint32_t distRIV2alloc_gap0_odd_LUT100_3[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_0[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_0[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_1[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_1[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_2[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_2[6000]; +uint32_t distRIV2alloc_gap1_even_LUT100_3[6000]; +uint32_t distRIV2alloc_gap1_odd_LUT100_3[6000]; +uint16_t RIV2nb_rb_LUT100[6000]; +uint16_t RIV2first_rb_LUT100[6000]; +uint16_t RIV_max100=0; + +extern RAN_CONTEXT_t RC; + +extern uint32_t current_dlsch_cqi; + +// Table 8.6.3-3 36.213 +uint16_t beta_cqi[16] = {0, //reserved + 0, //reserved + 9, //1.125 + 10, //1.250 + 11, //1.375 + 13, //1.625 + 14, //1.750 + 16, //2.000 + 18, //2.250 + 20, //2.500 + 23, //2.875 + 25, //3.125 + 28, //3.500 + 32, //4.000 + 40, //5.000 + 50 + }; //6.250 + +// Table 8.6.3-2 36.213 +uint16_t beta_ri[16] = {10, //1.250 + 13, //1.625 + 16, //2.000 + 20, //2.500 + 25, //3.125 + 32, //4.000 + 40, //5.000 + 50, //6.250 + 64, //8.000 + 80, //10.000 + 101, //12.625 + 127, //15.875 + 160, //20.000 + 0, //reserved + 0, //reserved + 0 + }; //reserved + +// Table 8.6.3-2 36.213 +uint16_t beta_ack[16] = {16, //2.000 + 20, //2.500 + 25, //3.125 + 32, //4.000 + 40, //5.000 + 50, //6.250 + 64, //8.000 + 80, //10.000 + 101, //12.625 + 127, //15.875 + 160, //20.000 + 248, //31.000 + 400, //50.000 + 640, //80.000 + 808 + };//126.00 + +int8_t delta_PUSCH_abs[4] = {-4,-1,1,4}; +int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; + +int8_t *delta_PUCCH_lut = delta_PUSCH_acc; + +uint8_t get_pmi(uint8_t N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb) +{ + /* + MIMO_mode_t mode = dlsch_harq->mimo_mode; + uint32_t pmi_alloc = dlsch_harq->pmi_alloc; + */ + + switch (N_RB_DL) { + case 6: // 1 PRB per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>(rb<<1))&3); + else + return((pmi_alloc>>rb)&1); + + break; + + default: + case 25: // 4 PRBs per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>((rb>>2)<<1))&3); + else + return((pmi_alloc>>(rb>>2))&1); + + break; + + case 50: // 6 PRBs per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>((rb/6)<<1))&3); + else + return((pmi_alloc>>(rb/6))&1); + + break; + + case 100: // 8 PRBs per subband + if (mode <= PUSCH_PRECODING1) + return((pmi_alloc>>((rb>>3)<<1))&3); + else + return((pmi_alloc>>(rb>>3))&1); + + break; + } +} + +uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi) +{ + + uint16_t i; + uint16_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + uint16_t mprime; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + if ((lprime>0) && (frame_parms->Ncp==0) ) + return(0); + + // printf("check_phich_reg : mi %d\n",mi); + + // compute REG based on symbol + if ((lprime == 0)|| + ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4))) + mprime = kprime/6; + else + mprime = kprime>>2; + + // check if PCFICH uses mprime + if ((lprime==0) && + ((mprime == pcfich_reg[0]) || + (mprime == pcfich_reg[1]) || + (mprime == pcfich_reg[2]) || + (mprime == pcfich_reg[3]))) { +#ifdef DEBUG_DCI_ENCODING + printf("[PHY] REG %d allocated to PCFICH\n",mprime); +#endif + return(1); + } + + // handle Special subframe case for TDD !!! + + // printf("Checking phich_reg %d\n",mprime); + if (mi > 0) { + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + if (frame_parms->Ncp == 1) { + Ngroup_PHICH<<=1; + } + + + + for (i=0; i<Ngroup_PHICH; i++) { + if ((mprime == frame_parms->phich_reg[i][0]) || + (mprime == frame_parms->phich_reg[i][1]) || + (mprime == frame_parms->phich_reg[i][2])) { +#ifdef DEBUG_DCI_ENCODING + printf("[PHY] REG %d (lprime %d) allocated to PHICH\n",mprime,lprime); +#endif + return(1); + } + } + } + + return(0); +} + +uint16_t get_nquad(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) +{ + + uint16_t Nreg=0; + uint8_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + if (frame_parms->Ncp == 1) { + Ngroup_PHICH<<=1; + } + + Ngroup_PHICH*=mi; + + if ((num_pdcch_symbols>0) && (num_pdcch_symbols<4)) + switch (frame_parms->N_RB_DL) { + case 6: + Nreg=12+(num_pdcch_symbols-1)*18; + break; + + case 25: + Nreg=50+(num_pdcch_symbols-1)*75; + break; + + case 50: + Nreg=100+(num_pdcch_symbols-1)*150; + break; + + case 100: + Nreg=200+(num_pdcch_symbols-1)*300; + break; + + default: + return(0); + } + + // printf("Nreg %d (%d)\n",Nreg,Nreg - 4 - (3*Ngroup_PHICH)); + return(Nreg - 4 - (3*Ngroup_PHICH)); +} + +uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi) +{ + return(get_nquad(num_pdcch_symbols,frame_parms,mi)/9); +} + + + +uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe) +{ + + // check for eNB only ! + return(get_nCCE(num_pdcch_symbols, + &RC.eNB[Mod_id][CC_id]->frame_parms, + get_mi(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe))); +} + + +void conv_eMTC_rballoc(uint16_t resource_block_coding, + uint32_t N_RB_DL, + uint32_t *rb_alloc) { + + + int narrowband = resource_block_coding>>5; + int RIV = resource_block_coding&31; + int N_NB_DL = N_RB_DL/6; + int i0 = (N_RB_DL>>1) - (3*N_NB_DL); + int first_rb = (6*narrowband)+i0; + int alloc = localRIV2alloc_LUT6[RIV]; + int ind = first_rb>>5; + int ind_mod = first_rb&31; + + if (((N_RB_DL&1) > 0) && (narrowband>=(N_NB_DL>>1))) first_rb++; + rb_alloc[0] = 0; + rb_alloc[1] = 0; + rb_alloc[2] = 0; + rb_alloc[3] = 0; + rb_alloc[ind] = alloc<<ind_mod; + if (ind_mod > 26) rb_alloc[ind+1] = alloc>>(6-(ind_mod-26)); +} + +void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2) +{ + + uint32_t i,shift,subset; + rb_alloc2[0] = 0; + rb_alloc2[1] = 0; + rb_alloc2[2] = 0; + rb_alloc2[3] = 0; + + // printf("N_RB_DL %d, ra_header %d, rb_alloc %x\n",N_RB_DL,ra_header,rb_alloc); + + switch (N_RB_DL) { + + case 6: + rb_alloc2[0] = rb_alloc&0x3f; + break; + + case 25: + if (ra_header == 0) {// Type 0 Allocation + + for (i=12; i>0; i--) { + if ((rb_alloc&(1<<i)) != 0) + rb_alloc2[0] |= (3<<((2*(12-i)))); + + // printf("rb_alloc2 (type 0) %x\n",rb_alloc2); + } + + if ((rb_alloc&1) != 0) + rb_alloc2[0] |= (1<<24); + } else { + subset = rb_alloc&1; + shift = (rb_alloc>>1)&1; + + for (i=0; i<11; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + rb_alloc2[0] |= (1<<(2*i)); + + //printf("rb_alloc2 (type 1) %x\n",rb_alloc2); + } + + if ((shift == 0) && (subset == 1)) + rb_alloc2[0]<<=1; + else if ((shift == 1) && (subset == 0)) + rb_alloc2[0]<<=4; + else if ((shift == 1) && (subset == 1)) + rb_alloc2[0]<<=3; + } + + break; + + case 50: + AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=50\n"); + + for (i=16; i>0; i--) { + if ((rb_alloc&(1<<i)) != 0) + rb_alloc2[(3*(16-i))>>5] |= (7<<((3*(16-i))%32)); + } + + // bit mask across + if ((rb_alloc2[0]>>31)==1) + rb_alloc2[1] |= 1; + + if ((rb_alloc&1) != 0) + rb_alloc2[1] |= (3<<16); + break; + + case 100: + AssertFatal(ra_header==0,"resource type 1 not supported for N_RB_DL=100\n"); + for (i=0; i<25; i++) { + if ((rb_alloc&(1<<(24-i))) != 0) + rb_alloc2[(4*i)>>5] |= (0xf<<((4*i)%32)); + + // printf("rb_alloc2[%d] (type 0) %x (%d)\n",(4*i)>>5,rb_alloc2[(4*i)>>5],rb_alloc&(1<<i)); + } + + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", N_RB_DL); + DevParam (N_RB_DL, 0, 0); + break; + } + +} + + + +uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL) +{ + + uint32_t nprb=0,i; + + switch (N_RB_DL) { + case 6: + for (i=0; i<6; i++) { + if ((rb_alloc&(1<<i)) != 0) + nprb += 1; + } + + break; + + case 25: + if (ra_header == 0) {// Type 0 Allocation + + for (i=12; i>0; i--) { + if ((rb_alloc&(1<<i)) != 0) + nprb += 2; + } + + if ((rb_alloc&1) != 0) + nprb += 1; + } else { + for (i=0; i<11; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + nprb += 1; + } + } + + break; + + case 50: + if (ra_header == 0) {// Type 0 Allocation + + for (i=0; i<16; i++) { + if ((rb_alloc&(1<<(16-i))) != 0) + nprb += 3; + } + + if ((rb_alloc&1) != 0) + nprb += 2; + + } else { + for (i=0; i<17; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + nprb += 1; + } + } + + break; + + case 100: + if (ra_header == 0) {// Type 0 Allocation + + for (i=0; i<25; i++) { + if ((rb_alloc&(1<<(24-i))) != 0) + nprb += 4; + } + } else { + for (i=0; i<25; i++) { + if ((rb_alloc&(1<<(i+2))) != 0) + nprb += 1; + } + } + + break; + + default: + LOG_E(PHY,"Invalide N_RB_DL %d\n", N_RB_DL); + DevParam (N_RB_DL, 0, 0); + break; + } + + return(nprb); +} + +uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs) +{ + + uint16_t RIV; + + if (Lcrbs<=(1+(N_RB_DL>>1))) + RIV = (N_RB_DL*(Lcrbs-1)) + RBstart; + else + RIV = (N_RB_DL*(N_RB_DL+1-Lcrbs)) + (N_RB_DL-1-RBstart); + + return(RIV); +} + +// Convert a DCI Format 1C RIV to a Format 1A RIV +// This extracts the start and length in PRBs from the 1C rballoc and +// recomputes the RIV as if it were the 1A rballoc + +uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL) { + + int NpDLVRB,N_RB_step,LpCRBsm1,RBpstart; + + switch (N_RB_DL) { + + case 6: // N_RB_step = 2, NDLVRB = 6, NpDLVRB = 3 + NpDLVRB = 3; + N_RB_step = 2; + break; + case 25: // N_RB_step = 2, NDLVRB = 24, NpDLVRB = 12 + NpDLVRB = 12; + N_RB_step = 2; + break; + case 50: // N_RB_step = 4, NDLVRB = 46, NpDLVRB = 11 + NpDLVRB = 11; + N_RB_step = 4; + break; + case 100: // N_RB_step = 4, NDLVRB = 96, NpDLVRB = 24 + NpDLVRB = 24; + N_RB_step = 4; + break; + default: + NpDLVRB = 24; + N_RB_step = 4; + break; + } + + // This is the 1C part from 7.1.6.3 in 36.213 + LpCRBsm1 = rballoc/NpDLVRB; + // printf("LpCRBs = %d\n",LpCRBsm1+1); + + if (LpCRBsm1 <= (NpDLVRB/2)) { + RBpstart = rballoc % NpDLVRB; + } + else { + LpCRBsm1 = NpDLVRB-LpCRBsm1; + RBpstart = NpDLVRB-(rballoc%NpDLVRB); + } + // printf("RBpstart %d\n",RBpstart); + return(computeRIV(N_RB_DL,N_RB_step*RBpstart,N_RB_step*(LpCRBsm1+1))); + +} + +uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { + + int offset; + + switch (N_RB_DL) { + + case 6: + // N_RB_DL = tildeN_RB_DL = 6 + // Ngap = 4 , P=1, Nrow = 2, Nnull = 2 + + switch (vrb) { + case 0: // even: 0->0, 1->2, odd: 0->3, 1->5 + case 1: + return ((3*odd_slot) + 2*(vrb&3))%6; + break; + case 2: // even: 2->3, 3->5, odd: 2->0, 3->2 + case 3: + return ((3*odd_slot) + 2*(vrb&3) + 5)%6; + break; + case 4: // even: 4->1, odd: 4->4 + return ((3*odd_slot) + 1)%6; + case 5: // even: 5->4, odd: 5->1 + return ((3*odd_slot) + 4)%6; + break; + } + break; + + case 15: + if (vrb<12) { + if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11 + return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); + else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13 + return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); + } + if (vrb==12) + return (3+(7*odd_slot)) % 14; + if (vrb==13) + return (10+(7*odd_slot)) % 14; + return 14; + break; + + case 25: + return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); + break; + + case 50: // P=3 + if (Ngap==0) { + // Nrow=12,Nnull=2,NVRBDL=46,Ngap1= 27 + if (vrb>=23) + offset=4; + else + offset=0; + if (vrb<44) { + if ((vrb&3)>=2) + return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; + else + return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; + } + if (vrb==44) // even: 44->11, odd: 45->34 + return offset+((23*odd_slot) + 22-12+1); + if (vrb==45) // even: 45->10, odd: 45->33 + return offset+((23*odd_slot) + 22+12); + if (vrb==46) + return offset+46+((23*odd_slot) + 23-12+1) % 46; + if (vrb==47) + return offset+46+((23*odd_slot) + 23+12) % 46; + if (vrb==48) + return offset+46+((23*odd_slot) + 23-12+1) % 46; + if (vrb==49) + return offset+46+((23*odd_slot) + 23+12) % 46; + } + else { + // Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27 + if (vrb>=9) + offset=18; + else + offset=0; + + if (vrb<12) { + if ((vrb&3)>=2) + return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; + else + return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; + } + else { + return offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18); + } + } + break; + case 75: + // Ngap1 = 32, NVRBRL=64, P=4, Nrow= 16, Nnull=0 + if (Ngap ==0) { + return ((32*odd_slot) + 16*(vrb&3) + (vrb>>2))%64 + (vrb/64); + } else { + // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 + return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); + } + break; + case 100: + // Ngap1 = 48, NVRBDL=96, Nrow=24, Nnull=0 + if (Ngap ==0) { + return ((48*odd_slot) + 24*(vrb&3) + (vrb>>2))%96 + (vrb/96); + } else { + // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 + return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); + } + break; + default: + LOG_E(PHY,"Unknown N_RB_DL %d\n",N_RB_DL); + return 0; + } + return 0; + +} + + +void generate_RIV_tables(void) +{ + + // 6RBs localized RIV + uint8_t Lcrbs,RBstart; + uint16_t RIV; + uint32_t alloc0,allocdist0_0_even,allocdist0_0_odd,allocdist0_1_even,allocdist0_1_odd; + uint32_t alloc1,allocdist1_0_even,allocdist1_0_odd,allocdist1_1_even,allocdist1_1_odd; + uint32_t alloc2,allocdist2_0_even,allocdist2_0_odd,allocdist2_1_even,allocdist2_1_odd; + uint32_t alloc3,allocdist3_0_even,allocdist3_0_odd,allocdist3_1_even,allocdist3_1_odd; + uint32_t nVRB,nVRB_even_dist,nVRB_odd_dist; + + for (RBstart=0; RBstart<6; RBstart++) { + alloc0 = 0; + allocdist0_0_even = 0; + allocdist0_0_odd = 0; + for (Lcrbs=1; Lcrbs<=(6-RBstart); Lcrbs++) { + //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); + nVRB = Lcrbs-1+RBstart; + alloc0 |= (1<<nVRB); + allocdist0_0_even |= (1<<get_prb(6,0,nVRB,0)); + allocdist0_0_odd |= (1<<get_prb(6,1,nVRB,0)); + RIV=computeRIV(6,RBstart,Lcrbs); + + if (RIV>RIV_max6) + RIV_max6 = RIV; + + // printf("RIV %d (%d) : first_rb %d NBRB %d\n",RIV,localRIV2alloc_LUT25[RIV],RBstart,Lcrbs); + localRIV2alloc_LUT6[RIV] = alloc0; + distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even; + distRIV2alloc_odd_LUT6[RIV] = allocdist0_0_odd; + RIV2nb_rb_LUT6[RIV] = Lcrbs; + RIV2first_rb_LUT6[RIV] = RBstart; + } + } + + + for (RBstart=0; RBstart<25; RBstart++) { + alloc0 = 0; + allocdist0_0_even = 0; + allocdist0_0_odd = 0; + for (Lcrbs=1; Lcrbs<=(25-RBstart); Lcrbs++) { + nVRB = Lcrbs-1+RBstart; + //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); + alloc0 |= (1<<nVRB); + allocdist0_0_even |= (1<<get_prb(25,0,nVRB,0)); + allocdist0_0_odd |= (1<<get_prb(25,1,nVRB,0)); + + //printf("alloc 0 %x, allocdist0_even %x, allocdist0_odd %x\n",alloc0,allocdist0_0_even,allocdist0_0_odd); + RIV=computeRIV(25,RBstart,Lcrbs); + + if (RIV>RIV_max25) + RIV_max25 = RIV;; + + + localRIV2alloc_LUT25[RIV] = alloc0; + distRIV2alloc_even_LUT25[RIV] = allocdist0_0_even; + distRIV2alloc_odd_LUT25[RIV] = allocdist0_0_odd; + RIV2nb_rb_LUT25[RIV] = Lcrbs; + RIV2first_rb_LUT25[RIV] = RBstart; + } + } + + + for (RBstart=0; RBstart<50; RBstart++) { + alloc0 = 0; + alloc1 = 0; + allocdist0_0_even=0; + allocdist1_0_even=0; + allocdist0_0_odd=0; + allocdist1_0_odd=0; + allocdist0_1_even=0; + allocdist1_1_even=0; + allocdist0_1_odd=0; + allocdist1_1_odd=0; + + for (Lcrbs=1; Lcrbs<=(50-RBstart); Lcrbs++) { + + nVRB = Lcrbs-1+RBstart; + + + if (nVRB<32) + alloc0 |= (1<<nVRB); + else + alloc1 |= (1<<(nVRB-32)); + + // Distributed Gap1, even slot + nVRB_even_dist = get_prb(50,0,nVRB,0); + if (nVRB_even_dist<32) + allocdist0_0_even |= (1<<nVRB_even_dist); + else + allocdist1_0_even |= (1<<(nVRB_even_dist-32)); + + // Distributed Gap1, odd slot + nVRB_odd_dist = get_prb(50,1,nVRB,0); + if (nVRB_odd_dist<32) + allocdist0_0_odd |= (1<<nVRB_odd_dist); + else + allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); + + // Distributed Gap2, even slot + nVRB_even_dist = get_prb(50,0,nVRB,1); + if (nVRB_even_dist<32) + allocdist0_1_even |= (1<<nVRB_even_dist); + else + allocdist1_1_even |= (1<<(nVRB_even_dist-32)); + + // Distributed Gap2, odd slot + nVRB_odd_dist = get_prb(50,1,nVRB,1); + if (nVRB_odd_dist<32) + allocdist0_1_odd |= (1<<nVRB_odd_dist); + else + allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); + + RIV=computeRIV(50,RBstart,Lcrbs); + + if (RIV>RIV_max50) + RIV_max50 = RIV; + + // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); + localRIV2alloc_LUT50_0[RIV] = alloc0; + localRIV2alloc_LUT50_1[RIV] = alloc1; + distRIV2alloc_gap0_even_LUT50_0[RIV] = allocdist0_0_even; + distRIV2alloc_gap0_even_LUT50_1[RIV] = allocdist1_0_even; + distRIV2alloc_gap0_odd_LUT50_0[RIV] = allocdist0_0_odd; + distRIV2alloc_gap0_odd_LUT50_1[RIV] = allocdist1_0_odd; + distRIV2alloc_gap1_even_LUT50_0[RIV] = allocdist0_1_even; + distRIV2alloc_gap1_even_LUT50_1[RIV] = allocdist1_1_even; + distRIV2alloc_gap1_odd_LUT50_0[RIV] = allocdist0_1_odd; + distRIV2alloc_gap1_odd_LUT50_1[RIV] = allocdist1_1_odd; + RIV2nb_rb_LUT50[RIV] = Lcrbs; + RIV2first_rb_LUT50[RIV] = RBstart; + } + } + + + for (RBstart=0; RBstart<100; RBstart++) { + alloc0 = 0; + alloc1 = 0; + alloc2 = 0; + alloc3 = 0; + allocdist0_0_even=0; + allocdist1_0_even=0; + allocdist2_0_even=0; + allocdist3_0_even=0; + allocdist0_0_odd=0; + allocdist1_0_odd=0; + allocdist2_0_odd=0; + allocdist3_0_odd=0; + allocdist0_1_even=0; + allocdist1_1_even=0; + allocdist2_1_even=0; + allocdist3_1_even=0; + allocdist0_1_odd=0; + allocdist1_1_odd=0; + allocdist2_1_odd=0; + allocdist3_1_odd=0; + + for (Lcrbs=1; Lcrbs<=(100-RBstart); Lcrbs++) { + + nVRB = Lcrbs-1+RBstart; + + if (nVRB<32) + alloc0 |= (1<<nVRB); + else if (nVRB<64) + alloc1 |= (1<<(nVRB-32)); + else if (nVRB<96) + alloc2 |= (1<<(nVRB-64)); + else + alloc3 |= (1<<(nVRB-96)); + + // Distributed Gap1, even slot + nVRB_even_dist = get_prb(100,0,nVRB,0); + +// if ((RBstart==0) && (Lcrbs<=8)) +// printf("nVRB %d => nVRB_even_dist %d\n",nVRB,nVRB_even_dist); + + + if (nVRB_even_dist<32) + allocdist0_0_even |= (1<<nVRB_even_dist); + else if (nVRB_even_dist<64) + allocdist1_0_even |= (1<<(nVRB_even_dist-32)); + else if (nVRB_even_dist<96) + allocdist2_0_even |= (1<<(nVRB_even_dist-64)); + else + allocdist3_0_even |= (1<<(nVRB_even_dist-96)); +/* if ((RBstart==0) && (Lcrbs<=8)) + printf("rballoc =>(%08x.%08x.%08x.%08x)\n", + allocdist0_0_even, + allocdist1_0_even, + allocdist2_0_even, + allocdist3_0_even + ); +*/ + // Distributed Gap1, odd slot + nVRB_odd_dist = get_prb(100,1,nVRB,0); + if (nVRB_odd_dist<32) + allocdist0_0_odd |= (1<<nVRB_odd_dist); + else if (nVRB_odd_dist<64) + allocdist1_0_odd |= (1<<(nVRB_odd_dist-32)); + else if (nVRB_odd_dist<96) + allocdist2_0_odd |= (1<<(nVRB_odd_dist-64)); + else + allocdist3_0_odd |= (1<<(nVRB_odd_dist-96)); + + + // Distributed Gap2, even slot + nVRB_even_dist = get_prb(100,0,nVRB,1); + if (nVRB_even_dist<32) + allocdist0_1_even |= (1<<nVRB_even_dist); + else if (nVRB_even_dist<64) + allocdist1_1_even |= (1<<(nVRB_even_dist-32)); + else if (nVRB_even_dist<96) + allocdist2_1_even |= (1<<(nVRB_even_dist-64)); + else + allocdist3_1_even |= (1<<(nVRB_even_dist-96)); + + + // Distributed Gap2, odd slot + nVRB_odd_dist = get_prb(100,1,nVRB,1); + if (nVRB_odd_dist<32) + allocdist0_1_odd |= (1<<nVRB_odd_dist); + else if (nVRB_odd_dist<64) + allocdist1_1_odd |= (1<<(nVRB_odd_dist-32)); + else if (nVRB_odd_dist<96) + allocdist2_1_odd |= (1<<(nVRB_odd_dist-64)); + else + allocdist3_1_odd |= (1<<(nVRB_odd_dist-96)); + + + RIV=computeRIV(100,RBstart,Lcrbs); + + if (RIV>RIV_max100) + RIV_max100 = RIV; + + // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); + localRIV2alloc_LUT100_0[RIV] = alloc0; + localRIV2alloc_LUT100_1[RIV] = alloc1; + localRIV2alloc_LUT100_2[RIV] = alloc2; + localRIV2alloc_LUT100_3[RIV] = alloc3; + distRIV2alloc_gap0_even_LUT100_0[RIV] = allocdist0_0_even; + distRIV2alloc_gap0_even_LUT100_1[RIV] = allocdist1_0_even; + distRIV2alloc_gap0_even_LUT100_2[RIV] = allocdist2_0_even; + distRIV2alloc_gap0_even_LUT100_3[RIV] = allocdist3_0_even; + distRIV2alloc_gap0_odd_LUT100_0[RIV] = allocdist0_0_odd; + distRIV2alloc_gap0_odd_LUT100_1[RIV] = allocdist1_0_odd; + distRIV2alloc_gap0_odd_LUT100_2[RIV] = allocdist2_0_odd; + distRIV2alloc_gap0_odd_LUT100_3[RIV] = allocdist3_0_odd; + distRIV2alloc_gap1_even_LUT100_0[RIV] = allocdist0_1_even; + distRIV2alloc_gap1_even_LUT100_1[RIV] = allocdist1_1_even; + distRIV2alloc_gap1_even_LUT100_2[RIV] = allocdist2_1_even; + distRIV2alloc_gap1_even_LUT100_3[RIV] = allocdist3_1_even; + distRIV2alloc_gap1_odd_LUT100_0[RIV] = allocdist0_1_odd; + distRIV2alloc_gap1_odd_LUT100_1[RIV] = allocdist1_1_odd; + distRIV2alloc_gap1_odd_LUT100_2[RIV] = allocdist2_1_odd; + distRIV2alloc_gap1_odd_LUT100_3[RIV] = allocdist3_1_odd; + + RIV2nb_rb_LUT100[RIV] = Lcrbs; + RIV2first_rb_LUT100[RIV] = RBstart; + } + } +} + +// Ngap = 3, N_VRB_DL=6, P=1, N_row=2, N_null=4*2-6=2 +// permutation for even slots : +// n_PRB'(0,2,4) = (0,1,2), n_PRB'(1,3,5) = (4,5,6) +// n_PRB''(0,1,2,3) = (0,2,4,6) +// => n_tilde_PRB(5) = (4) +// n_tilde_PRB(4) = (1) +// n_tilde_PRB(2,3) = (3,5) +// n_tilde_PRB(0,1) = (0,2) + +uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci) +{ + + return(localRIV2alloc_LUT25[rb_alloc_dci]); + +} + +uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) +{ + uint8_t ret = 255; + + if (frame_parms->frame_type == FDD) { + ret = (((frame*10)+subframe)&7); + } else { + + switch (frame_parms->tdd_config) { + + case 1: + if ((subframe==2) || + (subframe==3) || + (subframe==7) || + (subframe==8)) + switch (subframe) { + case 2: + case 3: + ret = (subframe-2); + break; + + case 7: + case 8: + ret = (subframe-5); + break; + + default: + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + break; + } + + break; + + case 2: + if ((subframe!=2) && (subframe!=7)) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret=255; + } + else ret = (subframe/7); + break; + + case 3: + if ((subframe<2) || (subframe>4)) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + } + else ret = (subframe-2); + break; + + case 4: + if ((subframe<2) || (subframe>3)) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + } + else ret = (subframe-2); + break; + + case 5: + if (subframe!=2) { + LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config); + ret = (255); + } + else ret = (subframe-2); + break; + + default: + LOG_E(PHY,"subframe2_harq_pid, Unsupported TDD mode %d\n",frame_parms->tdd_config); + ret = (255); + } + } + + AssertFatal(ret!=255, + "invalid harq_pid(%d) at SFN/SF = %d/%d\n", (int8_t)ret, frame, subframe); + return ret; +} + +uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) +{ + uint8_t ul_subframe = 255; + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1) && + ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 + ul_subframe = ((n+6)%10); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + ((n==0)||(n==1)||(n==5)||(n==6))) + ul_subframe = ((n+7)%10); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + (n==9)) // tdd_config 6 SF 9 + ul_subframe = ((n+5)%10); + else + ul_subframe = ((n+4)%10); + + AssertFatal(frame_parms->frame_type == FDD || subframe_select(frame_parms,ul_subframe) == SF_UL,"illegal ul_subframe %d (n %d)\n",ul_subframe,n); + + LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe); + return ul_subframe; +} + +uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) +{ + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1) && + ((n==7)||(n==2))) // tdd_config 0,1 SF 1,5 + return((n==7)? 1 : 6); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + ((n==7)||(n==8)||(n==2)||(n==3))) + return((n+3)%10); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + (n==4)) // tdd_config 6 SF 9 + return(9); + else + return((n+6)%10); +} + +uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) +{ + uint32_t ul_frame; + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1) && + ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 + ul_frame = (frame + (n==1 ? 0 : 1)); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + ((n==0)||(n==1)||(n==5)||(n==6))) + ul_frame = (frame + (n>=5 ? 1 : 0)); + else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 6) && + (n==9)) // tdd_config 6 SF 9 + ul_frame = (frame+1); + else + ul_frame = (frame+(n>=6 ? 1 : 0)); + + LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame); + return ul_frame % 1024; +} + +uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank) +{ + + uint8_t i,wideband_pmi2; + uint32_t pmi_ex = 0; + + if (frame_parms->N_RB_DL!=25) { + LOG_E(PHY,"pmi_extend not yet implemented for anything else than 25PRB\n"); + return(-1); + } + + if (rank==0) { + wideband_pmi2=wideband_pmi&3; + for (i=0; i<14; i+=2) + pmi_ex|=(wideband_pmi2<<i); + } + else if (rank==1) { + wideband_pmi2=wideband_pmi&1; + for (i=0; i<7; i++) + pmi_ex|=(wideband_pmi2<<i); + } + else { + LOG_E(PHY,"unsupported rank\n"); + return(-1); + } + + return(pmi_ex); +} + +uint64_t pmi2hex_2Ar1(uint32_t pmi) +{ + + uint64_t pmil = (uint64_t)pmi; + + return ((pmil&3) + (((pmil>>2)&3)<<4) + (((pmil>>4)&3)<<8) + (((pmil>>6)&3)<<12) + + (((pmil>>8)&3)<<16) + (((pmil>>10)&3)<<20) + (((pmil>>12)&3)<<24) + + (((pmil>>14)&3)<<28) + (((pmil>>16)&3)<<32) + (((pmil>>18)&3)<<36) + + (((pmil>>20)&3)<<40) + (((pmil>>22)&3)<<44) + (((pmil>>24)&3)<<48)); +} + +uint64_t pmi2hex_2Ar2(uint32_t pmi) +{ + + uint64_t pmil = (uint64_t)pmi; + return ((pmil&1) + (((pmil>>1)&1)<<4) + (((pmil>>2)&1)<<8) + (((pmil>>3)&1)<<12) + + (((pmil>>4)&1)<<16) + (((pmil>>5)&1)<<20) + (((pmil>>6)&1)<<24) + + (((pmil>>7)&1)<<28) + (((pmil>>8)&1)<<32) + (((pmil>>9)&1)<<36) + + (((pmil>>10)&1)<<40) + (((pmil>>11)&1)<<44) + (((pmil>>12)&1)<<48)); +} + + +int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) +{ + switch (dci->format) { + + case format0: // This is an UL SCH allocation so nothing here, inform MAC + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format0 (TDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 25: + LOG_D(PHY,"DCI format0 (TDD1-6, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 50: + LOG_D(PHY,"DCI format0 (TDD1-6, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 100: + LOG_D(PHY,"DCI format0 (TDD1-6, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, + ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + else if (frame_parms->frame_type == FDD) + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format0 (FDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 25: + LOG_D(PHY,"DCI format0 (FDD, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 50: + LOG_D(PHY,"DCI format0 (FDD, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + case 100: + LOG_D(PHY,"DCI format0 (FDD, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu[0])[0], + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->hopping, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cshift, + ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format1: + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) + + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1 (TDD 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + case 25: + LOG_D(PHY,"DCI format1 (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + case 50: + LOG_D(PHY,"DCI format1 (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + case 100: + LOG_D(PHY,"DCI format1 (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->dai); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + else if (frame_parms->frame_type == FDD) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1 (FDD, 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format1 (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format1 (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format1 (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format1A: // This is DLSCH allocation for control traffic + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) { + switch (frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1A (TDD1-6, 1_5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + case 25: + LOG_D(PHY,"DCI format1A (TDD1-6, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %d (NB_RB %d)\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + case 50: + LOG_D(PHY,"DCI format1A (TDD1-6, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + case 100: + LOG_D(PHY,"DCI format1A (TDD1-6, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); + LOG_D(PHY,"DAI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + } else if (frame_parms->frame_type == FDD) { + switch (frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1A(FDD, 1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format1A(FDD, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format1A(FDD, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format1A(FDD, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); + LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs); + LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); + LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi); + LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rv); + LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + + break; + + case format1C: // This is DLSCH allocation for control traffic + switch (frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format1C (1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n", + ((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT6[conv_1C_RIV(((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,6)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + case 25: + LOG_D(PHY,"DCI format1C (5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[conv_1C_RIV(((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,25)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + case 50: + LOG_D(PHY,"DCI format1C (10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"Ngap %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->Ngap); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,50)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + case 100: + LOG_D(PHY,"DCI format1C (20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); + LOG_D(PHY,"Ngap %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->Ngap); + LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,100)]); + LOG_D(PHY,"MCS %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->mcs); + break; + + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + + break; + + case format2: + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi + ); + break; + + case 25: + LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 50: + LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 100: + LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi + ); + break; + + case 25: + LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 50: + LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 100: + LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } else if (frame_parms->frame_type == FDD) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + + LOG_D(PHY,"DCI format2 2 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, swap %d, TPMI %d, TPC %d\n", + + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2 2 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2 2 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + + case 6: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2 4 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } + + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format2A: + + if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config>0)) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap + ); + break; + + case 25: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); + break; + + case 50: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); + break; + + case 100: + LOG_D(PHY,"DCI format2A 2 antennas (FDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi + ); + break; + + case 25: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 50: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + case 100: + LOG_D(PHY,"DCI format2A 4 antennas (TDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } else if (frame_parms->frame_type == FDD) { + if (frame_parms->nb_antenna_ports_eNB == 2) { + switch(frame_parms->N_RB_DL) { + case 6: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint32_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2A 2 antennas (FDD, 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + switch(frame_parms->N_RB_DL) { + + case 6: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 25: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 50: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + case 100: + LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", + dci->rnti, + ((uint64_t*)&dci->dci_pdu)[0], + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + } + } + + else + LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); + + break; + + case format1E_2A_M10PRB: + + LOG_D(PHY,"DCI format1E_2A_M10PRB, rnti %x (%8x): harq_pid %d, rah %d, rb_alloc %x, mcs %d, rv %d, tpmi %d, ndi %d, dl_power_offset %d\n", + dci->rnti, + ((uint32_t *)&dci->dci_pdu)[0], + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->harq_pid, + //((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tb_swap, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rah, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rballoc, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->mcs, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rv, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tpmi, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->ndi, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->dl_power_off + ); + + break; + + default: + LOG_E(PHY,"dci_tools.c: dump_dci, unknown format %d\n",dci->format); + return(-1); + } + + return(0); +} diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common_extern.h b/openair1/PHY/LTE_TRANSPORT/dci_tools_common_extern.h new file mode 100644 index 0000000000000000000000000000000000000000..b0a06fb9f1e2359d0e512eb7a78effd1549d88a9 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common_extern.h @@ -0,0 +1,89 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/dci_tools_common_extern.h + * \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler. + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include <stdint.h> + +extern uint32_t localRIV2alloc_LUT6[32]; +extern uint32_t distRIV2alloc_even_LUT6[32]; +extern uint32_t distRIV2alloc_odd_LUT6[32]; +extern uint16_t RIV2nb_rb_LUT6[32]; +extern uint16_t RIV2first_rb_LUT6[32]; +extern uint16_t RIV_max6; + +extern uint32_t localRIV2alloc_LUT25[512]; +extern uint32_t distRIV2alloc_even_LUT25[512]; +extern uint32_t distRIV2alloc_odd_LUT25[512]; +extern uint16_t RIV2nb_rb_LUT25[512]; +extern uint16_t RIV2first_rb_LUT25[512]; +extern uint16_t RIV_max25; + + +extern uint32_t localRIV2alloc_LUT50_0[1600]; +extern uint32_t localRIV2alloc_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap0_even_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap0_odd_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap0_even_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap0_odd_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap1_even_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap1_odd_LUT50_0[1600]; +extern uint32_t distRIV2alloc_gap1_even_LUT50_1[1600]; +extern uint32_t distRIV2alloc_gap1_odd_LUT50_1[1600]; +extern uint16_t RIV2nb_rb_LUT50[1600]; +extern uint16_t RIV2first_rb_LUT50[1600]; +extern uint16_t RIV_max50; + +extern uint32_t localRIV2alloc_LUT100_0[6000]; +extern uint32_t localRIV2alloc_LUT100_1[6000]; +extern uint32_t localRIV2alloc_LUT100_2[6000]; +extern uint32_t localRIV2alloc_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap0_even_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap0_odd_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_0[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_1[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_2[6000]; +extern uint32_t distRIV2alloc_gap1_even_LUT100_3[6000]; +extern uint32_t distRIV2alloc_gap1_odd_LUT100_3[6000]; +extern uint16_t RIV2nb_rb_LUT100[6000]; +extern uint16_t RIV2first_rb_LUT100[6000]; +extern uint16_t RIV_max100; + +extern int8_t *delta_PUCCH_lut; +extern int8_t delta_PUSCH_acc[4]; +extern int8_t delta_PUSCH_abs[4]; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index e91665e04eb19e23b7544ba94c1aefb2ab3806fc..a726621022743e5daebaaee5cae84d536da3f267 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -30,18 +30,18 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "SCHED/defs.h" -#include "defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/LOG/log.h" #include <syscall.h> +#include "targets/RT/USER/rt_wrapper.h" //#define DEBUG_DLSCH_CODING //#define DEBUG_DLSCH_FREE 1 @@ -52,7 +52,13 @@ ((pilots==1)&&(first_pilot==0)&&(((re<3))||((re>5)&&(re<9)))) \ */ #define is_not_pilot(pilots,first_pilot,re) (1) +/*extern void thread_top_init(char *thread_name, + int affinity, + uint64_t runtime, + uint64_t deadline, + uint64_t period);*/ +extern int codingw; void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { @@ -244,11 +250,15 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) } + + int dlsch_encoding_2threads0(te_params *tep) { LTE_eNB_DLSCH_t *dlsch = tep->dlsch; unsigned int G = tep->G; unsigned char harq_pid = tep->harq_pid; + unsigned int total_worker = tep->total_worker; + unsigned int current_worker = tep->current_worker; unsigned short iind; @@ -261,7 +271,7 @@ int dlsch_encoding_2threads0(te_params *tep) { if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - for (r=0; r<dlsch->harq_processes[harq_pid]->C>>1; r++) { + for (r=(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*current_worker; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) { if (r<dlsch->harq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -304,21 +314,34 @@ int dlsch_encoding_2threads0(te_params *tep) { // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the // outputs for each code segment, see Section 5.1.5 p.20 - for (r=0; r<dlsch->harq_processes[harq_pid]->C>>1; r++) { - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r + for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) { + if(r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker)){ + int Nl=dlsch->harq_processes[harq_pid]->Nl; + int Qm=dlsch->harq_processes[harq_pid]->Qm; + int C = dlsch->harq_processes[harq_pid]->C; + int Gp = G/Nl/Qm; + int GpmodC = Gp%C; + if (r < (C-(GpmodC))) + r_offset += Nl*Qm * (Gp/C); + else + r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); + } + else{ + r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], + G, //G + dlsch->harq_processes[harq_pid]->w[r], + dlsch->harq_processes[harq_pid]->e+r_offset, + dlsch->harq_processes[harq_pid]->C, // C + dlsch->Nsoft, // Nsoft, + dlsch->Mdlharq, + dlsch->Kmimo, + dlsch->harq_processes[harq_pid]->rvidx, + dlsch->harq_processes[harq_pid]->Qm, + dlsch->harq_processes[harq_pid]->Nl, + r, + nb_rb); + // m); // r + } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT); @@ -326,32 +349,46 @@ int dlsch_encoding_2threads0(te_params *tep) { return(0); } + extern int oai_exit; void *te_thread(void *param) { + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + thread_top_init("te_thread",1,200000,250000,500000); pthread_setname_np( pthread_self(),"te processing"); - LOG_I(PHY,"thread te created id=%ld", syscall(__NR_gettid)); + LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid)); + - eNB_proc_t *proc = &((te_params *)param)->eNB->proc; + te_params *tep = (te_params *)param; + + //wait_sync("te_thread"); + while (!oai_exit) { + if (wait_on_condition(&tep->mutex_te,&tep->cond_te,&tep->instance_cnt_te,"te thread")<0) break; + if(oai_exit) break; - if (wait_on_condition(&proc->mutex_te,&proc->cond_te,&proc->instance_cnt_te,"te thread")<0) break; - - dlsch_encoding_2threads0((te_params*)param); - + dlsch_encoding_2threads0(tep); - if (release_thread(&proc->mutex_te,&proc->instance_cnt_te,"te thread")<0) break; + if (release_thread(&tep->mutex_te,&tep->instance_cnt_te,"te thread")<0) break; - if (pthread_cond_signal(&proc->cond_te) != 0) { + if (pthread_cond_signal(&tep->cond_te) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); exit_fun( "ERROR pthread_cond_signal" ); return(NULL); } + /*if(opp_enabled == 1 && te_wakeup_stats0->diff_now>50*3000){ + print_meas_now(te_wakeup_stats0,"coding_wakeup",stderr); + printf("te_thread0 delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + }*/ } return(NULL); } + + int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, unsigned char *a, uint8_t num_pdcch_symbols, @@ -360,9 +397,16 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, - time_stats_t *i_stats) + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats, + int worker_num) { + //start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); + LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; eNB_proc_t *proc = &eNB->proc; unsigned int G; @@ -382,19 +426,22 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, mod_order = dlsch->harq_processes[harq_pid]->Qm; G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe,dlsch->harq_processes[harq_pid]->mimo_mode==TM7?7:0); - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet + start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); // Add 24-bit crc (polynomial A) to payload crc = crc24a(a, A)>>8; + stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); a[A>>3] = ((uint8_t*)&crc)[2]; a[1+(A>>3)] = ((uint8_t*)&crc)[1]; a[2+(A>>3)] = ((uint8_t*)&crc)[0]; dlsch->harq_processes[harq_pid]->B = A+24; memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); + //stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); + start_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, @@ -406,34 +453,41 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, &dlsch->harq_processes[harq_pid]->F)<0) return(-1); - - - if (proc->instance_cnt_te==0) { - printf("[eNB] TE thread busy\n"); - exit_fun("TE thread busy"); - pthread_mutex_unlock( &proc->mutex_te ); - return(-1); - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); - ++proc->instance_cnt_te; - - proc->tep.eNB = eNB; - proc->tep.dlsch = dlsch; - proc->tep.G = G; - proc->tep.harq_pid = harq_pid; - - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); + stop_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); + + start_meas(&eNB->dlsch_turbo_encoding_signal_stats); + for(int i=0;i<worker_num;i++) + { + proc->tep[i].eNB = eNB; + proc->tep[i].dlsch = dlsch; + proc->tep[i].G = G; + proc->tep[i].harq_pid = harq_pid; + proc->tep[i].total_worker = worker_num; + proc->tep[i].current_worker = i; + + pthread_mutex_lock( &proc->tep[i].mutex_te ); + if (proc->tep[i].instance_cnt_te==0) { + printf("[eNB] TE thread busy\n"); + exit_fun("TE thread busy"); + pthread_mutex_unlock( &proc->tep[i].mutex_te ); + return(-1); + } + + ++proc->tep[i].instance_cnt_te; + + // wakeup worker to do segments + if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread %d exit\n",i); + exit_fun( "ERROR pthread_cond_signal" ); + return (-1); + } + + pthread_mutex_unlock( &proc->tep[i].mutex_te ); } - pthread_mutex_unlock( &proc->mutex_te ); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); - for (r=dlsch->harq_processes[harq_pid]->C>>1; r<dlsch->harq_processes[harq_pid]->C; r++) { + stop_meas(&eNB->dlsch_turbo_encoding_signal_stats); + start_meas(te_main_stats); + for (r=(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num; r<dlsch->harq_processes[harq_pid]->C; r++) { if (r<dlsch->harq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -478,15 +532,18 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, } else { - proc->tep.eNB = eNB; - proc->tep.dlsch = dlsch; - proc->tep.G = G; - - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te) != 0) { + for(int i=0;i<worker_num;i++) + { + proc->tep[i].eNB = eNB; + proc->tep[i].dlsch = dlsch; + proc->tep[i].G = G; + proc->tep[i].total_worker = worker_num; + proc->tep[i].current_worker = i; + if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); exit_fun( "ERROR pthread_cond_signal" ); return (-1); + } } } @@ -496,7 +553,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, for (r=0,r_offset=0; r<dlsch->harq_processes[harq_pid]->C; r++) { // get information for E for the segments that are handled by the worker thread - if (r<(dlsch->harq_processes[harq_pid]->C>>1)) { + if (r<(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num) { int Nl=dlsch->harq_processes[harq_pid]->Nl; int Qm=dlsch->harq_processes[harq_pid]->Qm; int C = dlsch->harq_processes[harq_pid]->C; @@ -526,16 +583,138 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, stop_meas(rm_stats); } } + stop_meas(te_main_stats); - // wait for worker to finish - - wait_on_busy_condition(&proc->mutex_te,&proc->cond_te,&proc->instance_cnt_te,"te thread"); + start_meas(te_wait_stats); + if(worker_num == 1) + { + wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); + } + else if(worker_num == 2) + { + wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); + wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); + } + else + { + wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); + wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); + wait_on_busy_condition(&proc->tep[2].mutex_te,&proc->tep[2].cond_te,&proc->tep[2].instance_cnt_te,"te thread 2"); + } + stop_meas(te_wait_stats); + + /*if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){ + print_meas_now(te_wait_stats,"coding_wait",stderr); + printf("coding delay in wait on codition in frame_rx: %d \n",proc->frame_rx); + }*/ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); return(0); } +int dlsch_encoding_all(PHY_VARS_eNB *eNB, + unsigned char *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats) +{ + int encoding_return = 0; + unsigned int L,C,B; + B = dlsch->harq_processes[dlsch->harq_ids[subframe]]->B; + if(B<=6144) + { + L=0; + C=1; + } + else + { + L=24; + C = B/(6144-L); + if((6144-L)*C < B) + { + C = C+1; + } + } + + if(C >= 8 && get_nprocs()>=16 && codingw)//one main three worker + { + encoding_return = + dlsch_encoding_2threads(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + te_wait_stats, + te_main_stats, + te_wakeup_stats0, + te_wakeup_stats1, + i_stats, + 3); + } + else if(C >= 6 && get_nprocs()>=8 && codingw)//one main two worker + { + encoding_return = + dlsch_encoding_2threads(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + te_wait_stats, + te_main_stats, + te_wakeup_stats0, + te_wakeup_stats1, + i_stats, + 2); + } + else if(C >= 4 && get_nprocs()>=4 && codingw)//one main one worker + { + encoding_return = + dlsch_encoding_2threads(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + te_wait_stats, + te_main_stats, + te_wakeup_stats0, + te_wakeup_stats1, + i_stats, + 1); + } + else + { + encoding_return = + dlsch_encoding(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + i_stats); + } + return encoding_return; +} + int dlsch_encoding(PHY_VARS_eNB *eNB, unsigned char *a, @@ -720,186 +899,6 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, } -int dlsch_encoding_SIC(PHY_VARS_UE *ue, - unsigned char *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *i_stats) -{ - - unsigned int G; - unsigned int crc=1; - unsigned short iind; - - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - unsigned char harq_pid = ue->dlsch[subframe&2][0][0]->rnti; - unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; - unsigned int A; - unsigned char mod_order; - unsigned int Kr=0,Kr_bytes,r,r_offset=0; - // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; - uint8_t beamforming_mode=0; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); - - A = dlsch->harq_processes[harq_pid]->TBS; //6228 - // printf("Encoder: A: %d\n",A); - mod_order = dlsch->harq_processes[harq_pid]->Qm; - - if(dlsch->harq_processes[harq_pid]->mimo_mode == TM7) - beamforming_mode = 7; - else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM8) - beamforming_mode = 8; - else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM9_10) - beamforming_mode = 9; - G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe,beamforming_mode); - - - // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet -#ifdef DEBUG_DLSCH_CODING - printf("SIC encoding thinks this is a new packet \n"); -#endif - /* - int i; - printf("dlsch (tx): \n"); - for (i=0;i<(A>>3);i++) - printf("%02x.",a[i]); - printf("\n"); - */ - // Add 24-bit crc (polynomial A) to payload - crc = crc24a(a, - A)>>8; - a[A>>3] = ((uint8_t*)&crc)[2]; - a[1+(A>>3)] = ((uint8_t*)&crc)[1]; - a[2+(A>>3)] = ((uint8_t*)&crc)[0]; - // printf("CRC %x (A %d)\n",crc,A); - - dlsch->harq_processes[harq_pid]->B = A+24; - // dlsch->harq_processes[harq_pid]->b = a; - memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); - - if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, - dlsch->harq_processes[harq_pid]->c, - dlsch->harq_processes[harq_pid]->B, - &dlsch->harq_processes[harq_pid]->C, - &dlsch->harq_processes[harq_pid]->Cplus, - &dlsch->harq_processes[harq_pid]->Cminus, - &dlsch->harq_processes[harq_pid]->Kplus, - &dlsch->harq_processes[harq_pid]->Kminus, - &dlsch->harq_processes[harq_pid]->F)<0) - return(-1); - - for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { - - if (r<dlsch->harq_processes[harq_pid]->Cminus) - Kr = dlsch->harq_processes[harq_pid]->Kminus; - else - Kr = dlsch->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; - - // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) - if (Kr_bytes<=64) - iind = (Kr_bytes-5); - else if (Kr_bytes <=128) - iind = 59 + ((Kr_bytes-64)>>1); - else if (Kr_bytes <= 256) - iind = 91 + ((Kr_bytes-128)>>2); - else if (Kr_bytes <= 768) - iind = 123 + ((Kr_bytes-256)>>3); - else { - printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); - return(-1); - } - - -#ifdef DEBUG_DLSCH_CODING - printf("Generating Code Segment %d (%d bits)\n",r,Kr); - // generate codewords - - printf("bits_per_codeword (Kr)= %d, A %d\n",Kr,A); - printf("N_RB = %d\n",nb_rb); - printf("Ncp %d\n",frame_parms->Ncp); - printf("mod_order %d\n",mod_order); -#endif - - -#ifdef DEBUG_DLSCH_CODING - printf("Encoding ... iind %d f1 %d, f2 %d\n",iind,f1f2mat_old[iind*2],f1f2mat_old[(iind*2)+1]); -#endif - start_meas(te_stats); - encoder(dlsch->harq_processes[harq_pid]->c[r], - Kr>>3, - &dlsch->harq_processes[harq_pid]->d[r][96], - (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, - f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) - f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) - ); - stop_meas(te_stats); -#ifdef DEBUG_DLSCH_CODING - - if (r==0) - write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[r][96],(3*8*Kr_bytes)+12,1,4); - -#endif - start_meas(i_stats); - dlsch->harq_processes[harq_pid]->RTC[r] = - sub_block_interleaving_turbo(4+(Kr_bytes*8), - &dlsch->harq_processes[harq_pid]->d[r][96], - dlsch->harq_processes[harq_pid]->w[r]); - stop_meas(i_stats); - } - - } - - // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the - // outputs for each code segment, see Section 5.1.5 p.20 - - for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { -#ifdef DEBUG_DLSCH_CODING - printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", - r, - G, - Kr*3, - mod_order,nb_rb); -#endif - - start_meas(rm_stats); -#ifdef DEBUG_DLSCH_CODING - printf("rvidx in SIC encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx); -#endif - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r - stop_meas(rm_stats); -#ifdef DEBUG_DLSCH_CODING - - if (r==dlsch->harq_processes[harq_pid]->C-1) - write_output("enc_output.m","enc",dlsch->harq_processes[harq_pid]->e,r_offset,1,4); - -#endif - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); - - return(0); -} diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index f3a9a05ae5be7f7efe889d6fdafd34b4ad0b4345..a2f8f08073827072f130f0424bc019a3e7e4c97c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -29,16 +29,17 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" -//#define DEBUG_DLSCH_MODULATION 1 +//#define DEBUG_DLSCH_MODULATION +#define NEW_ALLOC_RE //#define is_not_pilot(pilots,re,nushift,use2ndpilots) ((pilots==0) || ((re!=nushift) && (re!=nushift+6)&&((re!=nushift+3)||(use2ndpilots==1))&&((re!=nushift+9)||(use2ndpilots==1)))?1:0) @@ -94,32 +95,8 @@ uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, return(0); } -void generate_64qam_table(void) -{ - - int a,b,c,index; - for (a=-1; a<=1; a+=2) - for (b=-1; b<=1; b+=2) - for (c=-1; c<=1; c+=2) { - index = (1+a)*2 + (1+b) + (1+c)/2; - qam64_table[index] = -a*(QAM64_n1 + b*(QAM64_n2 + (c*QAM64_n3))); // 0 1 2 - } -} - -void generate_16qam_table(void) -{ - - int a,b,index; - - for (a=-1; a<=1; a+=2) - for (b=-1; b<=1; b+=2) { - index = (1+a) + (1+b)/2; - qam16_table[index] = -a*(QAM16_n1 + (b*QAM16_n2)); - } -} - @@ -157,6 +134,158 @@ void layer1prec2A(int32_t *antenna0_sample, int32_t *antenna1_sample, uint8_t pr uint32_t FOUR[2]={0,4}; uint32_t TWO[2]={0,2}; +int allocate_REs_in_RB_no_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB, + int **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + uint8_t precoder_index, + int16_t *qam_table_s0, + int16_t *qam_table_s1, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t lprime, + uint8_t mprime, + uint8_t Ns, + int *P1_SHIFT, + int *P2_SHIFT) +{ + + LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms; + uint8_t *x0 = dlsch0_harq->e; + uint32_t qpsk_table_offset_re = 0; + uint32_t qpsk_table_offset_im = 0; + + uint32_t tti_offset; + uint8_t re; + uint8_t *x0p; + + if (skip_dc == 0) { + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset,re=0; + re<12; + re++,x0p+=2,tti_offset++) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + } + } + else { + // 1st half of PRB + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset,re=0; + re<6; + re++,x0p+=2,tti_offset++) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + } + // 2nd half of PRB + for (tti_offset=symbol_offset+re_offset-frame_parms->ofdm_symbol_size+7; + re<12; + re++,x0p+=2,tti_offset++) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + } + } + *re_allocated = *re_allocated + 12; + *jj=*jj + 24; + + return(0); +} + +int allocate_REs_in_RB_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB, + int **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + uint8_t precoder_index, + int16_t *qam_table_s0, + int16_t *qam_table_s1, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t lprime, + uint8_t mprime, + uint8_t Ns, + int *P1_SHIFT, + int *P2_SHIFT) +{ + + + LTE_DL_FRAME_PARMS *frame_parms=&phy_vars_eNB->frame_parms; + + uint8_t *x0 = dlsch0_harq->e; + uint32_t qpsk_table_offset_re = 0; + uint32_t qpsk_table_offset_im = 0; + + uint32_t tti_offset; + uint8_t re; + uint8_t *x0p; + + + if (skip_dc == 0) { + // printf("pilots: P1_SHIFT[0] %d\n",P1_SHIFT[0]); + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset+P1_SHIFT[0],re=P1_SHIFT[0]; + re<12; + x0p+=2) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + // printf("pilots: re %d, tti_offset %d, P1_SHIFT %d\n",re,tti_offset,P1_SHIFT[re+1]); + tti_offset+=P1_SHIFT[re+1]; + re+=P1_SHIFT[re+1]; + } + } + else { + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset+P1_SHIFT[0],re=P1_SHIFT[0]; + re<6; + x0p+=2) { + + qpsk_table_offset_re+=x0p[0]; + qpsk_table_offset_im+=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + tti_offset+=P1_SHIFT[re+1]; + re+=P1_SHIFT[re+1]; + } + + for (tti_offset=symbol_offset+re_offset-frame_parms->ofdm_symbol_size+6+P1_SHIFT[6]; + re<12; + x0p+=2) { + + qpsk_table_offset_re+=x0p[0]; + qpsk_table_offset_im+=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + tti_offset+=P1_SHIFT[re+1]; + re+=P1_SHIFT[re+1]; + } + } + *re_allocated = *re_allocated + 10; + *jj=*jj + 20; + + return(0); +} + int allocate_REs_in_RB_no_pilots_16QAM_siso(PHY_VARS_eNB* phy_vars_eNB, int **txdataF, uint32_t *jj, @@ -1806,48 +1935,6 @@ int allocate_REs_in_RB_MCH(int32_t **txdataF, return(0); } -uint8_t get_pmi(uint8_t N_RB_DL, MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb) -{ - /* - MIMO_mode_t mode = dlsch_harq->mimo_mode; - uint32_t pmi_alloc = dlsch_harq->pmi_alloc; - */ - - switch (N_RB_DL) { - case 6: // 1 PRB per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>(rb<<1))&3); - else - return((pmi_alloc>>rb)&1); - - break; - - default: - case 25: // 4 PRBs per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>((rb>>2)<<1))&3); - else - return((pmi_alloc>>(rb>>2))&1); - - break; - - case 50: // 6 PRBs per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>((rb/6)<<1))&3); - else - return((pmi_alloc>>(rb/6))&1); - - break; - - case 100: // 8 PRBs per subband - if (mode <= PUSCH_PRECODING1) - return((pmi_alloc>>((rb>>3)<<1))&3); - else - return((pmi_alloc>>(rb>>3))&1); - - break; - } -} inline int check_skip(int rb,int subframe_offset,LTE_DL_FRAME_PARMS *frame_parms,int l,int nsymb) __attribute__((always_inline)); @@ -2011,11 +2098,11 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, uint8_t mod_order0 = 0; uint8_t mod_order1 = 0; int16_t amp_rho_a, amp_rho_b; - int16_t qam16_table_a0[4],qam64_table_a0[8],qam16_table_b0[4],qam64_table_b0[8]; - int16_t qam16_table_a1[4],qam64_table_a1[8],qam16_table_b1[4],qam64_table_b1[8]; + int16_t qam16_table_a0[4],qam64_table_a0[8],qam16_table_b0[4],qam64_table_b0[8];//qpsk_table_a0[2],qpsk_table_b0[2] + int16_t qam16_table_a1[4],qam64_table_a1[8],qam16_table_b1[4],qam64_table_b1[8];//qpsk_table_a1[2],qpsk_table_b1[2] int16_t *qam_table_s0=NULL,*qam_table_s1=NULL; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: variable to be removed? */ int (*allocate_REs)(PHY_VARS_eNB*, int **, @@ -2125,8 +2212,15 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, amp_rho_b = (int16_t)(((int32_t)amp*dlsch1->sqrt_rho_b)>>13); } - - if (mod_order0 == 4) + /*if(mod_order0 == 2) + { + for(i=0;i<2;i++) + { + qpsk_table_a0[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_a)>>15); + qpsk_table_b0[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15); + } + } + else*/ if (mod_order0 == 4) for (i=0;i<4; i++) { qam16_table_a0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15); qam16_table_b0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15); @@ -2137,7 +2231,14 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, qam64_table_b0[i] = (int16_t)(((int32_t)qam64_table[i]*amp_rho_b)>>15); } - if (mod_order1 == 4) + /*if (mod_order1 == 2) + { + for (i=0; i<2; i++) { + qpsk_table_a1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_a)>>15); + qpsk_table_b1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15); + } + } + else*/ if (mod_order1 == 4) for (i=0; i<4; i++) { qam16_table_a1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15); qam16_table_b1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15); @@ -2259,7 +2360,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, re_offset = frame_parms->first_carrier_offset; symbol_offset = (uint32_t)frame_parms->ofdm_symbol_size*(l+(subframe_offset*nsymb)); -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = allocate_REs_in_RB; #endif @@ -2267,11 +2368,30 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order0) { case 2: qam_table_s0 = NULL; + /*if (pilots) { + qam_table_s0 = qpsk_table_b0; +#ifdef NEW_ALLOC_RE + // TODO: remove this code? // + allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? + allocate_REs_in_RB_pilots_QPSK_siso : + allocate_REs_in_RB; +#endif + } + else { + qam_table_s0 = qpsk_table_a0; +#ifdef NEW_ALLOC_RE + // TODO: remove this code? // + allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? + allocate_REs_in_RB_no_pilots_QPSK_siso : + allocate_REs_in_RB; +#endif + + }*/ break; case 4: if (pilots) { qam_table_s0 = qam16_table_b0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_pilots_16QAM_siso : @@ -2280,7 +2400,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, } else { qam_table_s0 = qam16_table_a0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_no_pilots_16QAM_siso : @@ -2293,7 +2413,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, case 6: if (pilots) { qam_table_s0 = qam64_table_b0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_pilots_64QAM_siso : @@ -2302,7 +2422,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, } else { qam_table_s0 = qam64_table_a0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_no_pilots_64QAM_siso : @@ -2316,10 +2436,16 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order1) { case 2: qam_table_s1 = NULL; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = allocate_REs_in_RB; #endif + /*if (pilots) { + qam_table_s1 = qpsk_table_b1; + } + else { + qam_table_s1 = qpsk_table_a1; + }*/ break; case 4: if (pilots) { diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c index 8d650bbe217db458bcacef79a463469c66c6813a..c1f80c40a4c1816525e9f51921f34866734f13d4 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c @@ -32,12 +32,12 @@ //#define DEBUG_SCRAMBLING 1 -#include "PHY/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "defs.h" -#include "extern.h" -#include "PHY/extern.h" +#include "transport_eNB.h" +#include "PHY/phy_extern.h" #include "UTIL/LOG/vcd_signal_dumper.h" static inline unsigned int lte_gold_scram(unsigned int *x1, unsigned int *x2, unsigned char reset) __attribute__((always_inline)); @@ -87,7 +87,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_SCRAMBLING, VCD_FUNCTION_IN); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) // Rule for accumulation of subframes for BL/CE UEs uint8_t Nacc=4; uint16_t j0,j,idelta; @@ -110,7 +110,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, // reset = 1; // x1 is set in lte_gold_generic if (mbsfn_flag == 0) { -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (dlsch->i0 != 0xFFFF) { // rule for BL/CE UEs from Section 6.3.1 in 36.211 x2= (dlsch->rnti<<14) + (q<<13) + ((((j0+j)*Nacc)%10)<<9) + frame_parms->Nid_cell; @@ -124,7 +124,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, } #ifdef DEBUG_SCRAMBLING -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) printf("scrambling: i0 %d rnti %x, q %d, Ns %d, Nid_cell %d, G %d x2 %x\n",dlsch->i0,dlsch->rnti,q,Ns,frame_parms->Nid_cell, G, x2); #else printf("scrambling: rnti %x, q %d, Ns %d, Nid_cell %d, G %d x2 %x\n",dlsch->rnti,q,Ns,frame_parms->Nid_cell, G, x2); @@ -187,6 +187,20 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, } + + +void init_scrambling_lut(void) { + + uint32_t s; + int i=0,j; + + for (s=0;s<=65535;s++) { + for (j=0;j<16;j++) { + scrambling_lut[i++] = (uint8_t)((s>>j)&1); + } + } +} + void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, int mbsfn_flag, LTE_UE_DLSCH_t *dlsch, @@ -228,7 +242,7 @@ void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, } } -void init_unscrambling_lut() { +void init_unscrambling_lut(void) { uint32_t s; int i=0,j; @@ -239,15 +253,3 @@ void init_unscrambling_lut() { } } } - -void init_scrambling_lut() { - - uint32_t s; - int i=0,j; - - for (s=0;s<=65535;s++) { - for (j=0;j<16;j++) { - scrambling_lut[i++] = (uint8_t)((s>>j)&1); - } - } -} diff --git a/openair1/PHY/LTE_TRANSPORT/edci.c b/openair1/PHY/LTE_TRANSPORT/edci.c index 5caf5bcd710f6da6e42ded836e5eca0ed547082e..ca60fd40618b7c2b6f7b5458883c3f6b34d717dc 100755 --- a/openair1/PHY/LTE_TRANSPORT/edci.c +++ b/openair1/PHY/LTE_TRANSPORT/edci.c @@ -32,21 +32,23 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "SIMULATION/TOOLS/sim.h" // for taus #include "PHY/sse_intrin.h" - +#include "transport_proto.h" +#include "transport_common_proto.h" #include "assertions.h" #include "T.h" #include "UTIL/LOG/log.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_DCI_ENCODING 1 //#define DEBUG_DCI_DECODING 1 //#define DEBUG_PHY -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void generate_edci_top(PHY_VARS_eNB *eNB, int frame, int subframe) { } diff --git a/openair1/PHY/LTE_TRANSPORT/group_hopping.c b/openair1/PHY/LTE_TRANSPORT/group_hopping.c index a7c8921c2ca0c10a76b666c9b79995b0fb8e10c1..6fc1f0a3e44ade5363eeaa05ce409ec711f135ee 100644 --- a/openair1/PHY/LTE_TRANSPORT/group_hopping.c +++ b/openair1/PHY/LTE_TRANSPORT/group_hopping.c @@ -29,7 +29,8 @@ * \note * \warning */ -#include "PHY/defs.h" +#include "PHY/defs_common.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_GROUPHOP 1 diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 88312e4a4611af3cab61f73476e003429fc4e073..986f97c23f930141208bb2e56b5b279bd241647c 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -30,10 +30,10 @@ * \warning */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "PHY/TOOLS/alaw_lut.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" //#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" @@ -47,7 +47,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { int32_t **txdataF = ru->common.txdataF_BF; int32_t **rxdataF = ru->common.rxdataF; int16_t **prach_rxsigF = ru->prach_rxsigF; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int16_t ***prach_rxsigF_br = ru->prach_rxsigF_br; #endif void *tx_buffer = ru->ifbuffer.tx[subframe&1]; @@ -221,7 +221,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { int16_t *rxF; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (packet_type > IF4p5_PRACH) rxF = &prach_rxsigF_br[packet_type - IF4p5_PRACH - 1][0][0]; else @@ -262,7 +262,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint int32_t **txdataF = ru->common.txdataF_BF; int32_t **rxdataF = ru->common.rxdataF; int16_t **prach_rxsigF = ru->prach_rxsigF; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int16_t ***prach_rxsigF_br = ru->prach_rxsigF_br; #endif void *rx_buffer = ru->ifbuffer.rx; @@ -359,7 +359,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint int16_t *rxF; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (*packet_type > IF4p5_PRACH) rxF = &prach_rxsigF_br[*packet_type - IF4p5_PRACH - 1][0][0]; else diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h index 0a95e60ead3c7af2bad4c55e73f742fc0308e4f1..4fcf537f832bcbbfb6ffc1a53213f8a1a2bde30f 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h @@ -32,7 +32,7 @@ #ifndef __IF4_TOOLS_H__ #define __IF4_TOOLS_H__ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" /// Macro for IF4 packet type #define IF4p5_PACKET_TYPE 0x080A diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c index b160318a6ee9899366430f656c2f300582a53251..06b4a4ad806fd746323c678dc8a568379f73c82a 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c @@ -30,7 +30,7 @@ * \warning */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "PHY/TOOLS/alaw_lut.h" #include "time_utils.h" diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.h b/openair1/PHY/LTE_TRANSPORT/if5_tools.h index 84ad5305261b2fa29bbc6fb20aec20f9013715c4..0f24f7becee0334c1e2d900a5b79133bb9130ba8 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.h @@ -34,7 +34,7 @@ #define __IF5_TOOLS_H__ #include <stdint.h> -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #define IF5_RRH_GW_DL 0x0022 #define IF5_RRH_GW_UL 0x0023 diff --git a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c index 910610b9694c806262928ccd891a5d38f7128150..a66344611b8c61921472f70b3a2766d9e6586cfe 100644 --- a/openair1/PHY/LTE_TRANSPORT/lte_mcs.c +++ b/openair1/PHY/LTE_TRANSPORT/lte_mcs.c @@ -30,9 +30,9 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/LTE_TRANSPORT/proto.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" unsigned char get_Qm(unsigned char I_MCS) { diff --git a/openair1/PHY/LTE_TRANSPORT/mdci.h b/openair1/PHY/LTE_TRANSPORT/mdci.h index 060227eac033a3f979d32b29077b5de1f0aaa577..7be278530860fc88792c315130f62e84d77d4292 100644 --- a/openair1/PHY/LTE_TRANSPORT/mdci.h +++ b/openair1/PHY/LTE_TRANSPORT/mdci.h @@ -30,6 +30,9 @@ * \warning */ +#ifndef __M_DCI__H__ +#define __M_DCI__H__ + #include <stdint.h> @@ -467,3 +470,4 @@ struct DCI6_2_di_20MHz { typedef struct DCI6_2_di_20MHz DCI6_2_di_20MHz_t; #define sizeof_DCI6_2_20MHz_t 13 +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c index 9e5b6757fc84e9411c32e28fecd2465b575aac0b..eae88a6afeb794deade5d27373be0bebf142a91f 100644 --- a/openair1/PHY/LTE_TRANSPORT/pbch.c +++ b/openair1/PHY/LTE_TRANSPORT/pbch.c @@ -29,13 +29,14 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "defs.h" -#include "extern.h" -#include "PHY/extern.h" +#include "transport_eNB.h" +#include "transport_proto.h" +#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_PBCH 1 //#define DEBUG_PBCH_ENCODING @@ -138,6 +139,31 @@ int allocate_pbch_REs_in_RB(LTE_DL_FRAME_PARMS *frame_parms, return(0); } +void pbch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t *pbch_e, + uint32_t length) +{ + int i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in lte_gold_generic + x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 + // msg("pbch_scrambling: Nid_cell = %d\n",x2); + + for (i=0; i<length; i++) { + if ((i&0x1f)==0) { + s = lte_gold_generic(&x1, &x2, reset); + // printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + pbch_e[i] = (pbch_e[i]&1) ^ ((s>>(i&0x1f))&1); + + } +} + //uint8_t pbch_d[96+(3*(16+PBCH_A))], pbch_w[3*3*(16+PBCH_A)],pbch_e[1920]; //one bit per byte int generate_pbch(LTE_eNB_PBCH *eNB_pbch, int32_t **txdataF, @@ -393,623 +419,5 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch, return(0); } -int32_t generate_pbch_emul(PHY_VARS_eNB *phy_vars_eNB,uint8_t *pbch_pdu) -{ - - LOG_D(PHY,"[eNB %d] generate_pbch_emul \n",phy_vars_eNB->Mod_id); - eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].cntl.pbch_flag=1; - // Copy PBCH payload - eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].cntl.pbch_payload=*(uint32_t *)pbch_pdu; - return(0); -} - -uint16_t pbch_extract(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - uint32_t symbol, - uint32_t high_speed_flag, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - - uint16_t rb,nb_rb=6; - uint8_t i,j,aarx,aatx; - int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; - - uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; - uint32_t symbol_mod = symbol % nsymb; - - int rx_offset = frame_parms->ofdm_symbol_size-3*12; - int ch_offset = frame_parms->N_RB_DL*6-3*12; - int nushiftmod3 = frame_parms->nushift%3; - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - /* - printf("extract_rbs (nushift %d): symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",frame_parms->nushift,symbol_mod, - (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, - LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); - */ - - rxF = &rxdataF[aarx][(rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; - rxF_ext = &rxdataF_ext[aarx][symbol_mod*(6*12)]; - - for (rb=0; rb<nb_rb; rb++) { - // skip DC carrier - if (rb==3) { - rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; - } - - if ((symbol_mod==0) || (symbol_mod==1)) { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - rxF_ext[j++]=rxF[i]; - } - } - - rxF+=12; - rxF_ext+=8; - } else { - for (i=0; i<12; i++) { - rxF_ext[i]=rxF[i]; - } - - rxF+=12; - rxF_ext+=12; - } - } - - for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { - if (high_speed_flag == 1) - dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset+(symbol*(frame_parms->ofdm_symbol_size))]; - else - dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset]; - - dl_ch0_ext = &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*(6*12)]; - - for (rb=0; rb<nb_rb; rb++) { - // skip DC carrier - // if (rb==3) dl_ch0++; - if (symbol_mod>1) { - memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int)); - dl_ch0+=12; - dl_ch0_ext+=12; - } else { - j=0; - - for (i=0; i<12; i++) { - if ((i!=nushiftmod3) && - (i!=(nushiftmod3+3)) && - (i!=(nushiftmod3+6)) && - (i!=(nushiftmod3+9))) { - // printf("PBCH extract i %d j %d => (%d,%d)\n",i,j,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - dl_ch0_ext[j++]=dl_ch0[i]; - } - } - - dl_ch0+=12; - dl_ch0_ext+=8; - } - } - } //tx antenna loop - - } - - return(0); -} - -//__m128i avg128; - -//compute average channel_level on each (TX,RX) antenna pair -int pbch_channel_level(int **dl_ch_estimates_ext, - LTE_DL_FRAME_PARMS *frame_parms, - uint32_t symbol) -{ - - int16_t rb, nb_rb=6; - uint8_t aatx,aarx; - -#if defined(__x86_64__) || defined(__i386__) - __m128i avg128; - __m128i *dl_ch128; -#elif defined(__arm__) - int32x4_t avg128; - int16x8_t *dl_ch128; -#endif - int avg1=0,avg2=0; - - uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; - uint32_t symbol_mod = symbol % nsymb; - - for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - //clear average level - -#if defined(__x86_64__) || defined(__i386__) - avg128 = _mm_setzero_si128(); - dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; -#elif defined(__arm__) - avg128 = vdupq_n_s32(0); - dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; - -#endif - for (rb=0; rb<nb_rb; rb++) { -#if defined(__x86_64__) || defined(__i386__) - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); -#elif defined(__arm__) -// to be filled in -#endif - dl_ch128+=3; - /* - if (rb==0) { - print_shorts("dl_ch128",&dl_ch128[0]); - print_shorts("dl_ch128",&dl_ch128[1]); - print_shorts("dl_ch128",&dl_ch128[2]); - } - */ - } - - avg1 = (((int*)&avg128)[0] + - ((int*)&avg128)[1] + - ((int*)&avg128)[2] + - ((int*)&avg128)[3])/(nb_rb*12); - - if (avg1>avg2) - avg2 = avg1; - - //msg("Channel level : %d, %d\n",avg1, avg2); - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - return(avg2); - -} - -#if defined(__x86_64__) || defined(__i386__) -__m128i mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; -#elif defined(__arm__) -int16x8_t mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; -#endif -void pbch_channel_compensation(int **rxdataF_ext, - int **dl_ch_estimates_ext, - int **rxdataF_comp, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - uint8_t output_shift) -{ - - uint16_t rb,nb_rb=6; - uint8_t aatx,aarx,symbol_mod; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; -#elif defined(__arm__) - -#endif - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - - for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol_mod*6*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol_mod*6*12]; - -#elif defined(__arm__) -// to be filled in -#endif - - for (rb=0; rb<nb_rb; rb++) { - //printf("rb %d\n",rb); -#if defined(__x86_64__) || defined(__i386__) - // multiply by conjugated channel - mmtmpP0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpP0); - // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) - mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpP1); - mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[0]); - // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); - // print_ints("re(shift)",&mmtmpP0); - mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); - // print_ints("im(shift)",&mmtmpP1); - mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); - mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); - // print_ints("c0",&mmtmpP2); - // print_ints("c1",&mmtmpP3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpP0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); - // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) - mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); - mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[1]); - // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); - mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); - mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); - mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - - if (symbol_mod>1) { - // multiply by conjugated channel - mmtmpP0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); - // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) - mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); - mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); - mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[2]); - // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); - mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); - mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); - mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128+2); - // print_shorts("ch:",dl_ch128+2); - // print_shorts("pack:",rxdataF_comp128+2); - - dl_ch128+=3; - rxdataF128+=3; - rxdataF_comp128+=3; - } else { - dl_ch128+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } -#elif defined(__arm__) -// to be filled in -#endif - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void pbch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - uint8_t symbol) -{ - - uint8_t aatx, symbol_mod; - int i, nb_rb=6; -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; -#endif - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - - if (frame_parms->nb_antennas_rx>1) { - for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; - -#endif - // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) - for (i=0; i<nb_rb*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); - -#endif - } - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void pbch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t *pbch_e, - uint32_t length) -{ - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in lte_gold_generic - x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 - // msg("pbch_scrambling: Nid_cell = %d\n",x2); - - for (i=0; i<length; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - pbch_e[i] = (pbch_e[i]&1) ^ ((s>>(i&0x1f))&1); - - } -} - -void pbch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, - int8_t* llr, - uint32_t length, - uint8_t frame_mod4) -{ - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in first call to lte_gold_generic - x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 - // msg("pbch_unscrambling: Nid_cell = %d\n",x2); - - for (i=0; i<length; i++) { - if (i%32==0) { - s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - // take the quarter of the PBCH that corresponds to this frame - if ((i>=(frame_mod4*(length>>2))) && (i<((1+frame_mod4)*(length>>2)))) { - - if (((s>>(i%32))&1)==0) - llr[i] = -llr[i]; - } - } -} - -void pbch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - uint8_t symbol) -{ - - int16_t *rxF0,*rxF1; - // __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b; - uint8_t rb,re,symbol_mod; - int jj; - // printf("Doing alamouti\n"); - symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; - jj = (symbol_mod*6*12); - - rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y - rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y - - for (rb=0; rb<6; rb++) { - - for (re=0; re<12; re+=2) { - - // Alamouti RX combining - - rxF0[0] = rxF0[0] + rxF1[2]; - rxF0[1] = rxF0[1] - rxF1[3]; - - rxF0[2] = rxF0[2] - rxF1[0]; - rxF0[3] = rxF0[3] + rxF1[1]; - - rxF0+=4; - rxF1+=4; - } - - } - -} - -void pbch_quantize(int8_t *pbch_llr8, - int16_t *pbch_llr, - uint16_t len) -{ - - uint16_t i; - - for (i=0; i<len; i++) { - if (pbch_llr[i]>7) - pbch_llr8[i]=7; - else if (pbch_llr[i]<-8) - pbch_llr8[i]=-8; - else - pbch_llr8[i] = (char)(pbch_llr[i]); - - } -} - -static unsigned char dummy_w_rx[3*3*(16+PBCH_A)]; -static int8_t pbch_w_rx[3*3*(16+PBCH_A)],pbch_d_rx[96+(3*(16+PBCH_A))]; - - -uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars, - LTE_UE_PBCH *lte_ue_pbch_vars, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t eNB_id, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t frame_mod4) -{ - - uint8_t log2_maxh;//,aatx,aarx; - int max_h=0; - - int symbol,i; - uint32_t nsymb = (frame_parms->Ncp==0) ? 14:12; - uint16_t pbch_E; - uint8_t pbch_a[8]; - uint8_t RCC; - - int8_t *pbch_e_rx; - uint8_t *decoded_output = lte_ue_pbch_vars->decoded_output; - uint16_t crc; - - - // pbch_D = 16+PBCH_A; - - pbch_E = (frame_parms->Ncp==0) ? 1920 : 1728; //RE/RB * #RB * bits/RB (QPSK) - pbch_e_rx = <e_ue_pbch_vars->llr[frame_mod4*(pbch_E>>2)]; -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode); -#endif - - // clear LLR buffer - memset(lte_ue_pbch_vars->llr,0,pbch_E); - - for (symbol=(nsymb>>1); symbol<(nsymb>>1)+4; symbol++) { - -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] starting extract\n"); -#endif - pbch_extract(lte_ue_common_vars->common_vars_rx_data_per_thread[0].rxdataF, - lte_ue_common_vars->common_vars_rx_data_per_thread[0].dl_ch_estimates[eNB_id], - lte_ue_pbch_vars->rxdataF_ext, - lte_ue_pbch_vars->dl_ch_estimates_ext, - symbol, - high_speed_flag, - frame_parms); -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PHY] PBCH Symbol %d\n",symbol); - LOG_D(PHY,"[PHY] PBCH starting channel_level\n"); -#endif - - max_h = pbch_channel_level(lte_ue_pbch_vars->dl_ch_estimates_ext, - frame_parms, - symbol); - log2_maxh = 3+(log2_approx(max_h)/2); - -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",log2_maxh,max_h); -#endif - - pbch_channel_compensation(lte_ue_pbch_vars->rxdataF_ext, - lte_ue_pbch_vars->dl_ch_estimates_ext, - lte_ue_pbch_vars->rxdataF_comp, - frame_parms, - symbol, - log2_maxh); // log2_maxh+I0_shift - - if (frame_parms->nb_antennas_rx > 1) - pbch_detection_mrc(frame_parms, - lte_ue_pbch_vars->rxdataF_comp, - symbol); - - - if (mimo_mode == ALAMOUTI) { - pbch_alamouti(frame_parms,lte_ue_pbch_vars->rxdataF_comp,symbol); - } else if (mimo_mode != SISO) { - LOG_D(PHY,"[PBCH][RX] Unsupported MIMO mode\n"); - return(-1); - } - - if (symbol>(nsymb>>1)+1) { - pbch_quantize(pbch_e_rx, - (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), - 144); - - pbch_e_rx+=144; - } else { - pbch_quantize(pbch_e_rx, - (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), - 96); - - pbch_e_rx+=96; - } - - - } - - pbch_e_rx = lte_ue_pbch_vars->llr; - - - - //un-scrambling -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] doing unscrambling\n"); -#endif - - - pbch_unscrambling(frame_parms, - pbch_e_rx, - pbch_E, - frame_mod4); - - - - //un-rate matching -#ifdef DEBUG_PBCH - LOG_D(PHY,"[PBCH] doing un-rate-matching\n"); -#endif - - - memset(dummy_w_rx,0,3*3*(16+PBCH_A)); - RCC = generate_dummy_w_cc(16+PBCH_A, - dummy_w_rx); - - - lte_rate_matching_cc_rx(RCC,pbch_E,pbch_w_rx,dummy_w_rx,pbch_e_rx); - - sub_block_deinterleaving_cc((unsigned int)(PBCH_A+16), - &pbch_d_rx[96], - &pbch_w_rx[0]); - - memset(pbch_a,0,((16+PBCH_A)>>3)); - - - - - phy_viterbi_lte_sse2(pbch_d_rx+96,pbch_a,16+PBCH_A); - - // Fix byte endian of PBCH (bit 23 goes in first) - for (i=0; i<(PBCH_A>>3); i++) - decoded_output[(PBCH_A>>3)-i-1] = pbch_a[i]; - -#ifdef DEBUG_PBCH - - for (i=0; i<(PBCH_A>>3); i++) - LOG_I(PHY,"[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); - -#endif //DEBUG_PBCH - -#ifdef DEBUG_PBCH - LOG_I(PHY,"PBCH CRC %x : %x\n", - crc16(pbch_a,PBCH_A), - ((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); -#endif - - crc = (crc16(pbch_a,PBCH_A)>>16) ^ - (((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); - - if (crc == 0x0000) - return(1); - else if (crc == 0xffff) - return(2); - else if (crc == 0x5555) - return(4); - else - return(-1); - - -} diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich.c b/openair1/PHY/LTE_TRANSPORT/pcfich.c index b7e24cb87dad212b71f461996a6a6a89f02468fa..18a156c3fbc004f0421c67eb635c08102833d5e8 100644 --- a/openair1/PHY/LTE_TRANSPORT/pcfich.c +++ b/openair1/PHY/LTE_TRANSPORT/pcfich.c @@ -29,48 +29,13 @@ * \note * \warning */ -#include "PHY/defs.h" +#include "PHY/impl_defs_top.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_PCFICH +extern uint8_t pcfich_b[4][32]; -void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) -{ - - uint16_t kbar = 6 * (frame_parms->Nid_cell %(2*frame_parms->N_RB_DL)); - uint16_t first_reg; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - pcfich_reg[0] = kbar/6; - first_reg = pcfich_reg[0]; - - frame_parms->pcfich_first_reg_idx=0; - - pcfich_reg[1] = ((kbar + (frame_parms->N_RB_DL>>1)*6)%(frame_parms->N_RB_DL*12))/6; - - if (pcfich_reg[1] < pcfich_reg[0]) { - frame_parms->pcfich_first_reg_idx = 1; - first_reg = pcfich_reg[1]; - } - - pcfich_reg[2] = ((kbar + (frame_parms->N_RB_DL)*6)%(frame_parms->N_RB_DL*12))/6; - - if (pcfich_reg[2] < first_reg) { - frame_parms->pcfich_first_reg_idx = 2; - first_reg = pcfich_reg[2]; - } - - pcfich_reg[3] = ((kbar + ((3*frame_parms->N_RB_DL)>>1)*6)%(frame_parms->N_RB_DL*12))/6; - - if (pcfich_reg[3] < first_reg) { - frame_parms->pcfich_first_reg_idx = 3; - first_reg = pcfich_reg[3]; - } - - - //#ifdef DEBUG_PCFICH - printf("pcfich_reg : %d,%d,%d,%d\n",pcfich_reg[0],pcfich_reg[1],pcfich_reg[2],pcfich_reg[3]); - //#endif -} void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, uint8_t subframe, @@ -96,37 +61,7 @@ void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, } } -void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - int16_t *d) -{ - - uint32_t i; - uint8_t reset; - uint32_t x1, x2, s=0; - reset = 1; - // x1 is set in lte_gold_generic - x2 = ((((2*frame_parms->Nid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 - - for (i=0; i<32; i++) { - if ((i&0x1f)==0) { - s = lte_gold_generic(&x1, &x2, reset); - //printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - if (((s>>(i&0x1f))&1) == 1) - d[i]=-d[i]; - - } -} - -uint8_t pcfich_b[4][32]= {{0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1}, - {1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0}, - {1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} -}; void generate_pcfich(uint8_t num_pdcch_symbols, int16_t amp, @@ -215,98 +150,3 @@ void generate_pcfich(uint8_t num_pdcch_symbols, } -uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - LTE_UE_PDCCH *lte_ue_pdcch_vars, - MIMO_mode_t mimo_mode) -{ - - uint8_t pcfich_quad; - uint8_t i,j; - uint16_t reg_offset; - - int32_t **rxdataF_comp = lte_ue_pdcch_vars->rxdataF_comp; - int16_t pcfich_d[32],*pcfich_d_ptr; - int32_t metric,old_metric=-16384; - uint8_t num_pdcch_symbols=3; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - // demapping - // loop over 4 quadruplets and lookup REGs - // m=0; - pcfich_d_ptr = pcfich_d; - - for (pcfich_quad=0; pcfich_quad<4; pcfich_quad++) { - reg_offset = (pcfich_reg[pcfich_quad]*4); - - for (i=0; i<4; i++) { - - pcfich_d_ptr[0] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0]; // RE component - pcfich_d_ptr[1] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1]; // IM component -#ifdef DEBUG_PCFICH - printf("rx_pcfich: quad %d, i %d, offset %d => (%d,%d) => pcfich_d_ptr[0] %d \n",pcfich_quad,i,reg_offset+i, - ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0], - ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1], - pcfich_d_ptr[0]); -#endif - pcfich_d_ptr+=2; - } - - /* - } - else { // ALAMOUTI - for (i=0;i<4;i+=2) { - pcfich_d_ptr[0] = 0; - pcfich_d_ptr[1] = 0; - pcfich_d_ptr[2] = 0; - pcfich_d_ptr[3] = 0; - for (j=0;j<frame_parms->nb_antennas_rx;j++) { - - pcfich_d_ptr[0] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[0]+ - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[0]); // RE component - pcfich_d_ptr[1] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[1] - - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[1]);// IM component - - pcfich_d_ptr[2] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[0]- - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[0]); // RE component - pcfich_d_ptr[3] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[1] + - ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[1]);// IM component - - - } - - pcfich_d_ptr+=4; - - } - */ - } - - // pcfhich unscrambling - - pcfich_unscrambling(frame_parms,subframe,pcfich_d); - - // pcfich detection - - for (i=0; i<3; i++) { - metric = 0; - - for (j=0; j<32; j++) { - // printf("pcfich_b[%d][%d] %d => pcfich_d[%d] %d\n",i,j,pcfich_b[i][j],j,pcfich_d[j]); - metric += (int32_t)(((pcfich_b[i][j]==0) ? (pcfich_d[j]) : (-pcfich_d[j]))); - } - -#ifdef DEBUG_PCFICH - printf("metric %d : %d\n",i,metric); -#endif - - if (metric > old_metric) { - num_pdcch_symbols = 1+i; - old_metric = metric; - } - } - -#ifdef DEBUG_PCFICH - printf("[PHY] PCFICH detected for %d PDCCH symbols\n",num_pdcch_symbols); -#endif - return(num_pdcch_symbols); -} diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich_common.c b/openair1/PHY/LTE_TRANSPORT/pcfich_common.c new file mode 100644 index 0000000000000000000000000000000000000000..d6466862a79ba02d4187ab74ada21bfc431549b9 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pcfich_common.c @@ -0,0 +1,72 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/pcfich.c +* \brief Top-level routines for generating and decoding the PCFICH/CFI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/impl_defs_top.h" +#include "PHY/defs_eNB.h" + +void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) +{ + + uint16_t kbar = 6 * (frame_parms->Nid_cell %(2*frame_parms->N_RB_DL)); + uint16_t first_reg; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + pcfich_reg[0] = kbar/6; + first_reg = pcfich_reg[0]; + + frame_parms->pcfich_first_reg_idx=0; + + pcfich_reg[1] = ((kbar + (frame_parms->N_RB_DL>>1)*6)%(frame_parms->N_RB_DL*12))/6; + + if (pcfich_reg[1] < pcfich_reg[0]) { + frame_parms->pcfich_first_reg_idx = 1; + first_reg = pcfich_reg[1]; + } + + pcfich_reg[2] = ((kbar + (frame_parms->N_RB_DL)*6)%(frame_parms->N_RB_DL*12))/6; + + if (pcfich_reg[2] < first_reg) { + frame_parms->pcfich_first_reg_idx = 2; + first_reg = pcfich_reg[2]; + } + + pcfich_reg[3] = ((kbar + ((3*frame_parms->N_RB_DL)>>1)*6)%(frame_parms->N_RB_DL*12))/6; + + if (pcfich_reg[3] < first_reg) { + frame_parms->pcfich_first_reg_idx = 3; + first_reg = pcfich_reg[3]; + } + + + //#ifdef DEBUG_PCFICH + printf("pcfich_reg : %d,%d,%d,%d\n",pcfich_reg[0],pcfich_reg[1],pcfich_reg[2],pcfich_reg[3]); + //#endif +} diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 2bd7140c32ccc96524b58d9e489280bae5cf7754..2e8a6e410c3a9804d109fb0c72b22f8a610e9df4 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -1,3 +1,4 @@ + /* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,7 +21,7 @@ */ /*! \file PHY/LTE_TRANSPORT/phich.c -* \brief Top-level routines for generating and decoding the PHICH/HI physical/transport channel V8.6 2009-03 +* \brief Top-level routines for generating the PHICH/HI physical/transport channel V8.6 2009-03 * \author R. Knopp * \date 2011 * \version 0.1 @@ -30,15 +31,11 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "defs.h" - -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" - +#include "PHY/defs_eNB.h" +#include "PHY/impl_defs_top.h" #include "T.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "transport_common_proto.h" //#define DEBUG_PHICH 1 @@ -48,365 +45,6 @@ //unsigned short phich_reg[MAX_NUM_PHICH_GROUPS][3]; -uint8_t rv_table[4] = {0, 2, 3, 1}; - -uint8_t get_mi(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) -{ - - // for FDD - if (frame_parms->frame_type == FDD) - return 1; - - // for TDD - switch (frame_parms->tdd_config) { - - case 0: - if ((subframe==0) || (subframe==5)) - return(2); - else return(1); - - break; - - case 1: - if ((subframe==0) || (subframe==5)) - return(0); - else return(1); - - break; - - case 2: - if ((subframe==3) || (subframe==8)) - return(1); - else return(0); - - break; - - case 3: - if ((subframe==0) || (subframe==8) || (subframe==9)) - return(1); - else return(0); - - break; - - case 4: - if ((subframe==8) || (subframe==9)) - return(1); - else return(0); - - break; - - case 5: - if (subframe==8) - return(1); - else return(0); - - break; - - case 6: - return(1); - break; - - default: - return(0); - } -} - -unsigned char subframe2_ul_harq(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) -{ - - if (frame_parms->frame_type == FDD) - return(subframe&7); - - switch (frame_parms->tdd_config) { - case 3: - if ( (subframe == 8) || (subframe == 9) ) { - return(subframe-8); - } else if (subframe==0) - return(2); - else { - LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - return(0); - } - - break; - - case 4: - if ( (subframe == 8) || (subframe == 9) ) { - return(subframe-8); - } else { - LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - return(0); - } - - break; - - } - - return(0); -} - -int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe) -{ - int pusch_frame; - - if (frame_parms->frame_type == FDD) { - pusch_frame = subframe<4 ? frame + 1024 - 1 : frame; - } else { - // Note this is not true, but it doesn't matter, the frame number is irrelevant for TDD! - pusch_frame = (frame); - } - - //LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, subframe, pusch_frame); - return pusch_frame % 1024; -} - -uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) -{ - uint8_t pusch_subframe = 255; - - if (frame_parms->frame_type == FDD) - return subframe < 4 ? subframe + 6 : subframe - 4; - - switch (frame_parms->tdd_config) { - case 0: - if (subframe == 0) - pusch_subframe = (3); - else if (subframe == 5) { - pusch_subframe = (8); - } else if (subframe == 6) - pusch_subframe = (2); - else if (subframe == 1) - pusch_subframe = (7); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 1: - if (subframe == 6) - pusch_subframe = (2); - else if (subframe == 9) - pusch_subframe = (3); - else if (subframe == 1) - pusch_subframe = (7); - else if (subframe == 4) - pusch_subframe = (8); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 2: - if (subframe == 8) - pusch_subframe = (2); - else if (subframe == 3) - pusch_subframe = (7); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 3: - if ( (subframe == 8) || (subframe == 9) ) { - pusch_subframe = (subframe-6); - } else if (subframe==0) - pusch_subframe = (4); - else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 4: - if ( (subframe == 8) || (subframe == 9) ) { - pusch_subframe = (subframe-6); - } else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 5: - if (subframe == 8) { - pusch_subframe = (2); - } else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - case 6: - if (subframe == 6) { - pusch_subframe = (2); - } else if (subframe == 9) { - pusch_subframe = (3); - } else if (subframe == 0) { - pusch_subframe = (4); - } else if (subframe == 1) { - pusch_subframe = (7); - } else if (subframe == 5) { - pusch_subframe = (8); - } else { - AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - pusch_subframe = (0); - } - - break; - - default: - AssertFatal(1==0, "no implementation for TDD UL/DL-config = %d!\n", frame_parms->tdd_config); - pusch_subframe = (0); - } - - LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", subframe, pusch_subframe); - return pusch_subframe; -} - -int check_pcfich(LTE_DL_FRAME_PARMS *frame_parms,uint16_t reg) -{ - - if ((reg == frame_parms->pcfich_reg[0]) || - (reg == frame_parms->pcfich_reg[1]) || - (reg == frame_parms->pcfich_reg[2]) || - (reg == frame_parms->pcfich_reg[3])) - return(1); - - return(0); -} - -void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) -{ - - unsigned short n0 = (frame_parms->N_RB_DL * 2) - 4; // 2 REG per RB less the 4 used by PCFICH in first symbol - unsigned short n1 = (frame_parms->N_RB_DL * 3); // 3 REG per RB in second and third symbol - unsigned short n2 = n1; - unsigned short mprime = 0; - unsigned short Ngroup_PHICH; - // uint16_t *phich_reg = frame_parms->phich_reg; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - // compute Ngroup_PHICH (see formula at beginning of Section 6.9 in 36-211 - Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - - - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - // check if Extended prefix - if (frame_parms->Ncp == 1) { - Ngroup_PHICH<<=1; - } - -#ifdef DEBUG_PHICH - LOG_D(PHY,"Ngroup_PHICH %d (phich_config_common.phich_resource %d,phich_config_common.phich_duration %s, NidCell %d,Ncp %d, frame_type %d), smallest pcfich REG %d, n0 %d, n1 %d (first PHICH REG %d)\n", - ((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)), - frame_parms->phich_config_common.phich_resource, - frame_parms->phich_config_common.phich_duration==normal?"normal":"extended", - frame_parms->Nid_cell,frame_parms->Ncp,frame_parms->frame_type, - pcfich_reg[frame_parms->pcfich_first_reg_idx], - n0, - n1, - ((frame_parms->Nid_cell))%n0); -#endif - - // This is the algorithm from Section 6.9.3 in 36-211, it works only for normal PHICH duration for now ... - - for (mprime=0; - mprime<((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)); - mprime++) { - - if (frame_parms->phich_config_common.phich_duration==normal) { // normal PHICH duration - - frame_parms->phich_reg[mprime][0] = (frame_parms->Nid_cell + mprime)%n0; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) - frame_parms->phich_reg[mprime][0]++; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) - frame_parms->phich_reg[mprime][0]++; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) - frame_parms->phich_reg[mprime][0]++; - - if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) - frame_parms->phich_reg[mprime][0]++; - - frame_parms->phich_reg[mprime][1] = (frame_parms->Nid_cell + mprime + (n0/3))%n0; - - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) - frame_parms->phich_reg[mprime][1]++; - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) - frame_parms->phich_reg[mprime][1]++; - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) - frame_parms->phich_reg[mprime][1]++; - - if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) - frame_parms->phich_reg[mprime][1]++; - - - frame_parms->phich_reg[mprime][2] = (frame_parms->Nid_cell + mprime + (2*n0/3))%n0; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) - frame_parms->phich_reg[mprime][2]++; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) - frame_parms->phich_reg[mprime][2]++; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) - frame_parms->phich_reg[mprime][2]++; - - if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) - frame_parms->phich_reg[mprime][2]++; - -#ifdef DEBUG_PHICH - printf("phich_reg :%d => %d,%d,%d\n",mprime,frame_parms->phich_reg[mprime][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); -#endif - } else { // extended PHICH duration - frame_parms->phich_reg[mprime<<1][0] = (frame_parms->Nid_cell + mprime)%n0; - frame_parms->phich_reg[1+(mprime<<1)][0] = (frame_parms->Nid_cell + mprime)%n0; - - frame_parms->phich_reg[mprime<<1][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; - frame_parms->phich_reg[mprime<<1][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; - - frame_parms->phich_reg[1+(mprime<<1)][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; - frame_parms->phich_reg[1+(mprime<<1)][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; - //#ifdef DEBUG_PHICH - printf("phich_reg :%d => %d,%d,%d\n",mprime<<1,frame_parms->phich_reg[mprime<<1][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); - printf("phich_reg :%d => %d,%d,%d\n",1+(mprime<<1),frame_parms->phich_reg[1+(mprime<<1)][0],frame_parms->phich_reg[1+(mprime<<1)][1],frame_parms->phich_reg[1+(mprime<<1)][2]); - //#endif - } - } // mprime loop -} // num_pdcch_symbols loop - - -void generate_phich_emul(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t HI, - uint8_t subframe) -{ - - -} int32_t alam_bpsk_perm1[4] = {2,1,4,3}; // -conj(x) 1 (-1-j) -> 2 (1-j), 2->1, 3 (-1+j) -> (4) 1+j, 4->3 int32_t alam_bpsk_perm2[4] = {3,4,2,1}; // conj(x) 1 (-1-j) -> 3 (-1+j), 3->1, 2 (1-j) -> 4 (1+j), 4->2 @@ -1065,436 +703,6 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, } // normal/extended prefix } -// This routine demodulates the PHICH and updates PUSCH/ULSCH parameters - -void rx_phich(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - uint8_t subframe, - uint8_t eNB_id) -{ - - - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - LTE_UE_PDCCH **pdcch_vars = &ue->pdcch_vars[ue->current_thread_id[subframe]][eNB_id]; - - // uint8_t HI; - uint8_t harq_pid = phich_subframe_to_harq_pid(frame_parms,proc->frame_rx,subframe); - LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - int16_t phich_d[24],*phich_d_ptr,HI16; - // unsigned int i,aa; - int8_t d[24],*dp; - uint16_t reg_offset; - - // scrambling - uint32_t x1, x2, s=0; - uint8_t reset = 1; - int16_t cs[12]; - uint32_t i,i2,i3,phich_quad; - int32_t **rxdataF_comp = pdcch_vars[eNB_id]->rxdataF_comp; - uint8_t Ngroup_PHICH,ngroup_PHICH,nseq_PHICH; - uint8_t NSF_PHICH = 4; - uint8_t pusch_subframe; - - int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; - - // check if we're expecting a PHICH in this subframe - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); - - if (!ulsch) - return; - - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX Status: %d \n",ue->Mod_id,harq_pid,proc->frame_rx,subframe, ulsch->harq_processes[harq_pid]->status); - - if (ulsch->harq_processes[harq_pid]->status == ACTIVE) { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX ACTIVE\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); - Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - if (frame_parms->Ncp == 1) - NSF_PHICH = 2; - - - ngroup_PHICH = (ulsch->harq_processes[harq_pid]->first_rb + - ulsch->harq_processes[harq_pid]->n_DMRS)%Ngroup_PHICH; - - if ((frame_parms->tdd_config == 0) && (frame_parms->frame_type == TDD) ) { - pusch_subframe = phich_subframe2_pusch_subframe(frame_parms,subframe); - - if ((pusch_subframe == 4) || (pusch_subframe == 9)) - ngroup_PHICH += Ngroup_PHICH; - } - - nseq_PHICH = ((ulsch->harq_processes[harq_pid]->first_rb/Ngroup_PHICH) + - ulsch->harq_processes[harq_pid]->n_DMRS)%(2*NSF_PHICH); - } else { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX %s\n", - ue->Mod_id, - harq_pid, - proc->frame_rx, - subframe, - (ulsch->harq_processes[harq_pid]->status==SCH_IDLE? "SCH_IDLE" : - (ulsch->harq_processes[harq_pid]->status==ACTIVE? "ACTIVE" : - (ulsch->harq_processes[harq_pid]->status==CBA_ACTIVE? "CBA_ACTIVE": - (ulsch->harq_processes[harq_pid]->status==DISABLED? "DISABLED" : "UNKNOWN"))))); - - return; - } - - memset(d,0,24*sizeof(int8_t)); - phich_d_ptr = phich_d; - - // x1 is set in lte_gold_generic - x2 = (((subframe+1)*((frame_parms->Nid_cell<<1)+1))<<9) + frame_parms->Nid_cell; - - s = lte_gold_generic(&x1, &x2, reset); - - // compute scrambling sequence - for (i=0; i<12; i++) { - cs[i] = 1-(((s>>(i&0x1f))&1)<<1); - } - - if (frame_parms->Ncp == 0) { // Normal Cyclic Prefix - - - // 12 output symbols (Msymb) - - for (i=0,i2=0,i3=0; i<3; i++,i2+=4,i3+=8) { - switch (nseq_PHICH) { - case 0: // +1 +1 +1 +1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = cs[1+i2]; - d[3+i3] = cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[5+i3] = cs[2+i2]; - d[6+i3] = cs[3+i2]; - d[7+i3] = cs[3+i2]; - break; - - case 1: // +1 -1 +1 -1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = -cs[1+i2]; - d[3+i3] = -cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[5+i3] = cs[2+i2]; - d[6+i3] = -cs[3+i2]; - d[7+i3] = -cs[3+i2]; - break; - - case 2: // +1 +1 -1 -1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = cs[1+i2]; - d[3+i3] = cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[5+i3] = -cs[2+i2]; - d[6+i3] = -cs[3+i2]; - d[7+i3] = -cs[3+i2]; - break; - - case 3: // +1 -1 -1 +1 - d[i3] = cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = -cs[1+i2]; - d[3+i3] = -cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[5+i3] = -cs[2+i2]; - d[6+i3] = cs[3+i2]; - d[7+i3] = cs[3+i2]; - break; - - case 4: // +j +j +j +j - d[i3] = -cs[i2]; - d[1+i3] = cs[i2]; - d[2+i3] = -cs[1+i2]; - d[3+i3] = cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[5+i3] = cs[2+i2]; - d[6+i3] = -cs[3+i2]; - d[7+i3] = cs[3+i2]; - break; - - case 5: // +j -j +j -j - d[1+i3] = cs[i2]; - d[3+i3] = -cs[1+i2]; - d[5+i3] = cs[2+i2]; - d[7+i3] = -cs[3+i2]; - d[i3] = -cs[i2]; - d[2+i3] = cs[1+i2]; - d[4+i3] = -cs[2+i2]; - d[6+i3] = cs[3+i2]; - break; - - case 6: // +j +j -j -j - d[1+i3] = cs[i2]; - d[3+i3] = cs[1+i2]; - d[5+i3] = -cs[2+i2]; - d[7+i3] = -cs[3+i2]; - d[i3] = -cs[i2]; - d[2+i3] = -cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[6+i3] = cs[3+i2]; - break; - - case 7: // +j -j -j +j - d[1+i3] = cs[i2]; - d[3+i3] = -cs[1+i2]; - d[5+i3] = -cs[2+i2]; - d[7+i3] = cs[3+i2]; - d[i3] = -cs[i2]; - d[2+i3] = cs[1+i2]; - d[4+i3] = cs[2+i2]; - d[6+i3] = -cs[3+i2]; - break; - - default: - AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); - } // nseq_PHICH - } - -#ifdef DEBUG_PHICH - LOG_D(PHY,"PHICH =>"); - - for (i=0; i<24; i++) { - LOG_D(PHY,"%2d,",d[i]); - } - - LOG_D(PHY,"\n"); -#endif - // demodulation here - - - } else { // extended prefix - - // 6 output symbols - if ((ngroup_PHICH & 1) == 1) - dp = &d[4]; - else - dp = d; - - switch (nseq_PHICH) { - case 0: // +1 +1 - dp[0] = cs[0]; - dp[2] = cs[1]; - dp[8] = cs[2]; - dp[10] = cs[3]; - dp[16] = cs[4]; - dp[18] = cs[5]; - dp[1] = cs[0]; - dp[3] = cs[1]; - dp[9] = cs[2]; - dp[11] = cs[3]; - dp[17] = cs[4]; - dp[19] = cs[5]; - break; - - case 1: // +1 -1 - dp[0] = cs[0]; - dp[2] = -cs[1]; - dp[8] = cs[2]; - dp[10] = -cs[3]; - dp[16] = cs[4]; - dp[18] = -cs[5]; - dp[1] = cs[0]; - dp[3] = -cs[1]; - dp[9] = cs[2]; - dp[11] = -cs[3]; - dp[17] = cs[4]; - dp[19] = -cs[5]; - break; - - case 2: // +j +j - dp[1] = cs[0]; - dp[3] = cs[1]; - dp[9] = cs[2]; - dp[11] = cs[3]; - dp[17] = cs[4]; - dp[19] = cs[5]; - dp[0] = -cs[0]; - dp[2] = -cs[1]; - dp[8] = -cs[2]; - dp[10] = -cs[3]; - dp[16] = -cs[4]; - dp[18] = -cs[5]; - - break; - - case 3: // +j -j - dp[1] = cs[0]; - dp[3] = -cs[1]; - dp[9] = cs[2]; - dp[11] = -cs[3]; - dp[17] = cs[4]; - dp[19] = -cs[5]; - dp[0] = -cs[0]; - dp[2] = cs[1]; - dp[8] = -cs[2]; - dp[10] = cs[3]; - dp[16] = -cs[4]; - dp[18] = cs[5]; - break; - - default: - AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); - } - } - - HI16 = 0; - - //#ifdef DEBUG_PHICH - - //#endif - /* - for (i=0;i<200;i++) - printf("re %d: %d %d\n",i,((int16_t*)&rxdataF_comp[0][i])[0],((int16_t*)&rxdataF_comp[0][i])[1]); - */ - for (phich_quad=0; phich_quad<3; phich_quad++) { - if (frame_parms->Ncp == 1) - reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4)+ (phich_quad*frame_parms->N_RB_DL*12); - else - reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4); - - // msg("\n[PUSCH 0]PHICH (RX) quad %d (%d)=>",phich_quad,reg_offset); - dp = &d[phich_quad*8];; - - for (i=0; i<8; i++) { - phich_d_ptr[i] = ((int16_t*)&rxdataF_comp[0][reg_offset])[i]; - -#ifdef DEBUG_PHICH - LOG_D(PHY,"%d,",((int16_t*)&rxdataF_comp[0][reg_offset])[i]); -#endif - - HI16 += (phich_d_ptr[i] * dp[i]); - } - } - -#ifdef DEBUG_PHICH - LOG_D(PHY,"\n"); - LOG_D(PHY,"HI16 %d\n",HI16); -#endif - - if (HI16>0) { //NACK - if (ue->ulsch_Msg3_active[eNB_id] == 1) { - LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received NAK (%d) nseq %d, ngroup %d\n", - ue->Mod_id,harq_pid, - proc->frame_rx, - subframe, - HI16, - nseq_PHICH, - ngroup_PHICH); - - ulsch->f_pusch += delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC]; - - LOG_D(PHY,"[PUSCH %d] AbsSubframe %d.%d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", - harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, - delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC], - ulsch->harq_processes[harq_pid]->TPC); - - - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - // ulsch->harq_processes[harq_pid]->Ndi = 0; - ulsch->harq_processes[harq_pid]->round++; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - - if (ulsch->harq_processes[harq_pid]->round>=ue->frame_parms.maxHARQ_Msg3Tx) { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag =0; - ulsch->harq_processes[harq_pid]->status = SCH_IDLE; - // inform MAC that Msg3 transmission has failed - ue->ulsch_Msg3_active[eNB_id] = 0; - } - } else { -#ifdef UE_DEBUG_TRACE - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received NAK (%d) nseq %d, ngroup %d round %d (Mlimit %d)\n", - ue->Mod_id,harq_pid, - proc->frame_rx%1024, - subframe, - HI16, - nseq_PHICH, - ngroup_PHICH, - ulsch->harq_processes[harq_pid]->round, - ulsch->Mlimit); -#endif - - // ulsch->harq_processes[harq_pid]->Ndi = 0; - ulsch->harq_processes[harq_pid]->round++; - - if ( ulsch->harq_processes[harq_pid]->round >= (ulsch->Mlimit - 1) ) - { - // this is last push re transmission - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - - // disable phich decoding since it is the last retransmission - ulsch->harq_processes[harq_pid]->status = SCH_IDLE; - - //ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - //ulsch->harq_processes[harq_pid]->round = 0; - - //LOG_I(PHY,"PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); - //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->Mlimit, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - } - else - { - // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); - } - } -#if T_TRACER - T(T_UE_PHY_ULSCH_UE_NACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), - T_INT(harq_pid)); -#endif - - } else { //ACK - if (ue->ulsch_Msg3_active[eNB_id] == 1) { - LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", - ue->Mod_id,harq_pid, - proc->frame_rx, - subframe, - HI16, - nseq_PHICH,ngroup_PHICH); - } else { -#ifdef UE_DEBUG_TRACE - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", - ue->Mod_id,harq_pid, - proc->frame_rx%1024, - subframe, HI16, - nseq_PHICH,ngroup_PHICH); -#endif - } - - // LOG_I(PHY,"[HARQ-UL harqId: %d] subframe_scheduling_flag = %d \n",harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag); - - // Incase of adaptive retransmission, PHICH is always decoded as ACK (at least with OAI-eNB) - // Workaround: - // rely only on DCI0 decoding and check if NDI has toggled - // save current harq_processes content in temporary struct - // harqId-8 corresponds to the temporary struct. In total we have 8 harq process(0 ..7) + 1 temporary harq process() - //ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; - - - ulsch->harq_processes[harq_pid]->status = SCH_IDLE; - ulsch->harq_processes[harq_pid]->round = 0; - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - // inform MAC? - ue->ulsch_Msg3_active[eNB_id] = 0; - -#if T_TRACER - T(T_UE_PHY_ULSCH_UE_ACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), - T_INT(harq_pid)); -#endif - - } - -} void generate_phich_top(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, diff --git a/openair1/PHY/LTE_TRANSPORT/phich_common.c b/openair1/PHY/LTE_TRANSPORT/phich_common.c new file mode 100644 index 0000000000000000000000000000000000000000..a3bc5250d5f79699e693cc77fd4855905a946801 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/phich_common.c @@ -0,0 +1,383 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/phich_common.c +* \brief Top-level routines for generating and decoding the PHICH/HI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ + +#include "PHY/defs_eNB.h" + + +uint8_t get_mi(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) +{ + + // for FDD + if (frame_parms->frame_type == FDD) + return 1; + + // for TDD + switch (frame_parms->tdd_config) { + + case 0: + if ((subframe==0) || (subframe==5)) + return(2); + else return(1); + + break; + + case 1: + if ((subframe==0) || (subframe==5)) + return(0); + else return(1); + + break; + + case 2: + if ((subframe==3) || (subframe==8)) + return(1); + else return(0); + + break; + + case 3: + if ((subframe==0) || (subframe==8) || (subframe==9)) + return(1); + else return(0); + + break; + + case 4: + if ((subframe==8) || (subframe==9)) + return(1); + else return(0); + + break; + + case 5: + if (subframe==8) + return(1); + else return(0); + + break; + + case 6: + return(1); + break; + + default: + return(0); + } +} + +unsigned char subframe2_ul_harq(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) +{ + + if (frame_parms->frame_type == FDD) + return(subframe&7); + + switch (frame_parms->tdd_config) { + case 3: + if ( (subframe == 8) || (subframe == 9) ) { + return(subframe-8); + } else if (subframe==0) + return(2); + else { + LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + return(0); + } + + break; + + case 4: + if ( (subframe == 8) || (subframe == 9) ) { + return(subframe-8); + } else { + LOG_E(PHY,"phich.c: subframe2_ul_harq, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + return(0); + } + + break; + + } + + return(0); +} + +int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe) +{ + int pusch_frame; + + if (frame_parms->frame_type == FDD) { + pusch_frame = subframe<4 ? frame + 1024 - 1 : frame; + } else { + // Note this is not true, but it doesn't matter, the frame number is irrelevant for TDD! + pusch_frame = (frame); + } + + //LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, subframe, pusch_frame); + return pusch_frame % 1024; +} + +uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) +{ + uint8_t pusch_subframe = 255; + + if (frame_parms->frame_type == FDD) + return subframe < 4 ? subframe + 6 : subframe - 4; + + switch (frame_parms->tdd_config) { + case 0: + if (subframe == 0) + pusch_subframe = (3); + else if (subframe == 5) { + pusch_subframe = (8); + } else if (subframe == 6) + pusch_subframe = (2); + else if (subframe == 1) + pusch_subframe = (7); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 1: + if (subframe == 6) + pusch_subframe = (2); + else if (subframe == 9) + pusch_subframe = (3); + else if (subframe == 1) + pusch_subframe = (7); + else if (subframe == 4) + pusch_subframe = (8); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 2: + if (subframe == 8) + pusch_subframe = (2); + else if (subframe == 3) + pusch_subframe = (7); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 3: + if ( (subframe == 8) || (subframe == 9) ) { + pusch_subframe = (subframe-6); + } else if (subframe==0) + pusch_subframe = (4); + else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 4: + if ( (subframe == 8) || (subframe == 9) ) { + pusch_subframe = (subframe-6); + } else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 5: + if (subframe == 8) { + pusch_subframe = (2); + } else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + case 6: + if (subframe == 6) { + pusch_subframe = (2); + } else if (subframe == 9) { + pusch_subframe = (3); + } else if (subframe == 0) { + pusch_subframe = (4); + } else if (subframe == 1) { + pusch_subframe = (7); + } else if (subframe == 5) { + pusch_subframe = (8); + } else { + AssertFatal(1==0,"phich.c: phich_subframe2_pusch_subframe, illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + pusch_subframe = (0); + } + + break; + + default: + AssertFatal(1==0, "no implementation for TDD UL/DL-config = %d!\n", frame_parms->tdd_config); + pusch_subframe = (0); + } + + LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", subframe, pusch_subframe); + return pusch_subframe; +} + +int check_pcfich(LTE_DL_FRAME_PARMS *frame_parms,uint16_t reg) +{ + + if ((reg == frame_parms->pcfich_reg[0]) || + (reg == frame_parms->pcfich_reg[1]) || + (reg == frame_parms->pcfich_reg[2]) || + (reg == frame_parms->pcfich_reg[3])) + return(1); + + return(0); +} + +void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) +{ + + unsigned short n0 = (frame_parms->N_RB_DL * 2) - 4; // 2 REG per RB less the 4 used by PCFICH in first symbol + unsigned short n1 = (frame_parms->N_RB_DL * 3); // 3 REG per RB in second and third symbol + unsigned short n2 = n1; + unsigned short mprime = 0; + unsigned short Ngroup_PHICH; + // uint16_t *phich_reg = frame_parms->phich_reg; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + // compute Ngroup_PHICH (see formula at beginning of Section 6.9 in 36-211 + Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + + + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + // check if Extended prefix + if (frame_parms->Ncp == 1) { + Ngroup_PHICH<<=1; + } + +#ifdef DEBUG_PHICH + LOG_D(PHY,"Ngroup_PHICH %d (phich_config_common.phich_resource %d,phich_config_common.phich_duration %s, NidCell %d,Ncp %d, frame_type %d), smallest pcfich REG %d, n0 %d, n1 %d (first PHICH REG %d)\n", + ((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)), + frame_parms->phich_config_common.phich_resource, + frame_parms->phich_config_common.phich_duration==normal?"normal":"extended", + frame_parms->Nid_cell,frame_parms->Ncp,frame_parms->frame_type, + pcfich_reg[frame_parms->pcfich_first_reg_idx], + n0, + n1, + ((frame_parms->Nid_cell))%n0); +#endif + + // This is the algorithm from Section 6.9.3 in 36-211, it works only for normal PHICH duration for now ... + + for (mprime=0; + mprime<((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)); + mprime++) { + + if (frame_parms->phich_config_common.phich_duration==normal) { // normal PHICH duration + + frame_parms->phich_reg[mprime][0] = (frame_parms->Nid_cell + mprime)%n0; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) + frame_parms->phich_reg[mprime][0]++; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) + frame_parms->phich_reg[mprime][0]++; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) + frame_parms->phich_reg[mprime][0]++; + + if (frame_parms->phich_reg[mprime][0]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) + frame_parms->phich_reg[mprime][0]++; + + frame_parms->phich_reg[mprime][1] = (frame_parms->Nid_cell + mprime + (n0/3))%n0; + + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) + frame_parms->phich_reg[mprime][1]++; + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) + frame_parms->phich_reg[mprime][1]++; + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) + frame_parms->phich_reg[mprime][1]++; + + if (frame_parms->phich_reg[mprime][1]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) + frame_parms->phich_reg[mprime][1]++; + + + frame_parms->phich_reg[mprime][2] = (frame_parms->Nid_cell + mprime + (2*n0/3))%n0; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[frame_parms->pcfich_first_reg_idx]) + frame_parms->phich_reg[mprime][2]++; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+1)&3]) + frame_parms->phich_reg[mprime][2]++; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+2)&3]) + frame_parms->phich_reg[mprime][2]++; + + if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) + frame_parms->phich_reg[mprime][2]++; + +#ifdef DEBUG_PHICH + printf("phich_reg :%d => %d,%d,%d\n",mprime,frame_parms->phich_reg[mprime][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); +#endif + } else { // extended PHICH duration + frame_parms->phich_reg[mprime<<1][0] = (frame_parms->Nid_cell + mprime)%n0; + frame_parms->phich_reg[1+(mprime<<1)][0] = (frame_parms->Nid_cell + mprime)%n0; + + frame_parms->phich_reg[mprime<<1][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; + frame_parms->phich_reg[mprime<<1][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; + + frame_parms->phich_reg[1+(mprime<<1)][1] = ((frame_parms->Nid_cell*n1/n0) + mprime + (n1/3))%n1; + frame_parms->phich_reg[1+(mprime<<1)][2] = ((frame_parms->Nid_cell*n2/n0) + mprime + (2*n2/3))%n2; + //#ifdef DEBUG_PHICH + printf("phich_reg :%d => %d,%d,%d\n",mprime<<1,frame_parms->phich_reg[mprime<<1][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); + printf("phich_reg :%d => %d,%d,%d\n",1+(mprime<<1),frame_parms->phich_reg[1+(mprime<<1)][0],frame_parms->phich_reg[1+(mprime<<1)][1],frame_parms->phich_reg[1+(mprime<<1)][2]); + //#endif + } + } // mprime loop +} // num_pdcch_symbols loop diff --git a/openair1/PHY/LTE_TRANSPORT/pilots.c b/openair1/PHY/LTE_TRANSPORT/pilots.c index 01b4bb7a8ea4e1ec0703e6ff51ce018e51d3da77..921f93ddb103ccf41017644057f97c92137ba320 100644 --- a/openair1/PHY/LTE_TRANSPORT/pilots.c +++ b/openair1/PHY/LTE_TRANSPORT/pilots.c @@ -29,8 +29,8 @@ * \note * \warning */ -//#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" void generate_pilots(PHY_VARS_eNB *eNB, int32_t **txdataF, diff --git a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c index 90e9ae329caed2bf17853f64ea511e4315ec21d8..fddc29b5242f4d005851fedf1b95b6d639619d24 100644 --- a/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c +++ b/openair1/PHY/LTE_TRANSPORT/pilots_mbsfn.c @@ -29,9 +29,9 @@ * \note * \warning */ -//#include "defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" int generate_mbsfn_pilot(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, diff --git a/openair1/PHY/LTE_TRANSPORT/pilots_ue_spec.c b/openair1/PHY/LTE_TRANSPORT/pilots_ue_spec.c deleted file mode 100644 index 63aac7f091b0288eb172e775ca103e5eec6a80f2..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_TRANSPORT/pilots_ue_spec.c +++ /dev/null @@ -1,209 +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 PHY/LTE_TRANSPORT/uespec_pilots.c -* \brief Top-level routines for generating DL ue-specific reference signals V12.5 2015-03 -* \author X.JIANG -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: xiwen.jiangeurecom.fr -* \note -* \warning -*/ -//#include "defs.h" -#include "PHY/defs.h" - -void generate_ue_spec_pilots(PHY_VARS_eNB *phy_vars_eNB, - uint8_t UE_id, - int32_t **txdataF, - int16_t amp, - uint16_t Ntti, - uint8_t beamforming_mode) -{ - - /*LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->lte_frame_parms; - - uint32_t tti,tti_offset,slot_offset,Nsymb,samples_per_symbol; - uint8_t second_pilot,aa; - - // printf("Doing TX pilots Nsymb %d, second_pilot %d\n",Nsymb,second_pilot); - - switch(beamforming_mode){ - case 7: - for (tti=0; tti<Ntti; tti++) { - - tti_offset = tti*frame_parms->ofdm_symbol_size*Nsymb; - samples_per_symbol = frame_parms->ofdm_symbol_size; - slot_offset = (tti*2)%20; - - // printf("tti %d : offset %d (slot %d)\n",tti,tti_offset,slot_offset); - //Generate UE specific Pilots - printf("generate_dl_ue_spec:tti_offset=%d\n",tti_offset); - - if(frame_parms->Ncp==0) { - for(aa=0;aa<frame_parms->nb_antennas_tx;aa++){ - //antenna port 5 symbol 0 slot 0 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+3*samples_per_symbol], - amp, - slot_offset, - 1, - 5, - 0); - - //antenna port 5 symbol 1 slot 0 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+6*samples_per_symbol], - amp, - slot_offset, - 1, - 5, - 0); - - //antenna port 5 symbol 0 slot 1 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+9*samples_per_symbol], - amp, - slot_offset+1, - 0, - 5, - 0); - - //antenna port 5 symbol 1 slot 1 - lte_dl_ue_spec(phy_vars_eNB, - UE_id, - &txdataF[aa][tti_offset+12*samples_per_symbol], - amp, - slot_offset+1, - 1, - 5, - 0); - } - } else{ - msg("generate_ue_soec_pilots:Extented Cyclic Prefix for TM7 is not supported yet.\n"); - } - - - } - break; - - case 8: - case 9: - case 10: - default: - msg("[generate_ue_spec_pilots(in uespec_pilots.c)]ERROR:beamforming mode %d is not supported\n",beamforming_mode); - - }*/ -} - -/*int generate_ue_spec_pilots_slot(PHY_VARS_eNB *phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint16_t slot, - int first_pilot_only) -{ - - LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->lte_frame_parms; - uint32_t slot_offset,Nsymb,samples_per_symbol; - uint8_t second_pilot; - - if (slot<0 || slot>= 20) { - msg("generate_pilots_slot: slot not in range (%d)\n",slot); - return(-1); - } - - Nsymb = (frame_parms->Ncp==0)?7:6; - second_pilot = (frame_parms->Ncp==0)?4:3; - - - slot_offset = slot*frame_parms->ofdm_symbol_size*Nsymb; - samples_per_symbol = frame_parms->ofdm_symbol_size; - - // printf("tti %d : offset %d (slot %d)\n",tti,tti_offset,slot_offset); - //Generate Pilots - - //antenna 0 symbol 0 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[0][slot_offset], - amp, - slot, - 0, - 0); - - - if (first_pilot_only==0) { - //antenna 0 symbol 3 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[0][slot_offset+(second_pilot*samples_per_symbol)], - amp, - slot, - 1, - 0); - } - - if (frame_parms->nb_antennas_tx > 1) { - if (frame_parms->mode1_flag) { - // antenna 1 symbol 0 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset], - amp, - slot, - 0, - 0); - - if (first_pilot_only==0) { - // antenna 1 symbol 3 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset+(second_pilot*samples_per_symbol)], - amp, - slot, - 1, - 0); - } - } else { - - // antenna 1 symbol 0 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset], - amp, - slot, - 0, - 1); - - if (first_pilot_only == 0) { - // antenna 1 symbol 3 slot 0 - lte_dl_cell_spec(phy_vars_eNB, - &txdataF[1][slot_offset+(second_pilot*samples_per_symbol)], - amp, - slot, - 1, - 1); - } - } - } - - return(0); -}*/ - diff --git a/openair1/PHY/LTE_TRANSPORT/pmch.c b/openair1/PHY/LTE_TRANSPORT/pmch.c index e756df1fe1a5b4fd4612d0f019bca3bd57c7a64f..23bc07f17448806c4c2a8563f47bf86f647fc024 100644 --- a/openair1/PHY/LTE_TRANSPORT/pmch.c +++ b/openair1/PHY/LTE_TRANSPORT/pmch.c @@ -19,10 +19,11 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/sse_intrin.h" - +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "transport_eNB.h" +#include "transport_proto.h" +#include "transport_common_proto.h" // Mask for identifying subframe for MBMS #define MBSFN_TDD_SF3 0x80// for TDD #define MBSFN_TDD_SF4 0x40 @@ -30,7 +31,7 @@ #define MBSFN_TDD_SF8 0x10 #define MBSFN_TDD_SF9 0x08 -#include "PHY/defs.h" + #define MBSFN_FDD_SF1 0x80// for FDD #define MBSFN_FDD_SF2 0x40 @@ -41,148 +42,6 @@ -void dump_mch(PHY_VARS_UE *ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe) -{ - - unsigned int nsymb_pmch=12; - char fname[32],vname[32]; - int N_RB_DL=ue->frame_parms.N_RB_DL; - - sprintf(fname,"mch_rxF_ext0.m"); - sprintf(vname,"pmch_rxF_ext0"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb_pmch,1,1); - sprintf(fname,"mch_ch_ext00.m"); - sprintf(vname,"pmch_ch_ext00"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb_pmch,1,1); - /* - write_output("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb_pmch,1,1); - write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb_pmch,1,1); - write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb_pmch,1,1); - write_output("dlsch%d_rho.m","dl_rho",pdsch_vars[eNB_id]->rho[0],12*N_RB_DL*nsymb_pmch,1,1); - */ - sprintf(fname,"mch_rxF_comp0.m"); - sprintf(vname,"pmch_rxF_comp0"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb_pmch,1,1); - sprintf(fname,"mch_rxF_llr.m"); - sprintf(vname,"pmch_llr"); - write_output(fname,vname, ue->pdsch_vars_MCH[eNB_id]->llr[0],coded_bits_per_codeword,1,0); - sprintf(fname,"mch_mag1.m"); - sprintf(vname,"pmch_mag1"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_mag0[0],12*N_RB_DL*nsymb_pmch,1,1); - sprintf(fname,"mch_mag2.m"); - sprintf(vname,"pmch_mag2"); - write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_magb0[0],12*N_RB_DL*nsymb_pmch,1,1); - - write_output("mch00_ch0.m","pmch00_ch0", - &(ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][0][0]), - ue->frame_parms.ofdm_symbol_size*12,1,1); - - write_output("rxsig_mch.m","rxs_mch", - &ue->common_vars.rxdata[0][subframe*ue->frame_parms.samples_per_tti], - ue->frame_parms.samples_per_tti,1,1); - - /* - if (PHY_vars_eNB_g) - write_output("txsig_mch.m","txs_mch", - &PHY_vars_eNB_g[0][0]->common_vars.txdata[0][0][subframe*ue->frame_parms.samples_per_tti], - ue->frame_parms.samples_per_tti,1,1);*/ -} - -int is_pmch_subframe(uint32_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms) -{ - - uint32_t period; - uint8_t i; - - // LOG_D(PHY,"is_pmch_subframe: frame %d, subframe %d, num_MBSFN_config %d\n", - // frame,subframe,frame_parms->num_MBSFN_config); - - for (i=0; i<frame_parms->num_MBSFN_config; i++) { // we have at least one MBSFN configuration - period = 1<<frame_parms->MBSFN_config[i].radioframeAllocationPeriod; - - if ((frame % period) == frame_parms->MBSFN_config[i].radioframeAllocationOffset) { - if (frame_parms->MBSFN_config[i].fourFrames_flag == 0) { - if (frame_parms->frame_type == FDD) { - switch (subframe) { - - case 1: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF1) > 0) - return(1); - - break; - - case 2: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF2) > 0) - return(1); - - break; - - case 3: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF3) > 0) - return(1); - - break; - - case 6: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF6) > 0) - return(1); - - break; - - case 7: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF7) > 0) - return(1); - - break; - - case 8: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF8) > 0) - return(1); - - break; - } - } else { - switch (subframe) { - case 3: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF3) > 0) - return(1); - - break; - - case 4: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF4) > 0) - return(1); - - break; - - case 7: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF7) > 0) - return(1); - - break; - - case 8: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF8) > 0) - return(1); - - break; - - case 9: - if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF9) > 0) - return(1); - - break; - } - } - - } else { // handle 4 frames case - - } - } - } - - return(0); -} void fill_eNB_dlsch_MCH(PHY_VARS_eNB *eNB,int mcs,int ndi,int rvidx) { @@ -221,64 +80,8 @@ void fill_eNB_dlsch_MCH(PHY_VARS_eNB *eNB,int mcs,int ndi,int rvidx) break; } - if (eNB->abstraction_flag) { - eNB_transport_info[eNB->Mod_id][eNB->CC_id].cntl.pmch_flag=1; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].num_pmch=1; // assumption: there is always one pmch in each SF - eNB_transport_info[eNB->Mod_id][eNB->CC_id].num_common_dci=0; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].num_ue_spec_dci=0; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].dlsch_type[0]=5;// put at the reserved position for PMCH - eNB_transport_info[eNB->Mod_id][eNB->CC_id].harq_pid[0]=0; - eNB_transport_info[eNB->Mod_id][eNB->CC_id].ue_id[0]=255;//broadcast - eNB_transport_info[eNB->Mod_id][eNB->CC_id].tbs[0]=dlsch->harq_processes[0]->TBS>>3; - } - } -void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id) -{ - - LTE_UE_DLSCH_t *dlsch = ue->dlsch_MCH[eNB_id]; - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - - // dlsch->rnti = M_RNTI; - dlsch->harq_processes[0]->mcs = mcs; - dlsch->harq_processes[0]->rvidx = rvidx; - // dlsch->harq_processes[0]->Ndi = ndi; - dlsch->harq_processes[0]->Nl = 1; - dlsch->harq_processes[0]->TBS = TBStable[get_I_TBS(dlsch->harq_processes[0]->mcs)][frame_parms->N_RB_DL-1]; - dlsch->current_harq_pid = 0; - dlsch->harq_processes[0]->nb_rb = frame_parms->N_RB_DL; - - switch(frame_parms->N_RB_DL) { - case 6: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0x3f; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x3f; - break; - - case 25: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0x1ffffff; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x1ffffff; - break; - - case 50: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[1] = 0x3ffff; - dlsch->harq_processes[0]->rb_alloc_odd[1] = 0x3ffff; - break; - - case 100: - dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[1] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[1] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[2] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_odd[2] = 0xffffffff; - dlsch->harq_processes[0]->rb_alloc_even[3] = 0xf; - dlsch->harq_processes[0]->rb_alloc_odd[3] = 0xf; - break; - } -} void generate_mch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t *a) { @@ -287,759 +90,36 @@ void generate_mch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t *a) int subframe = proc->subframe_tx; int frame = proc->frame_tx; - if (eNB->abstraction_flag != 0) { - if (eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]!=0) - printf("[PHY][EMU] PMCH transport block position is different than zero %d \n", eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]); - - memcpy(eNB->dlsch_MCH->harq_processes[0]->b, - a, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - LOG_D(PHY, "[eNB %d] dlsch_encoding_emul pmch , tbs is %d \n", - eNB->Mod_id, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - - memcpy(&eNB_transport_info[eNB->Mod_id][eNB->CC_id].transport_blocks[eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]], - a, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - eNB_transport_info_TB_index[eNB->Mod_id][eNB->CC_id]+= eNB->dlsch_MCH->harq_processes[0]->TBS>>3;//=eNB_transport_info[eNB->Mod_id].tbs[0]; - } else { - G = get_G(&eNB->frame_parms, - eNB->frame_parms.N_RB_DL, - eNB->dlsch_MCH->harq_processes[0]->rb_alloc, - get_Qm(eNB->dlsch_MCH->harq_processes[0]->mcs),1, - 2,proc->frame_tx,subframe,0); - - generate_mbsfn_pilot(eNB,proc, - eNB->common_vars.txdataF, - AMP); - - - AssertFatal(dlsch_encoding(eNB, - a, - 1, - eNB->dlsch_MCH, - proc->frame_tx, - subframe, - &eNB->dlsch_rate_matching_stats, - &eNB->dlsch_turbo_encoding_stats, - &eNB->dlsch_interleaving_stats)==0, - "problem in dlsch_encoding"); - - dlsch_scrambling(&eNB->frame_parms,1,eNB->dlsch_MCH,0,G,0,frame,subframe<<1); - - - mch_modulation(eNB->common_vars.txdataF, - AMP, - subframe, - &eNB->frame_parms, - eNB->dlsch_MCH); - } - -} - -void mch_extract_rbs(int **rxdataF, - int **dl_ch_estimates, - int **rxdataF_ext, - int **dl_ch_estimates_ext, - unsigned char symbol, - unsigned char subframe, - LTE_DL_FRAME_PARMS *frame_parms) -{ - - int pilots=0,i,j,offset,aarx; - - // printf("Extracting PMCH: symbol %d\n",symbol); - if ((symbol==2)|| - (symbol==10)) { - pilots = 1; - offset = 1; - } else if (symbol==6) { - pilots = 1; - offset = 0; - } - - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (pilots==1) { - for (i=offset,j=0; i<frame_parms->N_RB_DL*6; i+=2,j++) { - /* printf("MCH with pilots: i %d, j %d => %d,%d\n",i,j, - *(int16_t*)&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], - *(int16_t*)(1+&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)])); - */ - rxdataF_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)]; - rxdataF_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+1+ (symbol*frame_parms->ofdm_symbol_size)]; - dl_ch_estimates_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(symbol*frame_parms->ofdm_symbol_size)]; - dl_ch_estimates_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(frame_parms->N_RB_DL*6)+(symbol*frame_parms->ofdm_symbol_size)]; - } - } else { - - memcpy((void*)&rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], - (void*)&rxdataF[aarx][frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], - frame_parms->N_RB_DL*24); - memcpy((void*)&rxdataF_ext[aarx][(frame_parms->N_RB_DL*6) + symbol*(frame_parms->N_RB_DL*12)], - (void*)&rxdataF[aarx][1 + (symbol*frame_parms->ofdm_symbol_size)], - frame_parms->N_RB_DL*24); - memcpy((void*)&dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], - (void*)&dl_ch_estimates[aarx][(symbol*frame_parms->ofdm_symbol_size)], - frame_parms->N_RB_DL*48); - - } - - } - - - -} - -void mch_channel_level(int **dl_ch_estimates_ext, - LTE_DL_FRAME_PARMS *frame_parms, - int *avg, - uint8_t symbol, - unsigned short nb_rb) -{ - - int i,aarx,nre; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,avg128; -#elif defined(__arm__) - int32x4_t avg128; -#endif - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { -#if defined(__x86_64__) || defined(__i386__) - //clear average level - avg128 = _mm_setzero_si128(); - // 5 is always a symbol with no pilots for both normal and extended prefix - - dl_ch128=(__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - - -#endif - if ((symbol == 2) || (symbol == 6) || (symbol == 10)) - nre = (frame_parms->N_RB_DL*6); - else - nre = (frame_parms->N_RB_DL*12); - - for (i=0; i<(nre>>2); i++) { -#if defined(__x86_64__) || defined(__i386__) - avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); -#elif defined(__arm__) - -#endif - } - - avg[aarx] = (((int*)&avg128)[0] + - ((int*)&avg128)[1] + - ((int*)&avg128)[2] + - ((int*)&avg128)[3])/nre; - - // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -void mch_channel_compensation(int **rxdataF_ext, - int **dl_ch_estimates_ext, - int **dl_ch_mag, - int **dl_ch_magb, - int **rxdataF_comp, - LTE_DL_FRAME_PARMS *frame_parms, - unsigned char symbol, - unsigned char mod_order, - unsigned char output_shift) -{ - - int aarx,nre,i; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; -#elif defined(__arm__) - -#endif - if ((symbol == 2) || (symbol == 6) || (symbol == 10)) - nre = frame_parms->N_RB_DL*6; - else - nre = frame_parms->N_RB_DL*12; - -#if defined(__x86_64__) || defined(__i386__) - if (mod_order == 4) { - QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) - QAM_amp128b = _mm_setzero_si128(); - } else if (mod_order == 6) { - QAM_amp128 = _mm_set1_epi16(QAM64_n1); // - QAM_amp128b = _mm_set1_epi16(QAM64_n2); - } -#elif defined(__arm__) - -#endif - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128 = (__m128i *)&dl_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128b = (__m128i *)&dl_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - -#endif - - for (i=0; i<(nre>>2); i+=2) { - if (mod_order>2) { - // get channel amplitude if not QPSK -#if defined(__x86_64__) || defined(__i386__) - - mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128[0]); - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - - mmtmpD1 = _mm_madd_epi16(dl_ch128[1],dl_ch128[1]); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - - mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1); - - // store channel magnitude here in a new field of dlsch - - dl_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0); - dl_ch_mag128b[0] = dl_ch_mag128[0]; - dl_ch_mag128[0] = _mm_mulhi_epi16(dl_ch_mag128[0],QAM_amp128); - dl_ch_mag128[0] = _mm_slli_epi16(dl_ch_mag128[0],1); - - dl_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0); - dl_ch_mag128b[1] = dl_ch_mag128[1]; - dl_ch_mag128[1] = _mm_mulhi_epi16(dl_ch_mag128[1],QAM_amp128); - dl_ch_mag128[1] = _mm_slli_epi16(dl_ch_mag128[1],1); - - - dl_ch_mag128b[0] = _mm_mulhi_epi16(dl_ch_mag128b[0],QAM_amp128b); - dl_ch_mag128b[0] = _mm_slli_epi16(dl_ch_mag128b[0],1); - - - dl_ch_mag128b[1] = _mm_mulhi_epi16(dl_ch_mag128b[1],QAM_amp128b); - dl_ch_mag128b[1] = _mm_slli_epi16(dl_ch_mag128b[1],1); - -#elif defined(__arm__) - -#endif - } - -#if defined(__x86_64__) || defined(__i386__) - - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpD1); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - // print_ints("c0",&mmtmpD2); - // print_ints("c1",&mmtmpD3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); - mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); - mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); - mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); - mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); - - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - - dl_ch128+=2; - dl_ch_mag128+=2; - dl_ch_mag128b+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - -#elif defined(__arm__) - -#endif - } - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} - -void mch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - int **dl_ch_mag, - int **dl_ch_magb, - unsigned char symbol) -{ - - - int i; -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; -#elif defined(__arm__) - int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; -#endif - if (frame_parms->nb_antennas_rx>1) { - -#if defined(__x86_64__) || defined(__i386__) - - rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0 = (int16x8_t *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1 = (int16x8_t *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_0b = (int16x8_t *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; - dl_ch_mag128_1b = (int16x8_t *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; - -#endif - // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) - for (i=0; i<frame_parms->N_RB_DL*3; i++) { -#if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); - dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1)); - dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1)); -#elif defined(__arm__) - rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); - dl_ch_mag128_0[i] = vhaddq_s16(dl_ch_mag128_0[i],dl_ch_mag128_1[i]); - dl_ch_mag128_0b[i] = vhaddq_s16(dl_ch_mag128_0b[i],dl_ch_mag128_1b[i]); -#endif - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -int mch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - short *dlsch_llr, - unsigned char symbol, - short **llr32p) -{ - - uint32_t *rxF = (uint32_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - uint32_t *llr32; - int i,len; - - if (symbol==2) { - llr32 = (uint32_t*)dlsch_llr; - } else { - llr32 = (uint32_t*)(*llr32p); - } - - AssertFatal(llr32!=NULL,"dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32); - - - if ((symbol==2) || (symbol==6) || (symbol==10)) { - len = frame_parms->N_RB_DL*6; - } else { - len = frame_parms->N_RB_DL*12; - } - - // printf("dlsch_qpsk_llr: symbol %d,len %d,pbch_pss_sss_adjust %d\n",symbol,len,pbch_pss_sss_adjust); - for (i=0; i<len; i++) { - *llr32 = *rxF; - rxF++; - llr32++; - } - - *llr32p = (short *)llr32; - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - - return(0); -} - -//---------------------------------------------------------------------------------------------- -// 16-QAM -//---------------------------------------------------------------------------------------------- - -void mch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - short *dlsch_llr, - int **dl_ch_mag, - unsigned char symbol, - int16_t **llr32p) -{ - -#if defined(__x86_64__) || defined(__i386__) - __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - __m128i *ch_mag; - __m128i llr128[2],xmm0; - uint32_t *llr32; -#elif defined(__arm__) - int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int16x8_t *ch_mag; - int16x8_t llr128[2],xmm0; - int16_t *llr16; -#endif - int i,len; - unsigned char len_mod4=0; - -#if defined(__x86_64__) || defined(__i386__) - if (symbol==2) { - llr32 = (uint32_t*)dlsch_llr; - } else { - llr32 = (uint32_t*)*llr32p; - } -#elif defined(__arm__) - if (symbol==2) { - llr16 = (int16_t*)dlsch_llr; - } else { - llr16 = (int16_t*)*llr32p; - } -#endif -#if defined(__x86_64__) || defined(__i386__) - ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; -#elif defined(__arm__) - ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; -#endif - if ((symbol==2) || (symbol==6) || (symbol==10)) { - len = frame_parms->N_RB_DL*6; - } else { - len = frame_parms->N_RB_DL*12; - } - - - - // update output pointer according to number of REs in this symbol (<<2 because 4 bits per RE) - if (symbol==2) - *llr32p = dlsch_llr + (len<<2); - else - *llr32p += (len<<2); - - len_mod4 = len&3; - len>>=2; // length in quad words (4 REs) - len+=(len_mod4==0 ? 0 : 1); - - for (i=0; i<len; i++) { - -#if defined(__x86_64__) || defined(__i386__) - xmm0 = _mm_abs_epi16(rxF[i]); - xmm0 = _mm_subs_epi16(ch_mag[i],xmm0); - - // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 - llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0); - llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0); - llr32[0] = ((uint32_t *)&llr128[0])[0]; - llr32[1] = ((uint32_t *)&llr128[0])[1]; - llr32[2] = ((uint32_t *)&llr128[0])[2]; - llr32[3] = ((uint32_t *)&llr128[0])[3]; - llr32[4] = ((uint32_t *)&llr128[1])[0]; - llr32[5] = ((uint32_t *)&llr128[1])[1]; - llr32[6] = ((uint32_t *)&llr128[1])[2]; - llr32[7] = ((uint32_t *)&llr128[1])[3]; - llr32+=8; - -#elif defined(__arm__) - xmm0 = vabsq_s16(rxF[i]); - xmm0 = vsubq_s16(ch_mag[i],xmm0); - - // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 - - llr16[0] = vgetq_lane_s16(rxF[i],0); - llr16[1] = vgetq_lane_s16(xmm0,0); - llr16[2] = vgetq_lane_s16(rxF[i],1); - llr16[3] = vgetq_lane_s16(xmm0,1); - llr16[4] = vgetq_lane_s16(rxF[i],2); - llr16[5] = vgetq_lane_s16(xmm0,2); - llr16[6] = vgetq_lane_s16(rxF[i],2); - llr16[7] = vgetq_lane_s16(xmm0,3); - llr16[8] = vgetq_lane_s16(rxF[i],4); - llr16[9] = vgetq_lane_s16(xmm0,4); - llr16[10] = vgetq_lane_s16(rxF[i],5); - llr16[11] = vgetq_lane_s16(xmm0,5); - llr16[12] = vgetq_lane_s16(rxF[i],6); - llr16[13] = vgetq_lane_s16(xmm0,6); - llr16[14] = vgetq_lane_s16(rxF[i],7); - llr16[15] = vgetq_lane_s16(xmm0,7); - llr16+=16; -#endif - - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -//---------------------------------------------------------------------------------------------- -// 64-QAM -//---------------------------------------------------------------------------------------------- - -void mch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, - int **rxdataF_comp, - short *dlsch_llr, - int **dl_ch_mag, - int **dl_ch_magb, - unsigned char symbol, - short **llr_save) -{ - -#if defined(__x86_64__) || defined(__i386__) - __m128i xmm1,xmm2,*ch_mag,*ch_magb; - __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; -#elif defined(__arm__) - int16x8_t xmm1,xmm2,*ch_mag,*ch_magb; - int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; -#endif - - int i,len,len2; - // int j=0; - unsigned char len_mod4; - short *llr; - int16_t *llr2; - - if (symbol==2) - llr = dlsch_llr; - else - llr = *llr_save; - -#if defined(__x86_64__) || defined(__i386__) - ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; - ch_magb = (__m128i*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; -#elif defined(__arm__) - ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; - ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; -#endif - if ((symbol==2) || (symbol==6) || (symbol==10)) { - len = frame_parms->N_RB_DL*6; - } else { - len = frame_parms->N_RB_DL*12; - } - - - llr2 = llr; - llr += (len*6); - - len_mod4 =len&3; - len2=len>>2; // length in quad words (4 REs) - len2+=(len_mod4?0:1); - - - for (i=0; i<len2; i++) { -#if defined(__x86_64__) || defined(__i386__) - xmm1 = _mm_abs_epi16(rxF[i]); - xmm1 = _mm_subs_epi16(ch_mag[i],xmm1); - xmm2 = _mm_abs_epi16(xmm1); - xmm2 = _mm_subs_epi16(ch_magb[i],xmm2); -#elif defined(__arm__) - xmm1 = vabsq_s16(rxF[i]); - xmm1 = vsubq_s16(ch_mag[i],xmm1); - xmm2 = vabsq_s16(xmm1); - xmm2 = vsubq_s16(ch_magb[i],xmm2); -#endif - - /* - printf("pmch i: %d => mag (%d,%d) (%d,%d)\n",i,((short *)&ch_mag[i])[0],((short *)&ch_magb[i])[0], - ((short *)&rxF[i])[0],((short *)&rxF[i])[1]); - */ - // loop over all LLRs in quad word (24 coded bits) - /* - for (j=0;j<8;j+=2) { - llr2[0] = ((short *)&rxF[i])[j]; - llr2[1] = ((short *)&rxF[i])[j+1]; - llr2[2] = _mm_extract_epi16(xmm1,j); - llr2[3] = _mm_extract_epi16(xmm1,j+1);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,j);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,j+1);//((short *)&xmm2)[j+1]; - - llr2+=6; - } - */ - llr2[0] = ((short *)&rxF[i])[0]; - llr2[1] = ((short *)&rxF[i])[1]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,0); - llr2[3] = _mm_extract_epi16(xmm1,1);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,0);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,1);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,0); - llr2[3] = vgetq_lane_s16(xmm1,1);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,0);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,1);//((short *)&xmm2)[j+1]; -#endif - - llr2+=6; - llr2[0] = ((short *)&rxF[i])[2]; - llr2[1] = ((short *)&rxF[i])[3]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,2); - llr2[3] = _mm_extract_epi16(xmm1,3);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,2);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,3);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,2); - llr2[3] = vgetq_lane_s16(xmm1,3);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,2);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,3);//((short *)&xmm2)[j+1]; -#endif - llr2+=6; - llr2[0] = ((short *)&rxF[i])[4]; - llr2[1] = ((short *)&rxF[i])[5]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,4); - llr2[3] = _mm_extract_epi16(xmm1,5);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,4);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,5);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,4); - llr2[3] = vgetq_lane_s16(xmm1,5);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,4);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,5);//((short *)&xmm2)[j+1]; -#endif - llr2+=6; - llr2[0] = ((short *)&rxF[i])[6]; - llr2[1] = ((short *)&rxF[i])[7]; -#if defined(__x86_64__) || defined(__i386__) - llr2[2] = _mm_extract_epi16(xmm1,6); - llr2[3] = _mm_extract_epi16(xmm1,7);//((short *)&xmm1)[j+1]; - llr2[4] = _mm_extract_epi16(xmm2,6);//((short *)&xmm2)[j]; - llr2[5] = _mm_extract_epi16(xmm2,7);//((short *)&xmm2)[j+1]; -#elif defined(__arm__) - llr2[2] = vgetq_lane_s16(xmm1,6); - llr2[3] = vgetq_lane_s16(xmm1,7);//((short *)&xmm1)[j+1]; - llr2[4] = vgetq_lane_s16(xmm2,6);//((short *)&xmm2)[j]; - llr2[5] = vgetq_lane_s16(xmm2,7);//((short *)&xmm2)[j+1]; -#endif - llr2+=6; - } - - *llr_save = llr; -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} - -int avg_pmch[4]; -int rx_pmch(PHY_VARS_UE *ue, - unsigned char eNB_id, - uint8_t subframe, - unsigned char symbol) -{ - - LTE_UE_COMMON *common_vars = &ue->common_vars; - LTE_UE_PDSCH **pdsch_vars = &ue->pdsch_vars_MCH[eNB_id]; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - LTE_UE_DLSCH_t **dlsch = &ue->dlsch_MCH[eNB_id]; - int avgs,aarx; - - //printf("*********************mch: symbol %d\n",symbol); - - mch_extract_rbs(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], - pdsch_vars[eNB_id]->rxdataF_ext, - pdsch_vars[eNB_id]->dl_ch_estimates_ext, - symbol, - subframe, - frame_parms); - - if (symbol == 2) { - mch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext, - frame_parms, - avg_pmch, - symbol, - frame_parms->N_RB_DL); - } - - avgs = 0; - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) - avgs = cmax(avgs,avg_pmch[aarx]); - - if (get_Qm(dlsch[0]->harq_processes[0]->mcs)==2) - pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) ;// + 2 - else - pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2); // + 5;// + 2 - - mch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext, - pdsch_vars[eNB_id]->dl_ch_estimates_ext, - pdsch_vars[eNB_id]->dl_ch_mag0, - pdsch_vars[eNB_id]->dl_ch_magb0, - pdsch_vars[eNB_id]->rxdataF_comp0, - frame_parms, - symbol, - get_Qm(dlsch[0]->harq_processes[0]->mcs), - pdsch_vars[eNB_id]->log2_maxh); - - - if (frame_parms->nb_antennas_rx > 1) - mch_detection_mrc(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->dl_ch_mag0, - pdsch_vars[eNB_id]->dl_ch_magb0, - symbol); - - switch (get_Qm(dlsch[0]->harq_processes[0]->mcs)) { - case 2 : - mch_qpsk_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], - symbol, - pdsch_vars[eNB_id]->llr128); - break; - - case 4: - mch_16qam_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], - pdsch_vars[eNB_id]->dl_ch_mag0, - symbol, - pdsch_vars[eNB_id]->llr128); - break; - - case 6: - mch_64qam_llr(frame_parms, - pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], - pdsch_vars[eNB_id]->dl_ch_mag0, - pdsch_vars[eNB_id]->dl_ch_magb0, - symbol, - pdsch_vars[eNB_id]->llr128); - break; - } + G = get_G(&eNB->frame_parms, + eNB->frame_parms.N_RB_DL, + eNB->dlsch_MCH->harq_processes[0]->rb_alloc, + get_Qm(eNB->dlsch_MCH->harq_processes[0]->mcs),1, + 2,proc->frame_tx,subframe,0); + + generate_mbsfn_pilot(eNB,proc, + eNB->common_vars.txdataF, + AMP); + + + AssertFatal(dlsch_encoding(eNB, + a, + 1, + eNB->dlsch_MCH, + proc->frame_tx, + subframe, + &eNB->dlsch_rate_matching_stats, + &eNB->dlsch_turbo_encoding_stats, + &eNB->dlsch_interleaving_stats)==0, + "problem in dlsch_encoding"); + + dlsch_scrambling(&eNB->frame_parms,1,eNB->dlsch_MCH,0,G,0,frame,subframe<<1); + + + mch_modulation(eNB->common_vars.txdataF, + AMP, + subframe, + &eNB->frame_parms, + eNB->dlsch_MCH); - return(0); } diff --git a/openair1/PHY/LTE_TRANSPORT/pmch_common.c b/openair1/PHY/LTE_TRANSPORT/pmch_common.c new file mode 100644 index 0000000000000000000000000000000000000000..1d12c79621ea403c93c1eaa6389da0fa5065aa8c --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pmch_common.c @@ -0,0 +1,119 @@ +/* + * 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 "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" + +int is_pmch_subframe(uint32_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms) +{ + + uint32_t period; + uint8_t i; + + // LOG_D(PHY,"is_pmch_subframe: frame %d, subframe %d, num_MBSFN_config %d\n", + // frame,subframe,frame_parms->num_MBSFN_config); + + for (i=0; i<frame_parms->num_MBSFN_config; i++) { // we have at least one MBSFN configuration + period = 1<<frame_parms->MBSFN_config[i].radioframeAllocationPeriod; + + if ((frame % period) == frame_parms->MBSFN_config[i].radioframeAllocationOffset) { + if (frame_parms->MBSFN_config[i].fourFrames_flag == 0) { + if (frame_parms->frame_type == FDD) { + switch (subframe) { + + case 1: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF1) > 0) + return(1); + + break; + + case 2: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF2) > 0) + return(1); + + break; + + case 3: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF3) > 0) + return(1); + + break; + + case 6: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF6) > 0) + return(1); + + break; + + case 7: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF7) > 0) + return(1); + + break; + + case 8: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_FDD_SF8) > 0) + return(1); + + break; + } + } else { + switch (subframe) { + case 3: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF3) > 0) + return(1); + + break; + + case 4: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF4) > 0) + return(1); + + break; + + case 7: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF7) > 0) + return(1); + + break; + + case 8: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF8) > 0) + return(1); + + break; + + case 9: + if ((frame_parms->MBSFN_config[i].mbsfn_SubframeConfig & MBSFN_TDD_SF9) > 0) + return(1); + + break; + } + } + + } else { // handle 4 frames case + + } + } + } + + return(0); +} diff --git a/openair1/PHY/LTE_TRANSPORT/power_control.c b/openair1/PHY/LTE_TRANSPORT/power_control.c index 36b2bfbeab81abcaac6287a9219898f24160742e..32273015ce9417bd80cb8f408ffb662f043afcbc 100644 --- a/openair1/PHY/LTE_TRANSPORT/power_control.c +++ b/openair1/PHY/LTE_TRANSPORT/power_control.c @@ -19,7 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "PHY/impl_defs_lte.h" //#define DEBUG_PC 0 @@ -94,7 +95,6 @@ double computeRhoB_eNB(uint8_t pa, return(rho_b_dB); } - double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, LTE_UE_DLSCH_t *dlsch_ue, unsigned char dl_power_off, @@ -150,3 +150,4 @@ double computeRhoB_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, #endif return(rho_b_dB); } + diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index b58aa91636a4d83fb9aa5d6aabfa3a476fc2e884..90dca2337ed460ead6202e76bdaca8f89e3f7a8c 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -30,1066 +30,20 @@ * \warning */ #include "PHY/sse_intrin.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" //#include "prach.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "SCHED/sched_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "prach_extern.h" //#define PRACH_DEBUG 1 //#define PRACH_WRITE_OUTPUT_DEBUG 1 -uint16_t NCS_unrestricted[16] = {0,13,15,18,22,26,32,38,46,59,76,93,119,167,279,419}; -uint16_t NCS_restricted[15] = {15,18,22,26,32,38,46,55,68,82,100,128,158,202,237}; // high-speed case -uint16_t NCS_4[7] = {2,4,6,8,10,12,15}; - -int16_t ru[2*839]; // quantized roots of unity -uint32_t ZC_inv[839]; // multiplicative inverse for roots u -uint16_t du[838]; - -typedef struct { - uint8_t f_ra; - uint8_t t0_ra; - uint8_t t1_ra; - uint8_t t2_ra; -} PRACH_TDD_PREAMBLE_MAP_elem; -typedef struct { - uint8_t num_prach; - PRACH_TDD_PREAMBLE_MAP_elem map[6]; -} PRACH_TDD_PREAMBLE_MAP; - -// This is table 5.7.1-4 from 36.211 -PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7] = { - // TDD Configuration Index 0 - { {1,{{0,1,0,2}}},{1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}}, - // TDD Configuration Index 1 - { {1,{{0,2,0,2}}},{1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}}, - // TDD Configuration Index 2 - { {1,{{0,1,1,2}}},{1,{{0,1,1,1}}}, {1,{{0,1,1,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,1}}}}, - // TDD Configuration Index 3 - { {1,{{0,0,0,2}}},{1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}}, - // TDD Configuration Index 4 - { {1,{{0,0,1,2}}},{1,{{0,0,1,1}}}, {1,{{0,0,1,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,1}}}}, - // TDD Configuration Index 5 - { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, - // TDD Configuration Index 6 - { {2,{{0,0,0,2},{0,0,1,2}}}, {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {2,{{0,0,0,1},{0,0,0,2}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {2,{{0,0,0,2},{0,0,1,1}}}}, - // TDD Configuration Index 7 - { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,2}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, - // TDD Configuration Index 8 - { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,1,1}}}}, - // TDD Configuration Index 9 - { {3,{{0,0,0,1},{0,0,0,2},{0,0,1,2}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,0,2}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {3,{{0,0,0,1},{0,0,0,2},{0,0,1,1}}}}, - // TDD Configuration Index 10 - { {3,{{0,0,0,0},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,2},{0,0,1,0}}}}, - // TDD Configuration Index 11 - { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}}, - // TDD Configuration Index 12 - { {4,{{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, - {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,2}}}, - {4,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {4,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} - }, - // TDD Configuration Index 13 - { {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1}}} - }, - // TDD Configuration Index 14 - { {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} - }, - // TDD Configuration Index 15 - { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1}}}, - {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1},{1,0,0,2}}}, - {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,1}}}, {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, - {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} - }, - // TDD Configuration Index 16 - { {5,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,1,1}}}, - {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,1,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,2}}}, - {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} - }, - // TDD Configuration Index 17 - { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} - }, - // TDD Configuration Index 18 - { {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, - {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1},{1,0,0,2}}}, - {6,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0},{2,0,0,1}}}, - {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,0,2}}} - }, - // TDD Configuration Index 19 - { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0},{1,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,1,1}}} - }, - // TDD Configuration Index 20 - { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, - // TDD Configuration Index 21 - { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, - - // TDD Configuration Index 22 - { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, - - // TDD Configuration Index 23 - { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, - - // TDD Configuration Index 24 - { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, - - // TDD Configuration Index 25 - { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, - - // TDD Configuration Index 26 - { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, - - // TDD Configuration Index 27 - { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} - }, - - // TDD Configuration Index 28 - { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, - {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} - }, - - // TDD Configuration Index 29 - { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, - {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, - {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} - }, - - - // TDD Configuration Index 30 - { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, - - // TDD Configuration Index 31 - { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, - - // TDD Configuration Index 32 - { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, - - // TDD Configuration Index 33 - { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, - - // TDD Configuration Index 34 - { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, - - // TDD Configuration Index 35 - { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, - - // TDD Configuration Index 36 - { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, - - // TDD Configuration Index 37 - { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} - }, - - // TDD Configuration Index 38 - { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, - {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} - }, - - // TDD Configuration Index 39 - { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, - {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, - {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} - }, - - // TDD Configuration Index 40 - { {1,{{0,1,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}}, - // TDD Configuration Index 41 - { {1,{{0,2,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}}, - - // TDD Configuration Index 42 - { {1,{{0,1,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, - - // TDD Configuration Index 43 - { {1,{{0,0,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}}, - - // TDD Configuration Index 44 - { {1,{{0,0,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, - - // TDD Configuration Index 45 - { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}}, - - // TDD Configuration Index 46 - { {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}}, - - // TDD Configuration Index 47 - { {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, - {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}} - } -}; - - - -uint16_t prach_root_sequence_map0_3[838] = { 129, 710, 140, 699, 120, 719, 210, 629, 168, 671, 84, 755, 105, 734, 93, 746, 70, 769, 60, 779, - 2, 837, 1, 838, - 56, 783, 112, 727, 148, 691, - 80, 759, 42, 797, 40, 799, - 35, 804, 73, 766, 146, 693, - 31, 808, 28, 811, 30, 809, 27, 812, 29, 810, - 24, 815, 48, 791, 68, 771, 74, 765, 178, 661, 136, 703, - 86, 753, 78, 761, 43, 796, 39, 800, 20, 819, 21, 818, - 95, 744, 202, 637, 190, 649, 181, 658, 137, 702, 125, 714, 151, 688, - 217, 622, 128, 711, 142, 697, 122, 717, 203, 636, 118, 721, 110, 729, 89, 750, 103, 736, 61, - 778, 55, 784, 15, 824, 14, 825, - 12, 827, 23, 816, 34, 805, 37, 802, 46, 793, 207, 632, 179, 660, 145, 694, 130, 709, 223, 616, - 228, 611, 227, 612, 132, 707, 133, 706, 143, 696, 135, 704, 161, 678, 201, 638, 173, 666, 106, - 733, 83, 756, 91, 748, 66, 773, 53, 786, 10, 829, 9, 830, - 7, 832, 8, 831, 16, 823, 47, 792, 64, 775, 57, 782, 104, 735, 101, 738, 108, 731, 208, 631, 184, - 655, 197, 642, 191, 648, 121, 718, 141, 698, 149, 690, 216, 623, 218, 621, - 152, 687, 144, 695, 134, 705, 138, 701, 199, 640, 162, 677, 176, 663, 119, 720, 158, 681, 164, - 675, 174, 665, 171, 668, 170, 669, 87, 752, 169, 670, 88, 751, 107, 732, 81, 758, 82, 757, 100, - 739, 98, 741, 71, 768, 59, 780, 65, 774, 50, 789, 49, 790, 26, 813, 17, 822, 13, 826, 6, 833, - 5, 834, 33, 806, 51, 788, 75, 764, 99, 740, 96, 743, 97, 742, 166, 673, 172, 667, 175, 664, 187, - 652, 163, 676, 185, 654, 200, 639, 114, 725, 189, 650, 115, 724, 194, 645, 195, 644, 192, 647, - 182, 657, 157, 682, 156, 683, 211, 628, 154, 685, 123, 716, 139, 700, 212, 627, 153, 686, 213, - 626, 215, 624, 150, 689, - 225, 614, 224, 615, 221, 618, 220, 619, 127, 712, 147, 692, 124, 715, 193, 646, 205, 634, 206, - 633, 116, 723, 160, 679, 186, 653, 167, 672, 79, 760, 85, 754, 77, 762, 92, 747, 58, 781, 62, - 777, 69, 770, 54, 785, 36, 803, 32, 807, 25, 814, 18, 821, 11, 828, 4, 835, - 3, 836, 19, 820, 22, 817, 41, 798, 38, 801, 44, 795, 52, 787, 45, 794, 63, 776, 67, 772, 72, - 767, 76, 763, 94, 745, 102, 737, 90, 749, 109, 730, 165, 674, 111, 728, 209, 630, 204, 635, 117, - 722, 188, 651, 159, 680, 198, 641, 113, 726, 183, 656, 180, 659, 177, 662, 196, 643, 155, 684, - 214, 625, 126, 713, 131, 708, 219, 620, 222, 617, 226, 613, - 230, 609, 232, 607, 262, 577, 252, 587, 418, 421, 416, 423, 413, 426, 411, 428, 376, 463, 395, - 444, 283, 556, 285, 554, 379, 460, 390, 449, 363, 476, 384, 455, 388, 451, 386, 453, 361, 478, - 387, 452, 360, 479, 310, 529, 354, 485, 328, 511, 315, 524, 337, 502, 349, 490, 335, 504, 324, - 515, - 323, 516, 320, 519, 334, 505, 359, 480, 295, 544, 385, 454, 292, 547, 291, 548, 381, 458, 399, - 440, 380, 459, 397, 442, 369, 470, 377, 462, 410, 429, 407, 432, 281, 558, 414, 425, 247, 592, - 277, 562, 271, 568, 272, 567, 264, 575, 259, 580, - 237, 602, 239, 600, 244, 595, 243, 596, 275, 564, 278, 561, 250, 589, 246, 593, 417, 422, 248, - 591, 394, 445, 393, 446, 370, 469, 365, 474, 300, 539, 299, 540, 364, 475, 362, 477, 298, 541, - 312, 527, 313, 526, 314, 525, 353, 486, 352, 487, 343, 496, 327, 512, 350, 489, 326, 513, 319, - 520, 332, 507, 333, 506, 348, 491, 347, 492, 322, 517, - 330, 509, 338, 501, 341, 498, 340, 499, 342, 497, 301, 538, 366, 473, 401, 438, 371, 468, 408, - 431, 375, 464, 249, 590, 269, 570, 238, 601, 234, 605, - 257, 582, 273, 566, 255, 584, 254, 585, 245, 594, 251, 588, 412, 427, 372, 467, 282, 557, 403, - 436, 396, 443, 392, 447, 391, 448, 382, 457, 389, 450, 294, 545, 297, 542, 311, 528, 344, 495, - 345, 494, 318, 521, 331, 508, 325, 514, 321, 518, - 346, 493, 339, 500, 351, 488, 306, 533, 289, 550, 400, 439, 378, 461, 374, 465, 415, 424, 270, - 569, 241, 598, - 231, 608, 260, 579, 268, 571, 276, 563, 409, 430, 398, 441, 290, 549, 304, 535, 308, 531, 358, - 481, 316, 523, - 293, 546, 288, 551, 284, 555, 368, 471, 253, 586, 256, 583, 263, 576, - 242, 597, 274, 565, 402, 437, 383, 456, 357, 482, 329, 510, - 317, 522, 307, 532, 286, 553, 287, 552, 266, 573, 261, 578, - 236, 603, 303, 536, 356, 483, - 355, 484, 405, 434, 404, 435, 406, 433, - 235, 604, 267, 572, 302, 537, - 309, 530, 265, 574, 233, 606, - 367, 472, 296, 543, - 336, 503, 305, 534, 373, 466, 280, 559, 279, 560, 419, 420, 240, 599, 258, 581, 229, 610 - }; - -uint16_t prach_root_sequence_map4[138] = { 1,138,2,137,3,136,4,135,5,134,6,133,7,132,8,131,9,130,10,129, - 11,128,12,127,13,126,14,125,15,124,16,123,17,122,18,121,19,120,20,119, - 21,118,22,117,23,116,24,115,25,114,26,113,27,112,28,111,29,110,30,109, - 31,108,32,107,33,106,34,105,35,104,36,103,37,102,38,101,39,100,40,99, - 41,98,42,97,43,96,44,95,45,94,46,93,47,92,48,91,49,90,50,89, - 51,88,52,87,53,86,54,85,55,84,56,83,57,82,58,81,59,80,60,79, - 61,78,62,77,63,76,64,75,65,74,66,73,67,72,68,71,69,70 - }; - -void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) -{ - - FILE *fd; - - fd = fopen("prach_config.txt","w"); - fprintf(fd,"prach_config: subframe = %d\n",subframe); - fprintf(fd,"prach_config: N_RB_UL = %d\n",frame_parms->N_RB_UL); - fprintf(fd,"prach_config: frame_type = %s\n",(frame_parms->frame_type==1) ? "TDD":"FDD"); - - if(frame_parms->frame_type==1) fprintf(fd,"prach_config: tdd_config = %d\n",frame_parms->tdd_config); - - fprintf(fd,"prach_config: rootSequenceIndex = %d\n",frame_parms->prach_config_common.rootSequenceIndex); - fprintf(fd,"prach_config: prach_ConfigIndex = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex); - fprintf(fd,"prach_config: Ncs_config = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig); - fprintf(fd,"prach_config: highSpeedFlag = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag); - fprintf(fd,"prach_config: n_ra_prboffset = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset); - fclose(fd); - -} - -// This function computes the du -void fill_du(uint8_t prach_fmt) -{ - - uint16_t iu,u,p; - uint16_t N_ZC; - uint16_t *prach_root_sequence_map; - - if (prach_fmt<4) { - N_ZC = 839; - prach_root_sequence_map = prach_root_sequence_map0_3; - } else { - N_ZC = 139; - prach_root_sequence_map = prach_root_sequence_map4; - } - - for (iu=0; iu<(N_ZC-1); iu++) { - - u=prach_root_sequence_map[iu]; - p=1; - - while (((u*p)%N_ZC)!=1) - p++; - - du[u] = ((p<(N_ZC>>1)) ? p : (N_ZC-p)); - } - -} - -uint8_t get_num_prach_tdd(module_id_t Mod_id) -{ - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; - return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].num_prach); -} - -uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index) -{ - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; - return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].map[tdd_map_index].f_ra); -} - -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type) -{ - - if (frame_type == FDD) // FDD - return(prach_ConfigIndex>>4); - - else { - if (prach_ConfigIndex < 20) - return (0); - - if (prach_ConfigIndex < 30) - return (1); - - if (prach_ConfigIndex < 40) - return (2); - - if (prach_ConfigIndex < 48) - return (3); - else - return (4); - } -} - -uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t prach_ConfigIndex, - uint8_t n_ra_prboffset, - uint8_t tdd_mapindex, uint16_t Nf) -{ - lte_frame_type_t frame_type = frame_parms->frame_type; - uint8_t tdd_config = frame_parms->tdd_config; - - uint8_t n_ra_prb; - uint8_t f_ra,t1_ra; - uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); - uint8_t Nsp=2; - - if (frame_type == TDD) { // TDD - - if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { - LOG_E(PHY, "Illegal prach_ConfigIndex %"PRIu8"", prach_ConfigIndex); - return(-1); - } - - // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) - f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; - - if (prach_fmt < 4) { - if ((f_ra&1) == 0) { - n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); - } else { - n_ra_prb = frame_parms->N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); - } - } else { - if ((tdd_config >2) && (tdd_config<6)) - Nsp = 2; - - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - - if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { - n_ra_prb = 6*f_ra; - } else { - n_ra_prb = frame_parms->N_RB_UL - 6*(f_ra+1); - } - } - } - else { //FDD - n_ra_prb = n_ra_prboffset; - } - return(n_ra_prb); -} - -int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe) -{ - // uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - uint8_t tdd_config = frame_parms->tdd_config; - uint8_t t0_ra; - uint8_t t1_ra; - uint8_t t2_ra; - - int prach_mask = 0; - - if (frame_parms->frame_type == FDD) { //FDD - //implement Table 5.7.1-2 from 36.211 (Rel-10, p.41) - if ((((frame&1) == 1) && (subframe < 9)) || - (((frame&1) == 0) && (subframe == 9))) // This is an odd frame, ignore even-only PRACH frames - if (((prach_ConfigIndex&0xf)<3) || // 0,1,2,16,17,18,32,33,34,48,49,50 - ((prach_ConfigIndex&0x1f)==18) || // 18,50 - ((prach_ConfigIndex&0xf)==15)) // 15,47 - return(0); - - switch (prach_ConfigIndex&0x1f) { - case 0: - case 3: - if (subframe==1) prach_mask = 1; - break; - - case 1: - case 4: - if (subframe==4) prach_mask = 1; - break; - - case 2: - case 5: - if (subframe==7) prach_mask = 1; - break; - - case 6: - if ((subframe==1) || (subframe==6)) prach_mask=1; - break; - - case 7: - if ((subframe==2) || (subframe==7)) prach_mask=1; - break; - - case 8: - if ((subframe==3) || (subframe==8)) prach_mask=1; - break; - - case 9: - if ((subframe==1) || (subframe==4) || (subframe==7)) prach_mask=1; - break; - - case 10: - if ((subframe==2) || (subframe==5) || (subframe==8)) prach_mask=1; - break; - - case 11: - if ((subframe==3) || (subframe==6) || (subframe==9)) prach_mask=1; - break; - - case 12: - if ((subframe&1)==0) prach_mask=1; - break; - - case 13: - if ((subframe&1)==1) prach_mask=1; - break; - - case 14: - prach_mask=1; - break; - - case 15: - if (subframe==9) prach_mask=1; - break; - } - } else { // TDD - - AssertFatal(prach_ConfigIndex<64, - "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); - AssertFatal(tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach>0, - "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); - - t0_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t0_ra; - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - t2_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t2_ra; -#ifdef PRACH_DEBUG - LOG_I(PHY,"[PRACH] Checking for PRACH format (ConfigIndex %d) in TDD subframe %d (%d,%d,%d)\n", - prach_ConfigIndex, - subframe, - t0_ra,t1_ra,t2_ra); -#endif - - if ((((t0_ra == 1) && ((frame &1)==0))|| // frame is even and PRACH is in even frames - ((t0_ra == 2) && ((frame &1)==1))|| // frame is odd and PRACH is in odd frames - (t0_ra == 0)) && // PRACH is in all frames - (((subframe<5)&&(t1_ra==0)) || // PRACH is in 1st half-frame - (((subframe>4)&&(t1_ra==1))))) { // PRACH is in 2nd half-frame - if ((prach_ConfigIndex<48) && // PRACH only in normal UL subframe - (((subframe%5)-2)==t2_ra)) prach_mask=1; - else if ((prach_ConfigIndex>47) && (((subframe%5)-1)==t2_ra)) prach_mask=1; // PRACH can be in UpPTS - } - } - - return(prach_mask); -} - -int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) { - - uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - int prach_mask = is_prach_subframe0(frame_parms,prach_ConfigIndex,frame,subframe); - -#ifdef Rel14 - int i; - - for (i=0;i<4;i++) { - if (frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] == 1) - prach_mask|=(is_prach_subframe0(frame_parms,frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i],frame,subframe)<<(i+1)); - } -#endif - return(prach_mask); -} - -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; - //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; - uint8_t Ncs_config = ue->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig; - uint8_t restricted_set = ue->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag; - //uint8_t n_ra_prboffset = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; - uint8_t preamble_index = ue->prach_resources[eNB_id]->ra_PreambleIndex; - uint8_t tdd_mapindex = ue->prach_resources[eNB_id]->ra_TDD_map_index; - int16_t *prachF = ue->prach_vars[eNB_id]->prachF; - static int16_t prach_tmp[45600*2] __attribute__((aligned(32))); - int16_t *prach = prach_tmp; - int16_t *prach2; - int16_t amp = ue->prach_vars[eNB_id]->amp; - int16_t Ncp; - uint8_t n_ra_prb; - uint16_t NCS; - uint16_t *prach_root_sequence_map; - uint16_t preamble_offset,preamble_shift; - uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar; - uint16_t d_start,numshift; - - uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); - //uint8_t Nsp=2; - //uint8_t f_ra,t1_ra; - uint16_t N_ZC = (prach_fmt<4)?839:139; - uint8_t not_found; - int k; - int16_t *Xu; - uint16_t u; - int32_t Xu_re,Xu_im; - uint16_t offset,offset2; - int prach_start; - int i, prach_len; - uint16_t first_nonzero_root_idx=0; - -#if defined(EXMIMO) || defined(OAI_USRP) - 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); -#endif - - 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); - -#endif - - - // First compute physical root sequence - if (restricted_set == 0) { - AssertFatal(Ncs_config <= 15, - "[PHY] FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", Ncs_config ); - NCS = NCS_unrestricted[Ncs_config]; - } else { - AssertFatal(Ncs_config <= 14, - "[PHY] FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", Ncs_config ); - NCS = NCS_restricted[Ncs_config]; - } - - n_ra_prb = get_prach_prb_offset(&(ue->frame_parms), - ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset, - tdd_mapindex, Nf); - prach_root_sequence_map = (prach_fmt<4) ? prach_root_sequence_map0_3 : prach_root_sequence_map4; - - /* - // this code is not part of get_prach_prb_offset - if (frame_type == TDD) { // TDD - - if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { - LOG_E( PHY, "[PHY][UE %"PRIu8"] Illegal prach_ConfigIndex %"PRIu8" for ", ue->Mod_id, prach_ConfigIndex ); - } - - // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) - f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; - - if (prach_fmt < 4) { - if ((f_ra&1) == 0) { - n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); - } else { - n_ra_prb = ue->frame_parms.N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); - } - } else { - if ((tdd_config >2) && (tdd_config<6)) - Nsp = 2; - - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - - if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { - n_ra_prb = 6*f_ra; - } else { - n_ra_prb = ue->frame_parms.N_RB_UL - 6*(f_ra+1); - } - } - } - */ - - // This is the relative offset (for unrestricted case) in the root sequence table (5.7.2-4 from 36.211) for the given preamble index - preamble_offset = ((NCS==0)? preamble_index : (preamble_index/(N_ZC/NCS))); - - if (restricted_set == 0) { - // This is the \nu corresponding to the preamble index - preamble_shift = (NCS==0)? 0 : (preamble_index % (N_ZC/NCS)); - preamble_shift *= NCS; - } else { // This is the high-speed case - -#ifdef PRACH_DEBUG - LOG_I(PHY,"[UE %d] High-speed mode, NCS_config %d\n",ue->Mod_id,Ncs_config); -#endif - - not_found = 1; - preamble_index0 = preamble_index; - // set preamble_offset to initial rootSequenceIndex and look if we need more root sequences for this - // preamble index and find the corresponding cyclic shift - preamble_offset = 0; // relative rootSequenceIndex; - - while (not_found == 1) { - // current root depending on rootSequenceIndex and preamble_offset - int index = (rootSequenceIndex + preamble_offset) % N_ZC; - - if (prach_fmt<4) { - // prach_root_sequence_map points to prach_root_sequence_map0_3 - DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); - } else { - // prach_root_sequence_map points to prach_root_sequence_map4 - DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); - } - - u = prach_root_sequence_map[index]; - - uint16_t n_group_ra = 0; - - if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { - n_shift_ra = du[u]/NCS; - d_start = (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = N_ZC/d_start; - n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); - } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { - n_shift_ra = (N_ZC - (du[u]<<1))/NCS; - d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = du[u]/d_start; - n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); - } else { - n_shift_ra = 0; - n_shift_ra_bar = 0; - } - - // This is the number of cyclic shifts for the current root u - numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; - - if (numshift>0 && preamble_index0==preamble_index) - first_nonzero_root_idx = preamble_offset; - - if (preamble_index0 < numshift) { - not_found = 0; - preamble_shift = (d_start * (preamble_index0/n_shift_ra)) + ((preamble_index0%n_shift_ra)*NCS); - - } else { // skip to next rootSequenceIndex and recompute parameters - preamble_offset++; - preamble_index0 -= numshift; - } - } - } - - // now generate PRACH signal -#ifdef PRACH_DEBUG - - if (NCS>0) - LOG_I(PHY,"Generate PRACH for RootSeqIndex %d, Preamble Index %d, NCS %d (NCS_config %d, N_ZC/NCS %d) n_ra_prb %d: Preamble_offset %d, Preamble_shift %d\n", - rootSequenceIndex,preamble_index,NCS,Ncs_config,N_ZC/NCS,n_ra_prb, - preamble_offset,preamble_shift); - -#endif - - // nsymb = (frame_parms->Ncp==0) ? 14:12; - // subframe_offset = (unsigned int)frame_parms->ofdm_symbol_size*subframe*nsymb; - - k = (12*n_ra_prb) - 6*ue->frame_parms.N_RB_UL; - - if (k<0) - k+=ue->frame_parms.ofdm_symbol_size; - - k*=12; - k+=13; - - Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; - - /* - k+=(12*ue->frame_parms.first_carrier_offset); - if (k>(12*ue->frame_parms.ofdm_symbol_size)) - k-=(12*ue->frame_parms.ofdm_symbol_size); - */ - k*=2; - - switch (ue->frame_parms.N_RB_UL) { - case 6: - memset((void*)prachF,0,4*1536); - break; - - case 15: - memset((void*)prachF,0,4*3072); - break; - - case 25: - memset((void*)prachF,0,4*6144); - break; - - case 50: - memset((void*)prachF,0,4*12288); - break; - - case 75: - memset((void*)prachF,0,4*18432); - break; - - case 100: - if (ue->frame_parms.threequarter_fs == 0) - memset((void*)prachF,0,4*24576); - else - memset((void*)prachF,0,4*18432); - break; - } - - for (offset=0,offset2=0; offset<N_ZC; offset++,offset2+=preamble_shift) { - - if (offset2 >= N_ZC) - offset2 -= N_ZC; - - Xu_re = (((int32_t)Xu[offset<<1]*amp)>>15); - Xu_im = (((int32_t)Xu[1+(offset<<1)]*amp)>>15); - prachF[k++]= ((Xu_re*ru[offset2<<1]) - (Xu_im*ru[1+(offset2<<1)]))>>15; - prachF[k++]= ((Xu_im*ru[offset2<<1]) + (Xu_re*ru[1+(offset2<<1)]))>>15; - - if (k==(12*2*ue->frame_parms.ofdm_symbol_size)) - k=0; - } - - switch (prach_fmt) { - case 0: - Ncp = 3168; - break; - - case 1: - case 3: - Ncp = 21024; - break; - - case 2: - Ncp = 6240; - break; - - case 4: - Ncp = 448; - break; - - default: - Ncp = 3168; - break; - } - - switch (ue->frame_parms.N_RB_UL) { - case 6: - Ncp>>=4; - prach+=4; // makes prach2 aligned to 128-bit - break; - - case 15: - Ncp>>=3; - break; - - case 25: - Ncp>>=2; - break; - - case 50: - Ncp>>=1; - break; - - case 75: - Ncp=(Ncp*3)>>2; - break; - } - - if (ue->frame_parms.threequarter_fs == 1) - Ncp=(Ncp*3)>>2; - - prach2 = prach+(Ncp<<1); - - // do IDFT - switch (ue->frame_parms.N_RB_UL) { - case 6: - if (prach_fmt == 4) { - idft256(prachF,prach2,1); - memmove( prach, prach+512, Ncp<<2 ); - prach_len = 256+Ncp; - } else { - idft1536(prachF,prach2,1); - memmove( prach, prach+3072, Ncp<<2 ); - prach_len = 1536+Ncp; - - if (prach_fmt>1) { - memmove( prach2+3072, prach2, 6144 ); - prach_len = 2*1536+Ncp; - } - } - - break; - case 15: - if (prach_fmt == 4) { - idft512(prachF,prach2,1); - //TODO: account for repeated format in dft output - memmove( prach, prach+1024, Ncp<<2 ); - prach_len = 512+Ncp; - } else { - idft3072(prachF,prach2); - memmove( prach, prach+6144, Ncp<<2 ); - prach_len = 3072+Ncp; - - if (prach_fmt>1) { - memmove( prach2+6144, prach2, 12288 ); - prach_len = 2*3072+Ncp; - } - } - - break; - - case 25: - default: - if (prach_fmt == 4) { - idft1024(prachF,prach2,1); - memmove( prach, prach+2048, Ncp<<2 ); - prach_len = 1024+Ncp; - } else { - idft6144(prachF,prach2); - /*for (i=0;i<6144*2;i++) - prach2[i]<<=1;*/ - memmove( prach, prach+12288, Ncp<<2 ); - prach_len = 6144+Ncp; - - if (prach_fmt>1) { - memmove( prach2+12288, prach2, 24576 ); - prach_len = 2*6144+Ncp; - } - } - - break; - case 50: - if (prach_fmt == 4) { - idft2048(prachF,prach2,1); - memmove( prach, prach+4096, Ncp<<2 ); - prach_len = 2048+Ncp; - } else { - idft12288(prachF,prach2); - memmove( prach, prach+24576, Ncp<<2 ); - prach_len = 12288+Ncp; - - if (prach_fmt>1) { - memmove( prach2+24576, prach2, 49152 ); - prach_len = 2*12288+Ncp; - } - } - - break; - - case 75: - if (prach_fmt == 4) { - idft3072(prachF,prach2); - //TODO: account for repeated format in dft output - memmove( prach, prach+6144, Ncp<<2 ); - prach_len = 3072+Ncp; - } else { - idft18432(prachF,prach2); - memmove( prach, prach+36864, Ncp<<2 ); - prach_len = 18432+Ncp; - - if (prach_fmt>1) { - memmove( prach2+36834, prach2, 73728 ); - prach_len = 2*18432+Ncp; - } - } - - break; - - case 100: - if (ue->frame_parms.threequarter_fs == 0) { - if (prach_fmt == 4) { - idft4096(prachF,prach2,1); - memmove( prach, prach+8192, Ncp<<2 ); - prach_len = 4096+Ncp; - } else { - idft24576(prachF,prach2); - memmove( prach, prach+49152, Ncp<<2 ); - prach_len = 24576+Ncp; - - if (prach_fmt>1) { - memmove( prach2+49152, prach2, 98304 ); - prach_len = 2* 24576+Ncp; - } - } - } - else { - if (prach_fmt == 4) { - idft3072(prachF,prach2); - //TODO: account for repeated format in dft output - memmove( prach, prach+6144, Ncp<<2 ); - prach_len = 3072+Ncp; - } else { - idft18432(prachF,prach2); - memmove( prach, prach+36864, Ncp<<2 ); - prach_len = 18432+Ncp; - printf("Generated prach for 100 PRB, 3/4 sampling\n"); - if (prach_fmt>1) { - memmove( prach2+36834, prach2, 73728 ); - prach_len = 2*18432+Ncp; - } - } - } - - break; - } - - //LOG_I(PHY,"prach_len=%d\n",prach_len); - - AssertFatal(prach_fmt<4, - "prach_fmt4 not fully implemented" ); -#if defined(EXMIMO) || defined(OAI_USRP) - 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; i<min(ue->frame_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]<<4; - ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]<<4; - } - - for (i=0; i<overflow; i++,j++) { - ((int16_t*)ue->common_vars.txdata[0])[2*i] = prach[2*j]<<4; - ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1]<<4; - } -#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) ; k<prach_start ; k++) { - if (k<0) - ue->common_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 - - for (i=0; i<prach_len; i++) { - ((int16_t*)(&ue->common_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]; - } - -#endif - - - -#if defined(PRACH_WRITE_OUTPUT_DEBUG) - write_output("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1); - write_output("prach_tx0.m","prachtx0",prach+(Ncp<<1),prach_len-Ncp,1,1); - write_output("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][0]),2*ue->frame_parms.samples_per_tti,1,1); - exit(-1); -#endif - - return signal_energy( (int*)prach, 256 ); -} -//__m128i mmtmpX0,mmtmpX1,mmtmpX2,mmtmpX3; - -#ifndef Rel14 +#if (RRC_VERSION < MAKE_VERSION(14, 0, 0)) #define rx_prach0 rx_prach #endif @@ -1100,7 +54,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, uint16_t *max_preamble_delay, uint16_t Nf, uint8_t tdd_mapindex -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,uint8_t br_flag, uint8_t ce_level #endif @@ -1150,7 +104,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, int16_t prach_ifft_tmp[2048*2] __attribute__((aligned(32))); int32_t *prach_ifft=(int32_t*)NULL; int32_t **prach_ifftp=(int32_t **)NULL; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int prach_ifft_cnt=0; #endif #ifdef PRACH_DEBUG @@ -1169,7 +123,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, frame_type = fp->frame_type; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (br_flag == 1) { AssertFatal(fp->prach_emtc_config_common.prach_Config_enabled==1, "emtc prach_Config is not enabled\n"); @@ -1204,7 +158,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, uint16_t N_ZC = (prach_fmt <4)?839:139; if (eNB) { -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (br_flag == 1) { prach_ifftp = eNB->prach_vars_br.prach_ifft[ce_level]; #ifdef PRACH_DEBUG @@ -1238,7 +192,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, } } else { -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (br_flag == 1) { #ifdef PRACH_DEBUG frame = ru->proc.frame_prach_br; @@ -1501,7 +455,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, if ((eNB==NULL) && (ru!=NULL) && ru->function == NGFI_RRU_IF4p5) { /// **** send_IF4 of rxsigF to RAU **** /// -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (br_flag == 1) send_IF4p5(ru, ru->proc.frame_prach, ru->proc.subframe_prach, IF4p5_PRACH+1+ce_level); else @@ -1644,7 +598,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (new_dft == 1) { new_dft = 0; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (br_flag == 1) { Xu=(int16_t*)eNB->X_u_br[ce_level][preamble_offset-first_nonzero_root_idx]; prach_ifft = prach_ifftp[prach_ifft_cnt++]; @@ -1701,7 +655,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, } // new dft // check energy in nth time shift, for -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if ((br_flag==0) || (eNB->prach_vars_br.repetition_number[ce_level]== eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level])) @@ -1766,9 +720,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, } - - -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void rx_prach(PHY_VARS_eNB *eNB, RU_t *ru, @@ -1810,191 +762,4 @@ void rx_prach(PHY_VARS_eNB *eNB, } } -#endif /* Rel14 */ - -void init_prach_tables(int N_ZC) -{ - - int i,m; - - // Compute the modular multiplicative inverse 'iu' of u s.t. iu*u = 1 mod N_ZC - ZC_inv[0] = 0; - ZC_inv[1] = 1; - - for (i=2; i<N_ZC; i++) { - for (m=2; m<N_ZC; m++) - if (((i*m)%N_ZC) == 1) { - ZC_inv[i] = m; - break; - } - -#ifdef PRACH_DEBUG - - if (i<16) - printf("i %d : inv %d\n",i,ZC_inv[i]); - -#endif - } - - // Compute quantized roots of unity - for (i=0; i<N_ZC; i++) { - ru[i<<1] = (int16_t)(floor(32767.0*cos(2*M_PI*(double)i/N_ZC))); - ru[1+(i<<1)] = (int16_t)(floor(32767.0*sin(2*M_PI*(double)i/N_ZC))); -#ifdef PRACH_DEBUG - - if (i<16) - printf("i %d : runity %d,%d\n",i,ru[i<<1],ru[1+(i<<1)]); - -#endif - } -} - -void compute_prach_seq(uint16_t rootSequenceIndex, - uint8_t prach_ConfigIndex, - uint8_t zeroCorrelationZoneConfig, - uint8_t highSpeedFlag, - lte_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; - int N_ZC; - uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); - uint16_t *prach_root_sequence_map; - uint16_t u, preamble_offset; - uint16_t n_shift_ra,n_shift_ra_bar, d_start,numshift; - uint8_t not_found; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_IN); - -#ifdef PRACH_DEBUG - LOG_I(PHY,"compute_prach_seq: NCS_config %d, prach_fmt %d\n",zeroCorrelationZoneConfig, prach_fmt); -#endif - - AssertFatal(prach_fmt<4, - "PRACH sequence is only precomputed for prach_fmt<4 (have %"PRIu8")\n", prach_fmt ); - N_ZC = (prach_fmt < 4) ? 839 : 139; - //init_prach_tables(N_ZC); //moved to phy_init_lte_ue/eNB, since it takes to long in real-time - - if (prach_fmt < 4) { - prach_root_sequence_map = prach_root_sequence_map0_3; - } else { - // FIXME cannot be reached - prach_root_sequence_map = prach_root_sequence_map4; - } - - -#ifdef PRACH_DEBUG - LOG_I( PHY, "compute_prach_seq: done init prach_tables\n" ); -#endif - - if (highSpeedFlag== 0) { - -#ifdef PRACH_DEBUG - LOG_I(PHY,"Low speed prach : NCS_config %d\n",zeroCorrelationZoneConfig); -#endif - - AssertFatal(zeroCorrelationZoneConfig<=15, - "FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); - NCS = NCS_unrestricted[zeroCorrelationZoneConfig]; - - num_preambles = (NCS==0) ? 64 : ((64*NCS)/N_ZC); - - if (NCS>0) num_preambles++; - - preamble_offset = 0; - } else { - -#ifdef PRACH_DEBUG - LOG_I( PHY, "high speed prach : NCS_config %"PRIu8"\n", zeroCorrelationZoneConfig ); -#endif - - AssertFatal(zeroCorrelationZoneConfig<=14, - "FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); - NCS = NCS_restricted[zeroCorrelationZoneConfig]; - fill_du(prach_fmt); - - num_preambles = 64; // compute ZC sequence for 64 possible roots - // find first non-zero shift root (stored in preamble_offset) - not_found = 1; - preamble_offset = 0; - - while (not_found == 1) { - // current root depending on rootSequenceIndex - int index = (rootSequenceIndex + preamble_offset) % N_ZC; - - if (prach_fmt<4) { - // prach_root_sequence_map points to prach_root_sequence_map0_3 - DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); - } else { - // prach_root_sequence_map points to prach_root_sequence_map4 - DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); - } - - u = prach_root_sequence_map[index]; - - uint16_t n_group_ra = 0; - - if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { - n_shift_ra = du[u]/NCS; - d_start = (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = N_ZC/d_start; - n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); - } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { - n_shift_ra = (N_ZC - (du[u]<<1))/NCS; - d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); - n_group_ra = du[u]/d_start; - n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); - } else { - n_shift_ra = 0; - n_shift_ra_bar = 0; - } - - // This is the number of cyclic shifts for the current root u - numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; - - // skip to next root and recompute parameters if numshift==0 - if (numshift>0) - not_found = 0; - else - preamble_offset++; - } - } - -#ifdef PRACH_DEBUG - - if (NCS>0) - LOG_I( PHY, "Initializing %u preambles for PRACH (NCS_config %"PRIu8", NCS %u, N_ZC/NCS %u)\n", - num_preambles, zeroCorrelationZoneConfig, NCS, N_ZC/NCS ); - -#endif - - for (i=0; i<num_preambles; i++) { - int index = (rootSequenceIndex+i+preamble_offset) % N_ZC; - - if (prach_fmt<4) { - // prach_root_sequence_map points to prach_root_sequence_map0_3 - DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); - } else { - // prach_root_sequence_map points to prach_root_sequence_map4 - DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); - } - - u = prach_root_sequence_map[index]; - - inv_u = ZC_inv[u]; // multiplicative inverse of u - - - // X_u[0] stores the first ZC sequence where the root u has a non-zero number of shifts - // for the unrestricted case X_u[0] is the first root indicated by the rootSequenceIndex - - for (k=0; k<N_ZC; k++) { - // 420 is the multiplicative inverse of 2 (required since ru is exp[j 2\pi n]) - X_u[i][k] = ((uint32_t*)ru)[(((k*(1+(inv_u*k)))%N_ZC)*420)%N_ZC]; - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_OUT); - -} +#endif /* #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */ diff --git a/openair1/PHY/LTE_TRANSPORT/prach.h b/openair1/PHY/LTE_TRANSPORT/prach.h deleted file mode 100644 index f135af6d811b5187a2fe5d4892bdce7b7ff88b7b..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_TRANSPORT/prach.h +++ /dev/null @@ -1,35 +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 - */ - -short __attribute__((aligned(16))) X_u839[4][2*839] = {{25792,20209,24697,21533,21208,24977,14453,29407,3673,32560,-10603,31004,-25018,21161,-32697,2145,-25717,-20307,-2330,-32685,24778,-21441,31178,10078,4403,32469,-28990,15273,-22038,-24250,20546,-25526,26673,19030,-20065,25905,-22930,-23408,28086,-16877,6820,32049,-31985,-7121,22218,-24084,6580,32099,-28459,-16242,31873,-7599,-20642,25448,4038,-32518,10834,30923,-21115,-25058,26955,18629,-29699,-13845,30607,11698,-30291,-12497,28519,16134,-24291,-21993,16188,28488,-3308,-32600,-13118,30026,27959,-17087,-32353,-5193,18679,26921,9552,-31344,-31534,8904,22308,24000,14122,-29568,-32314,-5435,490,32763,32605,-3247,-2819,-32646,-32758,-798,-7539,31887,28149,16771,26458,-19330,-4283,-32487,-29271,-14729,-30052,13061,-12213,30405,9669,31307,25331,20784,32111,6520,32182,-6160,29046,-15165,25563,-20499,23450,-22887,23450,-22887,25563,-20499,29046,-15165,32182,-6160,32111,6520,25331,20784,9669,31307,-12213,30405,-30052,13061,-29271,-14729,-4283,-32487,26458,-19330,28149,16771,-7539,31887,-32758,-798,-2819,-32646,32605,-3247,490,32763,-32314,-5435,14122,-29568,22308,24000,-31534,8904,9552,-31344,18679,26921,-32353,-5193,27959,-17087,-13118,30026,-3308,-32600,16188,28488,-24291,-21993,28519,16134,-30291,-12497,30607,11698,-29699,-13845,26955,18629,-21115,-25058,10834,30923,4038,-32518,-20642,25448,31873,-7599,-28459,-16242,6580,32099,22218,-24084,-31985,-7121,6820,32049,28086,-16877,-22930,-23408,-20065,25905,26673,19030,20546,-25526,-22038,-24250,-28990,15273,4403,32469,31178,10078,24778,-21441,-2330,-32685,-25717,-20307,-32697,2145,-25018,21161,-10603,31004,3673,32560,14453,29407,21208,24977,24697,21533,25792,20209,24858,21348,21579,24657,15110,29074,4646,32435,-9435,31379,-24042,22263,-32540,3855,-26887,-18731,-4526,-32454,23104,-23235,31902,7479,7299,31943,-27368,18019,-24455,-21810,17555,-27668,28757,15705,-16614,28243,-25868,-20114,25409,-20690,11526,30672,-32705,-2024,17967,-27402,11984,30496,-30904,-10893,29902,-13399,-15328,28960,-2574,-32666,17034,27991,-26018,-19919,30428,12155,-32088,-6641,32509,4099,-32428,-4708,31663,8431,-29160,-14947,23191,23148,-12099,-30452,-4161,32501,21855,-24414,-32445,4585,25942,20016,-614,-32762,-27095,18426,28874,15490,3551,-32575,-32251,5797,11756,30585,29379,-14509,-14344,-29461,-30780,11238,4889,32400,32409,4828,16929,-28055,-16719,-28181,-32719,-1779,-22129,24166,1471,32733,21946,24331,31786,7956,31756,-8076,26166,-19724,19180,-26567,13454,-29878,10253,-31122,10020,-31198,12779,-30173,18172,-27267,25096,-21068,31140,-10196,32333,5313,24207,22082,5131,32362,-18881,26780,-32641,2879,-20927,-25215,11870,-30542,32741,-1288,11296,30758,-27635,17607,-20737,-25371,24938,-21255,19279,26494,-29435,14398,-5979,-32218,32205,6038,-19871,26054,-11412,-30716,31253,9845,-28640,15920,11181,-30801,8727,31583,-23278,-23062,30694,11469,-32751,-1043,32135,-6401,-31024,10544,30651,-11585,-31326,9610,32461,-4465,-32525,-3978,29103,15056,-19577,-26277,2940,32634,17347,-27799,-31600,8668,27501,17813,-1840,-32716,-27232,18223,28023,16981,6700,-32075,-32747,1165,5857,32239,31929,-7360,-5737,-32261,-32755,920,-7061,31997,27765,17399,27568,-17711,-1105,-32749,-27026,-18529,-31846,7717,-18275,27197,1716,32721,18477,27060,28397,16348,32292,5555,32650,-2758,31815,-7838,31289,-9729,31631,-8550,32493,-4222,32593,3368,29750,13733,21394,24818,6098,32194,-13790,29724,-29953,13286,-30196,-12724,-8373,-31680,22398,-23917,31396,9375,2451,32675,-30863,11008,-16082,-28550,27300,-18122,17451,27732,-29647,13955,-7181,-31971,32617,3123,-15975,28609,-17140,-27928,32711,1900,-22666,23663,-123,-32767,20450,25601,-31064,-10429,32390,-4951,-28275,16560,22576,-23748,-17866,27468,15436,-28904,-15760,28728,18780,-26851,-23875,22443,29487,-14289,-32726,1655,29541,14177,-16508,-28306,-5375,32323,26745,-18931,-31567,-8787,10137,31159,22754,-23579,-30475,-12042,-2697,32655,32553,-3735,-6941,-32024,-32011,7000,3916,32532,32679,2390,11641,-30630,-23959,-22354,-30945,10776,-8016,31771,19674,26202,32477,4342,27700,-17504,13005,-30076,-3063,-32624,-15653,-28787,-23621,-22710,-27831,-17296,-29594,-14067,-29802,-13623,-28580,-16029,-25254,-20879,-18579,-26991,-7420,-31916,7896,-31802,23790,-22533,32629,-3002,25640,20402,1226,32744,-26092,19821,-30100,-12950,-369,-32765,30984,-10661,17243,27862,-25487,20593,-21302,-24899,26312,-19527,14892,29187,-32062,6760,5010,-32382,26815,18830,-30149,12836,8134,-31742,17658,27601,-31501,-9023,30821,-11124,-21021,25135,8609,-31616,2206,32692,-9787,-31272,14011,29620,-15220,-29019,13566,29826,-8846,-31551,736,32758,10486,-31044,-22843,23492,31695,-8313,-30384,-12270,14232,29514,12326,-30361,-31726,8193,23364,22973,10718,-30965,-32765,429,8490,31647,30001,-13175,-14783,-29243,-29853,13510,9199,31449,32731,-1534,9317,-31415,-24617,-21626,-31103,10312,-9904,31234,16824,28117,31466,9140,30563,-11814,19772,-26130,6219,-32172,-5496,-32303,-13678,-29776,-18377,-27130,-20162,-25830,-19379,-26423,-15868,-28669,-9082,-31484,1349,-32740,14563,-29353,27163,-18326,32760,674,24372,21901,981,32752,-25176,20973,-31216,-9963,-5254,-32344,28212,-16667,23705,22621,-18071,27333,-28699,-15814,16294,-28429,26385,19428,-24536,21717,-13231,-29978,32765,-307,-15545,28845,-15002,-29132,31957,7240,-27896,17191,10950,-30884,7777,31830,-21672,-24577,29325,14618,-32272,-5677,32762,-553,-32568,3612,32580,-3491,-32767,184,32159,6279,-28933,-15382,20831,25292,-6461,-32124,-12441,30313,28816,-15599,-31432,-9259,12892,30123,17762,-27536,-32671,-2513,10370,31082,26602,-19131,-24125,-22174,-19478,26349,26530,19230,21487,-24739,-20355,-25679,-30337,12383,245,32766,29215,14837,28336,-16455,4768,-32419,-19968,-25981,-32037,-6881,-30244,12610,-20259,25754,-8254,31710,1961,32708,8963,31517,12666,30219,13342,29927,11065,30841,5616,32282,-3186,32611,-14674,29297,-26240,19625,-32661,2635,-27435,-17917,-7659,-31860,18980,-26710,32766,-62,16401,28366,-19081,26638,-31362,-9494,2084,-32701,32688,-2269,3429,32587,-32737,1410,3794,-32547,30518,11927,-21764,24495,-12554,-30267,32372,5071,-23536,22798,-859,-32756,22487,23832,-32229,-5919,30736,-11355,-23018,23321,13900,-29673,-6340,32147,1594,-32729,0,32767,1594,-32729,-6340,32147,13900,-29673,-23018,23321,30736,-11355,-32229,-5919,22487,23832,-859,-32756,-23536,22798,32372,5071,-12554,-30267,-21764,24495,30518,11927,3794,-32547,-32737,1410,3429,32587,32688,-2269,2084,-32701,-31362,-9494,-19081,26638,16401,28366,32766,-62,18980,-26710,-7659,-31860,-27435,-17917,-32661,2635,-26240,19625,-14674,29297,-3186,32611,5616,32282,11065,30841,13342,29927,12666,30219,8963,31517,1961,32708,-8254,31710,-20259,25754,-30244,12610,-32037,-6881,-19968,-25981,4768,-32419,28336,-16455,29215,14837,245,32766,-30337,12383,-20355,-25679,21487,-24739,26530,19230,-19478,26349,-24125,-22174,26602,-19131,10370,31082,-32671,-2513,17762,-27536,12892,30123,-31432,-9259,28816,-15599,-12441,30313,-6461,-32124,20831,25292,-28933,-15382,32159,6279,-32767,184,32580,-3491,-32568,3612,32762,-553,-32272,-5677,29325,14618,-21672,-24577,7777,31830,10950,-30884,-27896,17191,31957,7240,-15002,-29132,-15545,28845,32765,-307,-13231,-29978,-24536,21717,26385,19428,16294,-28429,-28699,-15814,-18071,27333,23705,22621,28212,-16667,-5254,-32344,-31216,-9963,-25176,20973,981,32752,24372,21901,32760,674,27163,-18326,14563,-29353,1349,-32740,-9082,-31484,-15868,-28669,-19379,-26423,-20162,-25830,-18377,-27130,-13678,-29776,-5496,-32303,6219,-32172,19772,-26130,30563,-11814,31466,9140,16824,28117,-9904,31234,-31103,10312,-24617,-21626,9317,-31415,32731,-1534,9199,31449,-29853,13510,-14783,-29243,30001,-13175,8490,31647,-32765,429,10718,-30965,23364,22973,-31726,8193,12326,-30361,14232,29514,-30384,-12270,31695,-8313,-22843,23492,10486,-31044,736,32758,-8846,-31551,13566,29826,-15220,-29019,14011,29620,-9787,-31272,2206,32692,8609,-31616,-21021,25135,30821,-11124,-31501,-9023,17658,27601,8134,-31742,-30149,12836,26815,18830,5010,-32382,-32062,6760,14892,29187,26312,-19527,-21302,-24899,-25487,20593,17243,27862,30984,-10661,-369,-32765,-30100,-12950,-26092,19821,1226,32744,25640,20402,32629,-3002,23790,-22533,7896,-31802,-7420,-31916,-18579,-26991,-25254,-20879,-28580,-16029,-29802,-13623,-29594,-14067,-27831,-17296,-23621,-22710,-15653,-28787,-3063,-32624,13005,-30076,27700,-17504,32477,4342,19674,26202,-8016,31771,-30945,10776,-23959,-22354,11641,-30630,32679,2390,3916,32532,-32011,7000,-6941,-32024,32553,-3735,-2697,32655,-30475,-12042,22754,-23579,10137,31159,-31567,-8787,26745,-18931,-5375,32323,-16508,-28306,29541,14177,-32726,1655,29487,-14289,-23875,22443,18780,-26851,-15760,28728,15436,-28904,-17866,27468,22576,-23748,-28275,16560,32390,-4951,-31064,-10429,20450,25601,-123,-32767,-22666,23663,32711,1900,-17140,-27928,-15975,28609,32617,3123,-7181,-31971,-29647,13955,17451,27732,27300,-18122,-16082,-28550,-30863,11008,2451,32675,31396,9375,22398,-23917,-8373,-31680,-30196,-12724,-29953,13286,-13790,29724,6098,32194,21394,24818,29750,13733,32593,3368,32493,-4222,31631,-8550,31289,-9729,31815,-7838,32650,-2758,32292,5555,28397,16348,18477,27060,1716,32721,-18275,27197,-31846,7717,-27026,-18529,-1105,-32749,27568,-17711,27765,17399,-7061,31997,-32755,920,-5737,-32261,31929,-7360,5857,32239,-32747,1165,6700,-32075,28023,16981,-27232,18223,-1840,-32716,27501,17813,-31600,8668,17347,-27799,2940,32634,-19577,-26277,29103,15056,-32525,-3978,32461,-4465,-31326,9610,30651,-11585,-31024,10544,32135,-6401,-32751,-1043,30694,11469,-23278,-23062,8727,31583,11181,-30801,-28640,15920,31253,9845,-11412,-30716,-19871,26054,32205,6038,-5979,-32218,-29435,14398,19279,26494,24938,-21255,-20737,-25371,-27635,17607,11296,30758,32741,-1288,11870,-30542,-20927,-25215,-32641,2879,-18881,26780,5131,32362,24207,22082,32333,5313,31140,-10196,25096,-21068,18172,-27267,12779,-30173,10020,-31198,10253,-31122,13454,-29878,19180,-26567,26166,-19724,31756,-8076,31786,7956,21946,24331,1471,32733,-22129,24166,-32719,-1779,-16719,-28181,16929,-28055,32409,4828,4889,32400,-30780,11238,-14344,-29461,29379,-14509,11756,30585,-32251,5797,3551,-32575,28874,15490,-27095,18426,-614,-32762,25942,20016,-32445,4585,21855,-24414,-4161,32501,-12099,-30452,23191,23148,-29160,-14947,31663,8431,-32428,-4708,32509,4099,-32088,-6641,30428,12155,-26018,-19919,17034,27991,-2574,-32666,-15328,28960,29902,-13399,-30904,-10893,11984,30496,17967,-27402,-32705,-2024,11526,30672,25409,-20690,-25868,-20114,-16614,28243,28757,15705,17555,-27668,-24455,-21810,-27368,18019,7299,31943,31902,7479,23104,-23235,-4526,-32454,-26887,-18731,-32540,3855,-24042,22263,-9435,31379,4646,32435,15110,29074,21579,24657,24858,21348}, - {25792,-20210,24858,-21349,21579,-24658,15110,-29075,4646,-32436,-9435,-31380,-24042,-22264,-32540,-3856,-26887,18730,-4526,32453,23104,23234,31902,-7480,7299,-31944,-27368,-18020,-24455,21809,17555,27667,28757,-15706,-16614,-28244,-25868,20113,25409,20689,11526,-30673,-32705,2023,17967,27401,11984,-30497,-30904,10892,29902,13398,-15328,-28961,-2574,32665,17034,-27992,-26018,19918,30428,-12156,-32088,6640,32509,-4100,-32428,4707,31663,-8432,-29160,14946,23191,-23149,-12099,30451,-4161,-32502,21855,24413,-32445,-4586,25942,-20017,-614,32761,-27095,-18427,28874,-15491,3551,32574,-32251,-5798,11756,-30586,29379,14508,-14344,29460,-30780,-11239,4889,-32401,32409,-4829,16929,28054,-16719,28180,-32719,1778,-22129,-24167,1471,-32734,21946,-24332,31786,-7957,31756,8075,26166,19723,19180,26566,13454,29877,10253,31121,10020,31197,12779,30172,18172,27266,25096,21067,31140,10195,32333,-5314,24207,-22083,5131,-32363,-18881,-26781,-32641,-2880,-20927,25214,11870,30541,32741,1287,11296,-30759,-27635,-17608,-20737,25370,24938,21254,19279,-26495,-29435,-14399,-5979,32217,32205,-6039,-19871,-26055,-11412,30715,31253,-9846,-28640,-15921,11181,30800,8727,-31584,-23278,23061,30694,-11470,-32751,1042,32135,6400,-31024,-10545,30651,11584,-31326,-9611,32461,4464,-32525,3977,29103,-15057,-19577,26276,2940,-32635,17347,27798,-31600,-8669,27501,-17814,-1840,32715,-27232,-18224,28023,-16982,6700,32074,-32747,-1166,5857,-32240,31929,7359,-5737,32260,-32755,-921,-7061,-31998,27765,-17400,27568,17710,-1105,32748,-27026,18528,-31846,-7718,-18275,-27198,1716,-32722,18477,-27061,28397,-16349,32292,-5556,32650,2757,31815,7837,31289,9728,31631,8549,32493,4221,32593,-3369,29750,-13734,21394,-24819,6098,-32195,-13790,-29725,-29953,-13287,-30196,12723,-8373,31679,22398,23916,31396,-9376,2451,-32676,-30863,-11009,-16082,28549,27300,18121,17451,-27733,-29647,-13956,-7181,31970,32617,-3124,-15975,-28610,-17140,27927,32711,-1901,-22666,-23664,-123,32766,20450,-25602,-31064,10428,32390,4950,-28275,-16561,22576,23747,-17866,-27469,15436,28903,-15760,-28729,18780,26850,-23875,-22444,29487,14288,-32726,-1656,29541,-14178,-16508,28305,-5375,-32324,26745,18930,-31567,8786,10137,-31160,22754,23578,-30475,12041,-2697,-32656,32553,3734,-6941,32023,-32011,-7001,3916,-32533,32679,-2391,11641,30629,-23959,22353,-30945,-10777,-8016,-31772,19674,-26203,32477,-4343,27700,17503,13005,30075,-3063,32623,-15653,28786,-23621,22709,-27831,17295,-29594,14066,-29802,13622,-28580,16028,-25254,20878,-18579,26990,-7420,31915,7896,31801,23790,22532,32629,3001,25640,-20403,1226,-32745,-26092,-19822,-30100,12949,-369,32764,30984,10660,17243,-27863,-25487,-20594,-21302,24898,26312,19526,14892,-29188,-32062,-6761,5010,32381,26815,-18831,-30149,-12837,8134,31741,17658,-27602,-31501,9022,30821,11123,-21021,-25136,8609,31615,2206,-32693,-9787,31271,14011,-29621,-15220,29018,13566,-29827,-8846,31550,736,-32759,10486,31043,-22843,-23493,31695,8312,-30384,12269,14232,-29515,12326,30360,-31726,-8194,23364,-22974,10718,30964,-32765,-430,8490,-31648,30001,13174,-14783,29242,-29853,-13511,9199,-31450,32731,1533,9317,31414,-24617,21625,-31103,-10313,-9904,-31235,16824,-28118,31466,-9141,30563,11813,19772,26129,6219,32171,-5496,32302,-13678,29775,-18377,27129,-20162,25829,-19379,26422,-15868,28668,-9082,31483,1349,32739,14563,29352,27163,18325,32760,-675,24372,-21902,981,-32753,-25176,-20974,-31216,9962,-5254,32343,28212,16666,23705,-22622,-18071,-27334,-28699,15813,16294,28428,26385,-19429,-24536,-21718,-13231,29977,32765,306,-15545,-28846,-15002,29131,31957,-7241,-27896,-17192,10950,30883,7777,-31831,-21672,24576,29325,-14619,-32272,5676,32762,552,-32568,-3613,32580,3490,-32767,-185,32159,-6280,-28933,15381,20831,-25293,-6461,32123,-12441,-30314,28816,15598,-31432,9258,12892,-30124,17762,27535,-32671,2512,10370,-31083,26602,19130,-24125,22173,-19478,-26350,26530,-19231,21487,24738,-20355,25678,-30337,-12384,245,-32767,29215,-14838,28336,16454,4768,32418,-19968,25980,-32037,6880,-30244,-12611,-20259,-25755,-8254,-31711,1961,-32709,8963,-31518,12666,-30220,13342,-29928,11065,-30842,5616,-32283,-3186,-32612,-14674,-29298,-26240,-19626,-32661,-2636,-27435,17916,-7659,31859,18980,26709,32766,61,16401,-28367,-19081,-26639,-31362,9493,2084,32700,32688,2268,3429,-32588,-32737,-1411,3794,32546,30518,-11928,-21764,-24496,-12554,30266,32372,-5072,-23536,-22799,-859,32755,22487,-23833,-32229,5918,30736,11354,-23018,-23322,13900,29672,-6340,-32148,1594,32728,-1,-32767,1594,32728,-6340,-32148,13900,29672,-23018,-23322,30736,11354,-32229,5918,22487,-23833,-859,32755,-23536,-22799,32372,-5072,-12554,30266,-21764,-24496,30518,-11928,3794,32546,-32737,-1411,3429,-32588,32688,2268,2084,32700,-31362,9493,-19081,-26639,16401,-28367,32766,61,18980,26709,-7659,31859,-27435,17916,-32661,-2636,-26240,-19626,-14674,-29298,-3186,-32612,5616,-32283,11065,-30842,13342,-29928,12666,-30220,8963,-31518,1961,-32709,-8254,-31711,-20259,-25755,-30244,-12611,-32037,6880,-19968,25980,4768,32418,28336,16454,29215,-14838,245,-32767,-30337,-12384,-20355,25678,21487,24738,26530,-19231,-19478,-26350,-24125,22173,26602,19130,10370,-31083,-32671,2512,17762,27535,12892,-30124,-31432,9258,28816,15598,-12441,-30314,-6461,32123,20831,-25293,-28933,15381,32159,-6280,-32767,-185,32580,3490,-32568,-3613,32762,552,-32272,5676,29325,-14619,-21672,24576,7777,-31831,10950,30883,-27896,-17192,31957,-7241,-15002,29131,-15545,-28846,32765,306,-13231,29977,-24536,-21718,26385,-19429,16294,28428,-28699,15813,-18071,-27334,23705,-22622,28212,16666,-5254,32343,-31216,9962,-25176,-20974,981,-32753,24372,-21902,32760,-675,27163,18325,14563,29352,1349,32739,-9082,31483,-15868,28668,-19379,26422,-20162,25829,-18377,27129,-13678,29775,-5496,32302,6219,32171,19772,26129,30563,11813,31466,-9141,16824,-28118,-9904,-31235,-31103,-10313,-24617,21625,9317,31414,32731,1533,9199,-31450,-29853,-13511,-14783,29242,30001,13174,8490,-31648,-32765,-430,10718,30964,23364,-22974,-31726,-8194,12326,30360,14232,-29515,-30384,12269,31695,8312,-22843,-23493,10486,31043,736,-32759,-8846,31550,13566,-29827,-15220,29018,14011,-29621,-9787,31271,2206,-32693,8609,31615,-21021,-25136,30821,11123,-31501,9022,17658,-27602,8134,31741,-30149,-12837,26815,-18831,5010,32381,-32062,-6761,14892,-29188,26312,19526,-21302,24898,-25487,-20594,17243,-27863,30984,10660,-369,32764,-30100,12949,-26092,-19822,1226,-32745,25640,-20403,32629,3001,23790,22532,7896,31801,-7420,31915,-18579,26990,-25254,20878,-28580,16028,-29802,13622,-29594,14066,-27831,17295,-23621,22709,-15653,28786,-3063,32623,13005,30075,27700,17503,32477,-4343,19674,-26203,-8016,-31772,-30945,-10777,-23959,22353,11641,30629,32679,-2391,3916,-32533,-32011,-7001,-6941,32023,32553,3734,-2697,-32656,-30475,12041,22754,23578,10137,-31160,-31567,8786,26745,18930,-5375,-32324,-16508,28305,29541,-14178,-32726,-1656,29487,14288,-23875,-22444,18780,26850,-15760,-28729,15436,28903,-17866,-27469,22576,23747,-28275,-16561,32390,4950,-31064,10428,20450,-25602,-123,32766,-22666,-23664,32711,-1901,-17140,27927,-15975,-28610,32617,-3124,-7181,31970,-29647,-13956,17451,-27733,27300,18121,-16082,28549,-30863,-11009,2451,-32676,31396,-9376,22398,23916,-8373,31679,-30196,12723,-29953,-13287,-13790,-29725,6098,-32195,21394,-24819,29750,-13734,32593,-3369,32493,4221,31631,8549,31289,9728,31815,7837,32650,2757,32292,-5556,28397,-16349,18477,-27061,1716,-32722,-18275,-27198,-31846,-7718,-27026,18528,-1105,32748,27568,17710,27765,-17400,-7061,-31998,-32755,-921,-5737,32260,31929,7359,5857,-32240,-32747,-1166,6700,32074,28023,-16982,-27232,-18224,-1840,32715,27501,-17814,-31600,-8669,17347,27798,2940,-32635,-19577,26276,29103,-15057,-32525,3977,32461,4464,-31326,-9611,30651,11584,-31024,-10545,32135,6400,-32751,1042,30694,-11470,-23278,23061,8727,-31584,11181,30800,-28640,-15921,31253,-9846,-11412,30715,-19871,-26055,32205,-6039,-5979,32217,-29435,-14399,19279,-26495,24938,21254,-20737,25370,-27635,-17608,11296,-30759,32741,1287,11870,30541,-20927,25214,-32641,-2880,-18881,-26781,5131,-32363,24207,-22083,32333,-5314,31140,10195,25096,21067,18172,27266,12779,30172,10020,31197,10253,31121,13454,29877,19180,26566,26166,19723,31756,8075,31786,-7957,21946,-24332,1471,-32734,-22129,-24167,-32719,1778,-16719,28180,16929,28054,32409,-4829,4889,-32401,-30780,-11239,-14344,29460,29379,14508,11756,-30586,-32251,-5798,3551,32574,28874,-15491,-27095,-18427,-614,32761,25942,-20017,-32445,-4586,21855,24413,-4161,-32502,-12099,30451,23191,-23149,-29160,14946,31663,-8432,-32428,4707,32509,-4100,-32088,6640,30428,-12156,-26018,19918,17034,-27992,-2574,32665,-15328,-28961,29902,13398,-30904,10892,11984,-30497,17967,27401,-32705,2023,11526,-30673,25409,20689,-25868,20113,-16614,-28244,28757,-15706,17555,27667,-24455,21809,-27368,-18020,7299,-31944,31902,-7480,23104,23234,-4526,32453,-26887,18730,-32540,-3856,-24042,-22264,-9435,-31380,4646,-32436,15110,-29075,21579,-24658,24858,-21349,25792,-20210,24697,-21534,21208,-24978,14453,-29408,3673,-32561,-10603,-31005,-25018,-21162,-32697,-2146,-25717,20306,-2330,32684,24778,21440,31178,-10079,4403,-32470,-28990,-15274,-22038,24249,20546,25525,26673,-19031,-20065,-25906,-22930,23407,28086,16876,6820,-32050,-31985,7120,22218,24083,6580,-32100,-28459,16241,31873,7598,-20642,-25449,4038,32517,10834,-30924,-21115,25057,26955,-18630,-29699,13844,30607,-11699,-30291,12496,28519,-16135,-24291,21992,16188,-28489,-3308,32599,-13118,-30027,27959,17086,-32353,5192,18679,-26922,9552,31343,-31534,-8905,22308,-24001,14122,29567,-32314,5434,490,-32764,32605,3246,-2819,32645,-32758,797,-7539,-31888,28149,-16772,26458,19329,-4283,32486,-29271,14728,-30052,-13062,-12213,-30406,9669,-31308,25331,-20785,32111,-6521,32182,6159,29046,15164,25563,20498,23450,22886,23450,22886,25563,20498,29046,15164,32182,6159,32111,-6521,25331,-20785,9669,-31308,-12213,-30406,-30052,-13062,-29271,14728,-4283,32486,26458,19329,28149,-16772,-7539,-31888,-32758,797,-2819,32645,32605,3246,490,-32764,-32314,5434,14122,29567,22308,-24001,-31534,-8905,9552,31343,18679,-26922,-32353,5192,27959,17086,-13118,-30027,-3308,32599,16188,-28489,-24291,21992,28519,-16135,-30291,12496,30607,-11699,-29699,13844,26955,-18630,-21115,25057,10834,-30924,4038,32517,-20642,-25449,31873,7598,-28459,16241,6580,-32100,22218,24083,-31985,7120,6820,-32050,28086,16876,-22930,23407,-20065,-25906,26673,-19031,20546,25525,-22038,24249,-28990,-15274,4403,-32470,31178,-10079,24778,21440,-2330,32684,-25717,20306,-32697,-2146,-25018,-21162,-10603,-31005,3673,-32561,14453,-29408,21208,-24978,24697,-21534}, - {-4283,-32487,4889,32400,-6941,-32024,10370,31082,-15002,-29132,20450,25601,-26018,-19919,30607,11698,-32751,-1043,30821,-11124,-23536,22798,10718,-30965,5857,32239,-22038,-24250,31902,7479,-29953,13286,14563,-29353,8963,31517,-28580,-16029,31140,-10196,-12213,30405,-16719,-28181,32679,2390,-19478,26349,-13231,-29978,32711,1900,-15328,28960,-21115,-25058,30651,-11585,2206,32692,-32229,-5919,12326,-30361,28023,16981,-20065,25905,-24455,-21810,22398,-23917,24372,21901,-20259,25754,-27831,-17296,12779,-30173,32111,6520,1471,32733,-30945,10776,-20355,-25679,16294,-28429,32617,3123,11984,30496,-20642,25448,-32525,-3978,-15220,-29019,13900,-29673,31695,-8313,27501,17813,6820,32049,-16614,28243,-30863,11008,-31216,-9963,-19968,-25981,-3063,-32624,13454,-29878,25563,-20499,31756,-8076,32477,4342,29215,14837,23705,22621,17451,27732,11526,30672,6580,32099,2940,32634,736,32758,0,32767,736,32758,2940,32634,6580,32099,11526,30672,17451,27732,23705,22621,29215,14837,32477,4342,31756,-8076,25563,-20499,13454,-29878,-3063,-32624,-19968,-25981,-31216,-9963,-30863,11008,-16614,28243,6820,32049,27501,17813,31695,-8313,13900,-29673,-15220,-29019,-32525,-3978,-20642,25448,11984,30496,32617,3123,16294,-28429,-20355,-25679,-30945,10776,1471,32733,32111,6520,12779,-30173,-27831,-17296,-20259,25754,24372,21901,22398,-23917,-24455,-21810,-20065,25905,28023,16981,12326,-30361,-32229,-5919,2206,32692,30651,-11585,-21115,-25058,-15328,28960,32711,1900,-13231,-29978,-19478,26349,32679,2390,-16719,-28181,-12213,30405,31140,-10196,-28580,-16029,8963,31517,14563,-29353,-29953,13286,31902,7479,-22038,-24250,5857,32239,10718,-30965,-23536,22798,30821,-11124,-32751,-1043,30607,11698,-26018,-19919,20450,25601,-15002,-29132,10370,31082,-6941,-32024,4889,32400,-4283,-32487,5131,32362,-7420,-31916,11065,30841,-15868,-28669,21394,24818,-26887,-18731,31178,10078,-32755,920,30001,-13175,-21764,24495,8134,-31742,8727,31583,-24291,-21993,32509,4099,-28275,16560,10950,-30884,12892,30123,-30475,-12042,29379,-14509,-7539,31887,-20927,-25215,32629,-3002,-14674,29297,-18377,-27130,32493,-4222,-9435,31379,-25717,-20307,27568,-17711,9199,31449,-32737,1410,5010,-32382,31253,9845,-13118,30026,-29160,-14947,15436,-28904,29325,14618,-12441,30313,-31567,-8787,3551,-32575,32605,-3247,11296,30758,-26092,19821,-27435,-17917,6219,-32172,31815,-7838,21579,24657,-10603,31004,-31846,7717,-24617,-21626,2084,-32701,26312,-19527,32205,6038,18679,26921,-4161,32501,-23875,22443,-32568,3612,-28933,-15382,-16508,-28306,-614,-32762,14122,-29568,24938,-21255,30984,-10661,32766,-62,31466,9140,28397,16348,24697,21533,21208,24977,18477,27060,16824,28117,16401,28366,17243,27862,19279,26494,22308,24000,25942,20016,29541,14177,32159,6279,32580,-3491,29487,-14289,21855,-24414,9552,-31344,-5979,-32218,-21302,-24899,-31362,-9494,-31103,10312,-18275,27197,3673,32560,24858,21348,32650,-2758,19772,-26130,-7659,-31860,-30100,-12950,-27635,17607,490,32763,28874,15490,26745,-18931,-6461,-32124,-32272,-5677,-15760,28728,23191,23148,27959,-17087,-11412,-30716,-32062,6760,3429,32587,32731,-1534,-1105,-32749,-32697,2145,4646,32435,31631,-8550,-13678,-29776,-26240,19625,25640,20402,11870,-30542,-32758,-798,11756,30585,22754,-23579,-31432,-9259,7777,31830,22576,-23748,-32428,-4708,16188,28488,11181,-30801,-30149,12836,30518,11927,-14783,-29243,-7061,31997,24778,-21441,-32540,3855,29750,13733,-19379,-26423,5616,32282,7896,-31802,-18881,26780,26458,-19330,-30780,11238,32553,-3735,-32671,-2513,31957,7240,-31064,-10429,30428,12155,-30291,-12497,30694,11469,-31501,-9023,32372,5071,-32765,429,31929,-7360,-28990,15273,23104,-23235,-13790,29724,1349,-32740,12666,30219,-25254,-20879,32333,5313,-30052,13061,16929,-28055,3916,32532,-24125,-22174,32765,-307,-22666,23663,-2574,-32666,26955,18629,-31024,10544,8609,-31616,22487,23832,-31726,8193,6700,-32075,26673,19030,-27368,18019,-8373,-31680,32760,674,-8254,31710,-29594,-14067,18172,-27267,25331,20784,-22129,24166,-23959,-22354,21487,-24739,26385,19428,-15975,28609,-30904,-10893,4038,-32518,32461,-4465,14011,29620,-23018,23321,-30384,-12270,-1840,-32716,28086,-16877,28757,15705,2451,32675,-25176,20973,-32037,-6881,-15653,-28787,10253,-31122,29046,-15165,31786,7956,19674,26202,245,32766,-18071,27333,-29647,13955,-32705,-2024,-28459,-16242,-19577,-26277,-8846,-31551,1594,-32729,10486,-31044,17347,-27799,22218,-24084,25409,-20690,27300,-18122,28212,-16667,28336,-16455,27700,-17504,26166,-19724,23450,-22887,19180,-26567,13005,-30076,4768,-32419,-5254,-32344,-16082,-28550,-25868,-20114,-31985,-7121,-31600,8668,-22843,23492,-6340,32147,13566,29826,29103,15056,31873,-7599,17967,-27402,-7181,-31971,-28699,-15814,-30337,12383,-8016,31771,21946,24331,32182,-6160,10020,-31198,-23621,-22710,-30244,12610,981,32752,31396,9375,17555,-27668,-22930,-23408,-27232,18223,14232,29514,30736,-11355,-9787,-31272,-31326,9610,10834,30923,29902,-13399,-17140,-27928,-24536,21717,26530,19230,11641,-30630,-32719,-1779,9669,31307,25096,-21068,-29802,-13623,1961,32708,27163,-18326,-30196,-12724,7299,31943,20546,-25526,-32747,1165,23364,22973,-859,-32756,-21021,25135,32135,-6401,-29699,-13845,17034,27991,-123,-32767,-15545,28845,26602,-19131,-32011,7000,32409,4828,-29271,-14729,24207,22082,-18579,-26991,13342,29927,-9082,-31484,6098,32194,-4526,-32454,4403,32469,-5737,-32261,8490,31647,-12554,-30267,17658,27601,-23278,-23062,28519,16134,-32088,-6641,32390,-4951,-27896,17191,17762,-27536,-2697,32655,-14344,-29461,28149,16771,-32641,2879,23790,-22533,-3186,32611,-20162,-25830,32593,3368,-24042,22263,-2330,-32685,27765,17399,-29853,13510,3794,-32547,26815,18830,-28640,15920,-3308,-32600,31663,8431,-17866,27468,-21672,-24577,28816,-15599,10137,31159,-32251,5797,-2819,-32646,32741,-1288,1226,32744,-32661,2635,-5496,-32303,31289,-9729,15110,29074,-25018,21161,-27026,-18529,9317,-31415,32688,-2269,14892,29187,-19871,26054,-32353,-5193,-12099,-30452,18780,-26851,32762,-553,20831,25292,-5375,32323,-27095,18426,-32314,-5435,-20737,-25371,-369,-32765,18980,-26710,30563,-11814,32292,5555,25792,20209,14453,29407,1716,32721,-9904,31234,-19081,26638,-25487,20593,-29435,14398,-31534,8904,-32445,4585,-32726,1655,-32767,184,-32767,184,-32726,1655,-32445,4585,-31534,8904,-29435,14398,-25487,20593,-19081,26638,-9904,31234,1716,32721,14453,29407,25792,20209,32292,5555,30563,-11814,18980,-26710,-369,-32765,-20737,-25371,-32314,-5435,-27095,18426,-5375,32323,20831,25292,32762,-553,18780,-26851,-12099,-30452,-32353,-5193,-19871,26054,14892,29187,32688,-2269,9317,-31415,-27026,-18529,-25018,21161,15110,29074,31289,-9729,-5496,-32303,-32661,2635,1226,32744,32741,-1288,-2819,-32646,-32251,5797,10137,31159,28816,-15599,-21672,-24577,-17866,27468,31663,8431,-3308,-32600,-28640,15920,26815,18830,3794,-32547,-29853,13510,27765,17399,-2330,-32685,-24042,22263,32593,3368,-20162,-25830,-3186,32611,23790,-22533,-32641,2879,28149,16771,-14344,-29461,-2697,32655,17762,-27536,-27896,17191,32390,-4951,-32088,-6641,28519,16134,-23278,-23062,17658,27601,-12554,-30267,8490,31647,-5737,-32261,4403,32469,-4526,-32454,6098,32194,-9082,-31484,13342,29927,-18579,-26991,24207,22082,-29271,-14729,32409,4828,-32011,7000,26602,-19131,-15545,28845,-123,-32767,17034,27991,-29699,-13845,32135,-6401,-21021,25135,-859,-32756,23364,22973,-32747,1165,20546,-25526,7299,31943,-30196,-12724,27163,-18326,1961,32708,-29802,-13623,25096,-21068,9669,31307,-32719,-1779,11641,-30630,26530,19230,-24536,21717,-17140,-27928,29902,-13399,10834,30923,-31326,9610,-9787,-31272,30736,-11355,14232,29514,-27232,18223,-22930,-23408,17555,-27668,31396,9375,981,32752,-30244,12610,-23621,-22710,10020,-31198,32182,-6160,21946,24331,-8016,31771,-30337,12383,-28699,-15814,-7181,-31971,17967,-27402,31873,-7599,29103,15056,13566,29826,-6340,32147,-22843,23492,-31600,8668,-31985,-7121,-25868,-20114,-16082,-28550,-5254,-32344,4768,-32419,13005,-30076,19180,-26567,23450,-22887,26166,-19724,27700,-17504,28336,-16455,28212,-16667,27300,-18122,25409,-20690,22218,-24084,17347,-27799,10486,-31044,1594,-32729,-8846,-31551,-19577,-26277,-28459,-16242,-32705,-2024,-29647,13955,-18071,27333,245,32766,19674,26202,31786,7956,29046,-15165,10253,-31122,-15653,-28787,-32037,-6881,-25176,20973,2451,32675,28757,15705,28086,-16877,-1840,-32716,-30384,-12270,-23018,23321,14011,29620,32461,-4465,4038,-32518,-30904,-10893,-15975,28609,26385,19428,21487,-24739,-23959,-22354,-22129,24166,25331,20784,18172,-27267,-29594,-14067,-8254,31710,32760,674,-8373,-31680,-27368,18019,26673,19030,6700,-32075,-31726,8193,22487,23832,8609,-31616,-31024,10544,26955,18629,-2574,-32666,-22666,23663,32765,-307,-24125,-22174,3916,32532,16929,-28055,-30052,13061,32333,5313,-25254,-20879,12666,30219,1349,-32740,-13790,29724,23104,-23235,-28990,15273,31929,-7360,-32765,429,32372,5071,-31501,-9023,30694,11469,-30291,-12497,30428,12155,-31064,-10429,31957,7240,-32671,-2513,32553,-3735,-30780,11238,26458,-19330,-18881,26780,7896,-31802,5616,32282,-19379,-26423,29750,13733,-32540,3855,24778,-21441,-7061,31997,-14783,-29243,30518,11927,-30149,12836,11181,-30801,16188,28488,-32428,-4708,22576,-23748,7777,31830,-31432,-9259,22754,-23579,11756,30585,-32758,-798,11870,-30542,25640,20402,-26240,19625,-13678,-29776,31631,-8550,4646,32435,-32697,2145,-1105,-32749,32731,-1534,3429,32587,-32062,6760,-11412,-30716,27959,-17087,23191,23148,-15760,28728,-32272,-5677,-6461,-32124,26745,-18931,28874,15490,490,32763,-27635,17607,-30100,-12950,-7659,-31860,19772,-26130,32650,-2758,24858,21348,3673,32560,-18275,27197,-31103,10312,-31362,-9494,-21302,-24899,-5979,-32218,9552,-31344,21855,-24414,29487,-14289,32580,-3491,32159,6279,29541,14177,25942,20016,22308,24000,19279,26494,17243,27862,16401,28366,16824,28117,18477,27060,21208,24977,24697,21533,28397,16348,31466,9140,32766,-62,30984,-10661,24938,-21255,14122,-29568,-614,-32762,-16508,-28306,-28933,-15382,-32568,3612,-23875,22443,-4161,32501,18679,26921,32205,6038,26312,-19527,2084,-32701,-24617,-21626,-31846,7717,-10603,31004,21579,24657,31815,-7838,6219,-32172,-27435,-17917,-26092,19821,11296,30758,32605,-3247,3551,-32575,-31567,-8787,-12441,30313,29325,14618,15436,-28904,-29160,-14947,-13118,30026,31253,9845,5010,-32382,-32737,1410,9199,31449,27568,-17711,-25717,-20307,-9435,31379,32493,-4222,-18377,-27130,-14674,29297,32629,-3002,-20927,-25215,-7539,31887,29379,-14509,-30475,-12042,12892,30123,10950,-30884,-28275,16560,32509,4099,-24291,-21993,8727,31583,8134,-31742,-21764,24495,30001,-13175,-32755,920,31178,10078,-26887,-18731,21394,24818,-15868,-28669,11065,30841,-7420,-31916,5131,32362}, - {-4283,32486,5131,-32363,-7420,31915,11065,-30842,-15868,28668,21394,-24819,-26887,18730,31178,-10079,-32755,-921,30001,13174,-21764,-24496,8134,31741,8727,-31584,-24291,21992,32509,-4100,-28275,-16561,10950,30883,12892,-30124,-30475,12041,29379,14508,-7539,-31888,-20927,25214,32629,3001,-14674,-29298,-18377,27129,32493,4221,-9435,-31380,-25717,20306,27568,17710,9199,-31450,-32737,-1411,5010,32381,31253,-9846,-13118,-30027,-29160,14946,15436,28903,29325,-14619,-12441,-30314,-31567,8786,3551,32574,32605,3246,11296,-30759,-26092,-19822,-27435,17916,6219,32171,31815,7837,21579,-24658,-10603,-31005,-31846,-7718,-24617,21625,2084,32700,26312,19526,32205,-6039,18679,-26922,-4161,-32502,-23875,-22444,-32568,-3613,-28933,15381,-16508,28305,-614,32761,14122,29567,24938,21254,30984,10660,32766,61,31466,-9141,28397,-16349,24697,-21534,21208,-24978,18477,-27061,16824,-28118,16401,-28367,17243,-27863,19279,-26495,22308,-24001,25942,-20017,29541,-14178,32159,-6280,32580,3490,29487,14288,21855,24413,9552,31343,-5979,32217,-21302,24898,-31362,9493,-31103,-10313,-18275,-27198,3673,-32561,24858,-21349,32650,2757,19772,26129,-7659,31859,-30100,12949,-27635,-17608,490,-32764,28874,-15491,26745,18930,-6461,32123,-32272,5676,-15760,-28729,23191,-23149,27959,17086,-11412,30715,-32062,-6761,3429,-32588,32731,1533,-1105,32748,-32697,-2146,4646,-32436,31631,8549,-13678,29775,-26240,-19626,25640,-20403,11870,30541,-32758,797,11756,-30586,22754,23578,-31432,9258,7777,-31831,22576,23747,-32428,4707,16188,-28489,11181,30800,-30149,-12837,30518,-11928,-14783,29242,-7061,-31998,24778,21440,-32540,-3856,29750,-13734,-19379,26422,5616,-32283,7896,31801,-18881,-26781,26458,19329,-30780,-11239,32553,3734,-32671,2512,31957,-7241,-31064,10428,30428,-12156,-30291,12496,30694,-11470,-31501,9022,32372,-5072,-32765,-430,31929,7359,-28990,-15274,23104,23234,-13790,-29725,1349,32739,12666,-30220,-25254,20878,32333,-5314,-30052,-13062,16929,28054,3916,-32533,-24125,22173,32765,306,-22666,-23664,-2574,32665,26955,-18630,-31024,-10545,8609,31615,22487,-23833,-31726,-8194,6700,32074,26673,-19031,-27368,-18020,-8373,31679,32760,-675,-8254,-31711,-29594,14066,18172,27266,25331,-20785,-22129,-24167,-23959,22353,21487,24738,26385,-19429,-15975,-28610,-30904,10892,4038,32517,32461,4464,14011,-29621,-23018,-23322,-30384,12269,-1840,32715,28086,16876,28757,-15706,2451,-32676,-25176,-20974,-32037,6880,-15653,28786,10253,31121,29046,15164,31786,-7957,19674,-26203,245,-32767,-18071,-27334,-29647,-13956,-32705,2023,-28459,16241,-19577,26276,-8846,31550,1594,32728,10486,31043,17347,27798,22218,24083,25409,20689,27300,18121,28212,16666,28336,16454,27700,17503,26166,19723,23450,22886,19180,26566,13005,30075,4768,32418,-5254,32343,-16082,28549,-25868,20113,-31985,7120,-31600,-8669,-22843,-23493,-6340,-32148,13566,-29827,29103,-15057,31873,7598,17967,27401,-7181,31970,-28699,15813,-30337,-12384,-8016,-31772,21946,-24332,32182,6159,10020,31197,-23621,22709,-30244,-12611,981,-32753,31396,-9376,17555,27667,-22930,23407,-27232,-18224,14232,-29515,30736,11354,-9787,31271,-31326,-9611,10834,-30924,29902,13398,-17140,27927,-24536,-21718,26530,-19231,11641,30629,-32719,1778,9669,-31308,25096,21067,-29802,13622,1961,-32709,27163,18325,-30196,12723,7299,-31944,20546,25525,-32747,-1166,23364,-22974,-859,32755,-21021,-25136,32135,6400,-29699,13844,17034,-27992,-123,32766,-15545,-28846,26602,19130,-32011,-7001,32409,-4829,-29271,14728,24207,-22083,-18579,26990,13342,-29928,-9082,31483,6098,-32195,-4526,32453,4403,-32470,-5737,32260,8490,-31648,-12554,30266,17658,-27602,-23278,23061,28519,-16135,-32088,6640,32390,4950,-27896,-17192,17762,27535,-2697,-32656,-14344,29460,28149,-16772,-32641,-2880,23790,22532,-3186,-32612,-20162,25829,32593,-3369,-24042,-22264,-2330,32684,27765,-17400,-29853,-13511,3794,32546,26815,-18831,-28640,-15921,-3308,32599,31663,-8432,-17866,-27469,-21672,24576,28816,15598,10137,-31160,-32251,-5798,-2819,32645,32741,1287,1226,-32745,-32661,-2636,-5496,32302,31289,9728,15110,-29075,-25018,-21162,-27026,18528,9317,31414,32688,2268,14892,-29188,-19871,-26055,-32353,5192,-12099,30451,18780,26850,32762,552,20831,-25293,-5375,-32324,-27095,-18427,-32314,5434,-20737,25370,-369,32764,18980,26709,30563,11813,32292,-5556,25792,-20210,14453,-29408,1716,-32722,-9904,-31235,-19081,-26639,-25487,-20594,-29435,-14399,-31534,-8905,-32445,-4586,-32726,-1656,-32767,-185,-32767,-185,-32726,-1656,-32445,-4586,-31534,-8905,-29435,-14399,-25487,-20594,-19081,-26639,-9904,-31235,1716,-32722,14453,-29408,25792,-20210,32292,-5556,30563,11813,18980,26709,-369,32764,-20737,25370,-32314,5434,-27095,-18427,-5375,-32324,20831,-25293,32762,552,18780,26850,-12099,30451,-32353,5192,-19871,-26055,14892,-29188,32688,2268,9317,31414,-27026,18528,-25018,-21162,15110,-29075,31289,9728,-5496,32302,-32661,-2636,1226,-32745,32741,1287,-2819,32645,-32251,-5798,10137,-31160,28816,15598,-21672,24576,-17866,-27469,31663,-8432,-3308,32599,-28640,-15921,26815,-18831,3794,32546,-29853,-13511,27765,-17400,-2330,32684,-24042,-22264,32593,-3369,-20162,25829,-3186,-32612,23790,22532,-32641,-2880,28149,-16772,-14344,29460,-2697,-32656,17762,27535,-27896,-17192,32390,4950,-32088,6640,28519,-16135,-23278,23061,17658,-27602,-12554,30266,8490,-31648,-5737,32260,4403,-32470,-4526,32453,6098,-32195,-9082,31483,13342,-29928,-18579,26990,24207,-22083,-29271,14728,32409,-4829,-32011,-7001,26602,19130,-15545,-28846,-123,32766,17034,-27992,-29699,13844,32135,6400,-21021,-25136,-859,32755,23364,-22974,-32747,-1166,20546,25525,7299,-31944,-30196,12723,27163,18325,1961,-32709,-29802,13622,25096,21067,9669,-31308,-32719,1778,11641,30629,26530,-19231,-24536,-21718,-17140,27927,29902,13398,10834,-30924,-31326,-9611,-9787,31271,30736,11354,14232,-29515,-27232,-18224,-22930,23407,17555,27667,31396,-9376,981,-32753,-30244,-12611,-23621,22709,10020,31197,32182,6159,21946,-24332,-8016,-31772,-30337,-12384,-28699,15813,-7181,31970,17967,27401,31873,7598,29103,-15057,13566,-29827,-6340,-32148,-22843,-23493,-31600,-8669,-31985,7120,-25868,20113,-16082,28549,-5254,32343,4768,32418,13005,30075,19180,26566,23450,22886,26166,19723,27700,17503,28336,16454,28212,16666,27300,18121,25409,20689,22218,24083,17347,27798,10486,31043,1594,32728,-8846,31550,-19577,26276,-28459,16241,-32705,2023,-29647,-13956,-18071,-27334,245,-32767,19674,-26203,31786,-7957,29046,15164,10253,31121,-15653,28786,-32037,6880,-25176,-20974,2451,-32676,28757,-15706,28086,16876,-1840,32715,-30384,12269,-23018,-23322,14011,-29621,32461,4464,4038,32517,-30904,10892,-15975,-28610,26385,-19429,21487,24738,-23959,22353,-22129,-24167,25331,-20785,18172,27266,-29594,14066,-8254,-31711,32760,-675,-8373,31679,-27368,-18020,26673,-19031,6700,32074,-31726,-8194,22487,-23833,8609,31615,-31024,-10545,26955,-18630,-2574,32665,-22666,-23664,32765,306,-24125,22173,3916,-32533,16929,28054,-30052,-13062,32333,-5314,-25254,20878,12666,-30220,1349,32739,-13790,-29725,23104,23234,-28990,-15274,31929,7359,-32765,-430,32372,-5072,-31501,9022,30694,-11470,-30291,12496,30428,-12156,-31064,10428,31957,-7241,-32671,2512,32553,3734,-30780,-11239,26458,19329,-18881,-26781,7896,31801,5616,-32283,-19379,26422,29750,-13734,-32540,-3856,24778,21440,-7061,-31998,-14783,29242,30518,-11928,-30149,-12837,11181,30800,16188,-28489,-32428,4707,22576,23747,7777,-31831,-31432,9258,22754,23578,11756,-30586,-32758,797,11870,30541,25640,-20403,-26240,-19626,-13678,29775,31631,8549,4646,-32436,-32697,-2146,-1105,32748,32731,1533,3429,-32588,-32062,-6761,-11412,30715,27959,17086,23191,-23149,-15760,-28729,-32272,5676,-6461,32123,26745,18930,28874,-15491,490,-32764,-27635,-17608,-30100,12949,-7659,31859,19772,26129,32650,2757,24858,-21349,3673,-32561,-18275,-27198,-31103,-10313,-31362,9493,-21302,24898,-5979,32217,9552,31343,21855,24413,29487,14288,32580,3490,32159,-6280,29541,-14178,25942,-20017,22308,-24001,19279,-26495,17243,-27863,16401,-28367,16824,-28118,18477,-27061,21208,-24978,24697,-21534,28397,-16349,31466,-9141,32766,61,30984,10660,24938,21254,14122,29567,-614,32761,-16508,28305,-28933,15381,-32568,-3613,-23875,-22444,-4161,-32502,18679,-26922,32205,-6039,26312,19526,2084,32700,-24617,21625,-31846,-7718,-10603,-31005,21579,-24658,31815,7837,6219,32171,-27435,17916,-26092,-19822,11296,-30759,32605,3246,3551,32574,-31567,8786,-12441,-30314,29325,-14619,15436,28903,-29160,14946,-13118,-30027,31253,-9846,5010,32381,-32737,-1411,9199,-31450,27568,17710,-25717,20306,-9435,-31380,32493,4221,-18377,27129,-14674,-29298,32629,3001,-20927,25214,-7539,-31888,29379,14508,-30475,12041,12892,-30124,10950,30883,-28275,-16561,32509,-4100,-24291,21992,8727,-31584,8134,31741,-21764,-24496,30001,13174,-32755,-921,31178,-10079,-26887,18730,21394,-24819,-15868,28668,11065,-30842,-7420,31915,5131,-32363,-4283,32486,4889,-32401,-6941,32023,10370,-31083,-15002,29131,20450,-25602,-26018,19918,30607,-11699,-32751,1042,30821,11123,-23536,-22799,10718,30964,5857,-32240,-22038,24249,31902,-7480,-29953,-13287,14563,29352,8963,-31518,-28580,16028,31140,10195,-12213,-30406,-16719,28180,32679,-2391,-19478,-26350,-13231,29977,32711,-1901,-15328,-28961,-21115,25057,30651,11584,2206,-32693,-32229,5918,12326,30360,28023,-16982,-20065,-25906,-24455,21809,22398,23916,24372,-21902,-20259,-25755,-27831,17295,12779,30172,32111,-6521,1471,-32734,-30945,-10777,-20355,25678,16294,28428,32617,-3124,11984,-30497,-20642,-25449,-32525,3977,-15220,29018,13900,29672,31695,8312,27501,-17814,6820,-32050,-16614,-28244,-30863,-11009,-31216,9962,-19968,25980,-3063,32623,13454,29877,25563,20498,31756,8075,32477,-4343,29215,-14838,23705,-22622,17451,-27733,11526,-30673,6580,-32100,2940,-32635,736,-32759,-1,-32767,736,-32759,2940,-32635,6580,-32100,11526,-30673,17451,-27733,23705,-22622,29215,-14838,32477,-4343,31756,8075,25563,20498,13454,29877,-3063,32623,-19968,25980,-31216,9962,-30863,-11009,-16614,-28244,6820,-32050,27501,-17814,31695,8312,13900,29672,-15220,29018,-32525,3977,-20642,-25449,11984,-30497,32617,-3124,16294,28428,-20355,25678,-30945,-10777,1471,-32734,32111,-6521,12779,30172,-27831,17295,-20259,-25755,24372,-21902,22398,23916,-24455,21809,-20065,-25906,28023,-16982,12326,30360,-32229,5918,2206,-32693,30651,11584,-21115,25057,-15328,-28961,32711,-1901,-13231,29977,-19478,-26350,32679,-2391,-16719,28180,-12213,-30406,31140,10195,-28580,16028,8963,-31518,14563,29352,-29953,-13287,31902,-7480,-22038,24249,5857,-32240,10718,30964,-23536,-22799,30821,11123,-32751,1042,30607,-11699,-26018,19918,20450,-25602,-15002,29131,10370,-31083,-6941,32023,4889,-32401} -}; -short __attribute__((aligned(16))) X_u139[4][2*139] = {{23300,23038,23300,23038,24317,21962,26201,19676,28620,15954,31023,10547,32597,3326,32297,-5528,28973,-15304,21685,-24565,10195,-31141,-4430,-32467,-19380,-26422,-30238,-12625,-32165,6256,-22236,24067,-2221,32691,19971,25977,32414,4796,25749,-20265,1480,-32734,-24808,-21407,-31849,7703,-10898,30901,21125,25048,32014,-6982,7342,-31934,-26640,-19080,-27064,18472,9489,31362,32748,-1111,5892,-32233,-30777,-11246,-14975,29145,27870,17231,18165,-27271,-27474,-17857,-16277,28438,29944,13304,8778,-31570,-32665,-2590,5162,32357,29635,-13979,-22774,-23560,-13643,29791,32764,370,-14313,-29476,-18778,26852,32714,1850,-16916,-28064,-12283,30377,31253,-9844,-28253,-16597,8062,31759,15629,-28800,-30515,11938,31468,9134,-20554,-25520,3695,32557,12965,-30093,-25286,20840,31666,-8422,-32515,-4063,29312,14644,-23816,-22507,17544,27674,-11593,-30648,6619,32091,-2959,-32634,740,32758,-1,-32767,740,32758,-2959,-32634,6619,32091,-11593,-30648,17544,27674,-23816,-22507,29312,14644,-32515,-4063,31666,-8422,-25286,20840,12965,-30093,3695,32557,-20554,-25520,31468,9134,-30515,11938,15629,-28800,8062,31759,-28253,-16597,31253,-9844,-12283,30377,-16916,-28064,32714,1850,-18778,26852,-14313,-29476,32764,370,-13643,29791,-22774,-23560,29635,-13979,5162,32357,-32665,-2590,8778,-31570,29944,13304,-16277,28438,-27474,-17857,18165,-27271,27870,17231,-14975,29145,-30777,-11246,5892,-32233,32748,-1111,9489,31362,-27064,18472,-26640,-19080,7342,-31934,32014,-6982,21125,25048,-10898,30901,-31849,7703,-24808,-21407,1480,-32734,25749,-20265,32414,4796,19971,25977,-2221,32691,-22236,24067,-32165,6256,-30238,-12625,-19380,-26422,-4430,-32467,10195,-31141,21685,-24565,28973,-15304,32297,-5528,32597,3326,31023,10547,28620,15954,26201,19676,24317,21962}, - {23300,-23039,24317,-21963,26201,-19677,28620,-15955,31023,-10548,32597,-3327,32297,5527,28973,15303,21685,24564,10195,31140,-4430,32466,-19380,26421,-30238,12624,-32165,-6257,-22236,-24068,-2221,-32692,19971,-25978,32414,-4797,25749,20264,1480,32733,-24808,21406,-31849,-7704,-10898,-30902,21125,-25049,32014,6981,7342,31933,-26640,19079,-27064,-18473,9489,-31363,32748,1110,5892,32232,-30777,11245,-14975,-29146,27870,-17232,18165,27270,-27474,17856,-16277,-28439,29944,-13305,8778,31569,-32665,2589,5162,-32358,29635,13978,-22774,23559,-13643,-29792,32764,-371,-14313,29475,-18778,-26853,32714,-1851,-16916,28063,-12283,-30378,31253,9843,-28253,16596,8062,-31760,15629,28799,-30515,-11939,31468,-9135,-20554,25519,3695,-32558,12965,30092,-25286,-20841,31666,8421,-32515,4062,29312,-14645,-23816,22506,17544,-27675,-11593,30647,6619,-32092,-2959,32633,740,-32759,0,32767,740,-32759,-2959,32633,6619,-32092,-11593,30647,17544,-27675,-23816,22506,29312,-14645,-32515,4062,31666,8421,-25286,-20841,12965,30092,3695,-32558,-20554,25519,31468,-9135,-30515,-11939,15629,28799,8062,-31760,-28253,16596,31253,9843,-12283,-30378,-16916,28063,32714,-1851,-18778,-26853,-14313,29475,32764,-371,-13643,-29792,-22774,23559,29635,13978,5162,-32358,-32665,2589,8778,31569,29944,-13305,-16277,-28439,-27474,17856,18165,27270,27870,-17232,-14975,-29146,-30777,11245,5892,32232,32748,1110,9489,-31363,-27064,-18473,-26640,19079,7342,31933,32014,6981,21125,-25049,-10898,-30902,-31849,-7704,-24808,21406,1480,32733,25749,20264,32414,-4797,19971,-25978,-2221,-32692,-22236,-24068,-32165,-6257,-30238,12624,-19380,26421,-4430,32466,10195,31140,21685,24564,28973,15303,32297,5527,32597,-3327,31023,-10548,28620,-15955,26201,-19677,24317,-21963,23300,-23039}, - {32764,-371,0,32767,32764,-371,1480,32733,32597,-3327,5892,32232,31468,-9135,12965,30092,27870,-17232,21685,24564,19971,-25978,29635,13978,6619,-32092,32714,-1851,-10898,-30902,26201,-19677,-27064,-18473,8062,-31760,-32515,4062,-16277,-28439,-19380,26421,-32165,-6257,8778,31569,-23816,22506,31253,9843,7342,31933,23300,-23039,32014,6981,-12283,-30378,17544,-27675,-32665,2589,-22236,-24068,-4430,32466,-27474,17856,31666,8421,15629,28799,9489,-31363,28620,-15955,-31849,-7704,-18778,-26853,-2959,32633,-22774,23559,32414,-4797,28973,15303,-14975,-29146,3695,-32558,-20554,25519,-30777,11245,32297,5527,25749,20264,-13643,-29792,740,-32759,-14313,29475,-24808,21406,31023,-10548,32748,1110,-30515,-11939,-25286,-20841,18165,27270,10195,31140,-2221,-32692,5162,-32358,-11593,30647,-16916,28063,21125,-25049,24317,-21963,-26640,19079,-28253,16596,29312,-14645,29944,-13305,-30238,12624,-30238,12624,29944,-13305,29312,-14645,-28253,16596,-26640,19079,24317,-21963,21125,-25049,-16916,28063,-11593,30647,5162,-32358,-2221,-32692,10195,31140,18165,27270,-25286,-20841,-30515,-11939,32748,1110,31023,-10548,-24808,21406,-14313,29475,740,-32759,-13643,-29792,25749,20264,32297,5527,-30777,11245,-20554,25519,3695,-32558,-14975,-29146,28973,15303,32414,-4797,-22774,23559,-2959,32633,-18778,-26853,-31849,-7704,28620,-15955,9489,-31363,15629,28799,31666,8421,-27474,17856,-4430,32466,-22236,-24068,-32665,2589,17544,-27675,-12283,-30378,32014,6981,23300,-23039,7342,31933,31253,9843,-23816,22506,8778,31569,-32165,-6257,-19380,26421,-16277,-28439,-32515,4062,8062,-31760,-27064,-18473,26201,-19677,-10898,-30902,32714,-1851,6619,-32092,29635,13978,19971,-25978,21685,24564,27870,-17232,12965,30092,31468,-9135,5892,32232,32597,-3327,1480,32733}, - {32764,370,1480,-32734,32597,3326,5892,-32233,31468,9134,12965,-30093,27870,17231,21685,-24565,19971,25977,29635,-13979,6619,32091,32714,1850,-10898,30901,26201,19676,-27064,18472,8062,31759,-32515,-4063,-16277,28438,-19380,-26422,-32165,6256,8778,-31570,-23816,-22507,31253,-9844,7342,-31934,23300,23038,32014,-6982,-12283,30377,17544,27674,-32665,-2590,-22236,24067,-4430,-32467,-27474,-17857,31666,-8422,15629,-28800,9489,31362,28620,15954,-31849,7703,-18778,26852,-2959,-32634,-22774,-23560,32414,4796,28973,-15304,-14975,29145,3695,32557,-20554,-25520,-30777,-11246,32297,-5528,25749,-20265,-13643,29791,740,32758,-14313,-29476,-24808,-21407,31023,10547,32748,-1111,-30515,11938,-25286,20840,18165,-27271,10195,-31141,-2221,32691,5162,32357,-11593,-30648,-16916,-28064,21125,25048,24317,21962,-26640,-19080,-28253,-16597,29312,14644,29944,13304,-30238,-12625,-30238,-12625,29944,13304,29312,14644,-28253,-16597,-26640,-19080,24317,21962,21125,25048,-16916,-28064,-11593,-30648,5162,32357,-2221,32691,10195,-31141,18165,-27271,-25286,20840,-30515,11938,32748,-1111,31023,10547,-24808,-21407,-14313,-29476,740,32758,-13643,29791,25749,-20265,32297,-5528,-30777,-11246,-20554,-25520,3695,32557,-14975,29145,28973,-15304,32414,4796,-22774,-23560,-2959,-32634,-18778,26852,-31849,7703,28620,15954,9489,31362,15629,-28800,31666,-8422,-27474,-17857,-4430,-32467,-22236,24067,-32665,-2590,17544,27674,-12283,30377,32014,-6982,23300,23038,7342,-31934,31253,-9844,-23816,-22507,8778,-31570,-32165,6256,-19380,-26422,-16277,28438,-32515,-4063,8062,31759,-27064,18472,26201,19676,-10898,30901,32714,1850,6619,32091,29635,-13979,19971,25977,21685,-24565,27870,17231,12965,-30093,31468,9134,5892,-32233,32597,3326,1480,-32734,32764,370,0,-32768} -}; - -int16_t e839[839*2] = {32767,0,32766,245,32763,490,32758,736,32752,981,32744,1226,32733,1471,32721,1716,32708,1961,32692,2206,32675,2451,32655,2696,32634,2940,32611,3185,32587,3429,32560,3673,32532,3916,32501,4160,32469,4403,32435,4646,32400,4889,32362,5131,32323,5374,32282,5616,32239,5857,32194,6098,32147,6339,32099,6580,32049,6820,31997,7060,31943,7299,31887,7538,31830,7777,31771,8015,31710,8253,31647,8490,31583,8727,31517,8963,31449,9199,31379,9434,31307,9669,31234,9903,31159,10137,31082,10370,31004,10602,30923,10834,30841,11065,30758,11296,30672,11526,30585,11756,30496,11984,30405,12212,30313,12440,30219,12666,30123,12892,30026,13117,29927,13342,29826,13566,29724,13789,29620,14011,29514,14232,29407,14453,29297,14673,29187,14892,29074,15110,28960,15327,28845,15544,28728,15759,28609,15974,28488,16188,28366,16401,28243,16613,28117,16824,27991,17034,27862,17243,27732,17451,27601,17658,27468,17865,27333,18070,27197,18274,27060,18477,26921,18679,26780,18880,26638,19080,26494,19279,26349,19477,26202,19674,26054,19870,25905,20064,25754,20258,25601,20450,25448,20641,25292,20831,25135,21020,24977,21208,24818,21394,24657,21579,24495,21763,24331,21946,24166,22128,24000,22308,23832,22487,23663,22665,23492,22842,23321,23017,23148,23191,22973,23364,22798,23535,22621,23705,22443,23874,22263,24041,22082,24207,21901,24372,21717,24535,21533,24697,21348,24858,21161,25017,20973,25175,20784,25331,20593,25486,20402,25640,20209,25792,20016,25942,19821,26091,19625,26239,19428,26385,19230,26530,19030,26673,18830,26815,18629,26955,18426,27094,18223,27231,18019,27367,17813,27501,17607,27634,17399,27765,17191,27895,16981,28023,16771,28149,16560,28274,16348,28397,16134,28519,15920,28639,15705,28757,15490,28874,15273,28989,15056,29103,14837,29215,14618,29325,14398,29434,14177,29541,13955,29646,13733,29750,13510,29852,13286,29952,13061,30051,12836,30148,12610,30243,12383,30336,12155,30428,11927,30518,11698,30607,11469,30694,11238,30779,11008,30862,10776,30944,10544,31023,10312,31102,10078,31178,9845,31253,9610,31325,9375,31396,9140,31466,8904,31533,8668,31599,8431,31663,8193,31725,7956,31786,7717,31845,7479,31902,7240,31957,7000,32010,6760,32061,6520,32111,6279,32159,6038,32205,5797,32250,5555,32292,5313,32333,5071,32372,4828,32409,4585,32444,4342,32477,4099,32509,3855,32539,3612,32567,3368,32593,3123,32617,2879,32640,2635,32660,2390,32679,2145,32696,1900,32711,1655,32725,1410,32736,1165,32746,920,32754,674,32760,429,32764,184,32766,-62,32766,-307,32765,-553,32762,-798,32757,-1043,32750,-1288,32741,-1534,32731,-1779,32718,-2024,32704,-2269,32688,-2513,32670,-2758,32650,-3002,32629,-3247,32605,-3491,32580,-3735,32553,-3978,32524,-4222,32493,-4465,32461,-4708,32427,-4951,32390,-5193,32352,-5435,32313,-5677,32271,-5919,32228,-6160,32182,-6401,32135,-6641,32087,-6881,32036,-7121,31984,-7360,31929,-7599,31873,-7838,31815,-8076,31756,-8313,31695,-8550,31631,-8787,31566,-9023,31500,-9259,31431,-9494,31361,-9729,31289,-9963,31215,-10196,31140,-10429,31063,-10661,30984,-10893,30903,-11124,30821,-11355,30736,-11585,30651,-11814,30563,-12042,30474,-12270,30383,-12497,30290,-12724,30195,-12950,30099,-13175,30001,-13399,29902,-13623,29801,-13845,29698,-14067,29593,-14289,29487,-14509,29379,-14729,29270,-14947,29159,-15165,29046,-15382,28932,-15599,28816,-15814,28698,-16029,28579,-16242,28458,-16455,28336,-16667,28212,-16877,28086,-17087,27959,-17296,27830,-17504,27700,-17711,27568,-17917,27434,-18122,27300,-18326,27163,-18529,27025,-18731,26886,-18931,26745,-19131,26602,-19330,26458,-19527,26312,-19724,26166,-19919,26017,-20114,25867,-20307,25716,-20499,25563,-20690,25409,-20879,25253,-21068,25096,-21255,24938,-21441,24778,-21626,24616,-21810,24454,-21993,24290,-22174,24124,-22354,23958,-22533,23790,-22710,23620,-22887,23450,-23062,23277,-23235,23104,-23408,22929,-23579,22754,-23748,22576,-23917,22398,-24084,22218,-24250,22037,-24414,21855,-24577,21671,-24739,21487,-24899,21301,-25058,21114,-25215,20926,-25371,20736,-25526,20546,-25679,20354,-25830,20161,-25981,19967,-26130,19772,-26277,19576,-26423,19378,-26567,19180,-26710,18980,-26851,18780,-26991,18578,-27130,18376,-27267,18172,-27402,17967,-27536,17762,-27668,17555,-27799,17347,-27928,17139,-28055,16929,-28181,16718,-28306,16507,-28429,16294,-28550,16081,-28669,15867,-28787,15652,-28904,15436,-29019,15219,-29132,15001,-29243,14782,-29353,14563,-29461,14343,-29568,14122,-29673,13900,-29776,13677,-29878,13454,-29978,13230,-30076,13005,-30173,12779,-30267,12553,-30361,12326,-30452,12098,-30542,11870,-30630,11641,-30716,11411,-30801,11181,-30884,10950,-30965,10718,-31044,10486,-31122,10253,-31198,10020,-31272,9786,-31344,9552,-31415,9317,-31484,9081,-31551,8845,-31616,8609,-31680,8372,-31742,8134,-31802,7896,-31860,7658,-31916,7419,-31971,7180,-32024,6940,-32075,6700,-32124,6460,-32172,6219,-32218,5978,-32261,5736,-32303,5495,-32344,5253,-32382,5010,-32419,4768,-32454,4525,-32487,4282,-32518,4038,-32547,3794,-32575,3551,-32600,3307,-32624,3062,-32646,2818,-32666,2573,-32685,2329,-32701,2084,-32716,1839,-32729,1594,-32740,1349,-32749,1104,-32756,858,-32762,613,-32765,368,-32767,122,-32767,-123,-32765,-369,-32762,-614,-32756,-859,-32749,-1105,-32740,-1350,-32729,-1595,-32716,-1840,-32701,-2085,-32685,-2330,-32666,-2574,-32646,-2819,-32624,-3063,-32600,-3308,-32575,-3552,-32547,-3795,-32518,-4039,-32487,-4283,-32454,-4526,-32419,-4769,-32382,-5011,-32344,-5254,-32303,-5496,-32261,-5737,-32218,-5979,-32172,-6220,-32124,-6461,-32075,-6701,-32024,-6941,-31971,-7181,-31916,-7420,-31860,-7659,-31802,-7897,-31742,-8135,-31680,-8373,-31616,-8610,-31551,-8846,-31484,-9082,-31415,-9318,-31344,-9553,-31272,-9787,-31198,-10021,-31122,-10254,-31044,-10487,-30965,-10719,-30884,-10951,-30801,-11182,-30716,-11412,-30630,-11642,-30542,-11871,-30452,-12099,-30361,-12327,-30267,-12554,-30173,-12780,-30076,-13006,-29978,-13231,-29878,-13455,-29776,-13678,-29673,-13901,-29568,-14123,-29461,-14344,-29353,-14564,-29243,-14783,-29132,-15002,-29019,-15220,-28904,-15437,-28787,-15653,-28669,-15868,-28550,-16082,-28429,-16295,-28306,-16508,-28181,-16719,-28055,-16930,-27928,-17140,-27799,-17348,-27668,-17556,-27536,-17763,-27402,-17968,-27267,-18173,-27130,-18377,-26991,-18579,-26851,-18781,-26710,-18981,-26567,-19181,-26423,-19379,-26277,-19577,-26130,-19773,-25981,-19968,-25830,-20162,-25679,-20355,-25526,-20547,-25371,-20737,-25215,-20927,-25058,-21115,-24899,-21302,-24739,-21488,-24577,-21672,-24414,-21856,-24250,-22038,-24084,-22219,-23917,-22399,-23748,-22577,-23579,-22755,-23408,-22930,-23235,-23105,-23062,-23278,-22887,-23451,-22710,-23621,-22533,-23791,-22354,-23959,-22174,-24125,-21993,-24291,-21810,-24455,-21626,-24617,-21441,-24779,-21255,-24939,-21068,-25097,-20879,-25254,-20690,-25410,-20499,-25564,-20307,-25717,-20114,-25868,-19919,-26018,-19724,-26167,-19527,-26313,-19330,-26459,-19131,-26603,-18931,-26746,-18731,-26887,-18529,-27026,-18326,-27164,-18122,-27301,-17917,-27435,-17711,-27569,-17504,-27701,-17296,-27831,-17087,-27960,-16877,-28087,-16667,-28213,-16455,-28337,-16242,-28459,-16029,-28580,-15814,-28699,-15599,-28817,-15382,-28933,-15165,-29047,-14947,-29160,-14729,-29271,-14509,-29380,-14289,-29488,-14067,-29594,-13845,-29699,-13623,-29802,-13399,-29903,-13175,-30002,-12950,-30100,-12724,-30196,-12497,-30291,-12270,-30384,-12042,-30475,-11814,-30564,-11585,-30652,-11355,-30737,-11124,-30822,-10893,-30904,-10661,-30985,-10429,-31064,-10196,-31141,-9963,-31216,-9729,-31290,-9494,-31362,-9259,-31432,-9023,-31501,-8787,-31567,-8550,-31632,-8313,-31696,-8076,-31757,-7838,-31816,-7599,-31874,-7360,-31930,-7121,-31985,-6881,-32037,-6641,-32088,-6401,-32136,-6160,-32183,-5919,-32229,-5677,-32272,-5435,-32314,-5193,-32353,-4951,-32391,-4708,-32428,-4465,-32462,-4222,-32494,-3978,-32525,-3735,-32554,-3491,-32581,-3247,-32606,-3002,-32630,-2758,-32651,-2513,-32671,-2269,-32689,-2024,-32705,-1779,-32719,-1534,-32732,-1288,-32742,-1043,-32751,-798,-32758,-553,-32763,-307,-32766,-62,-32767,184,-32767,429,-32765,674,-32761,920,-32755,1165,-32747,1410,-32737,1655,-32726,1900,-32712,2145,-32697,2390,-32680,2635,-32661,2879,-32641,3123,-32618,3368,-32594,3612,-32568,3855,-32540,4099,-32510,4342,-32478,4585,-32445,4828,-32410,5071,-32373,5313,-32334,5555,-32293,5797,-32251,6038,-32206,6279,-32160,6520,-32112,6760,-32062,7000,-32011,7240,-31958,7479,-31903,7717,-31846,7956,-31787,8193,-31726,8431,-31664,8668,-31600,8904,-31534,9140,-31467,9375,-31397,9610,-31326,9845,-31254,10078,-31179,10312,-31103,10544,-31024,10776,-30945,11008,-30863,11238,-30780,11469,-30695,11698,-30608,11927,-30519,12155,-30429,12383,-30337,12610,-30244,12836,-30149,13061,-30052,13286,-29953,13510,-29853,13733,-29751,13955,-29647,14177,-29542,14398,-29435,14618,-29326,14837,-29216,15056,-29104,15273,-28990,15490,-28875,15705,-28758,15920,-28640,16134,-28520,16348,-28398,16560,-28275,16771,-28150,16981,-28024,17191,-27896,17399,-27766,17607,-27635,17813,-27502,18019,-27368,18223,-27232,18426,-27095,18629,-26956,18830,-26816,19030,-26674,19230,-26531,19428,-26386,19625,-26240,19821,-26092,20016,-25943,20209,-25793,20402,-25641,20593,-25487,20784,-25332,20973,-25176,21161,-25018,21348,-24859,21533,-24698,21717,-24536,21901,-24373,22082,-24208,22263,-24042,22443,-23875,22621,-23706,22798,-23536,22973,-23365,23148,-23192,23321,-23018,23492,-22843,23663,-22666,23832,-22488,24000,-22309,24166,-22129,24331,-21947,24495,-21764,24657,-21580,24818,-21395,24977,-21209,25135,-21021,25292,-20832,25448,-20642,25601,-20451,25754,-20259,25905,-20065,26054,-19871,26202,-19675,26349,-19478,26494,-19280,26638,-19081,26780,-18881,26921,-18680,27060,-18478,27197,-18275,27333,-18071,27468,-17866,27601,-17659,27732,-17452,27862,-17244,27991,-17035,28117,-16825,28243,-16614,28366,-16402,28488,-16189,28609,-15975,28728,-15760,28845,-15545,28960,-15328,29074,-15111,29187,-14893,29297,-14674,29407,-14454,29514,-14233,29620,-14012,29724,-13790,29826,-13567,29927,-13343,30026,-13118,30123,-12893,30219,-12667,30313,-12441,30405,-12213,30496,-11985,30585,-11757,30672,-11527,30758,-11297,30841,-11066,30923,-10835,31004,-10603,31082,-10371,31159,-10138,31234,-9904,31307,-9670,31379,-9435,31449,-9200,31517,-8964,31583,-8728,31647,-8491,31710,-8254,31771,-8016,31830,-7778,31887,-7539,31943,-7300,31997,-7061,32049,-6821,32099,-6581,32147,-6340,32194,-6099,32239,-5858,32282,-5617,32323,-5375,32362,-5132,32400,-4890,32435,-4647,32469,-4404,32501,-4161,32532,-3917,32560,-3674,32587,-3430,32611,-3186,32634,-2941,32655,-2697,32675,-2452,32692,-2207,32708,-1962,32721,-1717,32733,-1472,32744,-1227,32752,-982,32758,-737,32763,-491,32766,-246}; - -int16_t e139[139*2] = {32767,0,32733,1480,32633,2958,32466,4429,32232,5892,31933,7342,31569,8778,31140,10195,30647,11592,30092,12965,29475,14312,28799,15629,28063,16915,27270,18165,26421,19379,25519,20553,24564,21685,23559,22773,22506,23815,21406,24807,20264,25749,19079,26639,17856,27473,16596,28252,15303,28973,13978,29635,12624,30237,11245,30776,9843,31253,8421,31666,6981,32014,5527,32297,4062,32514,2589,32664,1110,32748,-371,32764,-1851,32714,-3327,32597,-4797,32414,-6257,32164,-7704,31848,-9135,31468,-10548,31023,-11939,30514,-13305,29944,-14645,29312,-15955,28620,-17232,27870,-18473,27063,-19677,26201,-20841,25285,-21963,24317,-23039,23300,-24068,22235,-25049,21125,-25978,19971,-26853,18777,-27675,17544,-28439,16276,-29146,14974,-29792,13642,-30378,12282,-30902,10897,-31363,9489,-31760,8062,-32092,6619,-32358,5162,-32558,3695,-32692,2220,-32759,740,-32759,-741,-32692,-2221,-32558,-3696,-32358,-5163,-32092,-6620,-31760,-8063,-31363,-9490,-30902,-10898,-30378,-12283,-29792,-13643,-29146,-14975,-28439,-16277,-27675,-17545,-26853,-18778,-25978,-19972,-25049,-21126,-24068,-22236,-23039,-23301,-21963,-24318,-20841,-25286,-19677,-26202,-18473,-27064,-17232,-27871,-15955,-28621,-14645,-29313,-13305,-29945,-11939,-30515,-10548,-31024,-9135,-31469,-7704,-31849,-6257,-32165,-4797,-32415,-3327,-32598,-1851,-32715,-371,-32765,1110,-32749,2589,-32665,4062,-32515,5527,-32298,6981,-32015,8421,-31667,9843,-31254,11245,-30777,12624,-30238,13978,-29636,15303,-28974,16596,-28253,17856,-27474,19079,-26640,20264,-25750,21406,-24808,22506,-23816,23559,-22774,24564,-21686,25519,-20554,26421,-19380,27270,-18166,28063,-16916,28799,-15630,29475,-14313,30092,-12966,30647,-11593,31140,-10196,31569,-8779,31933,-7343,32232,-5893,32466,-4430,32633,-2959,32733,-1481}; diff --git a/openair1/PHY/LTE_TRANSPORT/prach_common.c b/openair1/PHY/LTE_TRANSPORT/prach_common.c new file mode 100644 index 0000000000000000000000000000000000000000..2f39346be2027e4fc1d9460ec6cb508026b9f666 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/prach_common.c @@ -0,0 +1,771 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/prach_common.c + * \brief Common routines for UE/eNB PRACH physical channel V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include "PHY/sse_intrin.h" +#include "PHY/defs_common.h" +#include "PHY/phy_extern.h" +#include "PHY/phy_extern_ue.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + + +uint16_t NCS_unrestricted[16] = {0,13,15,18,22,26,32,38,46,59,76,93,119,167,279,419}; +uint16_t NCS_restricted[15] = {15,18,22,26,32,38,46,55,68,82,100,128,158,202,237}; // high-speed case +uint16_t NCS_4[7] = {2,4,6,8,10,12,15}; + +int16_t ru[2*839]; // quantized roots of unity +uint32_t ZC_inv[839]; // multiplicative inverse for roots u +uint16_t du[838]; + +// This is table 5.7.1-4 from 36.211 +PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7] = { + // TDD Configuration Index 0 + { {1,{{0,1,0,2}}},{1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}}, + // TDD Configuration Index 1 + { {1,{{0,2,0,2}}},{1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}}, + // TDD Configuration Index 2 + { {1,{{0,1,1,2}}},{1,{{0,1,1,1}}}, {1,{{0,1,1,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,1}}}}, + // TDD Configuration Index 3 + { {1,{{0,0,0,2}}},{1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}}, + // TDD Configuration Index 4 + { {1,{{0,0,1,2}}},{1,{{0,0,1,1}}}, {1,{{0,0,1,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,1}}}}, + // TDD Configuration Index 5 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + // TDD Configuration Index 6 + { {2,{{0,0,0,2},{0,0,1,2}}}, {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {2,{{0,0,0,1},{0,0,0,2}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {2,{{0,0,0,2},{0,0,1,1}}}}, + // TDD Configuration Index 7 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,2}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + // TDD Configuration Index 8 + { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,1,1}}}}, + // TDD Configuration Index 9 + { {3,{{0,0,0,1},{0,0,0,2},{0,0,1,2}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,0,2}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {3,{{0,0,0,1},{0,0,0,2},{0,0,1,1}}}}, + // TDD Configuration Index 10 + { {3,{{0,0,0,0},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,2},{0,0,1,0}}}}, + // TDD Configuration Index 11 + { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}}, + // TDD Configuration Index 12 + { {4,{{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, + {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,2}}}, + {4,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {4,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 13 + { {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1}}} + }, + // TDD Configuration Index 14 + { {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 15 + { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1}}}, + {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1},{1,0,0,2}}}, + {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,1}}}, {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, + {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 16 + { {5,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,1,1}}}, + {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,1,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,2}}}, + {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} + }, + // TDD Configuration Index 17 + { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} + }, + // TDD Configuration Index 18 + { {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1},{1,0,0,2}}}, + {6,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0},{2,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,0,2}}} + }, + // TDD Configuration Index 19 + { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,1,1}}} + }, + // TDD Configuration Index 20 + { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, + // TDD Configuration Index 21 + { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, + + // TDD Configuration Index 22 + { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, + + // TDD Configuration Index 23 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + + // TDD Configuration Index 24 + { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, + + // TDD Configuration Index 25 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + + // TDD Configuration Index 26 + { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, + + // TDD Configuration Index 27 + { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} + }, + + // TDD Configuration Index 28 + { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, + {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} + }, + + // TDD Configuration Index 29 + { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} + }, + + + // TDD Configuration Index 30 + { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, + + // TDD Configuration Index 31 + { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, + + // TDD Configuration Index 32 + { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, + + // TDD Configuration Index 33 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + + // TDD Configuration Index 34 + { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, + + // TDD Configuration Index 35 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + + // TDD Configuration Index 36 + { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, + + // TDD Configuration Index 37 + { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} + }, + + // TDD Configuration Index 38 + { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, + {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} + }, + + // TDD Configuration Index 39 + { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} + }, + + // TDD Configuration Index 40 + { {1,{{0,1,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}}, + // TDD Configuration Index 41 + { {1,{{0,2,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}}, + + // TDD Configuration Index 42 + { {1,{{0,1,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, + + // TDD Configuration Index 43 + { {1,{{0,0,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}}, + + // TDD Configuration Index 44 + { {1,{{0,0,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, + + // TDD Configuration Index 45 + { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}}, + + // TDD Configuration Index 46 + { {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}}, + + // TDD Configuration Index 47 + { {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}} + } +}; + + + +uint16_t prach_root_sequence_map0_3[838] = { 129, 710, 140, 699, 120, 719, 210, 629, 168, 671, 84, 755, 105, 734, 93, 746, 70, 769, 60, 779, + 2, 837, 1, 838, + 56, 783, 112, 727, 148, 691, + 80, 759, 42, 797, 40, 799, + 35, 804, 73, 766, 146, 693, + 31, 808, 28, 811, 30, 809, 27, 812, 29, 810, + 24, 815, 48, 791, 68, 771, 74, 765, 178, 661, 136, 703, + 86, 753, 78, 761, 43, 796, 39, 800, 20, 819, 21, 818, + 95, 744, 202, 637, 190, 649, 181, 658, 137, 702, 125, 714, 151, 688, + 217, 622, 128, 711, 142, 697, 122, 717, 203, 636, 118, 721, 110, 729, 89, 750, 103, 736, 61, + 778, 55, 784, 15, 824, 14, 825, + 12, 827, 23, 816, 34, 805, 37, 802, 46, 793, 207, 632, 179, 660, 145, 694, 130, 709, 223, 616, + 228, 611, 227, 612, 132, 707, 133, 706, 143, 696, 135, 704, 161, 678, 201, 638, 173, 666, 106, + 733, 83, 756, 91, 748, 66, 773, 53, 786, 10, 829, 9, 830, + 7, 832, 8, 831, 16, 823, 47, 792, 64, 775, 57, 782, 104, 735, 101, 738, 108, 731, 208, 631, 184, + 655, 197, 642, 191, 648, 121, 718, 141, 698, 149, 690, 216, 623, 218, 621, + 152, 687, 144, 695, 134, 705, 138, 701, 199, 640, 162, 677, 176, 663, 119, 720, 158, 681, 164, + 675, 174, 665, 171, 668, 170, 669, 87, 752, 169, 670, 88, 751, 107, 732, 81, 758, 82, 757, 100, + 739, 98, 741, 71, 768, 59, 780, 65, 774, 50, 789, 49, 790, 26, 813, 17, 822, 13, 826, 6, 833, + 5, 834, 33, 806, 51, 788, 75, 764, 99, 740, 96, 743, 97, 742, 166, 673, 172, 667, 175, 664, 187, + 652, 163, 676, 185, 654, 200, 639, 114, 725, 189, 650, 115, 724, 194, 645, 195, 644, 192, 647, + 182, 657, 157, 682, 156, 683, 211, 628, 154, 685, 123, 716, 139, 700, 212, 627, 153, 686, 213, + 626, 215, 624, 150, 689, + 225, 614, 224, 615, 221, 618, 220, 619, 127, 712, 147, 692, 124, 715, 193, 646, 205, 634, 206, + 633, 116, 723, 160, 679, 186, 653, 167, 672, 79, 760, 85, 754, 77, 762, 92, 747, 58, 781, 62, + 777, 69, 770, 54, 785, 36, 803, 32, 807, 25, 814, 18, 821, 11, 828, 4, 835, + 3, 836, 19, 820, 22, 817, 41, 798, 38, 801, 44, 795, 52, 787, 45, 794, 63, 776, 67, 772, 72, + 767, 76, 763, 94, 745, 102, 737, 90, 749, 109, 730, 165, 674, 111, 728, 209, 630, 204, 635, 117, + 722, 188, 651, 159, 680, 198, 641, 113, 726, 183, 656, 180, 659, 177, 662, 196, 643, 155, 684, + 214, 625, 126, 713, 131, 708, 219, 620, 222, 617, 226, 613, + 230, 609, 232, 607, 262, 577, 252, 587, 418, 421, 416, 423, 413, 426, 411, 428, 376, 463, 395, + 444, 283, 556, 285, 554, 379, 460, 390, 449, 363, 476, 384, 455, 388, 451, 386, 453, 361, 478, + 387, 452, 360, 479, 310, 529, 354, 485, 328, 511, 315, 524, 337, 502, 349, 490, 335, 504, 324, + 515, + 323, 516, 320, 519, 334, 505, 359, 480, 295, 544, 385, 454, 292, 547, 291, 548, 381, 458, 399, + 440, 380, 459, 397, 442, 369, 470, 377, 462, 410, 429, 407, 432, 281, 558, 414, 425, 247, 592, + 277, 562, 271, 568, 272, 567, 264, 575, 259, 580, + 237, 602, 239, 600, 244, 595, 243, 596, 275, 564, 278, 561, 250, 589, 246, 593, 417, 422, 248, + 591, 394, 445, 393, 446, 370, 469, 365, 474, 300, 539, 299, 540, 364, 475, 362, 477, 298, 541, + 312, 527, 313, 526, 314, 525, 353, 486, 352, 487, 343, 496, 327, 512, 350, 489, 326, 513, 319, + 520, 332, 507, 333, 506, 348, 491, 347, 492, 322, 517, + 330, 509, 338, 501, 341, 498, 340, 499, 342, 497, 301, 538, 366, 473, 401, 438, 371, 468, 408, + 431, 375, 464, 249, 590, 269, 570, 238, 601, 234, 605, + 257, 582, 273, 566, 255, 584, 254, 585, 245, 594, 251, 588, 412, 427, 372, 467, 282, 557, 403, + 436, 396, 443, 392, 447, 391, 448, 382, 457, 389, 450, 294, 545, 297, 542, 311, 528, 344, 495, + 345, 494, 318, 521, 331, 508, 325, 514, 321, 518, + 346, 493, 339, 500, 351, 488, 306, 533, 289, 550, 400, 439, 378, 461, 374, 465, 415, 424, 270, + 569, 241, 598, + 231, 608, 260, 579, 268, 571, 276, 563, 409, 430, 398, 441, 290, 549, 304, 535, 308, 531, 358, + 481, 316, 523, + 293, 546, 288, 551, 284, 555, 368, 471, 253, 586, 256, 583, 263, 576, + 242, 597, 274, 565, 402, 437, 383, 456, 357, 482, 329, 510, + 317, 522, 307, 532, 286, 553, 287, 552, 266, 573, 261, 578, + 236, 603, 303, 536, 356, 483, + 355, 484, 405, 434, 404, 435, 406, 433, + 235, 604, 267, 572, 302, 537, + 309, 530, 265, 574, 233, 606, + 367, 472, 296, 543, + 336, 503, 305, 534, 373, 466, 280, 559, 279, 560, 419, 420, 240, 599, 258, 581, 229, 610 + }; + +uint16_t prach_root_sequence_map4[138] = { 1,138,2,137,3,136,4,135,5,134,6,133,7,132,8,131,9,130,10,129, + 11,128,12,127,13,126,14,125,15,124,16,123,17,122,18,121,19,120,20,119, + 21,118,22,117,23,116,24,115,25,114,26,113,27,112,28,111,29,110,30,109, + 31,108,32,107,33,106,34,105,35,104,36,103,37,102,38,101,39,100,40,99, + 41,98,42,97,43,96,44,95,45,94,46,93,47,92,48,91,49,90,50,89, + 51,88,52,87,53,86,54,85,55,84,56,83,57,82,58,81,59,80,60,79, + 61,78,62,77,63,76,64,75,65,74,66,73,67,72,68,71,69,70 + }; + +void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) +{ + + FILE *fd; + + fd = fopen("prach_config.txt","w"); + fprintf(fd,"prach_config: subframe = %d\n",subframe); + fprintf(fd,"prach_config: N_RB_UL = %d\n",frame_parms->N_RB_UL); + fprintf(fd,"prach_config: frame_type = %s\n",(frame_parms->frame_type==1) ? "TDD":"FDD"); + + if(frame_parms->frame_type==1) fprintf(fd,"prach_config: tdd_config = %d\n",frame_parms->tdd_config); + + fprintf(fd,"prach_config: rootSequenceIndex = %d\n",frame_parms->prach_config_common.rootSequenceIndex); + fprintf(fd,"prach_config: prach_ConfigIndex = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex); + fprintf(fd,"prach_config: Ncs_config = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig); + fprintf(fd,"prach_config: highSpeedFlag = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag); + fprintf(fd,"prach_config: n_ra_prboffset = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset); + fclose(fd); + +} + +// This function computes the du +void fill_du(uint8_t prach_fmt) +{ + + uint16_t iu,u,p; + uint16_t N_ZC; + uint16_t *prach_root_sequence_map; + + if (prach_fmt<4) { + N_ZC = 839; + prach_root_sequence_map = prach_root_sequence_map0_3; + } else { + N_ZC = 139; + prach_root_sequence_map = prach_root_sequence_map4; + } + + for (iu=0; iu<(N_ZC-1); iu++) { + + u=prach_root_sequence_map[iu]; + p=1; + + while (((u*p)%N_ZC)!=1) + p++; + + du[u] = ((p<(N_ZC>>1)) ? p : (N_ZC-p)); + } + +} + +uint8_t get_num_prach_tdd(module_id_t Mod_id) +{ + LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; + return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].num_prach); +} + +uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index) +{ + LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms; + return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].map[tdd_map_index].f_ra); +} + +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type) +{ + + if (frame_type == FDD) // FDD + return(prach_ConfigIndex>>4); + + else { + if (prach_ConfigIndex < 20) + return (0); + + if (prach_ConfigIndex < 30) + return (1); + + if (prach_ConfigIndex < 40) + return (2); + + if (prach_ConfigIndex < 48) + return (3); + else + return (4); + } +} + +uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf) +{ + lte_frame_type_t frame_type = frame_parms->frame_type; + uint8_t tdd_config = frame_parms->tdd_config; + + uint8_t n_ra_prb; + uint8_t f_ra,t1_ra; + uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); + uint8_t Nsp=2; + + if (frame_type == TDD) { // TDD + + if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { + LOG_E(PHY, "Illegal prach_ConfigIndex %"PRIu8"", prach_ConfigIndex); + return(-1); + } + + // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) + f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; + + if (prach_fmt < 4) { + if ((f_ra&1) == 0) { + n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); + } else { + n_ra_prb = frame_parms->N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); + } + } else { + if ((tdd_config >2) && (tdd_config<6)) + Nsp = 2; + + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + + if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { + n_ra_prb = 6*f_ra; + } else { + n_ra_prb = frame_parms->N_RB_UL - 6*(f_ra+1); + } + } + } + else { //FDD + n_ra_prb = n_ra_prboffset; + } + return(n_ra_prb); +} + +int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe) +{ + // uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + uint8_t tdd_config = frame_parms->tdd_config; + uint8_t t0_ra; + uint8_t t1_ra; + uint8_t t2_ra; + + int prach_mask = 0; + + if (frame_parms->frame_type == FDD) { //FDD + //implement Table 5.7.1-2 from 36.211 (Rel-10, p.41) + if ((((frame&1) == 1) && (subframe < 9)) || + (((frame&1) == 0) && (subframe == 9))) // This is an odd frame, ignore even-only PRACH frames + if (((prach_ConfigIndex&0xf)<3) || // 0,1,2,16,17,18,32,33,34,48,49,50 + ((prach_ConfigIndex&0x1f)==18) || // 18,50 + ((prach_ConfigIndex&0xf)==15)) // 15,47 + return(0); + + switch (prach_ConfigIndex&0x1f) { + case 0: + case 3: + if (subframe==1) prach_mask = 1; + break; + + case 1: + case 4: + if (subframe==4) prach_mask = 1; + break; + + case 2: + case 5: + if (subframe==7) prach_mask = 1; + break; + + case 6: + if ((subframe==1) || (subframe==6)) prach_mask=1; + break; + + case 7: + if ((subframe==2) || (subframe==7)) prach_mask=1; + break; + + case 8: + if ((subframe==3) || (subframe==8)) prach_mask=1; + break; + + case 9: + if ((subframe==1) || (subframe==4) || (subframe==7)) prach_mask=1; + break; + + case 10: + if ((subframe==2) || (subframe==5) || (subframe==8)) prach_mask=1; + break; + + case 11: + if ((subframe==3) || (subframe==6) || (subframe==9)) prach_mask=1; + break; + + case 12: + if ((subframe&1)==0) prach_mask=1; + break; + + case 13: + if ((subframe&1)==1) prach_mask=1; + break; + + case 14: + prach_mask=1; + break; + + case 15: + if (subframe==9) prach_mask=1; + break; + } + } else { // TDD + + AssertFatal(prach_ConfigIndex<64, + "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); + AssertFatal(tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach>0, + "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); + + t0_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t0_ra; + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + t2_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t2_ra; +#ifdef PRACH_DEBUG + LOG_I(PHY,"[PRACH] Checking for PRACH format (ConfigIndex %d) in TDD subframe %d (%d,%d,%d)\n", + prach_ConfigIndex, + subframe, + t0_ra,t1_ra,t2_ra); +#endif + + if ((((t0_ra == 1) && ((frame &1)==0))|| // frame is even and PRACH is in even frames + ((t0_ra == 2) && ((frame &1)==1))|| // frame is odd and PRACH is in odd frames + (t0_ra == 0)) && // PRACH is in all frames + (((subframe<5)&&(t1_ra==0)) || // PRACH is in 1st half-frame + (((subframe>4)&&(t1_ra==1))))) { // PRACH is in 2nd half-frame + if ((prach_ConfigIndex<48) && // PRACH only in normal UL subframe + (((subframe%5)-2)==t2_ra)) prach_mask=1; + else if ((prach_ConfigIndex>47) && (((subframe%5)-1)==t2_ra)) prach_mask=1; // PRACH can be in UpPTS + } + } + + return(prach_mask); +} + +int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) { + + uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + int prach_mask = is_prach_subframe0(frame_parms,prach_ConfigIndex,frame,subframe); + +#ifdef Rel14 + int i; + + for (i=0;i<4;i++) { + if (frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] == 1) + prach_mask|=(is_prach_subframe0(frame_parms,frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i],frame,subframe)<<(i+1)); + } +#endif + return(prach_mask); +} + + +void compute_prach_seq(uint16_t rootSequenceIndex, + uint8_t prach_ConfigIndex, + uint8_t zeroCorrelationZoneConfig, + uint8_t highSpeedFlag, + lte_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; + int N_ZC; + uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); + uint16_t *prach_root_sequence_map; + uint16_t u, preamble_offset; + uint16_t n_shift_ra,n_shift_ra_bar, d_start,numshift; + uint8_t not_found; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_IN); + +#ifdef PRACH_DEBUG + LOG_I(PHY,"compute_prach_seq: NCS_config %d, prach_fmt %d\n",zeroCorrelationZoneConfig, prach_fmt); +#endif + + AssertFatal(prach_fmt<4, + "PRACH sequence is only precomputed for prach_fmt<4 (have %"PRIu8")\n", prach_fmt ); + N_ZC = (prach_fmt < 4) ? 839 : 139; + //init_prach_tables(N_ZC); //moved to phy_init_lte_ue/eNB, since it takes to long in real-time + + if (prach_fmt < 4) { + prach_root_sequence_map = prach_root_sequence_map0_3; + } else { + // FIXME cannot be reached + prach_root_sequence_map = prach_root_sequence_map4; + } + + +#ifdef PRACH_DEBUG + LOG_I( PHY, "compute_prach_seq: done init prach_tables\n" ); +#endif + + if (highSpeedFlag== 0) { + +#ifdef PRACH_DEBUG + LOG_I(PHY,"Low speed prach : NCS_config %d\n",zeroCorrelationZoneConfig); +#endif + + AssertFatal(zeroCorrelationZoneConfig<=15, + "FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); + NCS = NCS_unrestricted[zeroCorrelationZoneConfig]; + + num_preambles = (NCS==0) ? 64 : ((64*NCS)/N_ZC); + + if (NCS>0) num_preambles++; + + preamble_offset = 0; + } else { + +#ifdef PRACH_DEBUG + LOG_I( PHY, "high speed prach : NCS_config %"PRIu8"\n", zeroCorrelationZoneConfig ); +#endif + + AssertFatal(zeroCorrelationZoneConfig<=14, + "FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", zeroCorrelationZoneConfig ); + NCS = NCS_restricted[zeroCorrelationZoneConfig]; + fill_du(prach_fmt); + + num_preambles = 64; // compute ZC sequence for 64 possible roots + // find first non-zero shift root (stored in preamble_offset) + not_found = 1; + preamble_offset = 0; + + while (not_found == 1) { + // current root depending on rootSequenceIndex + int index = (rootSequenceIndex + preamble_offset) % N_ZC; + + if (prach_fmt<4) { + // prach_root_sequence_map points to prach_root_sequence_map0_3 + DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); + } else { + // prach_root_sequence_map points to prach_root_sequence_map4 + DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); + } + + u = prach_root_sequence_map[index]; + + uint16_t n_group_ra = 0; + + if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { + n_shift_ra = du[u]/NCS; + d_start = (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = N_ZC/d_start; + n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); + } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { + n_shift_ra = (N_ZC - (du[u]<<1))/NCS; + d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = du[u]/d_start; + n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); + } else { + n_shift_ra = 0; + n_shift_ra_bar = 0; + } + + // This is the number of cyclic shifts for the current root u + numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; + + // skip to next root and recompute parameters if numshift==0 + if (numshift>0) + not_found = 0; + else + preamble_offset++; + } + } + +#ifdef PRACH_DEBUG + + if (NCS>0) + LOG_I( PHY, "Initializing %u preambles for PRACH (NCS_config %"PRIu8", NCS %u, N_ZC/NCS %u)\n", + num_preambles, zeroCorrelationZoneConfig, NCS, N_ZC/NCS ); + +#endif + + for (i=0; i<num_preambles; i++) { + int index = (rootSequenceIndex+i+preamble_offset) % N_ZC; + + if (prach_fmt<4) { + // prach_root_sequence_map points to prach_root_sequence_map0_3 + DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); + } else { + // prach_root_sequence_map points to prach_root_sequence_map4 + DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); + } + + u = prach_root_sequence_map[index]; + + inv_u = ZC_inv[u]; // multiplicative inverse of u + + + // X_u[0] stores the first ZC sequence where the root u has a non-zero number of shifts + // for the unrestricted case X_u[0] is the first root indicated by the rootSequenceIndex + + for (k=0; k<N_ZC; k++) { + // 420 is the multiplicative inverse of 2 (required since ru is exp[j 2\pi n]) + X_u[i][k] = ((uint32_t*)ru)[(((k*(1+(inv_u*k)))%N_ZC)*420)%N_ZC]; + } + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_OUT); + +} + +void init_prach_tables(int N_ZC) +{ + + int i,m; + + // Compute the modular multiplicative inverse 'iu' of u s.t. iu*u = 1 mod N_ZC + ZC_inv[0] = 0; + ZC_inv[1] = 1; + + for (i=2; i<N_ZC; i++) { + for (m=2; m<N_ZC; m++) + if (((i*m)%N_ZC) == 1) { + ZC_inv[i] = m; + break; + } + +#ifdef PRACH_DEBUG + + if (i<16) + printf("i %d : inv %d\n",i,ZC_inv[i]); + +#endif + } + + // Compute quantized roots of unity + for (i=0; i<N_ZC; i++) { + ru[i<<1] = (int16_t)(floor(32767.0*cos(2*M_PI*(double)i/N_ZC))); + ru[1+(i<<1)] = (int16_t)(floor(32767.0*sin(2*M_PI*(double)i/N_ZC))); +#ifdef PRACH_DEBUG + + if (i<16) + printf("i %d : runity %d,%d\n",i,ru[i<<1],ru[1+(i<<1)]); + +#endif + } +} + diff --git a/openair1/PHY/LTE_TRANSPORT/prach_extern.h b/openair1/PHY/LTE_TRANSPORT/prach_extern.h new file mode 100644 index 0000000000000000000000000000000000000000..2f8a83e24f2a052e3359cd499e8dddf395a5671d --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/prach_extern.h @@ -0,0 +1,93 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/prach_common.c + * \brief Common routines for UE/eNB PRACH physical channel V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include "PHY/sse_intrin.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" + +//#define PRACH_DEBUG 1 +//#define PRACH_WRITE_OUTPUT_DEBUG 1 + +extern uint16_t NCS_unrestricted[16]; +extern uint16_t NCS_restricted[15]; +extern uint16_t NCS_4[7]; + +extern int16_t ru[2*839]; // quantized roots of unity +extern uint32_t ZC_inv[839]; // multiplicative inverse for roots u +extern uint16_t du[838]; + + + +// This is table 5.7.1-4 from 36.211 +extern PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7]; + + + + +extern uint16_t prach_root_sequence_map0_3[838]; + + +extern uint16_t prach_root_sequence_map4[138]; + +void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + + +// This function computes the du +void fill_du(uint8_t prach_fmt); + + +uint8_t get_num_prach_tdd(module_id_t Mod_id); + + +uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index); + + +uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); + + +uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf); + + +int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe); + +int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe); + + +void compute_prach_seq(uint16_t rootSequenceIndex, + uint8_t prach_ConfigIndex, + uint8_t zeroCorrelationZoneConfig, + uint8_t highSpeedFlag, + lte_frame_type_t frame_type, + uint32_t X_u[64][839]); + diff --git a/openair1/PHY/LTE_TRANSPORT/print_stats.c b/openair1/PHY/LTE_TRANSPORT/print_stats.c deleted file mode 100644 index 9e328353a4fdd975b26640822813bd4d5a909846..0000000000000000000000000000000000000000 --- a/openair1/PHY/LTE_TRANSPORT/print_stats.c +++ /dev/null @@ -1,804 +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 PHY/LTE_TRANSPORT/print_stats.c -* \brief PHY statstic logging function -* \author R. Knopp, F. Kaltenberger, navid nikaein -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr -* \note -* \warning -*/ - -#include "PHY/LTE_TRANSPORT/proto.h" - -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" - -#ifdef OPENAIR2 -#include "../openair2/LAYER2/MAC/proto.h" -#include "../openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#endif - -extern int mac_get_rrc_status(uint8_t Mod_id,uint8_t eNB_flag,uint8_t index); -#if defined(OAI_USRP) || defined(EXMIMO) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) -#include "common_lib.h" -extern openair0_config_t openair0_cfg[]; -#endif - -int dump_ue_stats(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,char* buffer, int length, runmode_t mode, int input_level_dBm) -{ - - uint8_t eNB=0; - uint32_t RRC_status; - int len=length; - int harq_pid,round; - - if (ue==NULL) - return 0; - - if ((mode == normal_txrx) || (mode == no_L2_connect)) { - len += sprintf(&buffer[len], "[UE_PROC] UE %d, RNTI %x\n",ue->Mod_id, ue->pdcch_vars[0][0]->crnti); - len += sprintf(&buffer[len],"[UE PROC] RSRP[0] %.2f dBm/RE, RSSI %.2f dBm, RSRQ[0] %.2f dB, N0 %d dBm/RE (NF %.1f dB)\n", - 10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB, - 10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB, - 10*log10(ue->measurements.rsrq[0]), - ue->measurements.n0_power_tot_dBm, - (double)ue->measurements.n0_power_tot_dBm+132.24); - - /* - len += sprintf(&buffer[len], - "[UE PROC] Frame count: %d\neNB0 RSSI %d dBm/RE (%d dB, %d dB)\neNB1 RSSI %d dBm/RE (%d dB, %d dB)neNB2 RSSI %d dBm/RE (%d dB, %d dB)\nN0 %d dBm/RE, %f dBm/%dPRB (%d dB, %d dB)\n", - proc->frame_rx, - ue->measurements.rx_rssi_dBm[0], - ue->measurements.rx_power_dB[0][0], - ue->measurements.rx_power_dB[0][1], - ue->measurements.rx_rssi_dBm[1], - ue->measurements.rx_power_dB[1][0], - ue->measurements.rx_power_dB[1][1], - ue->measurements.rx_rssi_dBm[2], - ue->measurements.rx_power_dB[2][0], - ue->measurements.rx_power_dB[2][1], - ue->measurements.n0_power_tot_dBm, - ue->measurements.n0_power_tot_dBm+10*log10(12*ue->frame_parms.N_RB_DL), - ue->frame_parms.N_RB_DL, - ue->measurements.n0_power_dB[0], - ue->measurements.n0_power_dB[1]); - */ - -#ifdef EXMIMO - len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (LNA %d, vga %d dB)\n",ue->rx_total_gain_dB, openair0_cfg[0].rxg_mode[0],(int)openair0_cfg[0].rx_gain[0]); -#endif -#if defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB\n",ue->rx_total_gain_dB); -#endif -#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - len += sprintf(&buffer[len], "[UE_PROC] Frequency offset %d Hz, estimated carrier frequency %f Hz\n",ue->common_vars.freq_offset,openair0_cfg[0].rx_freq[0]-ue->common_vars.freq_offset); -#endif - len += sprintf(&buffer[len], "[UE PROC] UE mode = %s (%d)\n",mode_string[ue->UE_mode[0]],ue->UE_mode[0]); - len += sprintf(&buffer[len], "[UE PROC] timing_advance = %d\n",ue->timing_advance); - if (ue->UE_mode[0]==PUSCH) { - len += sprintf(&buffer[len], "[UE PROC] Po_PUSCH = %d dBm (PL %d dB, Po_NOMINAL_PUSCH %d dBm, PHR %d dB)\n", - ue->ulsch[0]->Po_PUSCH, - get_PL(ue->Mod_id,ue->CC_id,0), - ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH, - ue->ulsch[0]->PHR); - len += sprintf(&buffer[len], "[UE PROC] Po_PUCCH = %d dBm (Po_NOMINAL_PUCCH %d dBm, g_pucch %d dB)\n", - get_PL(ue->Mod_id,ue->CC_id,0)+ - ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH+ - ue->dlsch[0][0][0]->g_pucch, - ue->frame_parms.ul_power_control_config_common.p0_NominalPUCCH, - ue->dlsch[0][0][0]->g_pucch); - } - //for (eNB=0;eNB<NUMBER_OF_eNB_MAX;eNB++) { - for (eNB=0; eNB<1; eNB++) { - len += sprintf(&buffer[len], "[UE PROC] RX spatial power eNB%d: [%d %d; %d %d] dB\n", - eNB, - ue->measurements.rx_spatial_power_dB[eNB][0][0], - ue->measurements.rx_spatial_power_dB[eNB][0][1], - ue->measurements.rx_spatial_power_dB[eNB][1][0], - ue->measurements.rx_spatial_power_dB[eNB][1][1]); - - len += sprintf(&buffer[len], "[UE PROC] RX total power eNB%d: %d dB, avg: %d dB\n",eNB,ue->measurements.rx_power_tot_dB[eNB],ue->measurements.rx_power_avg_dB[eNB]); - len += sprintf(&buffer[len], "[UE PROC] RX total power lin: %d, avg: %d, RX total noise lin: %d, avg: %d\n",ue->measurements.rx_power_tot[eNB], - ue->measurements.rx_power_avg[eNB], ue->measurements.n0_power_tot, ue->measurements.n0_power_avg); - len += sprintf(&buffer[len], "[UE PROC] effective SINR %.2f dB\n",ue->sinr_eff); - len += sprintf(&buffer[len], "[UE PROC] Wideband CQI eNB %d: %d dB, avg: %d dB\n",eNB,ue->measurements.wideband_cqi_tot[eNB],ue->measurements.wideband_cqi_avg[eNB]); - - switch (ue->frame_parms.N_RB_DL) { - case 6: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,6))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,6)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,6))); - break; - - case 25: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5], - ue->measurements.subband_cqi_dB[eNB][0][6]); - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5], - ue->measurements.subband_cqi_dB[eNB][1][6]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0], - ue->measurements.subband_pmi_re[eNB][6][0], - ue->measurements.subband_pmi_im[eNB][6][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1], - ue->measurements.subband_pmi_re[eNB][6][1], - ue->measurements.subband_pmi_im[eNB][6][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5], - ue->measurements.selected_rx_antennas[eNB][6]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,7))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,7)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,7))); - break; - - case 50: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5], - ue->measurements.subband_cqi_dB[eNB][0][6], - ue->measurements.subband_cqi_dB[eNB][0][7], - ue->measurements.subband_cqi_dB[eNB][0][8]); - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5], - ue->measurements.subband_cqi_dB[eNB][1][6], - ue->measurements.subband_cqi_dB[eNB][1][7], - ue->measurements.subband_cqi_dB[eNB][1][8]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0], - ue->measurements.subband_pmi_re[eNB][6][0], - ue->measurements.subband_pmi_im[eNB][6][0], - ue->measurements.subband_pmi_re[eNB][7][0], - ue->measurements.subband_pmi_im[eNB][7][0], - ue->measurements.subband_pmi_re[eNB][8][0], - ue->measurements.subband_pmi_im[eNB][8][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1], - ue->measurements.subband_pmi_re[eNB][6][1], - ue->measurements.subband_pmi_im[eNB][6][1], - ue->measurements.subband_pmi_re[eNB][7][1], - ue->measurements.subband_pmi_im[eNB][7][1], - ue->measurements.subband_pmi_re[eNB][8][1], - ue->measurements.subband_pmi_im[eNB][8][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5], - ue->measurements.selected_rx_antennas[eNB][6], - ue->measurements.selected_rx_antennas[eNB][7], - ue->measurements.selected_rx_antennas[eNB][8]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,9))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,9)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,9))); - break; - - case 100: - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][0][0], - ue->measurements.subband_cqi_dB[eNB][0][1], - ue->measurements.subband_cqi_dB[eNB][0][2], - ue->measurements.subband_cqi_dB[eNB][0][3], - ue->measurements.subband_cqi_dB[eNB][0][4], - ue->measurements.subband_cqi_dB[eNB][0][5], - ue->measurements.subband_cqi_dB[eNB][0][6], - ue->measurements.subband_cqi_dB[eNB][0][7], - ue->measurements.subband_cqi_dB[eNB][0][8], - ue->measurements.subband_cqi_dB[eNB][0][9], - ue->measurements.subband_cqi_dB[eNB][0][10], - ue->measurements.subband_cqi_dB[eNB][0][11], - ue->measurements.subband_cqi_dB[eNB][0][12]); - - len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 1): [%d %d %d %d %d %d %d %d %d %d %d %d %d] dB\n", - eNB, - ue->measurements.subband_cqi_dB[eNB][1][0], - ue->measurements.subband_cqi_dB[eNB][1][1], - ue->measurements.subband_cqi_dB[eNB][1][2], - ue->measurements.subband_cqi_dB[eNB][1][3], - ue->measurements.subband_cqi_dB[eNB][1][4], - ue->measurements.subband_cqi_dB[eNB][1][5], - ue->measurements.subband_cqi_dB[eNB][1][6], - ue->measurements.subband_cqi_dB[eNB][1][7], - ue->measurements.subband_cqi_dB[eNB][1][8], - ue->measurements.subband_cqi_dB[eNB][1][9], - ue->measurements.subband_cqi_dB[eNB][1][10], - ue->measurements.subband_cqi_dB[eNB][1][11], - ue->measurements.subband_cqi_dB[eNB][1][12]); - - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 0): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][0], - ue->measurements.subband_pmi_im[eNB][0][0], - ue->measurements.subband_pmi_re[eNB][1][0], - ue->measurements.subband_pmi_im[eNB][1][0], - ue->measurements.subband_pmi_re[eNB][2][0], - ue->measurements.subband_pmi_im[eNB][2][0], - ue->measurements.subband_pmi_re[eNB][3][0], - ue->measurements.subband_pmi_im[eNB][3][0], - ue->measurements.subband_pmi_re[eNB][4][0], - ue->measurements.subband_pmi_im[eNB][4][0], - ue->measurements.subband_pmi_re[eNB][5][0], - ue->measurements.subband_pmi_im[eNB][5][0], - ue->measurements.subband_pmi_re[eNB][6][0], - ue->measurements.subband_pmi_im[eNB][6][0], - ue->measurements.subband_pmi_re[eNB][7][0], - ue->measurements.subband_pmi_im[eNB][7][0], - ue->measurements.subband_pmi_re[eNB][8][0], - ue->measurements.subband_pmi_im[eNB][8][0], - ue->measurements.subband_pmi_re[eNB][9][0], - ue->measurements.subband_pmi_im[eNB][9][0], - ue->measurements.subband_pmi_re[eNB][10][0], - ue->measurements.subband_pmi_im[eNB][10][0], - ue->measurements.subband_pmi_re[eNB][11][0], - ue->measurements.subband_pmi_im[eNB][11][0], - ue->measurements.subband_pmi_re[eNB][12][0], - ue->measurements.subband_pmi_im[eNB][12][0]); - - len += sprintf(&buffer[len], "[UE PROC] Subband PMI eNB%d (Ant 1): [(%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d) (%d %d)]\n", - eNB, - ue->measurements.subband_pmi_re[eNB][0][1], - ue->measurements.subband_pmi_im[eNB][0][1], - ue->measurements.subband_pmi_re[eNB][1][1], - ue->measurements.subband_pmi_im[eNB][1][1], - ue->measurements.subband_pmi_re[eNB][2][1], - ue->measurements.subband_pmi_im[eNB][2][1], - ue->measurements.subband_pmi_re[eNB][3][1], - ue->measurements.subband_pmi_im[eNB][3][1], - ue->measurements.subband_pmi_re[eNB][4][1], - ue->measurements.subband_pmi_im[eNB][4][1], - ue->measurements.subband_pmi_re[eNB][5][1], - ue->measurements.subband_pmi_im[eNB][5][1], - ue->measurements.subband_pmi_re[eNB][6][1], - ue->measurements.subband_pmi_im[eNB][6][1], - ue->measurements.subband_pmi_re[eNB][7][1], - ue->measurements.subband_pmi_im[eNB][7][1], - ue->measurements.subband_pmi_re[eNB][8][1], - ue->measurements.subband_pmi_im[eNB][8][1], - ue->measurements.subband_pmi_re[eNB][9][1], - ue->measurements.subband_pmi_im[eNB][9][1], - ue->measurements.subband_pmi_re[eNB][10][1], - ue->measurements.subband_pmi_im[eNB][10][1], - ue->measurements.subband_pmi_re[eNB][11][1], - ue->measurements.subband_pmi_im[eNB][11][1], - ue->measurements.subband_pmi_re[eNB][12][1], - ue->measurements.subband_pmi_im[eNB][12][1]); - - len += sprintf(&buffer[len], "[UE PROC] PMI Antenna selection eNB%d : [%d %d %d %d %d %d %d %d %d %d %d %d %d]\n", - eNB, - ue->measurements.selected_rx_antennas[eNB][0], - ue->measurements.selected_rx_antennas[eNB][1], - ue->measurements.selected_rx_antennas[eNB][2], - ue->measurements.selected_rx_antennas[eNB][3], - ue->measurements.selected_rx_antennas[eNB][4], - ue->measurements.selected_rx_antennas[eNB][5], - ue->measurements.selected_rx_antennas[eNB][6], - ue->measurements.selected_rx_antennas[eNB][7], - ue->measurements.selected_rx_antennas[eNB][8], - ue->measurements.selected_rx_antennas[eNB][9], - ue->measurements.selected_rx_antennas[eNB][10], - ue->measurements.selected_rx_antennas[eNB][11], - ue->measurements.selected_rx_antennas[eNB][12]); - - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (max): %jx\n",eNB,pmi2hex_2Ar1(quantize_subband_pmi(&ue->measurements,eNB,13))); - len += sprintf(&buffer[len], "[UE PROC] Quantized PMI eNB %d (both): %jx,%jx\n",eNB, - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,0,13)), - pmi2hex_2Ar1(quantize_subband_pmi2(&ue->measurements,eNB,1,13))); - break; - } - -#ifdef OPENAIR2 - RRC_status = mac_UE_get_rrc_status(ue->Mod_id, 0); - len += sprintf(&buffer[len],"[UE PROC] RRC status = %d\n",RRC_status); -#endif - - - len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d \n",ue->transmission_mode[eNB]); - len += sprintf(&buffer[len], "[UE PROC] PBCH err conseq %d, PBCH error total %d, PBCH FER %d\n", - ue->pbch_vars[eNB]->pdu_errors_conseq, - ue->pbch_vars[eNB]->pdu_errors, - ue->pbch_vars[eNB]->pdu_fer); - - if (ue->transmission_mode[eNB] == 6) - len += sprintf(&buffer[len], "[UE PROC] Mode 6 Wideband CQI eNB %d : %d dB\n",eNB,ue->measurements.precoded_cqi_dB[eNB][0]); - - for (harq_pid=0;harq_pid<8;harq_pid++) { - len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 0 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][0]->harq_processes[harq_pid]->mcs); - for (round=0;round<8;round++) - len+=sprintf(&buffer[len],"%d/%d ", - ue->dlsch[0][0][0]->harq_processes[harq_pid]->errors[round], - ue->dlsch[0][0][0]->harq_processes[harq_pid]->trials[round]); - len+=sprintf(&buffer[len],"\n"); - } - if (ue->dlsch[0][0] && ue->dlsch[0][0][0] && ue->dlsch[0][0][1]) { - len += sprintf(&buffer[len], "[UE PROC] Saved PMI for DLSCH eNB %d : %jx (%p)\n",eNB,pmi2hex_2Ar1(ue->dlsch[0][0][0]->pmi_alloc),ue->dlsch[0][0][0]); - - len += sprintf(&buffer[len], "[UE PROC] eNB %d: dl_power_off = %d\n",eNB,ue->dlsch[0][0][0]->harq_processes[0]->dl_power_off); - - for (harq_pid=0;harq_pid<8;harq_pid++) { - len+=sprintf(&buffer[len],"[UE PROC] eNB %d: CW 1 harq_pid %d, mcs %d:",eNB,harq_pid,ue->dlsch[0][0][1]->harq_processes[0]->mcs); - for (round=0;round<8;round++) - len+=sprintf(&buffer[len],"%d/%d ", - ue->dlsch[0][0][1]->harq_processes[harq_pid]->errors[round], - ue->dlsch[0][0][1]->harq_processes[harq_pid]->trials[round]); - len+=sprintf(&buffer[len],"\n"); - } - } - - len += sprintf(&buffer[len], "[UE PROC] DLSCH Total %d, Error %d, FER %d\n",ue->dlsch_received[0],ue->dlsch_errors[0],ue->dlsch_fer[0]); - len += sprintf(&buffer[len], "[UE PROC] DLSCH (SI) Total %d, Error %d\n",ue->dlsch_SI_received[0],ue->dlsch_SI_errors[0]); - len += sprintf(&buffer[len], "[UE PROC] DLSCH (RA) Total %d, Error %d\n",ue->dlsch_ra_received[0],ue->dlsch_ra_errors[0]); -#if defined(Rel10) || defined(Rel14) - int i=0; - - //len += sprintf(&buffer[len], "[UE PROC] MCH Total %d\n", ue->dlsch_mch_received[0]); - for(i=0; i <ue->frame_parms.num_MBSFN_config; i++ ) { - len += sprintf(&buffer[len], "[UE PROC] MCH (MCCH MBSFN %d) Total %d, Error %d, Trials %d\n", - i, ue->dlsch_mcch_received[i][0],ue->dlsch_mcch_errors[i][0],ue->dlsch_mcch_trials[i][0]); - len += sprintf(&buffer[len], "[UE PROC] MCH (MTCH MBSFN %d) Total %d, Error %d, Trials %d\n", - i, ue->dlsch_mtch_received[i][0],ue->dlsch_mtch_errors[i][0],ue->dlsch_mtch_trials[i][0]); - } - -#endif - len += sprintf(&buffer[len], "[UE PROC] DLSCH Bitrate %dkbps\n",(ue->bitrate[0]/1000)); - len += sprintf(&buffer[len], "[UE PROC] Total Received Bits %dkbits\n",(ue->total_received_bits[0]/1000)); - len += sprintf(&buffer[len], "[UE PROC] IA receiver %d\n",ue->use_ia_receiver); - - } - - } else { - len += sprintf(&buffer[len], "[UE PROC] Frame count: %d, RSSI %3.2f dB (%d dB, %d dB), N0 %3.2f dB (%d dB, %d dB)\n", - proc->frame_rx, - 10*log10(ue->measurements.rssi), - ue->measurements.rx_power_dB[0][0], - ue->measurements.rx_power_dB[0][1], - 10*log10(ue->measurements.n0_power_tot), - ue->measurements.n0_power_dB[0], - ue->measurements.n0_power_dB[1]); -#ifdef EXMIMO - ue->rx_total_gain_dB = ((int)(10*log10(ue->measurements.rssi)))-input_level_dBm; - len += sprintf(&buffer[len], "[UE PROC] rxg_mode %d, input level (set by user) %d dBm, VGA gain %d dB ==> total gain %3.2f dB, noise figure %3.2f dB\n", - openair0_cfg[0].rxg_mode[0], - input_level_dBm, - (int)openair0_cfg[0].rx_gain[0], - 10*log10(ue->measurements.rssi)-input_level_dBm, - 10*log10(ue->measurements.n0_power_tot)-ue->rx_total_gain_dB+105); -#endif - } - - len += sprintf(&buffer[len],"EOF\n"); - - return len; -} // is_clusterhead - -/* -int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length) -{ - - unsigned int success=0; - uint8_t eNB_id,UE_id,i,j,number_of_cards_l=1; - uint32_t ulsch_errors=0,dlsch_errors=0; - uint32_t ulsch_round_attempts[4]= {0,0,0,0},ulsch_round_errors[4]= {0,0,0,0}; - uint32_t dlsch_round_attempts[4]= {0,0,0,0},dlsch_round_errors[4]= {0,0,0,0}; - uint32_t UE_id_mac, RRC_status; - eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0]; - if (eNB==NULL) - return 0; - - int len = length; - - // if(eNB->frame==0){ - eNB->total_dlsch_bitrate = 0;//eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate; - eNB->total_transmitted_bits = 0;// eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_transmitted_bits; - eNB->total_system_throughput = 0;//eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput; - // } - - for (eNB_id=0; eNB_id<number_of_cards_l; eNB_id++) { - len += sprintf(&buffer[len],"eNB %d/%d Frame %d: RX Gain %d dB, I0 %d dBm (%d,%d) dB \n", - eNB_id,number_of_cards_l, - proc->frame_tx, - eNB->rx_total_gain_dB, - eNB->measurements.n0_power_tot_dBm, - eNB->measurements.n0_power_dB[0], - eNB->measurements.n0_power_dB[1]); - - len += sprintf(&buffer[len],"PRB I0 (%X.%X.%X.%X): ", - eNB->rb_mask_ul[0], - eNB->rb_mask_ul[1],eNB->rb_mask_ul[2],eNB->rb_mask_ul[3]); - - for (i=0; i<eNB->frame_parms.N_RB_UL; i++) { - len += sprintf(&buffer[len],"%4d ", - eNB->measurements.n0_subband_power_tot_dBm[i]); - if ((i>0) && ((i%25) == 0)) - len += sprintf(&buffer[len],"\n"); - } - len += sprintf(&buffer[len],"\n"); - len += sprintf(&buffer[len],"\nPERFORMANCE PARAMETERS\n"); - - for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - if (eNB && - (eNB->dlsch!=NULL) && - (eNB->dlsch[(uint8_t)UE_id]!=NULL) && - (eNB->dlsch[(uint8_t)UE_id][0]->rnti>0)&& - (eNB->UE_stats[UE_id].mode == PUSCH)) { - - eNB->total_dlsch_bitrate = eNB->UE_stats[UE_id].dlsch_bitrate + eNB->total_dlsch_bitrate; - eNB->total_transmitted_bits = eNB->UE_stats[UE_id].total_TBS + eNB->total_transmitted_bits; - - //eNB->total_system_throughput = eNB->UE_stats[UE_id].total_transmitted_bits + eNB->total_system_throughput; - - for (i=0; i<8; i++) - success = success + (eNB->UE_stats[UE_id].dlsch_trials[i][0] - eNB->UE_stats[UE_id].dlsch_l2_errors[i]); - - - - len += sprintf(&buffer[len],"Total DLSCH %d kbits / %d frames ",(eNB->total_transmitted_bits/1000),proc->frame_tx+1); - len += sprintf(&buffer[len],"Total DLSCH throughput %d kbps ",(eNB->total_dlsch_bitrate/1000)); - len += sprintf(&buffer[len],"Total DLSCH trans %d / %d frames\n",success,proc->frame_tx+1); - //len += sprintf(&buffer[len],"[eNB PROC] FULL MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->FULL_MUMIMO_transmissions,eNB->check_for_total_transmissions); - //len += sprintf(&buffer[len],"[eNB PROC] MU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_MUMIMO_transmissions,eNB->check_for_total_transmissions); - //len += sprintf(&buffer[len],"[eNB PROC] SU-MIMO Transmissions/Total Transmissions = %d/%d\n",eNB->check_for_SUMIMO_transmissions,eNB->check_for_total_transmissions); - - len += sprintf(&buffer[len],"UE %d (%x) Power: (%d,%d) dB, Po_PUSCH: (%d,%d) dBm, Po_PUCCH (%d/%d) dBm, Po_PUCCH1 (%d,%d) dBm, PUCCH1 Thres %d dBm \n", - UE_id, - eNB->UE_stats[UE_id].crnti, - dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[0]), - dB_fixed(eNB->pusch_vars[UE_id]->ulsch_power[1]), - eNB->UE_stats[UE_id].UL_rssi[0], - eNB->UE_stats[UE_id].UL_rssi[1], - dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB, - eNB->frame_parms.ul_power_control_config_common.p0_NominalPUCCH, - dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_below/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB, - dB_fixed(eNB->UE_stats[UE_id].Po_PUCCH1_above/eNB->frame_parms.N_RB_UL)-eNB->rx_total_gain_dB, - PUCCH1_THRES+eNB->measurements.n0_power_tot_dBm-dB_fixed(eNB->frame_parms.N_RB_UL)); - - len+= sprintf(&buffer[len],"DL mcs %d, UL mcs %d, UL rb %d, delta_TF %d, ", - eNB->dlsch[(uint8_t)UE_id][0]->harq_processes[0]->mcs, - eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->mcs, - eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->nb_rb, - eNB->ulsch[(uint8_t)UE_id]->harq_processes[0]->delta_TF); - - len += sprintf(&buffer[len],"Wideband CQI: (%d,%d) dB\n", - eNB->measurements.wideband_cqi_dB[UE_id][0], - eNB->measurements.wideband_cqi_dB[UE_id][1]); - - len += sprintf(&buffer[len],"DL TM %d, DL_cqi %d, DL_pmi_single %jx ", - eNB->transmission_mode[UE_id], - eNB->UE_stats[UE_id].DL_cqi[0], - pmi2hex_2Ar1(eNB->UE_stats[UE_id].DL_pmi_single)); - - len += sprintf(&buffer[len],"Timing advance %d samples (%d 16Ts), update %d ", - eNB->UE_stats[UE_id].UE_timing_offset, - eNB->UE_stats[UE_id].UE_timing_offset>>2, - eNB->UE_stats[UE_id].timing_advance_update); - - len += sprintf(&buffer[len],"Mode = %s(%d) ", - mode_string[eNB->UE_stats[UE_id].mode], - eNB->UE_stats[UE_id].mode); - UE_id_mac = find_UE_id(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti); - - if (UE_id_mac != -1) { - RRC_status = mac_eNB_get_rrc_status(eNB->Mod_id,eNB->dlsch[(uint8_t)UE_id][0]->rnti); - len += sprintf(&buffer[len],"UE_id_mac = %d, RRC status = %d\n",UE_id_mac,RRC_status); - } else - len += sprintf(&buffer[len],"UE_id_mac = -1\n"); - - len += sprintf(&buffer[len],"SR received/total: %d/%d (diff %d)\n", - eNB->UE_stats[UE_id].sr_received, - eNB->UE_stats[UE_id].sr_total, - eNB->UE_stats[UE_id].sr_total-eNB->UE_stats[UE_id].sr_received); - - len += sprintf(&buffer[len],"DL Subband CQI: "); - - int nb_sb; - switch (eNB->frame_parms.N_RB_DL) { - case 6: - nb_sb=0; - break; - case 15: - nb_sb = 4; - case 25: - nb_sb = 7; - break; - case 50: - nb_sb = 9; - break; - case 75: - nb_sb = 10; - break; - case 100: - nb_sb = 13; - break; - default: - nb_sb=0; - break; - } - for (i=0; i<nb_sb; i++) - len += sprintf(&buffer[len],"%2d ", - eNB->UE_stats[UE_id].DL_subband_cqi[0][i]); - len += sprintf(&buffer[len],"\n"); - - - - ulsch_errors = 0; - - for (j=0; j<4; j++) { - ulsch_round_attempts[j]=0; - ulsch_round_errors[j]=0; - } - - len += sprintf(&buffer[len],"ULSCH errors/attempts per harq (per round): \n"); - - for (i=0; i<8; i++) { - len += sprintf(&buffer[len]," harq %d: %d/%d (fer %d) (%d/%d, %d/%d, %d/%d, %d/%d) ", - i, - eNB->UE_stats[UE_id].ulsch_errors[i], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0], - eNB->UE_stats[UE_id].ulsch_round_fer[i][0], - eNB->UE_stats[UE_id].ulsch_round_errors[i][0], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][0], - eNB->UE_stats[UE_id].ulsch_round_errors[i][1], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][1], - eNB->UE_stats[UE_id].ulsch_round_errors[i][2], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][2], - eNB->UE_stats[UE_id].ulsch_round_errors[i][3], - eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][3]); - if ((i&1) == 1) - len += sprintf(&buffer[len],"\n"); - - ulsch_errors+=eNB->UE_stats[UE_id].ulsch_errors[i]; - - for (j=0; j<4; j++) { - ulsch_round_attempts[j]+=eNB->UE_stats[UE_id].ulsch_decoding_attempts[i][j]; - ulsch_round_errors[j]+=eNB->UE_stats[UE_id].ulsch_round_errors[i][j]; - } - } - - len += sprintf(&buffer[len],"ULSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d)\n", - ulsch_errors,ulsch_round_attempts[0], - - ulsch_round_errors[0],ulsch_round_attempts[0], - ulsch_round_errors[1],ulsch_round_attempts[1], - ulsch_round_errors[2],ulsch_round_attempts[2], - ulsch_round_errors[3],ulsch_round_attempts[3]); - - dlsch_errors = 0; - - for (j=0; j<4; j++) { - dlsch_round_attempts[j]=0; - dlsch_round_errors[j]=0; - } - - len += sprintf(&buffer[len],"DLSCH errors/attempts per harq (per round): \n"); - - for (i=0; i<8; i++) { - len += sprintf(&buffer[len]," harq %d: %d/%d (%d/%d/%d, %d/%d/%d, %d/%d/%d, %d/%d/%d) ", - i, - eNB->UE_stats[UE_id].dlsch_l2_errors[i], - eNB->UE_stats[UE_id].dlsch_trials[i][0], - eNB->UE_stats[UE_id].dlsch_ACK[i][0], - eNB->UE_stats[UE_id].dlsch_NAK[i][0], - eNB->UE_stats[UE_id].dlsch_trials[i][0], - eNB->UE_stats[UE_id].dlsch_ACK[i][1], - eNB->UE_stats[UE_id].dlsch_NAK[i][1], - eNB->UE_stats[UE_id].dlsch_trials[i][1], - eNB->UE_stats[UE_id].dlsch_ACK[i][2], - eNB->UE_stats[UE_id].dlsch_NAK[i][2], - eNB->UE_stats[UE_id].dlsch_trials[i][2], - eNB->UE_stats[UE_id].dlsch_ACK[i][3], - eNB->UE_stats[UE_id].dlsch_NAK[i][3], - eNB->UE_stats[UE_id].dlsch_trials[i][3]); - if ((i&1) == 1) - len += sprintf(&buffer[len],"\n"); - - - dlsch_errors+=eNB->UE_stats[UE_id].dlsch_l2_errors[i]; - - for (j=0; j<4; j++) { - dlsch_round_attempts[j]+=eNB->UE_stats[UE_id].dlsch_trials[i][j]; - dlsch_round_errors[j]+=eNB->UE_stats[UE_id].dlsch_NAK[i][j]; - } - } - - len += sprintf(&buffer[len],"DLSCH errors/attempts total %d/%d (%d/%d, %d/%d, %d/%d, %d/%d): \n", - dlsch_errors,dlsch_round_attempts[0], - dlsch_round_errors[0],dlsch_round_attempts[0], - dlsch_round_errors[1],dlsch_round_attempts[1], - dlsch_round_errors[2],dlsch_round_attempts[2], - dlsch_round_errors[3],dlsch_round_attempts[3]); - - - len += sprintf(&buffer[len],"DLSCH total bits from MAC: %dkbit ",(eNB->UE_stats[UE_id].total_TBS_MAC)/1000); - len += sprintf(&buffer[len],"DLSCH total bits ack'ed: %dkbit ",(eNB->UE_stats[UE_id].total_TBS)/1000); - len += sprintf(&buffer[len],"DLSCH Average throughput (100 frames): %dkbps\n",(eNB->UE_stats[UE_id].dlsch_bitrate/1000)); - // len += sprintf(&buffer[len],"[eNB PROC] Transmission Mode %d\n",eNB->transmission_mode[UE_id]); - } - } - - len += sprintf(&buffer[len],"\n"); - } - - len += sprintf(&buffer[len],"EOF\n"); - - return len; -} -*/ diff --git a/openair1/PHY/LTE_TRANSPORT/pss.c b/openair1/PHY/LTE_TRANSPORT/pss.c index c746a331db246e2e46139d4386120389d3549557..33bd5cc7e8246f06b49ec8e85b30072cd4d10f33 100644 --- a/openair1/PHY/LTE_TRANSPORT/pss.c +++ b/openair1/PHY/LTE_TRANSPORT/pss.c @@ -36,8 +36,8 @@ */ //#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" int generate_pss(int32_t **txdataF, short amp, @@ -75,6 +75,11 @@ 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 BASIC_SIMULATOR + /* 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; +#endif + Nsymb = (frame_parms->Ncp==NORMAL)?14:12; for (aa=0; aa<frame_parms->nb_antenna_ports_eNB; aa++) { @@ -105,10 +110,3 @@ int generate_pss(int32_t **txdataF, return(0); } -int generate_pss_emul(PHY_VARS_eNB *phy_vars_eNb,uint8_t sect_id) -{ - - LOG_D(PHY,"EMUL eNB generate_pss_emul eNB %d, sect_id %d\n",phy_vars_eNb->Mod_id,sect_id); - eNB_transport_info[phy_vars_eNb->Mod_id][phy_vars_eNb->CC_id].cntl.pss=sect_id; - return(0); -} diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index 9a19b0ddaf3dee79997ca3af075bd9448b74d43b..e7aa11d30ad4b6b2fa069b6a2dd3f254979a734f 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -29,9 +29,10 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "LAYER2/MAC/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "LAYER2/MAC/mac.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" @@ -42,6 +43,8 @@ //#define DEBUG_PUCCH_TXS //#define DEBUG_PUCCH_RX +#include "pucch_extern.h" + int16_t cfo_pucch_np[24*7] = {20787,-25330,27244,-18205,31356,-9512,32767,0,31356,9511,27244,18204,20787,25329, 27244,-18205,30272,-12540,32137,-6393,32767,0,32137,6392,30272,12539,27244,18204, 31356,-9512,32137,-6393,32609,-3212,32767,0,32609,3211,32137,6392,31356,9511, @@ -61,1083 +64,6 @@ int16_t cfo_pucch_ep[24*6] = {24278,-22005,29621,-14010,32412,-4808,32412,4807,2 }; -void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]) -{ - - uint8_t ns,l,reset=1,i,N_UL_symb; - uint32_t x1,x2,j=0,s=0; - - N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; - x2 = frame_parms->Nid_cell; - - for (ns=0; ns<20; ns++) { - - for (l=0; l<N_UL_symb; l++) { - ncs_cell[ns][l]=0; - - for (i=0; i<8; i++) { - if ((j%32) == 0) { - s = lte_gold_generic(&x1,&x2,reset); - // printf("s %x\n",s); - reset=0; - } - - if (((s>>(j%32))&1)==1) - ncs_cell[ns][l] += (1<<i); - - j++; - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH ncs_cell init (j %d): Ns %d, l %d => ncs_cell %d\n",j,ns,l,ncs_cell[ns][l]); -#endif - } - - } -} - -int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377}; -int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384}; - -int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, - {32767,-32768, 32767,-32768}, - {32767,-32768,-32768, 32767} -}; -int16_t W3_re[3][6] = {{32767, 32767, 32767}, - {32767,-16384,-16384}, - {32767,-16384,-16384} -}; - -int16_t W3_im[3][6] = {{0 ,0 ,0 }, - {0 , 28377,-28378}, - {0 ,-28378, 28377} -}; - -char *pucch_format_string[] = { - "format 1", - "format 1a", - "format 1b", - "pucch_format1b_csA2", - "pucch_format1b_csA3", - "pucch_format1b_csA4", - "format 2", - "format 2a", - "format 2b", - "pucch_format3" -}; - -/* PUCCH format3 >> */ -#define D_I 0 -#define D_Q 1 -#define D_IQDATA 2 -#define D_NSLT1SF 2 -#define D_NSYM1SLT 7 -#define D_NSYM1SF 2*7 -#define D_NSC1RB 12 -#define D_NRB1PUCCH 2 -#define D_NPUCCH_SF5 5 -#define D_NPUCCH_SF4 4 - -uint8_t chcod_tbl[128][48] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1}, - {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0}, - {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0}, - {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1}, - {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1}, - {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}, - {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0}, - {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1}, - {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1}, - {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0}, - {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0}, - {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1}, - {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1}, - {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1}, - {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}, - {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0}, - {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1}, - {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1}, - {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0}, - {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0}, - {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1}, - {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1}, - {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0}, - {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0}, - {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1}, - {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, - {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, - {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0}, - {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, - {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, - {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1}, - {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1}, - {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0}, - {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0}, - {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1}, - {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1}, - {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0}, - {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0}, - {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1}, - {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1}, - {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0}, - {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0}, - {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1}, - {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, - {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, - {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1}, - {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0}, - {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0}, - {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1}, - {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1}, - {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0}, - {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0}, - {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1}, - {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1}, - {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0}, - {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, - {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1}, - {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1}, - {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0}, - {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1}, - {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0}, - {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0}, - {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1}, - {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, - {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, - {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0}, - {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1}, - {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1}, - {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}, - {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0}, - {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1}, - {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1}, - {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0}, - {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0}, - {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1}, - {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0}, - {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1}, - {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1}, - {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0}, - {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0}, - {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1}, - {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1}, - {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0}, - {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1}, - {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1}, - {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0}, - {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0}, - {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1}, - {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0}, - {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1}, - {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1}, - {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0}, - {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}, - {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1}, - {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1}, - {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0}, - {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0}, - {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1}, - {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1}, - {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0}, - {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0}, - {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1}, - {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1}, - {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1}, - {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0}, - {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1}, - {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, - {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, - {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0}, - {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1}, - {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}, - {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0}, - {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0}, - {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1}, - {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1}, - {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0}, - {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0}, - {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1} }; - -// W5_TBL -int16_t W5_fmt3_re[5][5] = { {32767, 32767, 32767, 32767, 32767}, - {32767, 10125, -26509, -26509, 10125}, - {32767, -26509, 10125, 10125, -26509}, - {32767, -26509, 10125, 10125, -26509}, - {32767, 10125, -26509, -26509, 10125} }; - -int16_t W5_fmt3_im[5][5] = { {0, 0, 0, 0, 0}, - {0, 31163, 19259, -19259, -31163}, - {0, 19259, -31163, 31163, -19259}, - {0, -19259, 31163, -31163, 19259}, - {0, -31163, -19259, 19259, 31163} }; - -int16_t W4_fmt3[4][4] = { {32767, 32767, 32767, 32767}, - {32767, -32767, 32767, -32767}, - {32767, 32767, -32767, -32767}, - {32767, -32767, -32767, 32767} }; - -// W2 TBL -int16_t W2[2] = {32767, 32767}; - -// e^j*pai*floor (ncs_cell(ns,l)/64)/2 -int16_t RotTBL_re[4] = {32767, 0, -32767, 0}; -int16_t RotTBL_im[4] = {0, 32767, 0, -32767}; - -//np4_tbl, np5_tbl -uint8_t Np5_TBL[5] = {0, 3, 6, 8, 10}; -uint8_t Np4_TBL[4] = {0, 3, 6, 9}; - -// alpha_TBL -int16_t alphaTBL_re[12] = {32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383, 0, 16383, 28377}; -int16_t alphaTBL_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383}; - -/* PUCCH format3 << */ - -void generate_pucch1x(int32_t **txdataF, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n1_pucch, - uint8_t shortened_format, - uint8_t *payload, - int16_t amp, - uint8_t subframe) -{ - - uint32_t u,v,n; - uint32_t z[12*14],*zptr; - int16_t d0; - uint8_t ns,N_UL_symb,nsymb,n_oc,n_oc0,n_oc1; - uint8_t c = (frame_parms->Ncp==0) ? 3 : 2; - uint16_t nprime,nprime0,nprime1; - uint16_t i,j,re_offset,thres,h; - uint8_t Nprime_div_deltaPUCCH_Shift,Nprime,d; - uint8_t m,l,refs; - uint8_t n_cs,S,alpha_ind,rem; - int16_t tmp_re,tmp_im,ref_re,ref_im,W_re=0,W_im=0; - int32_t *txptr; - uint32_t symbol_offset; - - uint8_t deltaPUCCH_Shift = frame_parms->pucch_config_common.deltaPUCCH_Shift; - uint8_t NRB2 = frame_parms->pucch_config_common.nRB_CQI; - uint8_t Ncs1 = frame_parms->pucch_config_common.nCS_AN; - uint8_t Ncs1_div_deltaPUCCH_Shift = Ncs1/deltaPUCCH_Shift; - - LOG_D(PHY,"generate_pucch Start [deltaPUCCH_Shift %d, NRB2 %d, Ncs1_div_deltaPUCCH_Shift %d, n1_pucch %d]\n", deltaPUCCH_Shift, NRB2, Ncs1_div_deltaPUCCH_Shift,n1_pucch); - - - uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; - uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; - uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; - uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; - - if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { - printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); - return; - } - - if (Ncs1_div_deltaPUCCH_Shift > 7) { - printf("[PHY] generate_pucch: Illegal Ncs1_div_deltaPUCCH_Shift %d (should be 0...7)\n",Ncs1_div_deltaPUCCH_Shift); - return; - } - - zptr = z; - thres = (c*Ncs1_div_deltaPUCCH_Shift); - Nprime_div_deltaPUCCH_Shift = (n1_pucch < thres) ? Ncs1_div_deltaPUCCH_Shift : (12/deltaPUCCH_Shift); - Nprime = Nprime_div_deltaPUCCH_Shift * deltaPUCCH_Shift; - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: cNcs1/deltaPUCCH_Shift %d, Nprime %d, n1_pucch %d\n",thres,Nprime,n1_pucch); -#endif - - LOG_D(PHY,"[PHY] PUCCH: n1_pucch %d, thres %d Ncs1_div_deltaPUCCH_Shift %d (12/deltaPUCCH_Shift) %d Nprime_div_deltaPUCCH_Shift %d \n", - n1_pucch, thres, Ncs1_div_deltaPUCCH_Shift, (int)(12/deltaPUCCH_Shift), Nprime_div_deltaPUCCH_Shift); - LOG_D(PHY,"[PHY] PUCCH: deltaPUCCH_Shift %d, Nprime %d\n",deltaPUCCH_Shift,Nprime); - - - N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; - - if (n1_pucch < thres) - nprime0=n1_pucch; - else - nprime0 = (n1_pucch - thres)%(12*c/deltaPUCCH_Shift); - - if (n1_pucch >= thres) - nprime1= ((c*(nprime0+1))%((12*c/deltaPUCCH_Shift)+1))-1; - else { - d = (frame_parms->Ncp==0) ? 2 : 0; - h= (nprime0+d)%(c*Nprime_div_deltaPUCCH_Shift); -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: h %d, d %d\n",h,d); -#endif - nprime1 = (h/c) + (h%c)*Nprime_div_deltaPUCCH_Shift; - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: nprime0 %d nprime1 %d, %s, payload (%d,%d)\n",nprime0,nprime1,pucch_format_string[fmt],payload[0],payload[1]); -#endif - - n_oc0 = nprime0/Nprime_div_deltaPUCCH_Shift; - - if (frame_parms->Ncp==1) - n_oc0<<=1; - - n_oc1 = nprime1/Nprime_div_deltaPUCCH_Shift; - - if (frame_parms->Ncp==1) // extended CP - n_oc1<<=1; - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: noc0 %d noc1 %d\n",n_oc0,n_oc1); -#endif - - nprime=nprime0; - n_oc =n_oc0; - - // loop over 2 slots - for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { - - if ((nprime&1) == 0) - S=0; // 1 - else - S=1; // j - - //loop over symbols in slot - for (l=0; l<N_UL_symb; l++) { - // Compute n_cs (36.211 p. 18) - n_cs = ncs_cell[ns][l]; - - if (frame_parms->Ncp==0) { // normal CP - n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc%deltaPUCCH_Shift))%Nprime)%12; - } else { - n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc>>1))%Nprime)%12; - } - - - refs=0; - - // Comput W_noc(m) (36.211 p. 19) - if ((ns==(1+(subframe<<1))) && (shortened_format==1)) { // second slot and shortened format - - if (l<2) { // data - W_re=W3_re[n_oc][l]; - W_im=W3_im[n_oc][l]; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP - W_re=W3_re[n_oc][l-2]; - W_im=W3_im[n_oc][l-2]; - refs=1; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP - W_re=W4[n_oc][l-2]; - W_im=0; - refs=1; - } else if ((l>=N_UL_symb-2)) { // data - W_re=W3_re[n_oc][l-N_UL_symb+4]; - W_im=W3_im[n_oc][l-N_UL_symb+4]; - } - } else { - if (l<2) { // data - W_re=W4[n_oc][l]; - W_im=0; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP - W_re=W3_re[n_oc][l-2]; - W_im=W3_im[n_oc][l-2]; - refs=1; - } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP - W_re=W4[n_oc][l-2]; - W_im=0; - refs=1; - } else if ((l>=N_UL_symb-2)) { // data - W_re=W4[n_oc][l-N_UL_symb+4]; - W_im=0; - } - } - - // multiply W by S(ns) (36.211 p.17). only for data, reference symbols do not have this factor - if ((S==1)&&(refs==0)) { - tmp_re = W_re; - W_re = -W_im; - W_im = tmp_re; - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: ncs[%d][%d]=%d, W_re %d, W_im %d, S %d, refs %d\n",ns,l,n_cs,W_re,W_im,S,refs); -#endif - alpha_ind=0; - // compute output sequence - - for (n=0; n<12; n++) { - - // this is r_uv^alpha(n) - tmp_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); - tmp_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); - - // this is S(ns)*w_noc(m)*r_uv^alpha(n) - ref_re = (tmp_re*W_re - tmp_im*W_im)>>15; - ref_im = (tmp_re*W_im + tmp_im*W_re)>>15; - - if ((l<2)||(l>=(N_UL_symb-2))) { //these are PUCCH data symbols - switch (fmt) { - case pucch_format1: //OOK 1-bit - - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; - - break; - - case pucch_format1a: //BPSK 1-bit - d0 = (payload[0]&1)==0 ? amp : -amp; - ((int16_t *)&zptr[n])[0] = ((int32_t)d0*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)d0*ref_im)>>15; - // printf("d0 %d\n",d0); - break; - - case pucch_format1b: //QPSK 2-bits (Table 5.4.1-1 from 36.211, pg. 18) - if (((payload[0]&1)==0) && ((payload[1]&1)==0)) {// 1 - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; - } else if (((payload[0]&1)==0) && ((payload[1]&1)==1)) { // -j - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_im)>>15; - ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_re)>>15; - } else if (((payload[0]&1)==1) && ((payload[1]&1)==0)) { // j - ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_im)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_re)>>15; - } else { // -1 - ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_im)>>15; - } - - break; - case pucch_format1b_csA2: - case pucch_format1b_csA3: - case pucch_format1b_csA4: - AssertFatal(1==0,"PUCCH format 1b_csX not supported yet\n"); - break; - case pucch_format2: - case pucch_format2a: - case pucch_format2b: - AssertFatal(1==0,"should not go here\n"); - break; - - case pucch_format3: - fprintf(stderr, "PUCCH format 3 not handled\n"); - abort(); - } // switch fmt - } else { // These are PUCCH reference symbols - - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; - // printf("ref\n"); - } - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH subframe %d z(%d,%d) => %d,%d, alpha(%d) => %d,%d\n",subframe,l,n,((int16_t *)&zptr[n])[0],((int16_t *)&zptr[n])[1], - alpha_ind,alpha_re[alpha_ind],alpha_im[alpha_ind]); -#endif - alpha_ind = (alpha_ind + n_cs)%12; - } // n - - zptr+=12; - } // l - - nprime=nprime1; - n_oc =n_oc1; - } // ns - - rem = ((((12*Ncs1_div_deltaPUCCH_Shift)>>3)&7)>0) ? 1 : 0; - - m = (n1_pucch < thres) ? NRB2 : (((n1_pucch-thres)/(12*c/deltaPUCCH_Shift))+NRB2+((deltaPUCCH_Shift*Ncs1_div_deltaPUCCH_Shift)>>3)+rem); - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH: m %d\n",m); -#endif - nsymb = N_UL_symb<<1; - - //for (j=0,l=0;l<(nsymb-1);l++) { - for (j=0,l=0; l<(nsymb); l++) { - if ((l<(nsymb>>1)) && ((m&1) == 0)) - re_offset = (m*6) + frame_parms->first_carrier_offset; - else if ((l<(nsymb>>1)) && ((m&1) == 1)) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else if ((m&1) == 0) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else - re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; - - if (re_offset > frame_parms->ofdm_symbol_size) - re_offset -= (frame_parms->ofdm_symbol_size); - - symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb)); - txptr = &txdataF[0][symbol_offset]; - - for (i=0; i<12; i++,j++) { - txptr[re_offset++] = z[j]; - - if (re_offset==frame_parms->ofdm_symbol_size) - re_offset = 0; - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); -#endif - } - } - -} - -void generate_pucch_emul(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - PUCCH_FMT_t format, - uint8_t ncs1, - uint8_t *pucch_payload, - uint8_t sr) - -{ - - int subframe = proc->subframe_tx; - - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_flag = format; - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_Ncs1 = ncs1; - - - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.sr = sr; - // the value of ue->pucch_sel[subframe] is set by get_n1_pucch - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_sel = ue->pucch_sel[subframe]; - - // LOG_I(PHY,"subframe %d emu tx pucch_sel is %d sr is %d \n", subframe, UE_transport_info[ue->Mod_id].cntl.pucch_sel, sr); - - if (format == pucch_format1a) { - - ue->pucch_payload[0] = pucch_payload[0]; - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_payload = pucch_payload[0]; - } else if (format == pucch_format1b) { - ue->pucch_payload[0] = pucch_payload[0] + (pucch_payload[1]<<1); - UE_transport_info[ue->Mod_id][ue->CC_id].cntl.pucch_payload = pucch_payload[0] + (pucch_payload[1]<<1); - } else if (format == pucch_format1) { - // LOG_D(PHY,"[UE %d] Frame %d subframe %d Generating PUCCH for SR %d\n",ue->Mod_id,proc->frame_tx,subframe,sr); - } - - ue->sr[subframe] = sr; - -} - - -inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) __attribute__((always_inline)); -inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) { - - uint32_t x1, x2, s=0; - int i; - uint8_t c; - - x2 = (rnti) + ((uint32_t)(1+subframe)<<16)*(1+(fp->Nid_cell<<1)); //this is c_init in 36.211 Sec 6.3.1 - s = lte_gold_generic(&x1, &x2, 1); - for (i=0;i<19;i++) { - c = (uint8_t)((s>>i)&1); - btilde[i] = (((B>>i)&1) ^ c); - } -} - -inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) __attribute__((always_inline)); -inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) { - - int i; - - for (i=0;i<20;i++) - d[i] = btilde[i] == 1 ? -amp : amp; - -} - - - -uint32_t pucch_code[13] = {0xFFFFF,0x5A933,0x10E5A,0x6339C,0x73CE0, - 0xFFC00,0xD8E64,0x4F6B0,0x218EC,0x1B746, - 0x0FFFF,0x33FFF,0x3FFFC}; - - -void generate_pucch2x(int32_t **txdataF, - LTE_DL_FRAME_PARMS *fp, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n2_pucch, - uint8_t *payload, - int A, - int B2, - int16_t amp, - uint8_t subframe, - uint16_t rnti) { - - int i,j; - uint32_t B=0; - uint8_t btilde[20]; - int16_t d[22]; - uint8_t deltaPUCCH_Shift = fp->pucch_config_common.deltaPUCCH_Shift; - uint8_t NRB2 = fp->pucch_config_common.nRB_CQI; - uint8_t Ncs1 = fp->pucch_config_common.nCS_AN; - - uint32_t u0 = fp->pucch_config_common.grouphop[subframe<<1]; - uint32_t u1 = fp->pucch_config_common.grouphop[1+(subframe<<1)]; - uint32_t v0 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; - uint32_t v1 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; - - uint32_t z[12*14],*zptr; - uint32_t u,v,n; - uint8_t ns,N_UL_symb,nsymb_slot0,nsymb_pertti; - uint32_t nprime,l,n_cs; - int alpha_ind,data_ind; - int16_t ref_re,ref_im; - int m,re_offset,symbol_offset; - int32_t *txptr; - - if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { - printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); - return; - } - - if (Ncs1 > 7) { - printf("[PHY] generate_pucch: Illegal Ncs1 %d (should be 0...7)\n",Ncs1); - return; - } - - // pucch2x_encoding - for (i=0;i<A;i++) - if ((*payload & (1<<i)) > 0) - B=B^pucch_code[i]; - - // scrambling - pucch2x_scrambling(fp,subframe,rnti,B,btilde); - // modulation - pucch2x_modulation(btilde,d,amp); - - // add extra symbol for 2a/2b - d[20]=0; - d[21]=0; - if (fmt==pucch_format2a) - d[20] = (B2 == 0) ? amp : -amp; - else if (fmt==pucch_format2b) { - switch (B2) { - case 0: - d[20] = amp; - break; - case 1: - d[21] = -amp; - break; - case 2: - d[21] = amp; - break; - case 3: - d[20] = -amp; - break; - default: - AssertFatal(1==0,"Illegal modulation symbol %d for PUCCH %s\n",B2,pucch_format_string[fmt]); - break; - } - } - - -#ifdef DEBUG_PUCCH_TX - printf("[PHY] PUCCH2x: n2_pucch %d\n",n2_pucch); -#endif - - N_UL_symb = (fp->Ncp==0) ? 7 : 6; - data_ind = 0; - zptr = z; - nprime = 0; - for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { - - if ((ns&1) == 0) - nprime = (n2_pucch < 12*NRB2) ? - n2_pucch % 12 : - (n2_pucch+Ncs1 + 1)%12; - else { - nprime = (n2_pucch < 12*NRB2) ? - ((12*(nprime+1)) % 13)-1 : - (10-n2_pucch)%12; - } - //loop over symbols in slot - for (l=0; l<N_UL_symb; l++) { - // Compute n_cs (36.211 p. 18) - n_cs = (ncs_cell[ns][l]+nprime)%12; - - alpha_ind = 0; - for (n=0; n<12; n++) - { - // this is r_uv^alpha(n) - ref_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); - ref_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); - - if ((l!=1)&&(l!=5)) { //these are PUCCH data symbols - ((int16_t *)&zptr[n])[0] = ((int32_t)d[data_ind]*ref_re - (int32_t)d[data_ind+1]*ref_im)>>15; - ((int16_t *)&zptr[n])[1] = ((int32_t)d[data_ind]*ref_im + (int32_t)d[data_ind+1]*ref_re)>>15; - //LOG_I(PHY,"slot %d ofdm# %d ==> d[%d,%d] \n",ns,l,data_ind,n); - } - else { - if ((l==1) || ( (l==5) && (fmt==pucch_format2) )) - { - ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re>>15); - ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im>>15); - } - // l == 5 && pucch format 2a - else if (fmt==pucch_format2a) - { - ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); - ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); - } - // l == 5 && pucch format 2b - else if (fmt==pucch_format2b) - { - ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); - ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); - } - } // l==1 || l==5 - alpha_ind = (alpha_ind + n_cs)%12; - } // n - zptr+=12; - - if ((l!=1)&&(l!=5)) //these are PUCCH data symbols so increment data index - data_ind+=2; - } // l - } //ns - - m = n2_pucch/12; - -#ifdef DEBUG_PUCCH_TX - LOG_D(PHY,"[PHY] PUCCH: n2_pucch %d m %d\n",n2_pucch,m); -#endif - - nsymb_slot0 = ((fp->Ncp==0) ? 7 : 6); - nsymb_pertti = nsymb_slot0 << 1; - - //nsymb = nsymb_slot0<<1; - - //for (j=0,l=0;l<(nsymb-1);l++) { - for (j=0,l=0; l<(nsymb_pertti); l++) { - - if ((l<nsymb_slot0) && ((m&1) == 0)) - re_offset = (m*6) + fp->first_carrier_offset; - else if ((l<nsymb_slot0) && ((m&1) == 1)) - re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; - else if ((m&1) == 0) - re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; - else - re_offset = ((m-1)*6) + fp->first_carrier_offset; - - if (re_offset > fp->ofdm_symbol_size) - re_offset -= (fp->ofdm_symbol_size); - - - - symbol_offset = (unsigned int)fp->ofdm_symbol_size*(l+(subframe*nsymb_pertti)); - txptr = &txdataF[0][symbol_offset]; - - //LOG_I(PHY,"ofdmSymb %d/%d, firstCarrierOffset %d, symbolOffset[sfn %d] %d, reOffset %d, &txptr: %x \n", l, nsymb, fp->first_carrier_offset, subframe, symbol_offset, re_offset, &txptr[0]); - - for (i=0; i<12; i++,j++) { - txptr[re_offset] = z[j]; - - re_offset++; - - if (re_offset==fp->ofdm_symbol_size) - re_offset -= (fp->ofdm_symbol_size); - -#ifdef DEBUG_PUCCH_TX - LOG_D(PHY,"[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); -#endif - } - } -} - -/* PUCCH format3 >> */ -/* DFT */ -void pucchfmt3_Dft( int16_t *x, int16_t *y ) -{ - int16_t i, k; - int16_t tmp[2]; - int16_t calctmp[D_NSC1RB*2]={0}; - - for (i=0; i<D_NSC1RB; i++) { - for(k=0; k<D_NSC1RB; k++) { - tmp[0] = alphaTBL_re[(12-((i*k)%12))%12]; - tmp[1] = alphaTBL_im[(12-((i*k)%12))%12]; - - calctmp[2*i] += (((int32_t)x[2*k] * tmp[0] - (int32_t)x[2*k+1] * tmp[1])>>15); - calctmp[2*i+1] += (((int32_t)x[2*k+1] * tmp[0] + (int32_t)x[2*k] * tmp[1])>>15); - } - y[2*i] = (int16_t)( (double) calctmp[2*i] / sqrt(D_NSC1RB)); - y[2*i+1] = (int16_t)((double) calctmp[2*i+1] / sqrt(D_NSC1RB)); - } -} - -void generate_pucch3x(int32_t **txdataF, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t ncs_cell[20][7], - PUCCH_FMT_t fmt, - PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, - uint16_t n3_pucch, - uint8_t shortened_format, - uint8_t *payload, - int16_t amp, - uint8_t subframe, - uint16_t rnti) -{ - - uint32_t u, v; - uint16_t i, j, re_offset; - uint32_t z[12*14], *zptr; - uint32_t y_tilda[12*14]={}, *y_tilda_ptr; - uint8_t ns, nsymb, n_oc, n_oc0, n_oc1; - uint8_t N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; - uint8_t m, l; - uint8_t n_cs; - int16_t tmp_re, tmp_im, W_re=0, W_im=0; - int32_t *txptr; - uint32_t symbol_offset; - - uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; - uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; - uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; - uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; - - // variables for channel coding - uint8_t chcod_tbl_idx = 0; - //uint8_t chcod_dt[48] = {}; - - // variables for Scrambling - uint32_t cinit = 0; - uint32_t x1; - uint32_t s,s0,s1; - uint8_t C[48] ={}; - uint8_t scr_dt[48]={}; - - // variables for Modulation - int16_t d_re[24]={}; - int16_t d_im[24]={}; - - // variables for orthogonal sequence selection - uint8_t N_PUCCH_SF0 = 5; - uint8_t N_PUCCH_SF1 = (shortened_format==0)? 5:4; - uint8_t first_slot = 0; - int16_t rot_re=0; - int16_t rot_im=0; - - uint8_t dt_offset; - uint8_t sym_offset; - int16_t y_re[14][12]; //={0}; - int16_t y_im[14][12]; //={0}; - - // DMRS - uint8_t alpha_idx=0; - uint8_t m_alpha_idx=0; - - // TODO - // "SR+ACK/NACK" length is only 7 bits. - // This restriction will be lifted in the future. - // "CQI/PMI/RI+ACK/NACK" will be supported in the future. - - // Channel Coding - for (uint8_t i=0; i<7; i++) { - chcod_tbl_idx += (payload[i]<<i); - } - - // Scrambling - cinit = (subframe + 1) * ((2 * frame_parms->Nid_cell + 1)<<16) + rnti; - s0 = lte_gold_generic(&x1,&cinit,1); - s1 = lte_gold_generic(&x1,&cinit,0); - - for (i=0; i<48; i++) { - s = (i<32)? s0:s1; - j = (i<32)? i:(i-32); - C[i] = ((s>>j)&1); - } - - for (i=0; i<48; i++) { - scr_dt[i] = chcod_tbl[chcod_tbl_idx][i] ^ C[i]; - } - - // Modulation - for (uint8_t i=0; i<48; i+=2){ - if (scr_dt[i]==0 && scr_dt[i+1]==0){ - d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); - d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); - } else if (scr_dt[i]==0 && scr_dt[i+1]==1) { - d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); - d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp) >>15); - } else if (scr_dt[i]==1 && scr_dt[i+1]==0) { - d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); - d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp)>>15); - } else if (scr_dt[i]==1 && scr_dt[i+1]==1) { - d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); - d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); - } else { - //***log Modulation Error! - } - } - - // Calculate Orthogonal Sequence index - n_oc0 = n3_pucch % N_PUCCH_SF1; - if (N_PUCCH_SF1 == 5) { - n_oc1 = (3 * n_oc0) % N_PUCCH_SF1; - } else { - n_oc1 = n_oc0 % N_PUCCH_SF1; - } - - y_tilda_ptr = y_tilda; - zptr = z; - - // loop over 2 slots - for (ns=(subframe<<1), u=u0, v=v0; ns<(2+(subframe<<1)); ns++, u=u1, v=v1) { - first_slot = (ns==(subframe<<1))?1:0; - - //loop over symbols in slot - for (l=0; l<N_UL_symb; l++) { - rot_re = RotTBL_re[(uint8_t) ncs_cell[ns][l]/64] ; - rot_im = RotTBL_im[(uint8_t) ncs_cell[ns][l]/64] ; - - // Comput W_noc(m) (36.211 p. 19) - if ( first_slot == 0 && shortened_format==1) { // second slot and shortened format - n_oc = n_oc1; - - if (l<1) { // data - W_re=W4_fmt3[n_oc][l]; - W_im=0; - } else if (l==1) { // DMRS - W_re=W2[0]; - W_im=0; - } else if (l>=2 && l<5) { // data - W_re=W4_fmt3[n_oc][l-1]; - W_im=0; - } else if (l==5) { // DMRS - W_re=W2[1]; - W_im=0; - } else if ((l>=N_UL_symb-2)) { // data - ; - } else { - //***log W Select Error! - } - } else { - if (first_slot == 1) { // 1st slot or 2nd slot and not shortened - n_oc=n_oc0; - } else { - n_oc=n_oc1; - } - - if (l<1) { // data - W_re=W5_fmt3_re[n_oc][l]; - W_im=W5_fmt3_im[n_oc][l]; - } else if (l==1) { // DMRS - W_re=W2[0]; - W_im=0; - } else if (l>=2 && l<5) { // data - W_re=W5_fmt3_re[n_oc][l-1]; - W_im=W5_fmt3_im[n_oc][l-1]; - } else if (l==5) { // DMRS - W_re=W2[1]; - W_im=0; - } else if ((l>=N_UL_symb-1)) { // data - W_re=W5_fmt3_re[n_oc][l-N_UL_symb+5]; - W_im=W5_fmt3_im[n_oc][l-N_UL_symb+5]; - } else { - //***log W Select Error! - } - } // W Selection end - - // Compute n_cs (36.211 p. 18) - n_cs = ncs_cell[ns][l]; - if (N_PUCCH_SF1 == 5) { - alpha_idx = (n_cs + Np5_TBL[n_oc]) % 12; - } else { - alpha_idx = (n_cs + Np4_TBL[n_oc]) % 12; - } - - // generate pucch data - dt_offset = (first_slot == 1) ? 0:12; - sym_offset = (first_slot == 1) ? 0:7; - - for (i=0; i<12; i++) { - // Calculate yn(i) - tmp_re = (((int32_t) (W_re*rot_re - W_im*rot_im)) >>15); - tmp_im = (((int32_t) (W_re*rot_im + W_im*rot_re)) >>15); - y_re[l+sym_offset][i] = (((int32_t) (tmp_re*d_re[i+dt_offset] - tmp_im*d_im[i+dt_offset]))>>15); - y_im[l+sym_offset][i] = (((int32_t) (tmp_re*d_im[i+dt_offset] + tmp_im*d_re[i+dt_offset]))>>15); - - // cyclic shift - ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[0] = y_re[l+sym_offset][i]; - ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[1] = y_im[l+sym_offset][i]; - - // DMRS - m_alpha_idx = (alpha_idx * i) % 12; - if (l==1 || l==5) { - ((int16_t *)&zptr[(l+sym_offset)*12+i])[0] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][i<<1] - (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][1+(i<<1)])>>15) * (int32_t)amp)>>15); - ((int16_t *)&zptr[(l+sym_offset)*12+i])[1] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][1+(i<<1)] + (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][i<<1])>>15) * (int32_t)amp)>>15); - } - } - - } // l loop - } // ns - - // DFT for pucch-data - for (l=0; l<14; l++) { - if (l==1 || l==5 || l==8 || l==12) { - ; - } else { - pucchfmt3_Dft((int16_t*)&y_tilda_ptr[l*12],(int16_t*)&zptr[l*12]); - } - } - - - // Mapping - m = n3_pucch / N_PUCCH_SF0; - - if (shortened_format == 1) { - nsymb = (N_UL_symb<<1) - 1; - } else { - nsymb = (N_UL_symb<<1); - } - - for (j=0,l=0; l<(nsymb); l++) { - - if ((l<7) && ((m&1) == 0)) - re_offset = (m*6) + frame_parms->first_carrier_offset; - else if ((l<7) && ((m&1) == 1)) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else if ((m&1) == 0) - re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; - else - re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; - - if (re_offset > frame_parms->ofdm_symbol_size) - re_offset -= (frame_parms->ofdm_symbol_size); - - symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*14)); - txptr = &txdataF[0][symbol_offset]; - - for (i=0; i<12; i++,j++) { - txptr[re_offset++] = z[j]; - - if (re_offset==frame_parms->ofdm_symbol_size) - re_offset = 0; - -#ifdef DEBUG_PUCCH_TX - msg("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); -#endif - } - } - -} - -/* PUCCH format3 << */ - - -//#define Amax 13 -//void init_pucch2x_rx() {}; /* PUCCH format3 >> */ @@ -1278,7 +204,7 @@ uint16_t pucchfmt3_ChannelEstimation( int16_t SubCarrierDeMapData[NB_ANTENNAS_RX int32_t IP_CsData_allsfavg[NB_ANTENNAS_RX][14][4][2]; int32_t IP_allavg[D_NPUCCH_SF5]; //int16_t temp_ch[2]; - int16_t m[NUMBER_OF_UE_MAX], m_self, same_m_number; + int16_t m[NUMBER_OF_UE_MAX], m_self=0, same_m_number; uint16_t n3_pucch_sameRB[NUMBER_OF_UE_MAX]; int16_t n_oc0[NUMBER_OF_UE_MAX]; int16_t n_oc1[NUMBER_OF_UE_MAX]; diff --git a/openair1/PHY/LTE_TRANSPORT/pucch_common.c b/openair1/PHY/LTE_TRANSPORT/pucch_common.c new file mode 100644 index 0000000000000000000000000000000000000000..a9181a8b3dfe8107f42ad5b880b5eba3b5171d00 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pucch_common.c @@ -0,0 +1,270 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/pucch_common.c +* \brief Top-level routines common to eNB/UE for the PUCCH physical channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "LAYER2/MAC/mac.h" + +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +#include "T.h" + +void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]) +{ + + uint8_t ns,l,reset=1,i,N_UL_symb; + uint32_t x1,x2,j=0,s=0; + + N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; + x2 = frame_parms->Nid_cell; + + for (ns=0; ns<20; ns++) { + + for (l=0; l<N_UL_symb; l++) { + ncs_cell[ns][l]=0; + + for (i=0; i<8; i++) { + if ((j%32) == 0) { + s = lte_gold_generic(&x1,&x2,reset); + // printf("s %x\n",s); + reset=0; + } + + if (((s>>(j%32))&1)==1) + ncs_cell[ns][l] += (1<<i); + + j++; + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH ncs_cell init (j %d): Ns %d, l %d => ncs_cell %d\n",j,ns,l,ncs_cell[ns][l]); +#endif + } + + } +} + +int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, + {32767,-32768, 32767,-32768}, + {32767,-32768,-32768, 32767} +}; +int16_t W3_re[3][6] = {{32767, 32767, 32767}, + {32767,-16384,-16384}, + {32767,-16384,-16384} +}; + +int16_t W3_im[3][6] = {{0 ,0 ,0 }, + {0 , 28377,-28378}, + {0 ,-28378, 28377} +}; + +char *pucch_format_string[] = { + "format 1", + "format 1a", + "format 1b", + "pucch_format1b_csA2", + "pucch_format1b_csA3", + "pucch_format1b_csA4", + "format 2", + "format 2a", + "format 2b", + "pucch_format3" +}; + + + +uint8_t chcod_tbl[128][48] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1}, + {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0}, + {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0}, + {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1}, + {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1}, + {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}, + {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0}, + {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1}, + {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1}, + {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0}, + {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0}, + {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1}, + {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1}, + {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1}, + {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}, + {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0}, + {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1}, + {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1}, + {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0}, + {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0}, + {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1}, + {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1}, + {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0}, + {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0}, + {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1}, + {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, + {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, + {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0}, + {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, + {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, + {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1}, + {0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1}, + {1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0}, + {1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0}, + {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1}, + {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1}, + {1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0}, + {1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0}, + {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1}, + {0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1}, + {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0}, + {1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0}, + {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1}, + {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, + {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, + {1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1}, + {0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0}, + {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0}, + {1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1}, + {1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1}, + {0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0}, + {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0}, + {1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1}, + {1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1}, + {0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0}, + {0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, + {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1}, + {1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1}, + {0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0}, + {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1}, + {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0}, + {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0}, + {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1}, + {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0}, + {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1}, + {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1}, + {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}, + {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0}, + {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1}, + {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1}, + {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0}, + {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0}, + {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1}, + {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0}, + {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1}, + {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1}, + {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0}, + {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0}, + {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1}, + {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1}, + {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0}, + {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0}, + {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1}, + {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1}, + {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0}, + {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0}, + {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1}, + {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0}, + {1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1}, + {1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1}, + {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0}, + {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}, + {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1}, + {1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1}, + {0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0}, + {0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0}, + {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1}, + {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1}, + {0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0}, + {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1}, + {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1}, + {0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1}, + {1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0}, + {1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1}, + {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, + {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, + {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0}, + {0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1}, + {0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}, + {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0}, + {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0}, + {0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1}, + {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1}, + {1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0}, + {1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0}, + {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1} }; + +int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377}; +int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384}; + +// W5_TBL +int16_t W5_fmt3_re[5][5] = { {32767, 32767, 32767, 32767, 32767}, + {32767, 10125, -26509, -26509, 10125}, + {32767, -26509, 10125, 10125, -26509}, + {32767, -26509, 10125, 10125, -26509}, + {32767, 10125, -26509, -26509, 10125} }; + +int16_t W5_fmt3_im[5][5] = { {0, 0, 0, 0, 0}, + {0, 31163, 19259, -19259, -31163}, + {0, 19259, -31163, 31163, -19259}, + {0, -19259, 31163, -31163, 19259}, + {0, -31163, -19259, 19259, 31163} }; + +int16_t W4_fmt3[4][4] = { {32767, 32767, 32767, 32767}, + {32767, -32767, 32767, -32767}, + {32767, 32767, -32767, -32767}, + {32767, -32767, -32767, 32767} }; + +// W2 TBL +int16_t W2[2] = {32767, 32767}; + +// e^j*pai*floor (ncs_cell(ns,l)/64)/2 +int16_t RotTBL_re[4] = {32767, 0, -32767, 0}; +int16_t RotTBL_im[4] = {0, 32767, 0, -32767}; + +//np4_tbl, np5_tbl +uint8_t Np5_TBL[5] = {0, 3, 6, 8, 10}; +uint8_t Np4_TBL[4] = {0, 3, 6, 9}; + +// alpha_TBL +int16_t alphaTBL_re[12] = {32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383, 0, 16383, 28377}; +int16_t alphaTBL_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16383, -28377, -32767, -28377, -16383}; + diff --git a/openair1/PHY/LTE_TRANSPORT/pucch_extern.h b/openair1/PHY/LTE_TRANSPORT/pucch_extern.h new file mode 100644 index 0000000000000000000000000000000000000000..899b90430670af54af65a918d859689646e1129c --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/pucch_extern.h @@ -0,0 +1,78 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/pucch.c +* \brief Top-level routines for generating and decoding the PUCCH physical channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ + +#include <stdint.h> + +/* PUCCH format3 >> */ +#define D_I 0 +#define D_Q 1 +#define D_IQDATA 2 +#define D_NSLT1SF 2 +#define D_NSYM1SLT 7 +#define D_NSYM1SF 2*7 +#define D_NSC1RB 12 +#define D_NRB1PUCCH 2 +#define D_NPUCCH_SF5 5 +#define D_NPUCCH_SF4 4 + +extern int16_t W4[3][4]; + +extern int16_t W3_re[3][6]; + + +extern int16_t W3_im[3][6]; + +extern int16_t alpha_re[12]; +extern int16_t alpha_im[12]; + +extern char *pucch_format_string[]; + +extern uint8_t chcod_tbl[128][48]; + +extern int16_t W5_fmt3_re[5][5]; + +extern int16_t W5_fmt3_im[5][5]; + +extern int16_t W4_fmt3[4][4]; + +extern int16_t W2[2]; + +extern int16_t RotTBL_re[4]; +extern int16_t RotTBL_im[4]; + +//np4_tbl, np5_tbl +extern uint8_t Np5_TBL[5]; +extern uint8_t Np4_TBL[4]; + +// alpha_TBL +extern int16_t alphaTBL_re[12]; +extern int16_t alphaTBL_im[12]; diff --git a/openair1/PHY/LTE_TRANSPORT/rar_tools.c b/openair1/PHY/LTE_TRANSPORT/rar_tools.c index 9934b71d78b0165c32d9b4df855e97779c43ee33..ab4656716bcc509cfddf46ba96582c81adcc89fd 100644 --- a/openair1/PHY/LTE_TRANSPORT/rar_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/rar_tools.c @@ -20,7 +20,7 @@ */ /*! \file PHY/LTE_TRANSPORT/rar_tools.c -* \brief Routine for filling the PUSCH/ULSCH data structures based on a random-access response (RAR) SDU from MAC. Note this is both for UE and eNB. V8.6 2009-03 +* \brief Routine for filling the PUSCH/ULSCH data structures based on a random-access response (RAR) SDU from MAC. Note this is for eNB. * \author R. Knopp * \date 2011 * \version 0.1 @@ -29,14 +29,12 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "SCHED/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/LOG/vcd_signal_dumper.h" - +#include "PHY/LTE_TRANSPORT/transport_proto.h" #include "assertions.h" extern uint16_t RIV2nb_rb_LUT6[32]; @@ -194,159 +192,3 @@ int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, return(0); } -int8_t delta_PUSCH_msg2[8] = {-6,-4,-2,0,2,4,6,8}; - -int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - unsigned char eNB_id ) -{ - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_IN); - - // RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)rar_pdu; - uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - unsigned char *rar_pdu = ue->dlsch_ra[eNB_id]->harq_processes[0]->b; - unsigned char subframe = ue->ulsch_Msg3_subframe[eNB_id]; - LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - PHY_MEASUREMENTS *meas = &ue->measurements; - - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - // int current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; - - uint8_t *rar = (uint8_t *)(rar_pdu+1); - uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_tx,subframe); - uint16_t rballoc; - uint8_t cqireq; - uint16_t *RIV2nb_rb_LUT, *RIV2first_rb_LUT; - uint16_t RIV_max = 0; - - LOG_D(PHY,"[eNB][RAPROC] Frame %d: generate_ue_ulsch_params_from_rar: subframe %d (harq_pid %d)\n",proc->frame_tx,subframe,harq_pid); - - switch (frame_parms->N_RB_DL) { - case 6: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT6[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT6[0]; - RIV_max = RIV_max6; - break; - - case 25: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT25[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT25[0]; - RIV_max = RIV_max25; - break; - - case 50: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT50[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT50[0]; - RIV_max = RIV_max50; - break; - - case 100: - RIV2nb_rb_LUT = &RIV2nb_rb_LUT100[0]; - RIV2first_rb_LUT = &RIV2first_rb_LUT100[0]; - RIV_max = RIV_max100; - break; - - default: - DevParam(frame_parms->N_RB_DL, eNB_id, harq_pid); - break; - } - - - - ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7;//rar->TPC; - - rballoc = (((uint16_t)(rar[1]&7))<<7)|(rar[2]>>1); - cqireq=rar[3]&1; - - if (rballoc>RIV_max) { - LOG_D(PHY,"rar_tools.c: ERROR: rb_alloc (%x) > RIV_max\n",rballoc); - return(-1); - } - - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; - - AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb >0, "nb_rb == 0\n"); - - ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb]; - - AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb <= 6,"unlikely rb count for RAR grant : nb_rb > 6\n"); - - // ulsch->harq_processes[harq_pid]->Ndi = 1; - if (ulsch->harq_processes[harq_pid]->round == 0) - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - if (cqireq==1) { - ulsch->O_RI = 1; - - if (meas->rank[eNB_id] == 1) { - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->o_RI[0] = 1; - } else { - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - ulsch->o_RI[0] = 0; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - fill_CQI(ulsch,meas,eNB_id,0,ue->frame_parms.N_RB_DL,0, transmission_mode,ue->sinr_eff); - - if (((proc->frame_tx % 100) == 0) || (proc->frame_tx < 10)) - print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); - } else { - ulsch->O_RI = 0; - ulsch->O = 0; - } - - ulsch->harq_processes[harq_pid]->O_ACK = 0;//2; - - ulsch->beta_offset_cqi_times8 = 18; - ulsch->beta_offset_ri_times8 = 10; - ulsch->beta_offset_harqack_times8 = 16; - - ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1); - ulsch->rnti = (((uint16_t)rar[4])<<8)+rar[5]; //rar->t_crnti; - - if (ulsch->harq_processes[harq_pid]->round == 0) { - ulsch->harq_processes[harq_pid]->status = ACTIVE; - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = ((rar[2]&1)<<3)|(rar[3]>>5); - ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7; - //ulsch->harq_processes[harq_pid]->TBS = dlsch_tbs25[ulsch->harq_processes[harq_pid]->mcs][ulsch->harq_processes[harq_pid]->nb_rb-1]; - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = 9; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->round++; - } - - // initialize power control based on PRACH power - ulsch->f_pusch = delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC] + - get_deltaP_rampup(ue->Mod_id,ue->CC_id); - LOG_D(PHY,"[UE %d][PUSCH PC] Initializing f_pusch to %d dB, TPC %d (delta_PUSCH_msg2 %d dB), deltaP_rampup %d dB\n", - ue->Mod_id,ulsch->f_pusch,ulsch->harq_processes[harq_pid]->TPC,delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC], - get_deltaP_rampup(ue->Mod_id,ue->CC_id)); - - - //#ifdef DEBUG_RAR - LOG_D(PHY,"ulsch ra (UE): harq_pid %d\n",harq_pid); - LOG_D(PHY,"ulsch ra (UE): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"ulsch ra (UE): first_rb %x\n",ulsch->harq_processes[harq_pid]->first_rb); - LOG_D(PHY,"ulsch ra (UE): nb_rb %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"ulsch ra (UE): round %d\n",ulsch->harq_processes[harq_pid]->round); - LOG_D(PHY,"ulsch ra (UE): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - LOG_D(PHY,"ulsch ra (UE): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - LOG_D(PHY,"ulsch ra (UE): TPC %d\n",ulsch->harq_processes[harq_pid]->TPC); - LOG_D(PHY,"ulsch ra (UE): O %d\n",ulsch->O); - LOG_D(PHY,"ulsch ra (UE): ORI %d\n",ulsch->O_RI); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_OUT); - - //#endif - return(0); -} - diff --git a/openair1/PHY/LTE_TRANSPORT/sss.c b/openair1/PHY/LTE_TRANSPORT/sss.c index 17a4680c54f7a19beee1b91225b9ef54095ea672..bf03c185ef9664790957fafbb22a2295c8e24bfd 100644 --- a/openair1/PHY/LTE_TRANSPORT/sss.c +++ b/openair1/PHY/LTE_TRANSPORT/sss.c @@ -29,9 +29,9 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "transport_eNB.h" +#include "PHY/phy_extern.h" //#define DEBUG_SSS @@ -82,383 +82,3 @@ int generate_sss(int32_t **txdataF, return(0); } -int pss_ch_est(PHY_VARS_UE *ue, - int32_t pss_ext[4][72], - int32_t sss_ext[4][72]) -{ - - int16_t *pss; - int16_t *pss_ext2,*sss_ext2,*sss_ext3,tmp_re,tmp_im,tmp_re2,tmp_im2; - uint8_t aarx,i; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - - switch (ue->common_vars.eNb_id) { - - case 0: - pss = &primary_synch0[10]; - break; - - case 1: - pss = &primary_synch1[10]; - break; - - case 2: - pss = &primary_synch2[10]; - break; - - default: - pss = &primary_synch0[10]; - break; - } - - sss_ext3 = (int16_t*)&sss_ext[0][5]; - - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - sss_ext2 = (int16_t*)&sss_ext[aarx][5]; - pss_ext2 = (int16_t*)&pss_ext[aarx][5]; - - for (i=0; i<62; i++) { - - // This is H*(PSS) = R* \cdot PSS - tmp_re = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[i<<1])>>15) + ((pss_ext2[1+(i<<1)] * (int32_t)pss[1+(i<<1)])>>15)); - tmp_im = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[1+(i<<1)])>>15) - ((pss_ext2[1+(i<<1)] * (int32_t)pss[(i<<1)])>>15)); - // printf("H*(%d,%d) : (%d,%d)\n",aarx,i,tmp_re,tmp_im); - // This is R(SSS) \cdot H*(PSS) - tmp_re2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[i<<1])>>15) - ((tmp_im * (int32_t)sss_ext2[1+(i<<1)]>>15))); - tmp_im2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[1+(i<<1)])>>15) + ((tmp_im * (int32_t)sss_ext2[(i<<1)]>>15))); - - // printf("SSSi(%d,%d) : (%d,%d)\n",aarx,i,sss_ext2[i<<1],sss_ext2[1+(i<<1)]); - // printf("SSSo(%d,%d) : (%d,%d)\n",aarx,i,tmp_re2,tmp_im2); - // MRC on RX antennas - if (aarx==0) { - sss_ext3[i<<1] = tmp_re2; - sss_ext3[1+(i<<1)] = tmp_im2; - } else { - sss_ext3[i<<1] += tmp_re2; - sss_ext3[1+(i<<1)] += tmp_im2; - } - } - } - - // sss_ext now contains the compensated SSS - return(0); -} - - -int _do_pss_sss_extract(PHY_VARS_UE *ue, - int32_t pss_ext[4][72], - int32_t sss_ext[4][72], - uint8_t doPss, uint8_t doSss, - uint8_t subframe) // add flag to indicate extracting only PSS, only SSS, or both -{ - - - - uint16_t rb,nb_rb=6; - uint8_t i,aarx; - int32_t *pss_rxF,*pss_rxF_ext; - int32_t *sss_rxF,*sss_rxF_ext; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t next_thread_id = ue->current_thread_id[subframe]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[subframe]+1); - - int rx_offset = frame_parms->ofdm_symbol_size-3*12; - uint8_t pss_symb,sss_symb; - - int32_t **rxdataF; - - //LOG_I(PHY,"do_pss_sss_extract subframe %d \n",subframe); - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { - - if (frame_parms->frame_type == FDD) { - pss_symb = 6-frame_parms->Ncp; - sss_symb = pss_symb-1; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - - } else { - pss_symb = 2; - sss_symb = frame_parms->symbols_per_tti-1; - - if(subframe==5 || subframe==0) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else if(subframe==6 || subframe==1) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else - { - AssertFatal(0,""); - } - - } - //printf("extract_rbs: symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",symbol_mod, - // (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, - // LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); - - pss_rxF_ext = &pss_ext[aarx][0]; - sss_rxF_ext = &sss_ext[aarx][0]; - - for (rb=0; rb<nb_rb; rb++) { - // skip DC carrier - if (rb==3) { - if(frame_parms->frame_type == FDD) - { - sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else - { - if(subframe==5 || subframe==0) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else if(subframe==6 || subframe==1) - { - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; - pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; - - rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; - sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; - } - else - { - AssertFatal(0,""); - } - } - } - - for (i=0; i<12; i++) { - if (doPss) {pss_rxF_ext[i]=pss_rxF[i];} - if (doSss) {sss_rxF_ext[i]=sss_rxF[i];} - } - - pss_rxF+=12; - sss_rxF+=12; - pss_rxF_ext+=12; - sss_rxF_ext+=12; - } - - } - - return(0); -} - -int pss_sss_extract(PHY_VARS_UE *phy_vars_ue, - int32_t pss_ext[4][72], - int32_t sss_ext[4][72], - uint8_t subframe) -{ - return _do_pss_sss_extract(phy_vars_ue, pss_ext, sss_ext, 1 /* doPss */, 1 /* doSss */, subframe); -} - -int pss_only_extract(PHY_VARS_UE *phy_vars_ue, - int32_t pss_ext[4][72], - uint8_t subframe) -{ - static int32_t dummy[4][72]; - return _do_pss_sss_extract(phy_vars_ue, pss_ext, dummy, 1 /* doPss */, 0 /* doSss */, subframe); -} - - -int sss_only_extract(PHY_VARS_UE *phy_vars_ue, - int32_t sss_ext[4][72], - uint8_t subframe) -{ - static int32_t dummy[4][72]; - return _do_pss_sss_extract(phy_vars_ue, dummy, sss_ext, 0 /* doPss */, 1 /* doSss */, subframe); -} - - -int16_t phase_re[7] = {16383, 25101, 30791, 32767, 30791, 25101, 16383}; -int16_t phase_im[7] = {-28378, -21063, -11208, 0, 11207, 21062, 28377}; - - -int rx_sss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *flip_max,uint8_t *phase_max) -{ - - uint8_t i; - int32_t pss_ext[4][72]; - int32_t sss0_ext[4][72],sss5_ext[4][72]; - uint8_t Nid2 = ue->common_vars.eNb_id; - uint8_t flip,phase; - uint16_t Nid1; - int16_t *sss0,*sss5; - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - int32_t metric; - int16_t *d0,*d5; - - if (frame_parms->frame_type == FDD) { -#ifdef DEBUG_SSS - - if (frame_parms->Ncp == NORMAL) - msg("[PHY][UE%d] Doing SSS for FDD Normal Prefix\n",ue->Mod_id); - else - msg("[PHY][UE%d] Doing SSS for FDD Extended Prefix\n",ue->Mod_id); - -#endif - // Do FFTs for SSS/PSS - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-2, // second to last symbol of - 0, // slot 0 - ue->rx_offset, - 0, - 1); - // PSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-1, // last symbol of - 0, // slot 0 - ue->rx_offset, - 0, - 1); - } else { // TDD -#ifdef DEBUG_SSS - if (ue->frame_parms->Ncp == NORMAL) - msg("[PHY][UE%d] Doing SSS for TDD Normal Prefix\n",ue->Mod_id); - else - msg("[PHY][UE%d] Doing SSS for TDD Extended Prefix\n",ue->Mod_id); - -#endif - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti>>1)-1, // last symbol of - 1, // slot 1 - ue->rx_offset, - 0, - 1); - // PSS - slot_fep(ue, - 2, // symbol 2 of - 2, // slot 2 - ue->rx_offset, - 0, - 1); - } - // pss sss extract for subframe 0 - pss_sss_extract(ue, - pss_ext, - sss0_ext,0); - /* - write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata[0][0],ue->frame_parms.samples_per_tti,1,1); - write_output("rxdataF0.m","rxF0",&ue->common_vars.rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,2,1); - write_output("pss_ext0.m","pssext0",pss_ext,72,1,1); - write_output("sss0_ext0.m","sss0ext0",sss0_ext,72,1,1); - */ - - // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS - // and do channel estimation and compensation based on PSS - - pss_ch_est(ue, - pss_ext, - sss0_ext); - - // write_output("sss0_comp0.m","sss0comp0",sss0_ext,72,1,1); - - if (ue->frame_parms.frame_type == FDD) { // FDD - - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-2, - 10, - ue->rx_offset, - 0,1); - // PSS - slot_fep(ue, - (frame_parms->symbols_per_tti/2)-1, - 10, - ue->rx_offset, - 0,1); - } else { // TDD - // SSS - slot_fep(ue, - (frame_parms->symbols_per_tti>>1)-1, - 11, - ue->rx_offset, - 0, - 1); - // PSS - slot_fep(ue, - 2, - 12, - ue->rx_offset, - 0, - 1); - } - - // pss sss extract for subframe 5 - pss_sss_extract(ue, - pss_ext, - sss5_ext,5); - - // write_output("sss5_ext0.m","sss5ext0",sss5_ext,72,1,1); - // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS - // and do channel estimation and compensation based on PSS - - pss_ch_est(ue, - pss_ext, - sss5_ext); - - - - // now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h - - *tot_metric = -99999999; - - - sss0 = (int16_t*)&sss0_ext[0][5]; - sss5 = (int16_t*)&sss5_ext[0][5]; - - for (flip=0; flip<2; flip++) { // d0/d5 flip in RX frame - for (phase=0; phase<7; phase++) { // phase offset between PSS and SSS - for (Nid1 = 0 ; Nid1 <= 167; Nid1++) { // 168 possible Nid1 values - metric = 0; - - if (flip==0) { - d0 = &d0_sss[62*(Nid2 + (Nid1*3))]; - d5 = &d5_sss[62*(Nid2 + (Nid1*3))]; - } else { - d5 = &d0_sss[62*(Nid2 + (Nid1*3))]; - d0 = &d5_sss[62*(Nid2 + (Nid1*3))]; - } - - // This is the inner product using one particular value of each unknown parameter - for (i=0; i<62; i++) { - metric += (int16_t)(((d0[i]*((((phase_re[phase]*(int32_t)sss0[i<<1])>>19)-((phase_im[phase]*(int32_t)sss0[1+(i<<1)])>>19)))) + - (d5[i]*((((phase_re[phase]*(int32_t)sss5[i<<1])>>19)-((phase_im[phase]*(int32_t)sss5[1+(i<<1)])>>19)))))); - } - - // if the current metric is better than the last save it - if (metric > *tot_metric) { - *tot_metric = metric; - ue->frame_parms.Nid_cell = Nid2+(3*Nid1); - *phase_max = phase; - *flip_max=flip; -#ifdef DEBUG_SSS - msg("(flip,phase,Nid1) (%d,%d,%d), metric_phase %d tot_metric %d, phase_max %d, flip_max %d\n",flip,phase,Nid1,metric,*tot_metric,*phase_max,*flip_max); -#endif - - } - } - } - } - - return(0); -} - diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common.h b/openair1/PHY/LTE_TRANSPORT/transport_common.h new file mode 100644 index 0000000000000000000000000000000000000000..167e2b111a566a7929e1f76cc3003a41623ea756 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/transport_common.h @@ -0,0 +1,282 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/transport_commont.h +* \brief data structures for PDSCH/DLSCH/PUSCH/ULSCH physical and transport channel descriptors (TX/RX) common to both eNB/UE +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: raymond.knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it +* \note +* \warning +*/ +#ifndef __TRANSPORT_COMMON__H__ +#define __TRANSPORT_COMMON__H__ +#include "PHY/defs_common.h" +#include "PHY/impl_defs_lte.h" +#include "dci.h" +#include "mdci.h" +//#include "uci.h" +#ifndef STANDALONE_COMPILE +#include "UTIL/LISTS/list.h" +#endif + +#define MOD_TABLE_QPSK_OFFSET 1 +#define MOD_TABLE_16QAM_OFFSET 5 +#define MOD_TABLE_64QAM_OFFSET 21 +#define MOD_TABLE_PSS_OFFSET 85 + +// structures below implement 36-211 and 36-212 + +/** @addtogroup _PHY_TRANSPORT_ + * @{ + */ + + + +#define NSOFT 1827072 +#define LTE_NULL 2 + +// maximum of 3 segments before each coding block if data length exceeds 6144 bits. + +#define MAX_NUM_DLSCH_SEGMENTS 16 +#define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS +#define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768) +#define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768) + +#define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE +#define MAX_NUM_RE (14*1200) + +#if !defined(SI_RNTI) +#define SI_RNTI (rnti_t)0xffff +#endif +#if !defined(M_RNTI) +#define M_RNTI (rnti_t)0xfffd +#endif +#if !defined(P_RNTI) +#define P_RNTI (rnti_t)0xfffe +#endif +#if !defined(CBA_RNTI) +#define CBA_RNTI (rnti_t)0xfff4 +#endif +#if !defined(C_RNTI) +#define C_RNTI (rnti_t)0x1234 +#endif +// These are the codebook indexes according to Table 6.3.4.2.3-1 of 36.211 +//1 layer +#define PMI_2A_11 0 +#define PMI_2A_1m1 1 +#define PMI_2A_1j 2 +#define PMI_2A_1mj 3 +//2 layers +#define PMI_2A_R1_10 0 +#define PMI_2A_R1_11 1 +#define PMI_2A_R1_1j 2 + +typedef enum { SEARCH_EXIST=0, + SEARCH_EXIST_OR_FREE} find_type_t; + +typedef enum { + SCH_IDLE=0, + ACTIVE, + CBA_ACTIVE, + DISABLED +} SCH_status_t; + + + + +#ifdef Rel14 +typedef enum { + CEmodeA = 0, + CEmodeB = 1 +} CEmode_t; +#endif + +#define PUSCH_x 2 +#define PUSCH_y 3 + +typedef enum { + pucch_format1=0, + pucch_format1a, + pucch_format1b, + pucch_format1b_csA2, + pucch_format1b_csA3, + pucch_format1b_csA4, + pucch_format2, + pucch_format2a, + pucch_format2b, + pucch_format3 // PUCCH format3 +} PUCCH_FMT_t; + +typedef enum { + SR, + HARQ, + CQI, + HARQ_SR, + HARQ_CQI, + SR_CQI, + HARQ_SR_CQI +} UCI_type_t; + +#ifdef Rel14 +typedef enum { + NOCE, + CEMODEA, + CEMODEB +} UE_type_t; +#endif + + + + + +typedef enum { + SI_PDSCH=0, + RA_PDSCH, + P_PDSCH, + PDSCH, + PDSCH1, + PMCH +} PDSCH_t; + +typedef enum { + rx_standard=0, + rx_IC_single_stream, + rx_IC_dual_stream, + rx_SIC_dual_stream +} RX_type_t; + + +typedef enum { + DCI_COMMON_SPACE, + DCI_UE_SPACE +} dci_space_t; + +typedef struct { + uint8_t f_ra; + uint8_t t0_ra; + uint8_t t1_ra; + uint8_t t2_ra; +} PRACH_TDD_PREAMBLE_MAP_elem; +typedef struct { + uint8_t num_prach; + PRACH_TDD_PREAMBLE_MAP_elem map[6]; +} PRACH_TDD_PREAMBLE_MAP; + +#ifdef Rel14 + +typedef struct { + uint16_t slss_id; + uint8_t *slmib; +} SLSS_t; + +typedef struct { + // SL Configuration + /// Number of SL resource blocks (1-100) + uint32_t N_SL_RB; + /// prb-start (0-99) + uint32_t prb_Start; + /// prb-End (0-99) + uint32_t prb_End; + /// SL-OffsetIndicator (0-10239) + uint32_t SL_OffsetIndicator; + /// PSCCH subframe bitmap, first 64-bits (up to 40 bits for Rel 12) + uint64_t bitmap1; + /// PSCCH subframe bitmap, 2nd 64-bits (up to 100 bits for Rel 14) + uint64_t bitmap2; + + // SCI parameters + /// npscch resource index + uint32_t n_pscch; + /// format of SCI (0,1) + uint32_t format; + /// SCI0 frequency hopping flag + uint32_t freq_hopping_flag; + /// SCI0 Resource Block Coding + uint32_t resource_block_coding; + /// SCI0 Time Resource Pattern for SLSCH + uint32_t time_resource_pattern; + /// SCI0 MCS for SLSCH + uint32_t mcs; + /// SCI0 Timing advance indication for SLSCH + uint32_t timing_advance_indication; + /// SCI0 Group Destination ID for SLSCH + uint32_t group_destination_id; + + // SLSCH Parameters + /// Number of Subbands (36.213 14.1.1.2) + uint32_t Nsb; + /// N_RB_HO (36.213 14.1.1.2) + uint32_t N_RB_HO; + /// n_ss_PSSCH (36.211 9.2.4) + uint32_t n_ss_PSSCH; + /// n_ssf_PSSCH + uint32_t n_ssf_PSSCH; + /// cinit (36.331 hoppingParameter-r12) + uint32_t cinit; + /// redundancy version + uint32_t rvidx; + /// n_prime_VRB (36.213 14.1.1.2.1) + uint32_t n_prime_VRB; + /// M_RB_PSSCH_RP (36.213 14.1.3 + uint32_t M_RB_PSSCH_RP; + /// n_prime_PRB (36.213 14.1.1.4 + uint32_t n_prime_PRB; + /// m_nprime_PRB_PSSCH (36.213 14.1.3) + uint32_t m_nprime_PRB_PSCCH; + /// payload length + int payload_length; + /// pointer to payload + uint8_t *payload; +} SLSCH_t; + +typedef struct { + /// payload length + int payload_length; + uint8_t payload[100]; +} SLDCH_t; + +#define TTI_SYNC 0 +#define SLSS 1 +#define SLDCH 2 +#define SLSCH 3 + +typedef struct UE_tport_header_s { + int packet_type; + uint16_t absSF; +} UE_tport_header_t; + +typedef struct UE_tport_s { + UE_tport_header_t header; + union { + SLSS_t slss; + SLDCH_t sldch; + SLSCH_t slsch; + }; + uint8_t payload[1500]; +} UE_tport_t; + +#endif + +/**@}*/ +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h new file mode 100644 index 0000000000000000000000000000000000000000..0cc59360b612c57a7846abe5d4378a0517b791a7 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h @@ -0,0 +1,296 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/transport_proto.h + * \brief Function prototypes for eNB PHY physical/transport channel processing and generation V8.6 2009-03 + * \author R. Knopp, F. Kaltenberger + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#ifndef __LTE_TRANSPORT_COMMON_PROTO__H__ +#define __LTE_TRANSPORT_COMMON_PROTO__H__ +#include "PHY/defs_common.h" + + + + +// Functions below implement minor procedures from 36-211 and 36-212 + +/** \brief Compute Q (modulation order) based on I_MCS PDSCH. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS */ +uint8_t get_Qm(uint8_t I_MCS); + +/** \brief Compute Q (modulation order) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213. + @param I_MCS */ +uint8_t get_Qm_ul(uint8_t I_MCS); + +/** \brief Compute I_TBS (transport-block size) based on I_MCS for PDSCH. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS */ +uint8_t get_I_TBS(uint8_t I_MCS); + +/** \brief Compute I_TBS (transport-block size) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213. + @param I_MCS */ +unsigned char get_I_TBS_UL(unsigned char I_MCS); + +/** \brief Compute Q (modulation order) based on downlink I_MCS. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS + @param nb_rb + @return Transport block size */ +uint32_t get_TBS_DL(uint8_t mcs, uint16_t nb_rb); + +/** \brief Compute Q (modulation order) based on uplink I_MCS. Implements table 7.1.7.1-1 from 36.213. + @param I_MCS + @param nb_rb + @return Transport block size */ +uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb); + +/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type + @param N_RB_DL number of PRB on DL + @param indicator for even/odd slot + @param vrb vrb index + @param Ngap Gap indicator +*/ +uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap); + +/* \brief Return prb for a given vrb index + @param vrb_type VRB type (0=localized,1=distributed) + @param rb_alloc_dci rballoc field from DCI +*/ +uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci); + + +/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type + @returns Transmission mode (1-7) +*/ +uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); + + +/* \brief + @param ra_header Header of resource allocation (0,1) (See sections 7.1.6.1/7.1.6.2 of 36.213 Rel8.6) + @param rb_alloc Bitmap allocation from DCI (format 1,2) + @returns number of physical resource blocks +*/ +uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL); + +int get_G(LTE_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe, uint8_t beamforming_mode); + +int adjust_G(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe); +int adjust_G2(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol); + + +#ifndef modOrder +#define modOrder(I_MCS,I_TBS) ((I_MCS-I_TBS)*2+2) // Find modulation order from I_TBS and I_MCS +#endif + +/** \fn uint8_t I_TBS2I_MCS(uint8_t I_TBS); + \brief This function maps I_tbs to I_mcs according to Table 7.1.7.1-1 in 3GPP TS 36.213 V8.6.0. Where there is two supported modulation orders for the same I_TBS then either high or low modulation is chosen by changing the equality of the two first comparisons in the if-else statement. + \param I_TBS Index of Transport Block Size + \return I_MCS given I_TBS +*/ +uint8_t I_TBS2I_MCS(uint8_t I_TBS); + +/** \fn uint8_t SE2I_TBS(float SE, + uint8_t N_PRB, + uint8_t symbPerRB); + \brief This function maps a requested throughput in number of bits to I_tbs. The throughput is calculated as a function of modulation order, RB allocation and number of symbols per RB. The mapping orginates in the "Transport block size table" (Table 7.1.7.2.1-1 in 3GPP TS 36.213 V8.6.0) + \param SE Spectral Efficiency (before casting to integer, multiply by 1024, remember to divide result by 1024!) + \param N_PRB Number of PhysicalResourceBlocks allocated \sa lte_frame_parms->N_RB_DL + \param symbPerRB Number of symbols per resource block allocated to this channel + \return I_TBS given an SE and an N_PRB +*/ +uint8_t SE2I_TBS(float SE, + uint8_t N_PRB, + uint8_t symbPerRB); +/** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 36.211 v8.6.0. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence. + @param frame_parms LTE DL Frame Parameters + @param soundingrs_ul_config_dedicated Dynamic configuration from RRC during Connection Establishment + @param txdataF pointer to the frequency domain TX signal + @returns 0 on success*/ + +int generate_srs(LTE_DL_FRAME_PARMS *frame_parms, + SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated, + int *txdataF, + int16_t amp, + uint32_t subframe); + + +/*! + \brief This function generates the downlink reference signal for the PUSCH according to 36.211 v8.6.0. The DRS occuies the RS defined by rb_alloc and the symbols 2 and 8 for extended CP and 3 and 10 for normal CP. +*/ + + +/*! + \brief This function initializes the Group Hopping, Sequence Hopping and nPRS sequences for PUCCH/PUSCH according to 36.211 v8.6.0. It should be called after configuration of UE (reception of SIB2/3) and initial configuration of eNB (or after reconfiguration of cell-specific parameters). + @param frame_parms Pointer to a LTE_DL_FRAME_PARMS structure (eNB or UE)*/ +void init_ul_hopping(LTE_DL_FRAME_PARMS *frame_parms); + + +int32_t compareints (const void * a, const void * b); + +uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); + +int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci); + +void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms); + +void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms); + +uint32_t check_phich_reg(LTE_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi); + +void generate_RIV_tables(void); + +/** \brief This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH subframe (Table 8.3.-1 from 36.213). + @param frame_parms Pointer to DL frame configuration parameters + @param subframe Subframe of received/transmitted PHICH + @returns subframe of PUSCH transmission +*/ +uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + +/** \brief This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH frame (Table 8.3.-1 from 36.213). + @param frame_parms Pointer to DL frame configuration parameters + @param frame Frame of received/transmitted PHICH + @param subframe Subframe of received/transmitted PHICH + @returns frame of PUSCH transmission +*/ +int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe); + +uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); + +int get_nCCE_offset_l1(int *CCE_table, + const unsigned char L, + const int nCCE, + const int common_dci, + const unsigned short rnti, + const unsigned char subframe); + +uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi); + +uint16_t get_nquad(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi); + +uint8_t get_mi(LTE_DL_FRAME_PARMS *frame,uint8_t subframe); + +uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe); + +uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + +void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]); + +/*! + \brief Check for PRACH TXop in subframe + @param frame_parms Pointer to LTE_DL_FRAME_PARMS + @param frame frame index to check + @param subframe subframe index to check + @returns 0 on success +*/ +int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe); + +/*! + \brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index + @param frame_parms Pointer to LTE_DL_FRAME_PARMS structure + @returns 0-5 depending on number of available prach +*/ +uint8_t get_num_prach_tdd(module_id_t Mod_id); + +/*! + \brief Return the PRACH format as a function of the Configuration Index and Frame type. + @param prach_ConfigIndex PRACH Configuration Index + @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); + +/*! + \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index + @param frame_parms Pointer to LTE_DL_FRAME_PARMS structure + @returns 0-5 depending on number of available prach +*/ +uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index); + +/*! + \brief Comp ute DFT of PRACH ZC sequences. Used for generation of prach in UE and reception of PRACH in eNB. + @param rootSequenceIndex PRACH root sequence + #param prach_ConfigIndex PRACH Configuration Index + @param zeroCorrelationZoneConfig PRACH ncs_config + @param highSpeedFlat PRACH High-Speed Flag + @param frame_type TDD/FDD flag + @param Xu DFT output +*/ +void compute_prach_seq(uint16_t rootSequenceIndex, + uint8_t prach_ConfigIndex, + uint8_t zeroCorrelationZoneConfig, + uint8_t highSpeedFlag, + lte_frame_type_t frame_type, + uint32_t X_u[64][839]); + + +void init_prach_tables(int N_ZC); + +/*! + \brief Return the status of MBSFN in this frame/subframe + @param frame Frame index + @param subframe Subframe index + @param frame_parms Pointer to frame parameters + @returns 1 if subframe is for MBSFN +*/ +int is_pmch_subframe(frame_t frame, int subframe, LTE_DL_FRAME_PARMS *frame_parms); + + +/** \brief This routine expands a single (wideband) PMI to subband PMI bitmap similar to the one used in the UCI and in the dlsch_modulation routine + @param frame_parms Pointer to DL frame configuration parameters + @param wideband_pmi (0,1,2,3 for rank 0 and 0,1 for rank 1) + @param rank (0 or 1) + @returns subband PMI bitmap +*/ +uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank); + +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); + +// DL power control functions +double get_pa_dB(uint8_t pa); + +void init_scrambling_lut(void); + +void init_unscrambling_lut(void); + + +uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf); + +uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); +uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); + +uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL); + +void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2); + +int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs); + +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h similarity index 55% rename from openair1/PHY/LTE_TRANSPORT/defs.h rename to openair1/PHY/LTE_TRANSPORT/transport_eNB.h index f1f4be3072c86b166168fc906a061b599aa0cfc5..3013dfb2183ece44d3f17afae72f0804b7652d2b 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h @@ -29,21 +29,18 @@ * \note * \warning */ -#ifndef __LTE_TRANSPORT_DEFS__H__ -#define __LTE_TRANSPORT_DEFS__H__ -#include "PHY/defs.h" +#ifndef __TRANSPORT_ENB__H__ +#define __TRANSPORT_ENB__H__ +#include "transport_common.h" +//#include "PHY/defs_eNB.h" #include "PHY/impl_defs_lte.h" #include "dci.h" #include "mdci.h" -#include "uci.h" +#include "uci_common.h" #ifndef STANDALONE_COMPILE #include "UTIL/LISTS/list.h" #endif -#define MOD_TABLE_QPSK_OFFSET 1 -#define MOD_TABLE_16QAM_OFFSET 5 -#define MOD_TABLE_64QAM_OFFSET 21 -#define MOD_TABLE_PSS_OFFSET 85 // structures below implement 36-211 and 36-212 @@ -53,56 +50,6 @@ -#define NSOFT 1827072 -#define LTE_NULL 2 - -// maximum of 3 segments before each coding block if data length exceeds 6144 bits. - -#define MAX_NUM_DLSCH_SEGMENTS 16 -#define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS -#define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768) -#define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768) - -#define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE -#define MAX_NUM_RE (14*1200) - -#if !defined(SI_RNTI) -#define SI_RNTI (rnti_t)0xffff -#endif -#if !defined(M_RNTI) -#define M_RNTI (rnti_t)0xfffd -#endif -#if !defined(P_RNTI) -#define P_RNTI (rnti_t)0xfffe -#endif -#if !defined(CBA_RNTI) -#define CBA_RNTI (rnti_t)0xfff4 -#endif -#if !defined(C_RNTI) -#define C_RNTI (rnti_t)0x1234 -#endif -// These are the codebook indexes according to Table 6.3.4.2.3-1 of 36.211 -//1 layer -#define PMI_2A_11 0 -#define PMI_2A_1m1 1 -#define PMI_2A_1j 2 -#define PMI_2A_1mj 3 -//2 layers -#define PMI_2A_R1_10 0 -#define PMI_2A_R1_11 1 -#define PMI_2A_R1_1j 2 - -typedef enum { SEARCH_EXIST=0, - SEARCH_EXIST_OR_FREE} find_type_t; - -typedef enum { - SCH_IDLE=0, - ACTIVE, - CBA_ACTIVE, - DISABLED -} SCH_status_t; - - typedef struct { /// Status Flag indicating for this DLSCH (idle,active,disabled) SCH_status_t status; @@ -180,92 +127,12 @@ typedef struct { uint8_t codeword; } LTE_DL_eNB_HARQ_t; -typedef struct { - /// Indicator of first transmission - uint8_t first_tx; - /// Last Ndi received for this process on DCI (used for C-RNTI only) - uint8_t DCINdi; - /// Flag indicating that this ULSCH has a new packet (start of new round) - // uint8_t Ndi; - /// Status Flag indicating for this ULSCH (idle,active,disabled) - SCH_status_t status; - /// Subframe scheduling indicator (i.e. Transmission opportunity indicator) - uint8_t subframe_scheduling_flag; - /// Subframe cba scheduling indicator (i.e. Transmission opportunity indicator) - uint8_t subframe_cba_scheduling_flag; - /// First Allocated RB - uint16_t first_rb; - /// Current Number of RBs - uint16_t nb_rb; - /// Last TPC command - uint8_t TPC; - /// Transport block size - uint32_t TBS; - /// The payload + CRC size in bits, "B" from 36-212 - uint32_t B; - /// Length of ACK information (bits) - uint8_t O_ACK; - /// Pointer to the payload - uint8_t *b; - /// Pointers to transport block segments - uint8_t *c[MAX_NUM_ULSCH_SEGMENTS]; - /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) - uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS]; - /// Index of current HARQ round for this ULSCH - uint8_t round; - /// MCS format of this ULSCH - uint8_t mcs; - /// Redundancy-version of the current sub-frame - uint8_t rvidx; - /// Turbo-code outputs (36-212 V8.6 2009-03, p.12 - uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))]; - /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17) - uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144]; - /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) - uint32_t C; - /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cminus; - /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cplus; - /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kminus; - /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kplus; - /// Total number of bits across all segments - uint32_t sumKr; - /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t F; - /// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27) - uint16_t Msc_initial; - /// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27) - uint8_t Nsymb_initial; - /// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) - uint8_t n_DMRS; - /// n_DMRS2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1) - uint8_t n_DMRS2; - /// Flag to indicate that this is a control only ULSCH (i.e. no MAC SDU) - uint8_t control_only; - /// Flag to indicate that this is a calibration ULSCH (i.e. no MAC SDU and filled with TDD calibration information) - // int calibration_flag; - /// Number of soft channel bits - uint32_t G; - - // decode phich - uint8_t decode_phich; -} LTE_UL_UE_HARQ_t; - -#ifdef Rel14 -typedef enum { - CEmodeA = 0, - CEmodeB = 1 -} CEmode_t; -#endif typedef struct { /// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding) int32_t *txdataF[8]; /// beamforming weights for UE-spec transmission (antenna ports 5 or 7..14), for each codeword, maximum 4 layers? - int32_t **ue_spec_bf_weights[4]; + int32_t **ue_spec_bf_weights[4]; /// dl channel estimates (estimated from ul channel estimates) int32_t **calib_dl_ch_estimates; /// Allocated RNTI (0 means DLSCH_t is not currently used) @@ -302,7 +169,7 @@ typedef struct { int16_t sqrt_rho_a; /// amplitude of PDSCH (compared to RS) in symbols containing pilots int16_t sqrt_rho_b; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// indicator that this DLSCH corresponds to SIB1-BR, needed for c_init for scrambling uint8_t sib1_br_flag; /// initial absolute subframe (see 36.211 Section 6.3.1), needed for c_init for scrambling @@ -311,81 +178,7 @@ typedef struct { #endif } LTE_eNB_DLSCH_t; -#define PUSCH_x 2 -#define PUSCH_y 3 -typedef struct { - /// Current Number of Symbols - uint8_t Nsymb_pusch; - /// SRS active flag - uint8_t srs_active; - /// Pointers to 8 HARQ processes for the ULSCH - LTE_UL_UE_HARQ_t *harq_processes[8]; - /// 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 "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - uint8_t e[MAX_NUM_CHANNEL_BITS]; - /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) - 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) - 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 - uint16_t beta_offset_ri_times8; - /// beta_offset_harqack times 8 - uint16_t beta_offset_harqack_times8; - /// power_offset - uint8_t power_offset; - // for cooperative communication - uint8_t cooperation_flag; - /// RNTI attributed to this ULSCH - uint16_t rnti; - /// f_PUSCH parameter for PUSCH power control - int16_t f_pusch; - /// Po_PUSCH - target output power for PUSCH - int16_t Po_PUSCH; - /// PHR - current power headroom (based on last PUSCH transmission) - int16_t PHR; - /// Po_SRS - target output power for SRS - int16_t Po_SRS; - /// num active cba group - uint8_t num_active_cba_groups; - /// num dci found for cba - uint8_t num_cba_dci[10]; - /// allocated CBA RNTI - uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; - /// UL max-harq-retransmission - uint8_t Mlimit; -} LTE_UE_ULSCH_t; typedef struct { /// Flag indicating that this ULSCH has been allocated by a DCI (otherwise it is a retransmission based on PHICH NAK) @@ -413,7 +206,7 @@ typedef struct { /// is done after a new scheduling uint16_t previous_first_rb; /// Current Number of RBs - uint16_t nb_rb; + uint16_t nb_rb; /// Current Modulation order uint8_t Qm; /// Transport block size @@ -510,38 +303,6 @@ typedef struct { int32_t delta_TF; } LTE_UL_eNB_HARQ_t; - -typedef enum { - pucch_format1=0, - pucch_format1a, - pucch_format1b, - pucch_format1b_csA2, - pucch_format1b_csA3, - pucch_format1b_csA4, - pucch_format2, - pucch_format2a, - pucch_format2b, - pucch_format3 // PUCCH format3 -} PUCCH_FMT_t; - -typedef enum { - SR, - HARQ, - CQI, - HARQ_SR, - HARQ_CQI, - SR_CQI, - HARQ_SR_CQI -} UCI_type_t; - -#ifdef Rel14 -typedef enum { - NOCE, - CEMODEA, - CEMODEB -} UE_type_t; -#endif - typedef struct { uint8_t active; /// Absolute frame for this UCI @@ -556,7 +317,7 @@ typedef struct { uint8_t srs_active; /// PUCCH format to use PUCCH_FMT_t pucch_fmt; - /// number of PUCCH antenna ports + /// number of PUCCH antenna ports uint8_t num_antenna_ports; /// number of PUCCH resources uint8_t num_pucch_resources; @@ -572,7 +333,7 @@ typedef struct { uint8_t tdd_bundling; /// Received Energy uint32_t stat; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// non BL/CE, CEmodeA, CEmodeB UE_type_t ue_type; /// Indicates the symbols that are left empty due to eMTC retuning. @@ -592,124 +353,6 @@ typedef struct { #endif } LTE_eNB_UCI; -typedef struct { - /// HARQ process mask, indicates which processes are currently active - uint16_t harq_mask; - /// Pointers to 8 HARQ processes for the ULSCH - LTE_UL_eNB_HARQ_t *harq_processes[8]; - /// Maximum number of HARQ rounds - uint8_t Mlimit; - /// Maximum number of iterations used in eNB turbo decoder - uint8_t max_turbo_iterations; - /// ACK/NAK Bundling flag - uint8_t bundling; - /// beta_offset_cqi times 8 - uint16_t beta_offset_cqi_times8; - /// beta_offset_ri times 8 - uint16_t beta_offset_ri_times8; - /// beta_offset_harqack times 8 - uint16_t beta_offset_harqack_times8; - /// Flag to indicate that eNB awaits UE Msg3 - uint8_t Msg3_active; - /// RNTI attributed to this ULSCH - uint16_t rnti; - /// cyclic shift for DM RS - uint8_t cyclicShift; - /// cooperation flag - uint8_t cooperation_flag; - /// num active cba group - uint8_t num_active_cba_groups; - /// allocated CBA RNTI for this ulsch - uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; -#ifdef LOCALIZATION - /// epoch timestamp in millisecond - int32_t reference_timestamp_ms; - /// aggregate physical states every n millisecond - int32_t aggregation_period_ms; - /// a set of lists used for localization - struct list loc_rss_list[10], loc_rssi_list[10], loc_subcarrier_rss_list[10], loc_timing_advance_list[10], loc_timing_update_list[10]; - struct list tot_loc_rss_list, tot_loc_rssi_list, tot_loc_subcarrier_rss_list, tot_loc_timing_advance_list, tot_loc_timing_update_list; -#endif -} LTE_eNB_ULSCH_t; - -typedef struct { - /// Indicator of first transmission - uint8_t first_tx; - /// Last Ndi received for this process on DCI (used for C-RNTI only) - uint8_t DCINdi; - /// DLSCH status flag indicating - SCH_status_t status; - /// Transport block size - uint32_t TBS; - /// The payload + CRC size in bits - uint32_t B; - /// Pointer to the payload - uint8_t *b; - /// Pointers to transport block segments - uint8_t *c[MAX_NUM_DLSCH_SEGMENTS]; - /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) - uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS]; - /// Index of current HARQ round for this DLSCH - uint8_t round; - /// MCS format for this DLSCH - uint8_t mcs; - /// Qm (modulation order) for this DLSCH - uint8_t Qm; - /// Redundancy-version of the current sub-frame - uint8_t rvidx; - /// MIMO mode for this DLSCH - MIMO_mode_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_DLSCH_SEGMENTS][3*(6144+64)]; - /// 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_DLSCH_SEGMENTS][3*(6144+64)]; - /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - int16_t *d[MAX_NUM_DLSCH_SEGMENTS]; - /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) - uint32_t C; - /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cminus; - /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Cplus; - /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kminus; - /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t Kplus; - /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) - uint32_t F; - /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17) - uint8_t Nl; - /// current delta_pucch - int8_t delta_PUCCH; - /// Number of soft channel bits - uint32_t G; - /// Current Number of RBs - uint16_t nb_rb; - /// Current subband PMI allocation - uint16_t pmi_alloc; - /// Current RB allocation (even slots) - uint32_t rb_alloc_even[4]; - /// Current RB allocation (odd slots) - uint32_t rb_alloc_odd[4]; - /// distributed/localized flag - vrb_t vrb_type; - /// downlink power offset field - uint8_t dl_power_off; - /// trials per round statistics - uint32_t trials[8]; - /// error statistics per round - uint32_t errors[8]; - /// codeword this transport block is mapped to - uint8_t codeword; -} LTE_DL_UE_HARQ_t; - -typedef struct { - /// time-based localization, relying on TA and TOA - double time_based; - /// power-based localization, relying on RSS and RSSI - double power_based; -} eNB_UE_estimated_distances; - typedef struct { /// UL RSSI per receive antenna int32_t UL_rssi[NB_ANTENNAS_RX]; @@ -782,92 +425,38 @@ typedef struct { int total_TBS_last; /// Bitrate on the PDSCH [bps] unsigned int dlsch_bitrate; - // unsigned int total_transmitted_bits; -#ifdef LOCALIZATION - eNB_UE_estimated_distances distance; - int32_t *subcarrier_rssi; -#endif } LTE_eNB_UE_stats; typedef struct { - /// HARQ process id - uint8_t harq_id; - /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX - uint8_t ack; - /// send status (for PUCCH) - uint8_t send_harq_status; - /// nCCE (for PUCCH) - uint8_t nCCE; - /// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched - uint8_t vDAI_DL; - /// DAI value detected from DCI0/4. 0xff indicates not touched - uint8_t vDAI_UL; -} harq_status_t; - -typedef struct { - /// RNTI - uint16_t rnti; - /// Active flag for DLSCH demodulation - uint8_t active; - /// Transmission mode - uint8_t mode1_flag; - /// amplitude of PDSCH (compared to RS) in symbols without pilots - int16_t sqrt_rho_a; - /// amplitude of PDSCH (compared to RS) in symbols containing pilots - int16_t sqrt_rho_b; - /// Current HARQ process id threadRx Odd and threadRx Even - uint8_t current_harq_pid; - /// Current subband antenna selection - uint32_t antenna_alloc; - /// Current subband RI allocation - uint32_t ri_alloc; - /// Current subband CQI1 allocation - uint32_t cqi_alloc1; - /// Current subband CQI2 allocation - uint32_t cqi_alloc2; - /// saved subband PMI allocation from last PUSCH/PUCCH report - uint16_t pmi_alloc; - /// HARQ-ACKs - harq_status_t harq_ack[10]; - /// Pointers to up to 8 HARQ processes - LTE_DL_UE_HARQ_t *harq_processes[8]; - /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17 - uint8_t Mdlharq; - /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17) - uint8_t Kmimo; - /// Nsoft parameter related to UE Category - uint32_t Nsoft; - /// Maximum number of Turbo iterations + /// HARQ process mask, indicates which processes are currently active + uint16_t harq_mask; + /// Pointers to 8 HARQ processes for the ULSCH + LTE_UL_eNB_HARQ_t *harq_processes[8]; + /// Maximum number of HARQ rounds + uint8_t Mlimit; + /// Maximum number of iterations used in eNB turbo decoder uint8_t max_turbo_iterations; - /// number of iterations used in last turbo decoding - uint8_t last_iteration_cnt; - /// accumulated tx power adjustment for PUCCH - int8_t g_pucch; -} LTE_UE_DLSCH_t; - - - -typedef enum { - SI_PDSCH=0, - RA_PDSCH, - P_PDSCH, - PDSCH, - PDSCH1, - PMCH -} PDSCH_t; - -typedef enum { - rx_standard=0, - rx_IC_single_stream, - rx_IC_dual_stream, - rx_SIC_dual_stream -} RX_type_t; - - -typedef enum { - DCI_COMMON_SPACE, - DCI_UE_SPACE -} dci_space_t; + /// ACK/NAK Bundling flag + uint8_t bundling; + /// beta_offset_cqi times 8 + uint16_t beta_offset_cqi_times8; + /// beta_offset_ri times 8 + uint16_t beta_offset_ri_times8; + /// beta_offset_harqack times 8 + uint16_t beta_offset_harqack_times8; + /// Flag to indicate that eNB awaits UE Msg3 + uint8_t Msg3_active; + /// RNTI attributed to this ULSCH + uint16_t rnti; + /// cyclic shift for DM RS + uint8_t cyclicShift; + /// cooperation flag + uint8_t cooperation_flag; + /// num active cba group + uint8_t num_active_cba_groups; + /// allocated CBA RNTI for this ulsch + uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; +} LTE_eNB_ULSCH_t; /**@}*/ diff --git a/openair1/PHY/LTE_TRANSPORT/extern.h b/openair1/PHY/LTE_TRANSPORT/transport_extern.h similarity index 95% rename from openair1/PHY/LTE_TRANSPORT/extern.h rename to openair1/PHY/LTE_TRANSPORT/transport_extern.h index e791bec9a0c27f45fd047acc46f510d590684f69..6a9fa49405a9bb3d8d3161aedc4ab4b1159b44c7 100644 --- a/openair1/PHY/LTE_TRANSPORT/extern.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_extern.h @@ -30,7 +30,7 @@ extern short *ul_ref_sigs_rx[30][2][33]; extern unsigned short dftsizes[33]; extern unsigned short ref_primes[33]; -extern int qam64_table[8],qam16_table[4]; +extern int qam64_table[8],qam16_table[4],qpsk_table[2]; extern unsigned char cs_ri_normal[4]; extern unsigned char cs_ri_extended[4]; @@ -48,3 +48,5 @@ extern int16_t d0_sss[504*62],d5_sss[504*62]; extern uint8_t wACK[5][4]; extern int8_t wACK_RX[5][4]; + +extern uint32_t bitrev_cc_dci[32]; diff --git a/openair1/PHY/LTE_TRANSPORT/transport_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_proto.h new file mode 100644 index 0000000000000000000000000000000000000000..5547c308e9c320d1ea2c003b927f2f9e1776d3e0 --- /dev/null +++ b/openair1/PHY/LTE_TRANSPORT/transport_proto.h @@ -0,0 +1,621 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/transport_proto.h + * \brief Function prototypes for eNB PHY physical/transport channel processing and generation V8.6 2009-03 + * \author R. Knopp, F. Kaltenberger + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#ifndef __LTE_TRANSPORT_PROTO__H__ +#define __LTE_TRANSPORT_PROTO__H__ +#include "PHY/defs_eNB.h" +#include <math.h> +#include "nfapi_interface.h" +#include "transport_common_proto.h" + +// Functions below implement 36-211 and 36-212 + +/** @addtogroup _PHY_TRANSPORT_ + * @{ + */ + +/** \fn free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch,unsigned char N_RB_DL) + \brief This function frees memory allocated for a particular DLSCH at eNB + @param dlsch Pointer to DLSCH to be removed +*/ +void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch); + +void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); + +/** \fn new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms) + \brief This function allocates structures for a particular DLSCH at eNB + @returns Pointer to DLSCH to be removed + @param Kmimo Kmimo factor from 36-212/36-213 + @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) + @param Nsoft Soft-LLR buffer size from UE-Category + @params N_RB_DL total number of resource blocks (determine the operating BW) + @param abstraction_flag Flag to indicate abstracted interface + @param frame_parms Pointer to frame descriptor structure +*/ +LTE_eNB_DLSCH_t *new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms); + +void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); + +/** \fn free_eNB_ulsch(LTE_eNB_DLSCH_t *dlsch) + \brief This function frees memory allocated for a particular ULSCH at eNB + @param ulsch Pointer to ULSCH to be removed +*/ +void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch); + +LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); + +int dlsch_encoding_all(PHY_VARS_eNB *eNB, + unsigned char *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats); + +/** \fn dlsch_encoding(PHY_VARS_eNB *eNB, + uint8_t *input_buffer, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe) + \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). The implemented functions are: + - CRC computation and addition + - Code block segmentation and sub-block CRC addition + - Channel coding (Turbo coding) + - Rate matching (sub-block interleaving, bit collection, selection and transmission + - Code block concatenation + @param eNB Pointer to eNB PHY context + @param input_buffer Pointer to input buffer for sub-frame + @param frame_parms Pointer to frame descriptor structure + @param num_pdcch_symbols Number of PDCCH symbols in this subframe + @param dlsch Pointer to dlsch to be encoded + @param frame Frame number + @param subframe Subframe number + @param rm_stats Time statistics for rate-matching + @param te_stats Time statistics for turbo-encoding + @param i_stats Time statistics for interleaving + @returns status +*/ +int32_t dlsch_encoding(PHY_VARS_eNB *eNB, + uint8_t *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *i_stats); + + + + +/** \fn dlsch_encoding_2threads(PHY_VARS_eNB *eNB, + uint8_t *input_buffer, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe) + \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). This version spawns 1 worker thread. The implemented functions are: + - CRC computation and addition + - Code block segmentation and sub-block CRC addition + - Channel coding (Turbo coding) + - Rate matching (sub-block interleaving, bit collection, selection and transmission + - Code block concatenation + @param eNB Pointer to eNB PHY context + @param input_buffer Pointer to input buffer for sub-frame + @param num_pdcch_symbols Number of PDCCH symbols in this subframe + @param dlsch Pointer to dlsch to be encoded + @param frame Frame number + @param subframe Subframe number + @param rm_stats Time statistics for rate-matching + @param te_stats Time statistics for turbo-encoding + @param i_stats Time statistics for interleaving + @returns status +*/ +int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, + uint8_t *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, + time_stats_t *i_stats, + int worker_num); + +// Functions below implement 36-211 + +/** \fn allocate_REs_in_RB(int32_t **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + int16_t *qam_table_s, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t use2ndpilots, + LTE_DL_FRAME_PARMS *frame_parms); + + \brief Fills RB with data + \param txdataF pointer to output data (frequency domain signal) + \param jj index to output (from CW 1) + \param jj index to output (from CW 2) + \param re_offset index of the first RE of the RB + \param symbol_offset index to the OFDM symbol + \param dlsch0_harq Pointer to Transport block 0 HARQ structure + \param dlsch0_harq Pointer to Transport block 1 HARQ structure + \param pilots =1 if symbol_offset is an OFDM symbol that contains pilots, 0 otherwise + \param amp Amplitude for symbols + \param qam_table_s0 pointer to scaled QAM table for Transport Block 0 (by rho_a or rho_b) + \param qam_table_s1 pointer to scaled QAM table for Transport Block 1 (by rho_a or rho_b) + \param re_allocated pointer to allocation counter + \param skip_dc offset for positive RBs + \param skip_half indicate that first or second half of RB must be skipped for PBCH/PSS/SSS + \param use2ndpilots Set to use the pilots from antenna port 1 for PDSCH + \param frame_parms Frame parameter descriptor +*/ + +int32_t allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, + int32_t **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + uint8_t precoder_index, + int16_t *qam_table_s0, + int16_t *qam_table_s1, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t lprime, + uint8_t mprime, + uint8_t Ns, + int *P1_SHIFT, + int *P2_SHIFT); + + +/** \fn int32_t dlsch_modulation(int32_t **txdataF, + int16_t amp, + uint32_t sub_frame_offset, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch); + + \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for DLSCH. + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param sub_frame_offset Offset of this subframe in units of subframes (usually 0) + @param frame_parms Pointer to frame descriptor + @param num_pdcch_symbols Number of PDCCH symbols in this subframe + @param dlsch0 Pointer to Transport Block 0 DLSCH descriptor for this allocation + @param dlsch1 Pointer to Transport Block 0 DLSCH descriptor for this allocation +*/ +int32_t dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, + int32_t **txdataF, + int16_t amp, + uint32_t sub_frame_offset, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch0, + LTE_eNB_DLSCH_t *dlsch1); + +int32_t dlsch_modulation_SIC(int32_t **sic_buffer, + uint32_t sub_frame_offset, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch0, + int G); +/* + \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for MCH. + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param subframe_offset Offset of this subframe in units of subframes (usually 0) + @param frame_parms Pointer to frame descriptor + @param dlsch Pointer to DLSCH descriptor for this allocation +*/ +int mch_modulation(int32_t **txdataF, + int16_t amp, + uint32_t subframe_offset, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_eNB_DLSCH_t *dlsch); + +/** \brief Top-level generation function for eNB TX of MBSFN + @param phy_vars_eNB Pointer to eNB variables + @param a Pointer to transport block + @param abstraction_flag + +*/ +void generate_mch(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,uint8_t *a); + +/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) + @param phy_vars_eNB Pointer to eNB variables + @param proc Pointer to RXn-TXnp4 proc information + @param mcs MCS for MBSFN + @param ndi new data indicator + @param rdvix +*/ +void fill_eNB_dlsch_MCH(PHY_VARS_eNB *phy_vars_eNB,int mcs,int ndi,int rvidx); + +/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) + @param phy_vars_ue Pointer to UE variables + @param mcs MCS for MBSFN + @param eNB_id index of eNB in ue variables +*/ + +/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) + for N subframes. + @param phy_vars_eNB Pointer to eNB variables + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param N Number of sub-frames to generate +*/ +void generate_pilots(PHY_VARS_eNB *phy_vars_eNB, + int32_t **txdataF, + int16_t amp, + uint16_t N); + +/** + \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) for one slot only + @param phy_vars_eNB Pointer to eNB variables + @param txdataF Table of pointers for frequency-domain TX signals + @param amp Amplitude of signal + @param slot index (0..19) + @param first_pilot_only (0 no) +*/ +int32_t generate_pilots_slot(PHY_VARS_eNB *phy_vars_eNB, + int32_t **txdataF, + int16_t amp, + uint16_t slot, + int first_pilot_only); + +int32_t generate_mbsfn_pilot(PHY_VARS_eNB *phy_vars_eNB, + eNB_rxtx_proc_t *proc, + int32_t **txdataF, + int16_t amp); + +void generate_ue_spec_pilots(PHY_VARS_eNB *phy_vars_eNB, + uint8_t UE_id, + int32_t **txdataF, + int16_t amp, + uint16_t Ntti, + uint8_t beamforming_mode); + +int32_t generate_pss(int32_t **txdataF, + int16_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + uint16_t l, + uint16_t Ns); + + +int32_t generate_sss(int32_t **txdataF, + short amp, + LTE_DL_FRAME_PARMS *frame_parms, + unsigned short symbol, + unsigned short slot_offset); + +int32_t generate_pbch(LTE_eNB_PBCH *eNB_pbch, + int32_t **txdataF, + int32_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t *pbch_pdu, + uint8_t frame_mod4); + + + + +/*! \brief DCI Encoding. This routine codes an arbitrary DCI PDU after appending the 8-bit 3GPP CRC. It then applied sub-block interleaving and rate matching. + \param a Pointer to DCI PDU (coded in bytes) + \param A Length of DCI PDU in bits + \param E Length of DCI PDU in coded bits + \param e Pointer to sequence + \param rnti RNTI for CRC scrambling*/ +void dci_encoding(uint8_t *a, + uint8_t A, + uint16_t E, + uint8_t *e, + uint16_t rnti); + +/*! \brief Top-level DCI entry point. This routine codes an set of DCI PDUs and performs PDCCH modulation, interleaving and mapping. + \param num_dci Number of pdcch symbols + \param num_dci Number of DCI pdus to encode + \param dci_alloc Allocation vectors for each DCI pdu + \param n_rnti n_RNTI (see ) + \param amp Amplitude of QPSK symbols + \param frame_parms Pointer to DL Frame parameter structure + \param txdataF Pointer to tx signal buffers + \param sub_frame_offset subframe offset in frame + @returns Number of PDCCH symbols +*/ + +uint8_t generate_dci_top(uint8_t num_pdcch_symbols, + uint8_t num_dci, + DCI_ALLOC_t *dci_alloc, + uint32_t n_rnti, + int16_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t **txdataF, + uint32_t sub_frame_offset); + + +void generate_64qam_table(void); +void generate_16qam_table(void); + + + + + + + + +void ulsch_extract_rbs_single(int32_t **rxdataF, + int32_t **rxdataF_ext, + uint32_t first_rb, + uint32_t nb_rb, + uint8_t l, + uint8_t Ns, + LTE_DL_FRAME_PARMS *frame_parms); + + + + + +void fill_dci_and_dlsch(PHY_VARS_eNB *eNB, + int frame, + int subframe, + eNB_rxtx_proc_t *proc, + DCI_ALLOC_t *dci_alloc, + nfapi_dl_config_dci_dl_pdu *pdu); + +void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *dci_alloc,nfapi_dl_config_mpdcch_pdu *pdu); + +void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, + nfapi_hi_dci0_dci_pdu *pdu); + +void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe); + +int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, + unsigned char *rar_pdu, + uint32_t frame, + unsigned char subframe); + +int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *PHY_vars_eNB, + eNB_rxtx_proc_t *proc, + void *dci_pdu, + rnti_t rnti, + DCI_format_t dci_format, + uint8_t UE_id, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint16_t cba_rnti, + uint8_t use_srs); + + +void dump_ulsch(PHY_VARS_eNB *phy_vars_eNB,int frame, int subframe, uint8_t UE_id,int round); + + + + + +void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + uint8_t *b, + uint8_t *bt); + + +void generate_pcfich(uint8_t num_pdcch_symbols, + int16_t amp, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t **txdataF, + uint8_t subframe); + + + + + +void init_transport_channels(uint8_t); + + + +void rx_ulsch(PHY_VARS_eNB *eNB, + eNB_rxtx_proc_t *proc, + uint8_t UE_id); + + +int ulsch_decoding_data_all(PHY_VARS_eNB *eNB, + int UE_id, + int harq_pid, + int llr8_flag); + +/*! + \brief Decoding of PUSCH/ACK/RI/ACK from 36-212. + @param phy_vars_eNB Pointer to eNB top-level descriptor + @param proc Pointer to RXTX proc variables + @param UE_id ID of UE transmitting this PUSCH + @param subframe Index of subframe for PUSCH + @param control_only_flag Receive PUSCH with control information only + @param Nbundled Nbundled parameter for ACK/NAK scrambling from 36-212/36-213 + @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used + @returns 0 on success +*/ +unsigned int ulsch_decoding(PHY_VARS_eNB *phy_vars_eNB, + eNB_rxtx_proc_t *proc, + uint8_t UE_id, + uint8_t control_only_flag, + uint8_t Nbundled, + uint8_t llr8_flag); + +/*! + \brief Decoding of ULSCH data component from 36-212. This one spawns 1 worker thread in parallel,half of the segments in each thread. + @param phy_vars_eNB Pointer to eNB top-level descriptor + @param UE_id ID of UE transmitting this PUSCH + @param harq_pid HARQ process ID + @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used + @returns 0 on success +*/ +int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB, + int UE_id, + int harq_pid, + int llr8_flag); + +/*! + \brief Decoding of ULSCH data component from 36-212. This one is single thread. + @param phy_vars_eNB Pointer to eNB top-level descriptor + @param UE_id ID of UE transmitting this PUSCH + @param harq_pid HARQ process ID + @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used + @returns 0 on success +*/ +int ulsch_decoding_data(PHY_VARS_eNB *eNB, + int UE_id, + int harq_pid, + int llr8_flag); + +void generate_phich_top(PHY_VARS_eNB *phy_vars_eNB, + eNB_rxtx_proc_t *proc, + int16_t amp); + + + + + + + +void pdcch_interleaving(LTE_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi); + +void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + int8_t* llr, + uint32_t length); + + +void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, + int mbsfn_flag, + LTE_eNB_DLSCH_t *dlsch, + int hard_pid, + int G, + uint8_t q, + uint16_t frame, + uint8_t Ns); + + + +uint32_t rx_pucch(PHY_VARS_eNB *phy_vars_eNB, + PUCCH_FMT_t fmt, + uint8_t UE_id, + uint16_t n1_pucch, + uint16_t n2_pucch, + uint8_t shortened_format, + uint8_t *payload, + int frame, + uint8_t subframe, + uint8_t pucch1_thres); + + +/*! + \brief Process PRACH waveform + @param phy_vars_eNB Pointer to eNB top-level descriptor. If NULL, then this is an RRU + @param ru Pointer to RU top-level descriptor. If NULL, then this is an eNB and we make use of the RU_list + @param max_preamble most likely preamble + @param max_preamble_energy Estimated Energy of most likely preamble + @param max_preamble_delay Estimated Delay of most likely preamble + @param Nf System frame number + @param tdd_mapindex Index of PRACH resource in Table 5.7.1-4 (TDD) + @param br_flag indicator to act on eMTC PRACH + @returns 0 on success + +*/ +void rx_prach(PHY_VARS_eNB *phy_vars_eNB,RU_t *ru, + uint16_t *max_preamble, + uint16_t *max_preamble_energy, + uint16_t *max_preamble_delay, + uint16_t Nf, uint8_t tdd_mapindex +#ifdef Rel14 + , + uint8_t br_flag +#endif + ); + + +void init_unscrambling_lut(void); + + + +uint8_t is_not_pilot(uint8_t pilots, uint8_t re, uint8_t nushift, uint8_t use2ndpilots); + +uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, uint8_t beamforming_mode); + + + +double computeRhoA_eNB(uint8_t pa, + LTE_eNB_DLSCH_t *dlsch_eNB, + int dl_power_off, + uint8_t n_antenna_port); + +double computeRhoB_eNB(uint8_t pa, + uint8_t pb, + uint8_t n_antenna_port, + LTE_eNB_DLSCH_t *dlsch_eNB, + int dl_power_off); + + + +void conv_eMTC_rballoc(uint16_t resource_block_coding, + uint32_t N_RB_DL, + uint32_t *rb_alloc); + +int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); + +int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); + +int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); + +/**@}*/ +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/vars.h b/openair1/PHY/LTE_TRANSPORT/transport_vars.h similarity index 88% rename from openair1/PHY/LTE_TRANSPORT/vars.h rename to openair1/PHY/LTE_TRANSPORT/transport_vars.h index 4b6fa920ea76b863d1e6d2b0f5b8dae19c9c9ea1..611028e1e9805d748de9c9c4f77ba0b8856b2170 100644 --- a/openair1/PHY/LTE_TRANSPORT/vars.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_vars.h @@ -62,7 +62,7 @@ unsigned char ue_power_offsets[25] = {14,11,9,8,7,6,6,5,4,4,4,3,3,3,2,2,2,1,1,1, short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; -int qam64_table[8],qam16_table[4]; +int qam64_table[8],qam16_table[4],qpsk_table[2]; unsigned char cs_ri_normal[4] = {1,4,7,10}; unsigned char cs_ri_extended[4] = {0,3,5,8}; @@ -78,3 +78,11 @@ char dci_format_strings[15][13] = {"0","1","1A","1B","1C","1D","1E_2A_M10PRB", uint8_t wACK[5][4] = {{1,1,1,1},{1,0,1,0},{1,1,0,0},{1,0,0,1},{0,0,0,0}}; int8_t wACK_RX[5][4] = {{-1,-1,-1,-1},{-1,1,-1,1},{-1,-1,1,1},{-1,1,1,-1},{1,1,1,1}}; + +uint32_t bitrev_cc_dci[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30}; + +uint8_t pcfich_b[4][32]= {{0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1}, + {1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0}, + {1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +}; diff --git a/openair1/PHY/LTE_TRANSPORT/uci.h b/openair1/PHY/LTE_TRANSPORT/uci_common.h similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/uci.h rename to openair1/PHY/LTE_TRANSPORT/uci_common.h index c7741533da543b909aa00bbaad4151274b210595..78555d4928c2f8b45f95092212ddc9ff36c924cd 100644 --- a/openair1/PHY/LTE_TRANSPORT/uci.h +++ b/openair1/PHY/LTE_TRANSPORT/uci_common.h @@ -19,6 +19,8 @@ * contact@openairinterface.org */ +#ifndef __UCI_COMMON__H +#define __UCI_COMMON__H #include "PHY/types.h" @@ -318,3 +320,5 @@ HLC_subband_cqi_mcs_CBA_20MHz; #define MAX_CQI_BYTES (sizeof(HLC_subband_cqi_rank2_2A_20MHz)) #define MAX_ACK_PAYLOAD 18 #define MAX_RI_PAYLOAD 6 + +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/uci_tools.c b/openair1/PHY/LTE_TRANSPORT/uci_tools.c index 65640e2ec713331c9531e5b852dd953a45707bea..539d5476ab8a92ff67b9ec8e36f1a685e2551fd1 100644 --- a/openair1/PHY/LTE_TRANSPORT/uci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/uci_tools.c @@ -29,765 +29,13 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" #ifdef DEBUG_UCI_TOOLS #include "PHY/vars.h" #endif //#define DEBUG_UCI 1 -uint64_t pmi2hex_2Ar1(uint32_t pmi) -{ - - uint64_t pmil = (uint64_t)pmi; - - return ((pmil&3) + (((pmil>>2)&3)<<4) + (((pmil>>4)&3)<<8) + (((pmil>>6)&3)<<12) + - (((pmil>>8)&3)<<16) + (((pmil>>10)&3)<<20) + (((pmil>>12)&3)<<24) + - (((pmil>>14)&3)<<28) + (((pmil>>16)&3)<<32) + (((pmil>>18)&3)<<36) + - (((pmil>>20)&3)<<40) + (((pmil>>22)&3)<<44) + (((pmil>>24)&3)<<48)); -} - -uint64_t pmi2hex_2Ar2(uint32_t pmi) -{ - - uint64_t pmil = (uint64_t)pmi; - return ((pmil&1) + (((pmil>>1)&1)<<4) + (((pmil>>2)&1)<<8) + (((pmil>>3)&1)<<12) + - (((pmil>>4)&1)<<16) + (((pmil>>5)&1)<<20) + (((pmil>>6)&1)<<24) + - (((pmil>>7)&1)<<28) + (((pmil>>8)&1)<<32) + (((pmil>>9)&1)<<36) + - (((pmil>>10)&1)<<40) + (((pmil>>11)&1)<<44) + (((pmil>>12)&1)<<48)); -} - -uint64_t cqi2hex(uint32_t cqi) -{ - - uint64_t cqil = (uint64_t)cqi; - return ((cqil&3) + (((cqil>>2)&3)<<4) + (((cqil>>4)&3)<<8) + (((cqil>>6)&3)<<12) + - (((cqil>>8)&3)<<16) + (((cqil>>10)&3)<<20) + (((cqil>>12)&3)<<24) + - (((cqil>>14)&3)<<28) + (((cqil>>16)&3)<<32) + (((cqil>>18)&3)<<36) + - (((cqil>>20)&3)<<40) + (((cqil>>22)&3)<<44) + (((cqil>>24)&3)<<48)); -} - -//void do_diff_cqi(uint8_t N_RB_DL, -// uint8_t *DL_subband_cqi, -// uint8_t DL_cqi, -// uint32_t diffcqi1) { -// -// uint8_t nb_sb,i,offset; -// -// // This is table 7.2.1-3 from 36.213 (with k replaced by the number of subbands, nb_sb) -// switch (N_RB_DL) { -// case 6: -// nb_sb=0; -// break; -// case 15: -// nb_sb = 4; -// case 25: -// nb_sb = 7; -// break; -// case 50: -// nb_sb = 9; -// break; -// case 75: -// nb_sb = 10; -// break; -// case 100: -// nb_sb = 13; -// break; -// default: -// nb_sb=0; -// break; -// } -// -// memset(DL_subband_cqi,0,13); -// -// for (i=0;i<nb_sb;i++) { -// offset = (DL_cqi>>(2*i))&3; -// if (offset == 3) -// DL_subband_cqi[i] = DL_cqi - 1; -// else -// DL_subband_cqi[i] = DL_cqi + offset; -// } -//} - - -void do_diff_cqi(uint8_t N_RB_DL, - uint8_t *DL_subband_cqi, - uint8_t DL_cqi, - uint32_t diffcqi1) -{ - - uint8_t nb_sb,i,offset; - - // This is table 7.2.1-3 from 36.213 (with k replaced by the number of subbands, nb_sb) - switch (N_RB_DL) { - case 6: - nb_sb=1; - break; - - case 15: - nb_sb = 4; - break; - - case 25: - nb_sb = 7; - break; - - case 50: - nb_sb = 9; - break; - - case 75: - nb_sb = 10; - break; - - case 100: - nb_sb = 13; - break; - - default: - nb_sb=0; - break; - } - - memset(DL_subband_cqi,0,13); - - for (i=0; i<nb_sb; i++) { - offset = (diffcqi1>>(2*i))&3; - - if (offset == 3) - DL_subband_cqi[i] = DL_cqi - 1; - else - DL_subband_cqi[i] = DL_cqi + offset; - } -} - -void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats, uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode) -{ - - //unsigned char rank; - //UCI_format fmt; - //uint8_t N_RB_DL = 25; - uint8_t i; - LOG_D(PHY,"[eNB][UCI] N_RB_DL %d uci format %d\n", N_RB_DL,uci_format); - - switch(N_RB_DL) { - case 6: - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_1_5MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (rb %d)\n",N_RB_DL); - break; - } - - break; - - case 25: - - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_5MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_5MHz *)o)->pmi; - //this translates the 2-layer PMI into a single layer PMI for the first codeword - //the PMI for the second codeword will be stats->DL_pmi_single^0x1555 - stats->DL_pmi_single = 0; - for (i=0;i<7;i++) - stats->DL_pmi_single = stats->DL_pmi_single | (((stats->DL_pmi_dual&(1<i))>>i)*2)<<2*i; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (rb %d)\n",N_RB_DL); - break; - } - - break; - - case 50: - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_10MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_10MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_10MHz *)o)->pmi; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (RB %d)\n",N_RB_DL); - break; - } - - break; - - case 100: - switch(uci_format) { - case wideband_cqi_rank1_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_20MHz *)o)->pmi; - break; - - case wideband_cqi_rank2_2A: - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_20MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_20MHz *)o)->pmi; - break; - - case HLC_subband_cqi_nopmi: - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1); - break; - - case HLC_subband_cqi_rank1_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi; - break; - - case HLC_subband_cqi_rank2_2A: - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1); - - if (stats->DL_cqi[0] > 24) - stats->DL_cqi[0] = 24; - - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2); - - if (stats->DL_cqi[1] > 24) - stats->DL_cqi[1] = 24; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi; - break; - - case unknown_cqi: - default: - LOG_N(PHY,"[eNB][UCI] received unknown uci (RB %d)\n",N_RB_DL); - break; - } - - break; - - default: - LOG_N(PHY,"[eNB][UCI] unknown RB %d\n",N_RB_DL); - break; - } - - /* - switch (tmode) { - - case 1: - case 2: - case 3: - case 5: - case 6: - case 7: - default: - fmt = hlc_cqi; - break; - case 4: - fmt = wideband_cqi; - break; - } - - rank = o_RI[0]; - //printf("extract_CQI: rank = %d\n",rank); - - switch (fmt) { - - case wideband_cqi: //and subband pmi - if (rank == 0) { - stats->DL_cqi[0] = (((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - stats->DL_pmi_single = ((wideband_cqi_rank1_2A_5MHz *)o)->pmi; - } - else { - stats->DL_cqi[0] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - stats->DL_cqi[1] = (((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - if (stats->DL_cqi[1] > 15) - stats->DL_cqi[1] = 15; - stats->DL_pmi_dual = ((wideband_cqi_rank2_2A_5MHz *)o)->pmi; - } - break; - case hlc_cqi: - if (tmode > 2) { - if (rank == 0) { - stats->DL_cqi[0] = (((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - stats->DL_pmi_single = ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi; - } - else { - stats->DL_cqi[0] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - stats->DL_cqi[1] = (((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - if (stats->DL_cqi[1] > 15) - stats->DL_cqi[1] = 15; - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[1],stats->DL_cqi[1],(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - stats->DL_pmi_dual = ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi; - } - } - else { - stats->DL_cqi[0] = (((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1); - if (stats->DL_cqi[0] > 15) - stats->DL_cqi[0] = 15; - - do_diff_cqi(N_RB_DL,stats->DL_subband_cqi[0],stats->DL_cqi[0],((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1); - - } - break; - default: - break; - } - */ - -} - - -void print_CQI(void *o,UCI_format_t uci_format,unsigned char eNB_id,int N_RB_DL) -{ - - - switch(uci_format) { - case wideband_cqi_rank1_2A: -#ifdef DEBUG_UCI - LOG_D(PHY,"[PRINT CQI] flat_LA %d\n", flag_LA); - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi)); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_5MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)o)->pmi)); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_10MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_10MHz *)o)->pmi)); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, - ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, - ((wideband_cqi_rank1_2A_20MHz *)o)->pmi, - pmi2hex_2Ar1(((wideband_cqi_rank1_2A_20MHz *)o)->pmi)); - break; - } - -#endif //DEBUG_UCI - break; - - case wideband_cqi_rank2_2A: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi)); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_5MHz *)o)->pmi)); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_10MHz *)o)->pmi)); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_20MHz *)o)->pmi)); - break; - } - -#endif //DEBUG_UCI - break; - - case HLC_subband_cqi_nopmi: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1)); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1)); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1)); - break; - } - -#endif //DEBUG_UCI - break; - - case HLC_subband_cqi_rank1_2A: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - break; - } - -#endif //DEBUG_UCI - break; - - case HLC_subband_cqi_rank2_2A: -#ifdef DEBUG_UCI - switch(N_RB_DL) { - case 6: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi); - break; - - case 25: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi); - break; - - case 50: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi); - break; - - case 100: - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2)); - LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi); - break; - } - -#endif //DEBUG_UCI - break; - - case ue_selected: -#ifdef DEBUG_UCI - LOG_W(PHY,"[PRINT CQI] ue_selected CQI not supported yet!!!\n"); -#endif //DEBUG_UCI - break; - - default: -#ifdef DEBUG_UCI - LOG_E(PHY,"[PRINT CQI] unsupported CQI mode (%d)!!!\n",uci_format); -#endif //DEBUG_UCI - break; - } - - /* - switch (tmode) { - - case 1: - case 2: - case 3: - case 5: - case 6: - case 7: - default: - fmt = hlc_cqi; - break; - case 4: - fmt = wideband_cqi; - break; - } - - switch (fmt) { - - case wideband_cqi: - if (rank == 0) { - #ifdef DEBUG_UCI - msg("[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id,((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id,((wideband_cqi_rank1_2A_5MHz *)o)->pmi,pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)o)->pmi)); - #endif //DEBUG_UCI - } - else { - #ifdef DEBUG_UCI - msg("[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); - msg("[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_5MHz *)o)->pmi)); - #endif //DEBUG_UCI - } - break; - case hlc_cqi: - if (tmode > 2) { - if (rank == 0) { - #ifdef DEBUG_UCI - msg("[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - msg("[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); - #endif //DEBUG_UCI - } - else { - #ifdef DEBUG_UCI - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); - msg("[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi); - #endif //DEBUG_UCI - } - } - else { - #ifdef DEBUG_UCI - msg("[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); - msg("[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); - #endif //DEBUG_UCI - } - break; - case ue_selected: - #ifdef DEBUG_UCI - msg("dci_tools.c: print_CQI ue_selected CQI not supported yet!!!\n"); - #endif //DEBUG_UCI - break; - } - */ - -} - int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type) { uint8_t i; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 0d9bf8fd7611b89703fcfed195490a30294570ed..50f469011f0237923c090dc48c0c59d8492d0cf7 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -30,22 +30,22 @@ * \warning */ -//#include "defs.h" - -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/extern.h" -#include "extern.h" -#include "SCHED/extern.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" -#endif + +#include <syscall.h> +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_extern.h" +#include "SCHED/sched_eNB.h" +#include "LAYER2/MAC/mac.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_ULSCH_DECODING +#include "targets/RT/USER/rt_wrapper.h" +#include "transport_proto.h" + +extern int codingw; void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch) { @@ -221,8 +221,6 @@ uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH) - - int ulsch_decoding_data_2thread0(td_params* tdp) { PHY_VARS_eNB *eNB = tdp->eNB; @@ -414,13 +412,20 @@ int ulsch_decoding_data_2thread0(td_params* tdp) { extern int oai_exit; void *td_thread(void *param) { - pthread_setname_np( pthread_self(), "td processing"); PHY_VARS_eNB *eNB = ((td_params*)param)->eNB; eNB_proc_t *proc = &eNB->proc; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + thread_top_init("td_thread",1,200000,250000,500000); + pthread_setname_np( pthread_self(),"td processing"); + LOG_I(PHY,"thread td created id=%ld\n", syscall(__NR_gettid)); + //wait_sync("td_thread"); while (!oai_exit) { if (wait_on_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread")<0) break; + if(oai_exit) break; ((td_params*)param)->ret = ulsch_decoding_data_2thread0((td_params*)param); @@ -623,6 +628,7 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr break; } stop_meas(&eNB->ulsch_turbo_decoding_stats); + //printf("/////////////////////////////////////////**************************loop for %d time in ulsch_decoding main\n",r); } // wait for worker to finish @@ -782,6 +788,20 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) return(ret); } +int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) +{ + int ret = 0; + /*if(codingw) + { + ret = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); + } + else*/ + { + ret = ulsch_decoding_data(eNB,UE_id,harq_pid,llr8_flag); + } + return ret; +} + static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2, unsigned char reset) __attribute__((always_inline)); static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2, unsigned char reset) { diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 920d8ff3fdbdfd1505d6f7e059217ec844bd632e..0ffe3d735b23f86748fac00508501f9d24c07c65 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -30,12 +30,14 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "transport_eNB.h" //#define DEBUG_ULSCH #include "PHY/sse_intrin.h" +#include "transport_common_proto.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/MODULATION/modulation_eNB.h" #include "T.h" @@ -1104,7 +1106,7 @@ void ulsch_channel_level(int32_t **drs_ch_estimates_ext, int ulsch_power_LUT[750]; -void init_ulsch_power_LUT() { +void init_ulsch_power_LUT(void) { int i; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..82dedd9bc999895101ce99aeb0b00879227e8867 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_tools_ue.c @@ -0,0 +1,5160 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_UE_TRANSPORT/dci_tools_ue.c + * \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler. + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#ifdef DEBUG_DCI_TOOLS +#include "PHY/phy_vars.h" +#endif +#include "assertions.h" + + +//#define DEBUG_HARQ + + +#include "LAYER2/MAC/mac.h" + +//#define DEBUG_DCI + +#include "../LTE_TRANSPORT/dci_tools_common_extern.h" +#include "../LTE_TRANSPORT/transport_proto.h" +#include "transport_proto_ue.h" +#include "../LTE_TRANSPORT/transport_common_proto.h" +#include "SCHED/sched_common.h" + +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) +{ + uint8_t harq_pid=0; + uint32_t rballoc=0; + uint8_t vrb_type=0; + uint8_t mcs=0; + uint8_t rv=0; + uint8_t ndi=0; + uint8_t TPC=0; + + uint8_t dai=0; + + switch (N_RB_DL) { + case 6: + if (frame_type == TDD) { + vrb_type = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; + // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } + break; + + case 25: + + if (frame_type == TDD) { + vrb_type = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai; + //printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_5MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_5MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } + + break; + + case 50: + if (frame_type == TDD) { + vrb_type = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai; + // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_10MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_10MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_10MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, vrb_type %d, rballoc %x,ndi %d, rv %d, TPC %d\n",mcs,vrb_type,rballoc,ndi,rv,TPC); + } + break; + + case 100: + if (frame_type == TDD) { + vrb_type = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; + rv = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rv; + ndi = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->ndi; + TPC = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid; + dai = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai; + // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } else { + vrb_type = ((DCI1A_20MHz_FDD_t *)dci_pdu)->vrb_type; + mcs = ((DCI1A_20MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv; + ndi = ((DCI1A_20MHz_FDD_t *)dci_pdu)->ndi; + TPC = ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC; + harq_pid = ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid; + //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); + } + break; + } + + pdci_info_extarcted->vrb_type = vrb_type; + pdci_info_extarcted->mcs1 = mcs; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->rv1 = rv; + pdci_info_extarcted->ndi1 = ndi; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->harq_pid = harq_pid; + 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) +{ + + uint32_t rballoc=0; + uint8_t mcs=0; + + switch (N_RB_DL) { + case 6: + mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); + + break; + + case 25: + mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); + + break; + + case 50: + mcs = ((DCI1C_10MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_10MHz_t *)dci_pdu)->rballoc,6); + + break; + + case 100: + mcs = ((DCI1C_20MHz_t *)dci_pdu)->mcs; + rballoc = conv_1C_RIV(((DCI1C_20MHz_t *)dci_pdu)->rballoc,6); + break; + + default: + AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",N_RB_DL); + break; + } + + pdci_info_extarcted->mcs1 = mcs; + pdci_info_extarcted->rballoc = rballoc; +} + +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) +{ + + uint32_t rballoc=0; + uint8_t mcs=0; + uint8_t rah=0; + uint8_t rv=0; + uint8_t TPC=0; + uint8_t ndi=0; + uint8_t harq_pid=0; + + switch (N_RB_DL) { + case 6: + if (frame_type == TDD) { + mcs = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + + case 25: + if (frame_type == TDD) { + mcs = ((DCI1_5MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_5MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_5MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_5MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_5MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_5MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_5MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_5MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_5MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_5MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_5MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_5MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_5MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + + case 50: + if (frame_type == TDD) { + mcs = ((DCI1_10MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_10MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_10MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_10MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_10MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_10MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_10MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_10MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_10MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_10MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_10MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_10MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_10MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_10MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + + case 100: + if (frame_type == TDD) { + mcs = ((DCI1_20MHz_TDD_t *)dci_pdu)->mcs; + rballoc = ((DCI1_20MHz_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI1_20MHz_TDD_t *)dci_pdu)->rah; + rv = ((DCI1_20MHz_TDD_t *)dci_pdu)->rv; + TPC = ((DCI1_20MHz_TDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_20MHz_TDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_20MHz_TDD_t *)dci_pdu)->harq_pid; + } else { + mcs = ((DCI1_20MHz_FDD_t *)dci_pdu)->mcs; + rah = ((DCI1_20MHz_FDD_t *)dci_pdu)->rah; + rballoc = ((DCI1_20MHz_FDD_t *)dci_pdu)->rballoc; + rv = ((DCI1_20MHz_FDD_t *)dci_pdu)->rv; + TPC = ((DCI1_20MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI1_20MHz_FDD_t *)dci_pdu)->ndi; + harq_pid = ((DCI1_20MHz_FDD_t *)dci_pdu)->harq_pid; + } + + break; + } + + pdci_info_extarcted->mcs1 = mcs; + pdci_info_extarcted->rah = rah; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->rv1 = rv; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->ndi1 = ndi; + pdci_info_extarcted->harq_pid = harq_pid; + +} + +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) +{ + + uint32_t rballoc=0; + uint8_t rah=0; + uint8_t mcs1=0; + uint8_t mcs2=0; + uint8_t rv1=0; + uint8_t rv2=0; + uint8_t ndi1=0; + uint8_t ndi2=0; + uint8_t tbswap=0; + uint8_t tpmi=0; + uint8_t harq_pid=0; + uint8_t TPC=0; + + switch (N_RB_DL) { + + case 6: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + + case 25: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + + case 50: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + + case 100: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + rah = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi2; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + rah = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi2; + } else { + rah = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rah; + mcs1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv2; + harq_pid = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->TPC; + ndi1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi2; + } + } else { + LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); + } + + break; + } + + pdci_info_extarcted->rah = rah; + pdci_info_extarcted->mcs1 = mcs1; + pdci_info_extarcted->mcs2 = mcs2; + pdci_info_extarcted->rv1 = rv1; + pdci_info_extarcted->rv2 = rv2; + pdci_info_extarcted->harq_pid = harq_pid; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->tb_swap = tbswap; + pdci_info_extarcted->tpmi = tpmi; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->ndi1 = ndi1; + pdci_info_extarcted->ndi2 = ndi2; + +} + +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) +{ + + uint32_t rballoc=0; + uint8_t rah=0; + uint8_t mcs1=0; + uint8_t mcs2=0; + uint8_t rv1=0; + uint8_t rv2=0; + uint8_t ndi1=0; + uint8_t ndi2=0; + uint8_t tbswap=0; + uint8_t tpmi=0; + uint8_t harq_pid=0; + uint8_t TPC=0; + + AssertFatal( (nb_antenna_ports_eNB == 2) || (nb_antenna_ports_eNB == 4), "unsupported nb_antenna_ports_eNB %d\n", nb_antenna_ports_eNB); + switch (N_RB_DL) { + + case 6: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rv1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + + break; + + case 25: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + break; + + case 50: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + + break; + + case 100: + if (nb_antenna_ports_eNB == 2) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; + TPC = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->TPC; + } + } else if (nb_antenna_ports_eNB == 4) { + if (frame_type == TDD) { + mcs1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->TPC; + } else { + mcs1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs1; + mcs2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs2; + rballoc = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rballoc; + rah = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rah; + rv1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv1; + rv2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv2; + ndi1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi1; + ndi2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi2; + harq_pid = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; + tbswap = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; + tpmi = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tpmi; + TPC = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->TPC; + } + } + + break; + } + + pdci_info_extarcted->mcs1 = mcs1; + pdci_info_extarcted->mcs2 = mcs2; + pdci_info_extarcted->rballoc = rballoc; + pdci_info_extarcted->rah = rah; + pdci_info_extarcted->rv1 = rv1; + pdci_info_extarcted->rv2 = rv2; + pdci_info_extarcted->ndi1 = ndi1; + pdci_info_extarcted->ndi2 = ndi2; + pdci_info_extarcted->harq_pid = harq_pid; + pdci_info_extarcted->tb_swap = tbswap; + pdci_info_extarcted->TPC = TPC; + pdci_info_extarcted->tpmi = tpmi; +} + +int check_dci_format1_1a_coherency(DCI_format_t dci_format, + uint8_t N_RB_DL, + uint16_t rnti, + uint16_t tc_rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint32_t frame, + uint8_t subframe, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_UE_HARQ_t *pdlsch0_harq) +{ + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t TPC = pdci_info_extarcted->TPC; + uint8_t rah = pdci_info_extarcted->rah; +#ifdef DEBUG_DCI + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t ndi1 = pdci_info_extarcted->ndi1; +#endif + + uint8_t NPRB = 0; + long long int RIV_max = 0; + +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1-1A] AbsSubframe %d.%d dci_format %d\n", frame, subframe, dci_format); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rnti %x\n", rnti); + LOG_I(PHY,"[DCI-FORMAT-1-1A] harq_pid %d\n", harq_pid); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rah %d\n", rah); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rballoc %x\n", rballoc); + LOG_I(PHY,"[DCI-FORMAT-1-1A] mcs1 %d\n", mcs1); + LOG_I(PHY,"[DCI-FORMAT-1-1A] rv1 %d\n", rv1); + LOG_I(PHY,"[DCI-FORMAT-1-1A] ndi1 %d\n", ndi1); + LOG_I(PHY,"[DCI-FORMAT-1-1A] TPC %d\n", TPC); +#endif + + + // I- check dci content minimum coherency + if( ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) && harq_pid > 0) + { + return(0); + } + + if(harq_pid>=8) + { + // LOG_I(PHY,"bad harq id \n"); + return(0); + } + + if(dci_format == format1 && ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) ) + { + // LOG_I(PHY,"bad dci format \n"); + return(0); + } + + + if( mcs1 > 28) + { + if(pdlsch0_harq->round == 0) + { + // LOG_I(PHY,"bad dci mcs + round \n"); + return(0); + } + + if((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + // LOG_I(PHY,"bad dci mcs + rnti \n"); + return(0); + } + } + + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + NPRB = (TPC&1) + 2; + switch (N_RB_DL) { + case 6: + RIV_max = RIV_max6; + break; + case 25: + RIV_max = RIV_max25; + break; + case 50: + RIV_max = RIV_max50; + break; + case 100: + RIV_max = RIV_max100; + break; + } + } + else + { + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max6; + else + RIV_max = 0x3F; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max25; + else + RIV_max = 0x1FFF; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max50; + else + RIV_max = 0x1FFFF; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; + if(rah) + RIV_max = RIV_max100; + else + RIV_max = 0x1FFFFFF; + break; + } + } + + + if(dci_format == format1) + { + NPRB = conv_nprb(rah, rballoc, N_RB_DL); + } + + + if(rballoc > RIV_max) + { + // LOG_I(PHY,"bad dci rballoc rballoc %d RIV_max %lld \n",rballoc, RIV_max); + // DCI false detection + return(0); + } + + if(NPRB == 0) + { + // DCI false detection + // LOG_I(PHY,"bad NPRB = 0 \n"); + return(0); + } + + // this a retransmission + if(pdlsch0_harq->round>0) + { + // compare old TBS to new TBS + if((mcs1<29) && (pdlsch0_harq->TBS != TBStable[get_I_TBS(mcs1)][NPRB-1])) + { + // this is an eNB issue + // retransmisison but old and new TBS are different !!! + // work around, consider it as a new transmission + LOG_E(PHY,"Format1A Retransmission but TBS are different: consider it as new transmission !!! \n"); + pdlsch0_harq->round = 0; + //return(0); // ?? to cross check + } + } + + return(1); +} + +int check_dci_format1c_coherency(uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + uint16_t rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + LTE_DL_UE_HARQ_t *pdlsch0_harq) +{ + uint32_t rballoc = pdci_info_extarcted->rballoc; + + uint8_t NPRB = 0; + uint32_t RIV_max = 0; + + // I- check dci content minimum coherency + + if((rnti!=si_rnti) && (rnti!=p_rnti) && (rnti!=ra_rnti)) + return(0); + + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; + RIV_max = RIV_max6; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; + RIV_max = RIV_max25; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; + RIV_max = RIV_max50; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; + RIV_max = RIV_max100; + break; + } + + if(rballoc > RIV_max) + { + // DCI false detection + return(0); + } + + if(NPRB == 0) + { + // DCI false detection + return(0); + } + + return(1); +} + +int check_dci_format2_2a_coherency(DCI_format_t dci_format, + uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + uint16_t rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + LTE_DL_UE_HARQ_t *pdlsch0_harq, + LTE_DL_UE_HARQ_t *pdlsch1_harq) +{ + uint8_t rah = pdci_info_extarcted->rah; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t mcs2 = pdci_info_extarcted->mcs2; + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t rv2 = pdci_info_extarcted->rv2; + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + +#ifdef DEBUG_DCI + uint8_t ndi1 = pdci_info_extarcted->ndi1; + uint8_t ndi2 = pdci_info_extarcted->ndi2; +#endif + + uint8_t NPRB = 0; + long long RIV_max = 0; + +#ifdef DEBUG_DCI + LOG_I(PHY, "extarcted dci - dci_format %d \n", dci_format); + LOG_I(PHY, "extarcted dci - rnti %d \n", rnti); + LOG_I(PHY, "extarcted dci - rah %d \n", rah); + LOG_I(PHY, "extarcted dci - mcs1 %d \n", mcs1); + LOG_I(PHY, "extarcted dci - mcs2 %d \n", mcs2); + LOG_I(PHY, "extarcted dci - rv1 %d \n", rv1); + LOG_I(PHY, "extarcted dci - rv2 %d \n", rv2); + //LOG_I(PHY, "extarcted dci - ndi1 %d \n", ndi1); + //LOG_I(PHY, "extarcted dci - ndi2 %d \n", ndi2); + LOG_I(PHY, "extarcted dci - rballoc %x \n", rballoc); + LOG_I(PHY, "extarcted dci - harq pid %d \n", harq_pid); + LOG_I(PHY, "extarcted dci - round0 %d \n", pdlsch0_harq->round); + LOG_I(PHY, "extarcted dci - round1 %d \n", pdlsch1_harq->round); +#endif + + // I- check dci content minimum coherency + if(harq_pid>=8) + { + // LOG_I(PHY,"bad harq pid\n"); + return(0); + } + + if( (rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti) ) + { + // LOG_I(PHY,"bad rnti\n"); + return(0); + } + + + if( mcs1 > 28) + { + if(pdlsch0_harq->round == 0) + { + // LOG_I(PHY,"bad mcs1\n"); + return(0); + } + } + + if( mcs2 > 28) + { + if(pdlsch1_harq->round == 0) + { + // LOG_I(PHY,"bad mcs2\n"); + return(0); + } + } + + + if((pdlsch0_harq->round == 0) && (rv1 > 0) && (mcs1 != 0)) + { + // DCI false detection + // LOG_I(PHY,"bad rv1\n"); + return(0); + } + + if((pdlsch1_harq->round == 0) && (rv2 > 0) && (mcs2 != 0)) + { + // DCI false detection + // LOG_I(PHY,"bad rv2\n"); + return(0); + } + + + switch (N_RB_DL) { + case 6: + if (rah == 0) + { + //RBG = 1; + RIV_max = 0x3F; + } + else + { + RIV_max = RIV_max6; + } + break; + case 25: + if (rah == 0) + { + //RBG = 2; + RIV_max = 0x1FFF; + } + else + { + RIV_max = RIV_max25; + } + break; + case 50: + if (rah == 0) + { + //RBG = 3; + RIV_max = 0x1FFFF; + } + else + { + RIV_max = RIV_max50; + } + break; + case 100: + if (rah == 0) + { + //RBG = 4; + RIV_max = 0x1FFFFFF; + } + else + { + RIV_max = RIV_max100; + } + break; + } + + NPRB = conv_nprb(rah, + rballoc, + N_RB_DL); + + + + if( (rballoc > RIV_max) && (rah == 1) ) + { + // DCI false detection + // LOG_I(PHY,"bad rballoc %d RIV_max %lld\n", rballoc, RIV_max); + return(0); + } + + if(NPRB == 0) + { + // DCI false detection + // LOG_I(PHY,"bad NPRB\n"); + return(0); + } + + return(1); +} + +void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + LTE_DL_UE_HARQ_t *dlsch0_harq, + uint8_t nb_rb_alloc, + uint8_t subframe) +{ + uint32_t pbch_pss_sss_re; + uint32_t crs_re; + uint32_t granted_re; + uint32_t data_re; + uint32_t llr_offset; + uint8_t symbol; + uint8_t symbol_mod; + + pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; + + LOG_D(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); + + //dlsch0_harq->rb_alloc_even; + //dlsch0_harq->rb_alloc_odd; + + for(symbol=pdcch_vars->num_pdcch_symbols; symbol<frame_parms->symbols_per_tti; symbol++) + { + symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; + if((symbol_mod == 0) || symbol_mod == (4-frame_parms->Ncp)) + { + if (frame_parms->nb_antennas_tx == 2) + crs_re = 4; + else + crs_re = 2; + } + else + { + crs_re = 0; + } + + granted_re = nb_rb_alloc * (12-crs_re); + pbch_pss_sss_re = adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,subframe,symbol); + pbch_pss_sss_re = (double)pbch_pss_sss_re * ((double)(12-crs_re)/12); + data_re = granted_re - pbch_pss_sss_re; + llr_offset = data_re * dlsch0_harq->Qm * 2; + + pdsch_vars->llr_length[symbol] = data_re; + if(symbol < (frame_parms->symbols_per_tti-1)) + pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; + + LOG_D(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); + LOG_D(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); + LOG_D(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); + LOG_D(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); + + + + LOG_D(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, + pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); + } +} +void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, + uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + uint8_t subframe, + uint16_t rnti, + uint16_t tc_rnti, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + LTE_DL_UE_HARQ_t *pdlsch0_harq, + LTE_UE_DLSCH_t *pdlsch0) +{ + + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint8_t vrb_type = pdci_info_extarcted->vrb_type; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t ndi1 = pdci_info_extarcted->ndi1; + uint8_t TPC = pdci_info_extarcted->TPC; + uint8_t rah = pdci_info_extarcted->rah; + uint8_t dai = pdci_info_extarcted->dai; + + + uint8_t NPRB = 0; + uint8_t NPRB4TBS = 0; + + if(dci_format == format1A) + { + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc]; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc]; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc]; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc]; + break; + } + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + NPRB4TBS = (TPC&1) + 2; + } + else + { + NPRB4TBS = NPRB; + /* + switch (N_RB_DL) { + case 6: + NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; + break; + case 25: + NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; + break; + case 50: + NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; + break; + case 100: + NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; + break; + } + + */ + } + } + else // format1 + { + NPRB = conv_nprb(rah, rballoc, N_RB_DL); + NPRB4TBS=NPRB; + } + + pdlsch0->current_harq_pid = harq_pid; + pdlsch0->active = 1; + pdlsch0->rnti = rnti; + if(dci_format == format1A) + pdlsch0->harq_ack[subframe].vDAI_DL = dai+1; + + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + pdlsch0_harq->round = 0; + pdlsch0_harq->status = ACTIVE; + } + else //CRNTI + { + if (rnti == tc_rnti) { + //fix for standalone Contention Resolution Id + pdlsch0_harq->DCINdi = (uint8_t)-1; + LOG_D(PHY,"UE (%x/%d): Format1A DCI: C-RNTI is temporary. Set NDI = %d and to be ignored\n", + rnti,harq_pid,pdlsch0_harq->DCINdi); + } + + // NDI has been toggled or this is the first transmission + if ((ndi1!=pdlsch0_harq->DCINdi) || (pdlsch0_harq->first_tx==1)) + { + pdlsch0_harq->round = 0; + pdlsch0_harq->first_tx = 0; + pdlsch0_harq->status = ACTIVE; + + }else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if (pdlsch0_harq->status == SCH_IDLE) + //packet was actually decoded in previous transmission (ACK was missed by eNB) + //However, the round is not a good check as it might have been decoded in a retransmission prior to this one. + { + // LOG_D(PHY,"skip pdsch decoding and report ack\n"); + // skip pdsch decoding and report ack + //pdlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + pdlsch0->harq_ack[subframe].ack = 1; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch0->harq_ack[subframe].send_harq_status = 1; + + //pdlsch0_harq->first_tx = 0; + } + else //normal retransmission + { + // nothing special to do + } + } + else + { + pdlsch0_harq->status = ACTIVE; + } + } + + pdlsch0_harq->DCINdi = ndi1; + pdlsch0_harq->mcs = mcs1; + pdlsch0_harq->rvidx = rv1; + pdlsch0_harq->nb_rb = NPRB; + + pdlsch0_harq->codeword = 0; + pdlsch0_harq->Nl = 1; + pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; + pdlsch0_harq->dl_power_off = 1; //no power offset + pdlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC &3]; + + // compute resource allocation + if(dci_format == format1A) + { + switch (N_RB_DL) { + case 6: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT6[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; + } + break; + + case 25: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT25[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; + } + break; + + case 50: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT50_1[rballoc]; + } else { // DISTRIBUTED + if ((rballoc&(1<<10)) == 0) { + rballoc = rballoc&(~(1<<10)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; + } + else { + rballoc = rballoc&(~(1<<10)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; + } + } + break; + + case 100: + if (vrb_type == LOCALIZED) { + pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = localRIV2alloc_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = localRIV2alloc_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = localRIV2alloc_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = localRIV2alloc_LUT100_3[rballoc]; + } else { + if ((rballoc&(1<<10)) == 0) { //Gap 1 + rballoc = rballoc&(~(1<<12)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; + } + else { //Gap 2 + rballoc = rballoc&(~(1<<12)); + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; + } + } + break; + } + } + else // format1 + { + conv_rballoc(rah,rballoc,frame_parms->N_RB_DL,pdlsch0_harq->rb_alloc_even); + pdlsch0_harq->rb_alloc_odd[0]= pdlsch0_harq->rb_alloc_even[0]; + pdlsch0_harq->rb_alloc_odd[1]= pdlsch0_harq->rb_alloc_even[1]; + pdlsch0_harq->rb_alloc_odd[2]= pdlsch0_harq->rb_alloc_even[2]; + pdlsch0_harq->rb_alloc_odd[3]= pdlsch0_harq->rb_alloc_even[3]; + } + if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) + { + pdlsch0_harq->TBS = TBStable[mcs1][NPRB4TBS-1]; + pdlsch0_harq->Qm = 2; + } + else + { + if(mcs1 < 29) + { + pdlsch0_harq->TBS = TBStable[get_I_TBS(mcs1)][NPRB4TBS-1]; + pdlsch0_harq->Qm = get_Qm(mcs1); + } + } + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + pdlsch0_harq, + NPRB, + subframe); +} + +void prepare_dl_decoding_format1C(uint8_t N_RB_DL, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + uint32_t rnti, + uint32_t si_rnti, + uint32_t ra_rnti, + uint32_t p_rnti, + uint32_t frame, + uint8_t subframe, + LTE_DL_UE_HARQ_t *pdlsch0_harq, + LTE_UE_DLSCH_t *pdlsch0) +{ + + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t Ngap = pdci_info_extarcted->Ngap; + + pdlsch0_harq->round = 0; + pdlsch0_harq->first_tx = 1; + pdlsch0_harq->vrb_type = DISTRIBUTED; + + if (rnti==si_rnti) { // rule from Section 5.3.1 of 36.321 + if (((frame&1) == 0) && (subframe == 5)) + pdlsch0_harq->rvidx = (((3*((frame>>1)&3))+1)>>1)&3; // SIB1 + else + pdlsch0_harq->rvidx = (((3*(subframe&3))+1)>>1)&3; // other SIBs + } + else if ((rnti==p_rnti) || (rnti==ra_rnti)) { // Section 7.1.7.3 + pdlsch0_harq->rvidx = 0; + } + + + pdlsch0_harq->Nl = 1; + pdlsch0_harq->mimo_mode = frame_parms->nb_antenna_ports_eNB == 1 ?SISO : ALAMOUTI; + pdlsch0_harq->dl_power_off = 1; //no power offset + + pdlsch0_harq->codeword = 0; + pdlsch0_harq->mcs = mcs1; + pdlsch0_harq->TBS = TBStable1C[mcs1]; + pdlsch0_harq->Qm = 2; + + + pdlsch0->current_harq_pid = harq_pid; + pdlsch0->active = 1; + pdlsch0->rnti = rnti; + + switch (N_RB_DL) { + case 6: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; + + break; + + case 25: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; + break; + + case 50: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT50[rballoc]; + if (Ngap == 0) { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT50_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT50_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT50_1[rballoc]; + } + break; + + case 100: + pdlsch0_harq->nb_rb = RIV2nb_rb_LUT100[rballoc]; + if (Ngap==0) { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; + } + else { + pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; + pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; + pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; + pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; + pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; + } + break; + + default: + AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",frame_parms->N_RB_DL); + break; + } + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + pdlsch0_harq, + pdlsch0_harq->nb_rb, + subframe); + +} + +void compute_precoding_info_2cw(uint8_t tpmi, uint8_t tbswap, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch0_harq, LTE_DL_UE_HARQ_t *dlsch1_harq) +{ + +switch (tpmi) { + case 0: + dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; + dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); + dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); + break; + case 1: + dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; + dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); + dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); + break; + case 2: // PUSCH precoding + dlsch0_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; + dlsch1_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; + if (tbswap==0){ + dlsch0_harq->pmi_alloc = pmi_alloc; + dlsch1_harq->pmi_alloc = pmi_alloc^0x1555; + } else { + dlsch1_harq->pmi_alloc = pmi_alloc; + dlsch0_harq->pmi_alloc = pmi_alloc^0x1555; + } +#ifdef DEBUG_HARQ + printf ("\n \n compute_precoding_info_2cw pmi_alloc_new = %d\n", dlsch0_harq->pmi_alloc); + #endif + break; + default: + break; + } +} + +void compute_precoding_info_1cw(uint8_t tpmi, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch_harq) +{ + +switch (tpmi) { + case 0 : + dlsch_harq->mimo_mode = ALAMOUTI; + break; + case 1: + dlsch_harq->mimo_mode = UNIFORM_PRECODING11; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,0, 0); + break; + case 2: + dlsch_harq->mimo_mode = UNIFORM_PRECODING1m1; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); + break; + case 3: + dlsch_harq->mimo_mode = UNIFORM_PRECODING1j; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); + break; + case 4: + dlsch_harq->mimo_mode = UNIFORM_PRECODING1mj; + dlsch_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); + break; + case 5: + dlsch_harq->mimo_mode = PUSCH_PRECODING0; + dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,0); + break; + case 6: + dlsch_harq->mimo_mode = PUSCH_PRECODING1; + dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,1); + break; + } + #ifdef DEBUG_HARQ + printf ("[DCI UE] I am calling from the UE side pmi_alloc_new = %d with tpmi %d\n", dlsch_harq->pmi_alloc, tpmi); + #endif + } + +void compute_precoding_info_format2A(uint8_t tpmi, + uint8_t nb_antenna_ports_eNB, + uint8_t tb0_active, + uint8_t tb1_active, + LTE_DL_UE_HARQ_t *dlsch0_harq, + LTE_DL_UE_HARQ_t *dlsch1_harq) +{ + + dlsch0_harq->dl_power_off = 0; + dlsch1_harq->dl_power_off = 0; + + if (nb_antenna_ports_eNB == 2) { + if ((tb0_active==1) && (tb1_active==1)) { + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + } else { + dlsch0_harq->mimo_mode = ALAMOUTI; + dlsch1_harq->mimo_mode = ALAMOUTI; + } + } else if (nb_antenna_ports_eNB == 4) { // 4 antenna case + if ((tb0_active==1) && (tb1_active==1)) { + switch (tpmi) { + case 0: // one layer per transport block + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + break; + + case 1: // one-layers on TB 0, two on TB 1 + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + break; + + case 2: // two-layers on TB 0, two on TB 1 + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + break; + + case 3: // + LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n"); + break; + } + } else if (tb0_active == 1) { + switch (tpmi) { + case 0: // one layer per transport block + dlsch0_harq->mimo_mode = ALAMOUTI; + dlsch1_harq->mimo_mode = ALAMOUTI; + break; + + case 1: // two-layers on TB 0 + dlsch0_harq->mimo_mode = LARGE_CDD; + dlsch0_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + break; + + case 2: // two-layers on TB 0, two on TB 1 + case 3: // + LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); + break; + } + } else if (tb1_active == 1) { + switch (tpmi) { + case 0: // one layer per transport block + dlsch0_harq->mimo_mode = ALAMOUTI; + dlsch1_harq->mimo_mode = ALAMOUTI; + break; + + case 1: // two-layers on TB 0 + dlsch1_harq->mimo_mode = LARGE_CDD; + dlsch1_harq->Nl = 2; + dlsch0_harq->dl_power_off = 1; + break; + + case 2: // two-layers on TB 0, two on TB 1 + case 3: // + LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); + break; + } + } + } + // printf("Format 2A: NPRB=%d (rballoc %x,mcs1 %d, mcs2 %d, frame_type %d N_RB_DL %d,active %d/%d)\n",NPRB,rballoc,mcs1,mcs2,frame_parms->frame_type,frame_parms->N_RB_DL,dlsch0->active,dlsch1->active); + //printf("UE (%x/%d): Subframe %d Format2A DCI: ndi1 %d, old_ndi1 %d, ndi2 %d, old_ndi2 %d (first tx1 %d, first tx2 %d) harq_status1 %d, harq_status2 %d\n",dlsch0->rnti,harq_pid,subframe,ndi,dlsch0_harq->DCINdi, + // dlsch0_harq->first_tx,dlsch1_harq->first_tx,dlsch0_harq->status,dlsch1_harq->status); + //printf("TBS0 %d, TBS1 %d\n",dlsch0_harq->TBS,dlsch1_harq->TBS); + +} + +void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, + DCI_INFO_EXTRACTED_t *pdci_info_extarcted, + LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + uint16_t rnti, + uint8_t subframe, + LTE_DL_UE_HARQ_t *dlsch0_harq, + LTE_DL_UE_HARQ_t *dlsch1_harq, + LTE_UE_DLSCH_t *pdlsch0, + LTE_UE_DLSCH_t *pdlsch1) +{ + + uint8_t rah = pdci_info_extarcted->rah; + uint8_t mcs1 = pdci_info_extarcted->mcs1; + uint8_t mcs2 = pdci_info_extarcted->mcs2; + uint8_t rv1 = pdci_info_extarcted->rv1; + uint8_t rv2 = pdci_info_extarcted->rv2; + uint8_t harq_pid = pdci_info_extarcted->harq_pid; + uint32_t rballoc = pdci_info_extarcted->rballoc; + uint8_t tbswap = pdci_info_extarcted->tb_swap; + uint8_t tpmi = pdci_info_extarcted->tpmi; + uint8_t TPC = pdci_info_extarcted->TPC; + uint8_t ndi1 = pdci_info_extarcted->ndi1; + uint8_t ndi2 = pdci_info_extarcted->ndi2; + + uint8_t TB0_active = 1; + uint8_t TB1_active = 1; + + // printf("inside prepare pdlsch1->pmi_alloc %d \n",pdlsch1->pmi_alloc); + + + if ((rv1 == 1) && (mcs1 == 0)) { + TB0_active=0; + } + if ((rv2 == 1) && (mcs2 == 0)) { + TB1_active=0; + } + +#ifdef DEBUG_HARQ + printf("[DCI UE]: TB0 status %d , TB1 status %d\n", TB0_active, TB1_active); +#endif + + dlsch0_harq->mcs = mcs1; + dlsch1_harq->mcs = mcs2; + dlsch0_harq->rvidx = rv1; + dlsch1_harq->rvidx = rv2; + dlsch0_harq->DCINdi = ndi1; + dlsch1_harq->DCINdi = ndi2; + + dlsch0_harq->codeword = 0; + dlsch1_harq->codeword = 1; + dlsch0_harq->Nl = 1; + dlsch1_harq->Nl = 1; + dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; + dlsch1_harq->delta_PUCCH = delta_PUCCH_lut[TPC&3]; + dlsch0_harq->dl_power_off = 1; + dlsch1_harq->dl_power_off = 1; + + pdlsch0->current_harq_pid = harq_pid; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch1->current_harq_pid = harq_pid; + pdlsch1->harq_ack[subframe].harq_id = harq_pid; + + // assume two CW are active + dlsch0_harq->status = ACTIVE; + dlsch1_harq->status = ACTIVE; + pdlsch0->active = 1; + pdlsch1->active = 1; + pdlsch0->rnti = rnti; + pdlsch1->rnti = rnti; + + + if (TB0_active && TB1_active && tbswap==1) { + dlsch0_harq->codeword = 1; + dlsch1_harq->codeword = 0; + } + + + if (!TB0_active && TB1_active){ + dlsch1_harq->codeword = 0; + } + + if (TB0_active && !TB1_active){ + dlsch0_harq->codeword = 0; + } + + + if (TB0_active==0) { + dlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + #ifdef DEBUG_HARQ + printf("[DCI UE]: TB0 is deactivated, retransmit TB1 transmit in TM6\n"); + #endif + } + + if (TB1_active==0) { + dlsch1_harq->status = SCH_IDLE; + pdlsch1->active = 0; + } + +#ifdef DEBUG_HARQ + printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); +#endif + + // compute resource allocation + if (TB0_active == 1){ + + dlsch0_harq->nb_rb = conv_nprb(rah, + rballoc, + frame_parms->N_RB_DL); + conv_rballoc(rah, + rballoc, + frame_parms->N_RB_DL, + dlsch0_harq->rb_alloc_even); + + dlsch0_harq->rb_alloc_odd[0]= dlsch0_harq->rb_alloc_even[0]; + dlsch0_harq->rb_alloc_odd[1]= dlsch0_harq->rb_alloc_even[1]; + dlsch0_harq->rb_alloc_odd[2]= dlsch0_harq->rb_alloc_even[2]; + dlsch0_harq->rb_alloc_odd[3]= dlsch0_harq->rb_alloc_even[3]; + + if (TB1_active == 1){ + dlsch1_harq->rb_alloc_even[0]= dlsch0_harq->rb_alloc_even[0]; + dlsch1_harq->rb_alloc_even[1]= dlsch0_harq->rb_alloc_even[1]; + dlsch1_harq->rb_alloc_even[2]= dlsch0_harq->rb_alloc_even[2]; + dlsch1_harq->rb_alloc_even[3]= dlsch0_harq->rb_alloc_even[3]; + dlsch1_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_odd[0]; + dlsch1_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_odd[1]; + dlsch1_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_odd[2]; + dlsch1_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_odd[3]; + + dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; + + //dlsch0_harq->Nl = 1; + //dlsch1_harq->Nl = 1; + } + } else if ((TB0_active == 0) && (TB1_active == 1)){ + + conv_rballoc(rah, + rballoc, + frame_parms->N_RB_DL, + dlsch1_harq->rb_alloc_even); + + dlsch1_harq->rb_alloc_odd[0]= dlsch1_harq->rb_alloc_even[0]; + dlsch1_harq->rb_alloc_odd[1]= dlsch1_harq->rb_alloc_even[1]; + dlsch1_harq->rb_alloc_odd[2]= dlsch1_harq->rb_alloc_even[2]; + dlsch1_harq->rb_alloc_odd[3]= dlsch1_harq->rb_alloc_even[3]; + dlsch1_harq->nb_rb = conv_nprb(rah, + rballoc, + frame_parms->N_RB_DL); + } + + + // compute precoding matrix + mimo mode + if(dci_format == format2) + { + if ((TB0_active) && (TB1_active)){ //two CW active + compute_precoding_info_2cw(tpmi, tbswap, pdlsch0->pmi_alloc,frame_parms, dlsch0_harq, dlsch1_harq); + + // printf("[DCI UE 1]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + } else if ((TB0_active) && (!TB1_active)) { // only CW 0 active + compute_precoding_info_1cw(tpmi, pdlsch0->pmi_alloc, frame_parms, dlsch0_harq); + } else { + compute_precoding_info_1cw(tpmi, pdlsch1->pmi_alloc, frame_parms, dlsch1_harq); + // printf("I am doing compute_precoding_info_1cw with tpmi %d \n", tpmi); + } + //printf(" UE DCI harq0 MIMO mode = %d\n", dlsch0_harq->mimo_mode); + if ((frame_parms->nb_antenna_ports_eNB == 1) && (TB0_active)) + dlsch0_harq->mimo_mode = SISO; + } + else + { + compute_precoding_info_format2A( tpmi, + frame_parms->nb_antenna_ports_eNB, + TB0_active, + TB1_active, + dlsch0_harq, + dlsch1_harq); + } + // printf("[DCI UE 2]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + // reset round + compute Qm + if (TB0_active) { + // printf("TB0 ndi1 =%d, dlsch0_harq->DCINdi =%d, dlsch0_harq->first_tx = %d\n", ndi1, dlsch0_harq->DCINdi, dlsch0_harq->first_tx); + if ((ndi1!=dlsch0_harq->DCINdi) || (dlsch0_harq->first_tx==1)) { + dlsch0_harq->round = 0; + dlsch0_harq->status = ACTIVE; + dlsch0_harq->DCINdi = ndi1; + + //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW0 subframe %d (pid %d, round %d)\n", + // subframe,harq_pid,dlsch0_harq->round); + if ( dlsch0_harq->first_tx==1) { + // LOG_D(PHY,"Format 2 DCI First TX0: Clearing flag\n"); + dlsch0_harq->first_tx = 0; + } + } + /*else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if(dlsch0_harq->status == SCH_IDLE) { + // skip pdsch decoding and report ack + //dlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + pdlsch0->harq_ack[subframe].ack = 1; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch0->harq_ack[subframe].send_harq_status = 1; + }*/ + + // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest + // PDCCH for the same trasport block using Imcs in [0 .. 28] + if(dlsch0_harq->mcs <= 28) + { + dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; + LOG_D(PHY,"[UE] DLSCH: New TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); + } + else + { + LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW0 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); + } + //if(dlsch0_harq->Nl == 2) + //dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1]; + if (mcs1 <= 28) + dlsch0_harq->Qm = get_Qm(mcs1); + else if (mcs1<=31) + dlsch0_harq->Qm = (mcs1-28)<<1; + } + + // printf("[DCI UE 3]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + + if (TB1_active) { + // printf("TB1 ndi2 =%d, dlsch1_harq->DCINdi =%d, dlsch1_harq->first_tx = %d\n", ndi2, dlsch1_harq->DCINdi, dlsch1_harq->first_tx); + if ((ndi2!=dlsch1_harq->DCINdi) || (dlsch1_harq->first_tx==1)) { + dlsch1_harq->round = 0; + dlsch1_harq->status = ACTIVE; + dlsch1_harq->DCINdi = ndi2; + //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW1 subframe %d (pid %d, round %d)\n", + // subframe,harq_pid,dlsch0_harq->round); + if (dlsch1_harq->first_tx==1) { + // LOG_D(PHY,"Format 2 DCI First TX1: Clearing flag\n"); + dlsch1_harq->first_tx = 0; + } + } + /*else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if(dlsch1_harq->status == SCH_IDLE) { + // skip pdsch decoding and report ack + //dlsch1_harq->status = SCH_IDLE; + pdlsch1->active = 0; + pdlsch1->harq_ack[subframe].ack = 1; + pdlsch1->harq_ack[subframe].harq_id = harq_pid; + pdlsch1->harq_ack[subframe].send_harq_status = 1; + } + }*/ + + // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest + // PDCCH for the same trasport block using Imcs in [0 .. 28] + if(dlsch1_harq->mcs <= 28) + { + dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; + LOG_D(PHY,"[UE] DLSCH: New TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); + } + else + { + LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW1 subframe %d (pid %d, round %d) TBS %d \n", + subframe,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); + } + if (mcs2 <= 28) + dlsch1_harq->Qm = get_Qm(mcs2); + else if (mcs1<=31) + dlsch1_harq->Qm = (mcs2-28)<<1; + } + + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + dlsch0_harq, + dlsch0_harq->nb_rb, + subframe); + + + /* #ifdef DEBUG_HARQ + printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); + printf("[DCI UE]: TB0_active %d , TB1_active %d\n", TB0_active, TB1_active); + if (dlsch0 != NULL && dlsch1 != NULL) + printf("[DCI UE] dlsch0_harq status = %d, dlsch1_harq status = %d\n", dlsch0_harq->status, dlsch1_harq->status); + else if (dlsch0 == NULL && dlsch1 != NULL) + printf("[DCI UE] dlsch0_harq NULL dlsch1_harq status = %d\n", dlsch1_harq->status); + else if (dlsch0 != NULL && dlsch1 == NULL) + printf("[DCI UE] dlsch1_harq NULL dlsch0_harq status = %d\n", dlsch0_harq->status); + #endif*/ +} + +int generate_ue_dlsch_params_from_dci(int frame, + uint8_t subframe, + void *dci_pdu, + uint16_t rnti, + DCI_format_t dci_format, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + LTE_UE_DLSCH_t **dlsch, + LTE_DL_FRAME_PARMS *frame_parms, + PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint8_t beamforming_mode, + uint16_t tc_rnti) +{ + + uint8_t harq_pid=0; + uint8_t frame_type=frame_parms->frame_type; + uint8_t tpmi=0; + LTE_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; + LTE_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; + + DCI_INFO_EXTRACTED_t dci_info_extarcted; + uint8_t status=0; + + if (!dlsch[0]) return -1; + + #ifdef DEBUG_DCI + LOG_D(PHY,"dci_tools.c: Filling ue dlsch params -> rnti %x, SFN/SF %d/%d, dci_format %s\n", + rnti, + frame%1024, + subframe, + (dci_format==format0? "Format 0":( + dci_format==format1? "format 1":( + dci_format==format1A? "format 1A":( + dci_format==format1B? "format 1B":( + dci_format==format1C? "format 1C":( + dci_format==format1D? "format 1D":( + dci_format==format1E_2A_M10PRB? "format 1E_2A_M10PRB":( + dci_format==format2? "format 2":( + dci_format==format2A? "format 2A":( + dci_format==format2B? "format 2B":( + dci_format==format2C? "format 2C":( + dci_format==format2D? "format 2D":( + dci_format==format3? "format 3": "UNKNOWN" + )))))))))))))); + #endif + + memset(&dci_info_extarcted,0,sizeof(dci_info_extarcted)); + switch (dci_format) { + + case format0: // This is an ULSCH allocation so nothing here, inform MAC + LOG_E(PHY,"format0 not possible\n"); + return(-1); + break; + + case format1A: + { + // extract dci infomation +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d extarct dci info \n", frame, subframe); +#endif + extract_dci1A_info(frame_parms->N_RB_DL, + frame_type, + dci_pdu, + &dci_info_extarcted); + + + // check dci content + dlsch0 = dlsch[0]; + dlsch0->active = 0; + dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d check dci coherency \n", frame, subframe); +#endif + status = check_dci_format1_1a_coherency(format1A, + frame_parms->N_RB_DL, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti,frame,subframe, + &dci_info_extarcted, + dlsch0_harq); + if(status == 0) + { + printf("bad DCI 1A !!! \n"); + return(-1); + } + + // dci is correct ==> update internal structure and prepare dl decoding +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); +#endif + prepare_dl_decoding_format1_1A(format1A, + frame_parms->N_RB_DL, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + subframe, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch0); + + + + break; + } + case format1C: + { + // extract dci infomation +#ifdef DEBUG_DL_DECODING + LOG_I(PHY,"[DCI Format-1C] extact dci information \n"); +#endif + extract_dci1C_info(frame_parms->N_RB_DL, + frame_type, + dci_pdu, + &dci_info_extarcted); + + + // check dci content +#ifdef DEBUG_DL_DECODING + LOG_I(PHY,"[DCI Format-1C] check dci content \n"); +#endif + dlsch0 = dlsch[0]; + dlsch0->active = 0; + dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; + + status = check_dci_format1c_coherency(frame_parms->N_RB_DL, + &dci_info_extarcted, + rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq); + if(status == 0) + return(-1); + + // dci is correct ==> update internal structure and prepare dl decoding +#ifdef DEBUG_DL_DECODING + LOG_I(PHY,"[DCI Format-1C] prepare downlink decoding \n"); +#endif + prepare_dl_decoding_format1C(frame_parms->N_RB_DL, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + rnti, + si_rnti, + ra_rnti, + p_rnti, + frame, + subframe, + dlsch0_harq, + dlsch0); + + break; + } + + case format1: + { + // extract dci infomation +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d extarct dci info \n", frame, subframe); +#endif + extract_dci1_info(frame_parms->N_RB_DL, + frame_type, + dci_pdu, + &dci_info_extarcted); + + // check dci content + dlsch0 = dlsch[0]; + dlsch0->active = 0; + dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; + +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d check dci coherency \n", frame, subframe); +#endif + status = check_dci_format1_1a_coherency(format1, + frame_parms->N_RB_DL, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti,frame,subframe, + &dci_info_extarcted, + dlsch0_harq); + if(status == 0) + { + printf("bad DCI 1 !!! \n"); + return(-1); + } + + + // dci is correct ==> update internal structure and prepare dl decoding +#ifdef DEBUG_DCI + LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); +#endif + prepare_dl_decoding_format1_1A(format1, + frame_parms->N_RB_DL, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + subframe, + rnti, + tc_rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch0); + break; + } + + case format2: + { + // extract dci infomation + //LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame, subframe); + extract_dci2_info(frame_parms->N_RB_DL, + frame_type, + frame_parms->nb_antenna_ports_eNB, + dci_pdu, + &dci_info_extarcted); + + + // check dci content + dlsch[0]->active = 1; + dlsch[1]->active = 1; + + dlsch0 = dlsch[0]; + dlsch1 = dlsch[1]; + + dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; + dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; + // printf("before coherency dlsch[1]->pmi_alloc %d\n",dlsch[1]->pmi_alloc); + // printf("before coherency dlsch1->pmi_alloc %d\n",dlsch1->pmi_alloc); + // printf("before coherency dlsch1_harq->pmi_alloc %d\n",dlsch1_harq->pmi_alloc); + + //LOG_I(PHY,"[DCI-format2] check dci content \n"); + status = check_dci_format2_2a_coherency(format2, + frame_parms->N_RB_DL, + &dci_info_extarcted, + rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch1_harq); + if(status == 0) + return(-1); + + + // dci is correct ==> update internal structure and prepare dl decoding + //LOG_I(PHY,"[DCI-format2] update internal structure and prepare dl decoding \n"); + prepare_dl_decoding_format2_2A(format2, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + rnti, + subframe, + dlsch0_harq, + dlsch1_harq, + dlsch0, + dlsch1); + } + break; + + case format2A: + { + // extract dci infomation + LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame%1024, subframe); + extract_dci2A_info(frame_parms->N_RB_DL, + frame_type, + frame_parms->nb_antenna_ports_eNB, + dci_pdu, + &dci_info_extarcted); + + // check dci content + //LOG_I(PHY,"[DCI-format2A] check dci content \n"); + //LOG_I(PHY,"[DCI-format2A] tb_swap %d harq_pid %d\n", dci_info_extarcted.tb_swap, dci_info_extarcted.harq_pid); + //dlsch[0]->active = 0; + //dlsch[1]->active = 0; + + if (dci_info_extarcted.tb_swap == 0) { + dlsch0 = dlsch[0]; + dlsch1 = dlsch[1]; + } else { + dlsch0 = dlsch[1]; + dlsch1 = dlsch[0]; + } + dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; + dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; + + //LOG_I(PHY,"[DCI-format2A] check dci content \n"); + status = check_dci_format2_2a_coherency(format2A, + frame_parms->N_RB_DL, + &dci_info_extarcted, + rnti, + si_rnti, + ra_rnti, + p_rnti, + dlsch0_harq, + dlsch1_harq); + if(status == 0) + return(-1); + + // dci is correct ==> update internal structure and prepare dl decoding + //LOG_I(PHY,"[DCI-format2A] update internal structure and prepare dl decoding \n"); + prepare_dl_decoding_format2_2A(format2A, + &dci_info_extarcted, + frame_parms, + pdcch_vars, + pdsch_vars, + rnti, + subframe, + dlsch0_harq, + dlsch1_harq, + dlsch0, + dlsch1); + } + break; + + case format1E_2A_M10PRB: + if (!dlsch[0]) return -1; + + harq_pid = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->harq_pid; + + if (harq_pid>=8) { + LOG_E(PHY,"Format 1E_2A_M10PRB: harq_pid=%d >= 8\n", harq_pid); + return(-1); + } + + dlsch[0]->current_harq_pid = harq_pid; + dlsch[0]->harq_ack[subframe].harq_id = harq_pid; + + /* + tbswap = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tb_swap; + if (tbswap == 0) { + dlsch0 = dlsch[0]; + dlsch1 = dlsch[1]; + } + else{ + dlsch0 = dlsch[1]; + dlsch1 = dlsch[0]; + } + */ + dlsch0 = dlsch[0]; + + dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; + // Needs to be checked + dlsch0_harq->codeword=0; + conv_rballoc(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc,frame_parms->N_RB_DL, + dlsch0_harq->rb_alloc_even); + + dlsch0_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_even[0]; + dlsch0_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_even[1]; + dlsch0_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_even[2]; + dlsch0_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_even[3]; + /* + dlsch1_harq->rb_alloc_even[0] = dlsch0_harq->rb_alloc_even[0]; + dlsch1_harq->rb_alloc_even[1] = dlsch0_harq->rb_alloc_even[1]; + dlsch1_harq->rb_alloc_even[2] = dlsch0_harq->rb_alloc_even[2]; + dlsch1_harq->rb_alloc_even[3] = dlsch0_harq->rb_alloc_even[3]; + */ + dlsch0_harq->nb_rb = conv_nprb(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, + ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc, + frame_parms->N_RB_DL); + //dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; + + dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; + dlsch0_harq->delta_PUCCH = delta_PUCCH_lut[((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->TPC&3]; + + + + /* + if (dlsch0_harq->mcs>20) { + printf("dci_tools.c: mcs > 20 disabled for now (asked %d)\n",dlsch0_harq->mcs); + return(-1); + } + */ + + //dlsch1_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs2; + dlsch0_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv; + //dlsch1_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv2; + + // check if either TB is disabled (see 36-213 V8.6 p. 26) + + if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { + dlsch0_harq->status = DISABLED; + } + + //if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { + //dlsch1_harq->status = DISABLED; + //} + dlsch0_harq->Nl = 1; + + //dlsch0->layer_index = tbswap; + //dlsch1->layer_index = 1-tbswap; + + + // Fix this + tpmi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tpmi; + // printf("ue: tpmi %d\n",tpmi); + + switch (tpmi) { + case 0 : + dlsch0_harq->mimo_mode = ALAMOUTI; + break; + + case 1: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING11; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0,0); + break; + + case 2: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); + break; + + case 3: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); + + break; + + case 4: + dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj; + dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); + break; + + case 5: + dlsch0_harq->mimo_mode = PUSCH_PRECODING0; + // pmi stored from ulsch allocation routine + dlsch0_harq->pmi_alloc = dlsch0->pmi_alloc; + //LOG_I(PHY,"XXX using PMI %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc)); + break; + + + case 6: + dlsch0_harq->mimo_mode = PUSCH_PRECODING1; + LOG_E(PHY,"Unsupported TPMI\n"); + return(-1); + break; + } + + + if (frame_parms->nb_antenna_ports_eNB == 1) + dlsch0_harq->mimo_mode = SISO; + + + if ((dlsch0_harq->DCINdi != ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi) || + (dlsch0_harq->first_tx==1)) { + + dlsch0_harq->round = 0; + dlsch0_harq->first_tx = 0; + dlsch0_harq->status = ACTIVE; + } + /* + else if (dlsch0_harq->status == SCH_IDLE) { // we got same ndi for a previously decoded process, + // this happens if either another harq process in the same + // is NAK or an ACK was not received + + dlsch0->harq_ack[subframe].ack = 1; + dlsch0->harq_ack[subframe].harq_id = harq_pid; + dlsch0->harq_ack[subframe].send_harq_status = 1; + dlsch0->active = 0; + return(0); + } + */ + + dlsch0_harq->DCINdi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi; + dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; + + if (dlsch0_harq->nb_rb>1) { + dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; + } else + dlsch0_harq->TBS =0; + + dlsch0->rnti = rnti; + //dlsch1->rnti = rnti; + + dlsch0->active = 1; + //dlsch1->active = 1; + + dlsch0_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; + //dlsch1_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; + + + break; + + default: + LOG_E(PHY,"format %d not yet implemented\n",dci_format); + return(-1); + break; + } + +#ifdef UE_DEBUG_TRACE + + if (dlsch[0] && (dlsch[0]->rnti != 0xffff)) { + LOG_I(PHY,"dci_format:%d Abssubframe: %d.%d \n",dci_format,frame%1024,subframe); + LOG_I(PHY,"PDSCH dlsch0 UE: rnti %x\n",dlsch[0]->rnti); + LOG_D(PHY,"PDSCH dlsch0 UE: NBRB %d\n",dlsch0_harq->nb_rb); + LOG_D(PHY,"PDSCH dlsch0 UE: rballoc %x\n",dlsch0_harq->rb_alloc_even[0]); + LOG_I(PHY,"PDSCH dlsch0 UE: harq_pid %d\n",dci_info_extarcted.harq_pid); + LOG_I(PHY,"PDSCH dlsch0 UE: g %d\n",dlsch[0]->g_pucch); + LOG_D(PHY,"PDSCH dlsch0 UE: round %d\n",dlsch0_harq->round); + LOG_D(PHY,"PDSCH dlsch0 UE: DCINdi %d\n",dlsch0_harq->DCINdi); + LOG_D(PHY,"PDSCH dlsch0 UE: rvidx %d\n",dlsch0_harq->rvidx); + LOG_D(PHY,"PDSCH dlsch0 UE: TBS %d\n",dlsch0_harq->TBS); + LOG_D(PHY,"PDSCH dlsch0 UE: mcs %d\n",dlsch0_harq->mcs); + LOG_D(PHY,"PDSCH dlsch0 UE: pwr_off %d\n",dlsch0_harq->dl_power_off); + } +#endif + +#if T_TRACER + if( (dlsch[0]->rnti != si_rnti) && (dlsch[0]->rnti != ra_rnti) && (dlsch[0]->rnti != p_rnti)) + { + T(T_UE_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame%1024), T_INT(subframe), + T_INT(dlsch[0]->rnti), T_INT(dci_format), + T_INT(harq_pid), + T_INT(dlsch0_harq->mcs), + T_INT(dlsch0_harq->TBS)); + } +#endif + + + // compute DL power control parameters + if (dlsch0_harq != NULL){ + computeRhoA_UE(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); + computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[0],dlsch0_harq->dl_power_off); + } + + if (dlsch1_harq != NULL) { + computeRhoA_UE(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); + computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[1],dlsch1_harq->dl_power_off); + } + + + return(0); +} + + + +int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb) +{ + int nb_subbands = 0; + int32_t pmi_alloc_new = 0, pmi_new = 0, pmi_old = 0; + int i; + + switch (nb_rb) { + case 6: + nb_subbands = 6; + break; + default: + case 25: + nb_subbands = 7; + break; + case 50: + nb_subbands = 9; + break; + case 100: + nb_subbands = 13; + break; + } + + for (i = 0; i < nb_subbands; i++) { + pmi_old = (pmi_alloc >> i)&1; + + if (pmi_old == 0) + if (tpmi == 5) + pmi_new = 0; + else + pmi_new = 1; + else + if (tpmi == 5) + pmi_new = 2; + else + pmi_new = 3; + + pmi_alloc_new|=pmi_new<<(2*i); + + } +#ifdef DEBUG_HARQ +printf(" [DCI UE] pmi_alloc_old %d, pmi_alloc_new %d pmi_old %d , pmi_new %d\n", pmi_alloc, pmi_alloc_new,pmi_old, pmi_new ); +#endif +return(pmi_alloc_new); + +} + +uint16_t quantize_subband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,int nb_rb) +{ + + int i, aarx; + uint16_t pmiq=0; + uint32_t pmivect = 0; + uint8_t rank = meas->rank[eNB_id]; + int pmi_re,pmi_im; + int nb_subbands=0; + + + switch (nb_rb) { + case 6: + nb_subbands = 6; + break; + default: + case 25: + nb_subbands = 7; + break; + case 50: + nb_subbands = 9; + break; + case 100: + nb_subbands = 13; + break; + } + + + for (i=0; i<nb_subbands; i++) { + pmi_re = 0; + pmi_im = 0; + + if (rank == 0) { + for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { + pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; + pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; + } + + // pmi_re = meas->subband_pmi_re[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; + // pmi_im = meas->subband_pmi_im[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; + + // printf("pmi => (%d,%d)\n",pmi_re,pmi_im); + if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_11; + else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_1j; + else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1m1; + else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1mj; + + // printf("subband %d, pmi%d \n",i,pmiq); + pmivect |= (pmiq<<(2*i)); + } + + else if (rank==1) { + for (aarx=0; aarx<meas->nb_antennas_rx; aarx++) { + pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; + //printf("meas->subband_pmi_re[eNB_id][i][%d]=%d\n", aarx, meas->subband_pmi_re[eNB_id][i][aarx]); + pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; + //printf("meas->subband_pmi_im[eNB_id][i][%d]=%d\n",aarx, meas->subband_pmi_im[eNB_id][i][aarx]); + } + if (pmi_re >= pmi_im) // this is not orthogonal + // this is orthogonal + //if (((pmi_re >= pmi_im) && (pmi_re >= -pmi_im)) || ((pmi_re <= pmi_im) && (pmi_re >= -pmi_im))) + pmiq = PMI_2A_R1_11; + else + pmiq = PMI_2A_R1_1j; + + // printf("subband %d, pmi_re %d, pmi_im %d, pmiq %d \n",i,pmi_re,pmi_im,pmiq); + // printf("subband %d, pmi%d \n",i,pmiq); + //According to Section 7.2.4 of 36.213 + + pmivect |= ((pmiq-1)<<(i)); //shift 1 since only one bit + } + else { + LOG_E(PHY,"PMI feedback for rank>1 not supported!\n"); + pmivect = 0; + } + + } +#ifdef DEBUG_HARQ + printf( "quantize_subband_pmi pmivect %d \n", pmivect); +#endif + return(pmivect); +} + +uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands) +{ + + uint8_t i; + uint16_t pmiq=0; + uint16_t pmivect = 0; + uint8_t rank = meas->rank[eNB_id]; + int pmi_re,pmi_im; + + for (i=0; i<nb_subbands; i++) { + + if (rank == 0) { + pmi_re = meas->subband_pmi_re[eNB_id][i][a_id]; + pmi_im = meas->subband_pmi_im[eNB_id][i][a_id]; + + if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_11; + else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_1j; + else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1m1; + else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1mj; + + pmivect |= (pmiq<<(2*i)); + } else { + // This needs to be done properly!!! + pmivect = 0; + } + } + + return(pmivect); +} + +uint16_t quantize_wideband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) +{ + + uint16_t pmiq=0; + uint8_t rank = meas->rank[eNB_id]; + //int pmi; + int pmi_re,pmi_im; + + if (rank == 1) { + //pmi = + pmi_re = meas->wideband_pmi_re[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; + pmi_im = meas->wideband_pmi_im[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; + + if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_11; + else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) + pmiq = PMI_2A_1j; + else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1m1; + else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) + pmiq = PMI_2A_1mj; + + } else { + // This needs to be done properly! + pmiq = PMI_2A_11; + } + + + return(pmiq); +} +/* + uint8_t sinr2cqi(int sinr) { + if (sinr<-3) + return(0); + if (sinr>14) + return(10); + else + return(3+(sinr>>1)); + } +*/ + +uint8_t sinr2cqi(double sinr,uint8_t trans_mode) +{ + // int flag_LA=0; + + uint8_t retValue = 0; + + if(flag_LA==0) { + // Ideal Channel Estimation + if (sinr<=-4.89) + retValue = (0); + else if (sinr < -3.53) + retValue = (3); + else if (sinr <= -1.93) + retValue = (4); + else if (sinr <= -0.43) + retValue = (5); + else if (sinr <= 1.11) + retValue = (6); + else if (sinr <= 3.26) + retValue = (7); + else if (sinr <= 5.0) + retValue = (8); + else if (sinr <= 7.0) + retValue = (9); + else if (sinr <= 9.0) + retValue = (10); + else if (sinr <= 11.0) + retValue = (11); + else if (sinr <= 13.0) + retValue = (12); + else if (sinr <= 15.5) + retValue = (13); + else if (sinr <= 17.5) + retValue = (14); + else + retValue = (15); + } else { + int h=0; + int trans_mode_tmp; + + if (trans_mode ==5) + trans_mode_tmp=2; + else if(trans_mode ==6) + trans_mode_tmp=3; + else + trans_mode_tmp = trans_mode-1; + + for(h=0; h<16; h++) { + if(sinr<=sinr_to_cqi[trans_mode_tmp][h]) + retValue = (h); + } + } + + LOG_D(PHY, "sinr=%f trans_mode=%d cqi=%d\n", sinr, trans_mode, retValue); + return retValue; +} +//uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) { +// +// uint8_t i; +//// uint16_t cqivect = 0; +// uint32_t cqivect = 0; +// +//// char diff_cqi; +// int diff_cqi=0; +// +// for (i=0;i<NUMBER_OF_SUBBANDS;i++) { +// +// diff_cqi = -sinr2cqi(meas->wideband_cqi_dB[eNB_id][0]) + sinr2cqi(meas->subband_cqi_dB[eNB_id][0][i]); +// +// // Note, this is Table 7.2.1-2 from 36.213 +// if (diff_cqi<=-1) +// diff_cqi = 3; +// else if (diff_cqi>2) +// diff_cqi = 2; +// cqivect |= (diff_cqi<<(2*i)); +// +// } +// +// return(cqivect); +//} + + +uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t trans_mode,int nb_subbands) +{ + + uint8_t i; + + uint32_t cqivect = 0,offset=0; + + + int diff_cqi=0; + + for (i=0; i<nb_subbands; i++) { + + diff_cqi = -sinr2cqi(meas->wideband_cqi_avg[eNB_id],trans_mode) + sinr2cqi(meas->subband_cqi_tot_dB[eNB_id][i],trans_mode); + + // Note, this is Table 7.2.1-2 from 36.213 + if (diff_cqi<=-1) + offset = 3; + else if (diff_cqi>=2) + offset = 2; + else + offset=(uint32_t)diff_cqi; + + cqivect |= (offset<<(2*i)); + + } + + return(cqivect); +} + +void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t harq_pid,int N_RB_DL,uint16_t rnti, uint8_t trans_mode, double sinr_eff) +{ + + // printf("[PHY][UE] Filling CQI for eNB %d, meas->wideband_cqi_tot[%d] %d\n", + // eNB_id,eNB_id,meas->wideband_cqi_tot[eNB_id]); + double sinr_tmp; + uint8_t *o = ulsch->o; + UCI_format_t uci_format = ulsch->uci_format; + + if(flag_LA==1) + sinr_tmp = sinr_eff; + else + sinr_tmp = (double) meas->wideband_cqi_avg[eNB_id]; + + + + //LOG_I(PHY,"[UE][UCI] Filling CQI format %d for eNB %d N_RB_DL %d\n",uci_format,eNB_id,N_RB_DL); + + switch (N_RB_DL) { + + case 6: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,6); + ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti = rnti; + LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + case 25: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,7); + ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = rnti; + LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + case 50: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,9); + ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti = rnti; + LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + case 100: + switch (uci_format) { + case wideband_cqi_rank1_2A: + ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((wideband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); + break; + + case wideband_cqi_rank2_2A: + ((wideband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi + ((wideband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); + break; + + case HLC_subband_cqi_nopmi: + ((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + break; + + case HLC_subband_cqi_rank1_2A: + ((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); + break; + + case HLC_subband_cqi_rank2_2A: + // This has to be improved!!! + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,13); + ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); + break; + + case HLC_subband_cqi_mcs_CBA: + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; + ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti = rnti; + LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); + break; + + case ue_selected: + LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); + AssertFatal(1==0,"fill_CQI ue_selected CQI not supported yet!!!"); + break; + + default: + LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); + AssertFatal(1==0,"unsupported CQI mode !!!"); + break; + + } + + break; + + } + + +} + +void reset_cba_uci(void *o) +{ + // this is the cba mcs uci for cba transmission + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = 0; //fixme + ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = 0x0; +} + + + + + +int generate_ue_ulsch_params_from_dci(void *dci_pdu, + uint16_t rnti, + uint8_t subframe, + DCI_format_t dci_format, + PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint16_t cba_rnti, + uint8_t eNB_id, + uint8_t use_srs) +{ + + uint8_t harq_pid; + uint8_t transmission_mode = ue->transmission_mode[eNB_id]; + ANFBmode_t AckNackFBMode; + LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + LTE_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[subframe]][0]; + PHY_MEASUREMENTS *meas = &ue->measurements; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + // uint32_t current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; + + if(frame_parms->frame_type == TDD) + { + AckNackFBMode = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; + } + else + { + AckNackFBMode = 1; // 1: multiplexing for FDD + } + + uint32_t cqi_req; + uint32_t dai=3; + uint32_t cshift; + uint32_t TPC; + uint32_t ndi; + uint32_t mcs; + uint32_t rballoc,RIV_max; + uint16_t* RIV2first_rb_LUT; + uint16_t* RIV2nb_rb_LUT; + + // uint32_t hopping; + // uint32_t type; + + if (dci_format == format0) { + + if (!ulsch) + return -1; + + if (rnti == ra_rnti) + harq_pid = 0; + else + harq_pid = subframe2harq_pid(frame_parms, + pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,subframe), + pdcch_alloc2ul_subframe(frame_parms,subframe)); + LOG_D(PHY,"Frame %d, Subframe %d: Programming ULSCH for (%d.%d) => harq_pid %d\n", + proc->frame_rx,subframe, + pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,subframe), + pdcch_alloc2ul_subframe(frame_parms,subframe), harq_pid); + + if (harq_pid == 255) { + LOG_E(PHY, "frame %d, subframe %d, rnti %x, format %d: illegal harq_pid!\n", + proc->frame_rx, subframe, rnti, dci_format); + return(-1); + } + + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max6; + RIV2first_rb_LUT = RIV2first_rb_LUT6; + RIV2nb_rb_LUT = RIV2nb_rb_LUT6; + + break; + + case 25: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_5MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max25; + RIV2first_rb_LUT = RIV2first_rb_LUT25; + RIV2nb_rb_LUT = RIV2nb_rb_LUT25; + // printf("***********rballoc %d, first_rb %d, nb_rb %d (dci %p)\n",rballoc,ulsch->harq_processes[harq_pid]->first_rb,ulsch->harq_processes[harq_pid]->nb_rb,dci_pdu); + break; + + case 50: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_10MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max50; + RIV2first_rb_LUT = RIV2first_rb_LUT50; + RIV2nb_rb_LUT = RIV2nb_rb_LUT50; + + break; + + case 100: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; + ndi = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->ndi; + mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; + ndi = ((DCI0_20MHz_FDD_t *)dci_pdu)->ndi; + mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max100; + RIV2first_rb_LUT = RIV2first_rb_LUT100; + RIV2nb_rb_LUT = RIV2nb_rb_LUT100; + + // printf("rb_alloc (20 MHz dci) %d\n",rballoc); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + + if (rballoc > RIV_max) { + LOG_E(PHY,"frame %d, subframe %d, rnti %x, format %d: FATAL ERROR: generate_ue_ulsch_params_from_dci, rb_alloc[%d] > RIV_max[%d]\n", + proc->frame_rx, subframe, rnti, dci_format,rballoc,RIV_max); + LOG_E(PHY,"Wrong DCI0 detection, do not transmit PUSCH for HARQID: %d\n",harq_pid); + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + return(-1); + } + + + // indicate that this process is to be serviced in subframe n+4 + if ((rnti >= cba_rnti) && (rnti < p_rnti)) + ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1; //+=1 this indicates the number of dci / cba group: not supported in the data struct + else + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + //LOG_I(PHY,"[HARQ-UL harqId: %d] DCI0 ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + + } + + ulsch->harq_processes[harq_pid]->TPC = TPC; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; + + if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", + ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, + delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], + ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); + ulsch->f_pusch += delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; + } else { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d: f_pusch (ABS) %d, adjusting to %d (TPC %d)\n", + ue->Mod_id,harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, + delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], + ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); + ulsch->f_pusch = delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; + } + + if (ulsch->harq_processes[harq_pid]->first_tx==1) { + // ulsch->harq_processes[harq_pid]->Ndi = 1; + ulsch->harq_processes[harq_pid]->first_tx=0; + ulsch->harq_processes[harq_pid]->DCINdi= ndi; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + if (ulsch->harq_processes[harq_pid]->DCINdi!=ndi) { // new SDU opportunity + // ulsch->harq_processes[harq_pid]->Ndi = 1; + ulsch->harq_processes[harq_pid]->DCINdi= ndi; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + // ulsch->harq_processes[harq_pid]->Ndi = 0; + //ulsch->harq_processes[harq_pid]->round++; // This is done in phich RX + + //#ifdef DEBUG_PHICH + //LOG_I(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d Adaptative Retrans, NDI not toggled => Nack. maxHARQ_Tx %d \n", + // ue->Mod_id,harq_pid, + // proc->frame_rx, + // subframe, + // ulsch->Mlimit); + //#endif +/* + if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich + { + // ulsch->harq_processes[harq_pid]->round++; already done on phich_rx + // ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; + // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); + + if (ulsch->harq_processes[harq_pid]->round >= ulsch->Mlimit) //UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) + { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ulsch->harq_processes[harq_pid]->round = 0; + ulsch->harq_processes[harq_pid]->status = IDLE; + //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + } + else + { + // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + uint8_t rv_table[4] = {0, 2, 3, 1}; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + } + } +*/ + } + } + + ulsch->harq_processes[harq_pid]->n_DMRS = cshift; + + //printf("nb_rb %d, first_rb %d (RIV %d)\n",ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb,rballoc); + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + // ulsch->cba_rnti[0]=rnti; + } else { + ulsch->rnti = rnti; + } + + // printf("[PHY][UE] DCI format 0: harq_pid %d nb_rb %d, rballoc %d\n",harq_pid,ulsch->harq_processes[harq_pid]->nb_rb, + // ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc); + //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) + if(cshift == 0) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; + else if(cshift == 1) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; + else if(cshift == 2) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; + else if(cshift == 3) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; + else if(cshift == 4) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; + else if(cshift == 5) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; + else if(cshift == 6) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; + else if(cshift == 7) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; + + + //reserved for cooperative communication + /* + if(ulsch->n_DMRS2 == 6) + ulsch->cooperation_flag = 2; + else + ulsch->cooperation_flag = 0; + */ + + if ((ulsch->harq_processes[harq_pid]->nb_rb>0) && (ulsch->harq_processes[harq_pid]->nb_rb < 25)) + ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb-1]; + + // if (ulsch->harq_processes[harq_pid]->Ndi == 1) + // ulsch->harq_processes[harq_pid]->status = ACTIVE; + + + if (cqi_req == 1) { + + if( (AntennaInfoDedicated__transmissionMode_tm3 == transmission_mode) || (AntennaInfoDedicated__transmissionMode_tm4 == transmission_mode) ) + { + ulsch->O_RI = 1; + } + else + { + ulsch->O_RI = 0; + } + //ulsch->O_RI = 0; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table + + switch(transmission_mode) { + // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling + case 1: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + case 2: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + case 3: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + case 4: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->o_RI[0] = 1; + } + + break; + + case 5: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->o_RI[0] = 1; + } + + break; + + case 6: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + break; + + case 50: + ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; + break; + + case 100: + ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; + break; + } + + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->o_RI[0] = 1; + } + + break; + + case 7: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_mcs_CBA; + ulsch->o_RI[0] = 0; + } else if(meas->rank[eNB_id] == 0) { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 0; + } else { + switch (ue->frame_parms.N_RB_DL) { + case 6: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + ulsch->o_RI[0] = 1; + } + + break; + + default: + LOG_E(PHY,"Incorrect Transmission Mode \n"); + break; + } + } else { + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + } + + print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); + + ulsch->bundling = 1-AckNackFBMode; + + if (frame_parms->frame_type == FDD) { + //int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); + int dl_subframe = subframe; + + if (ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_ack[dl_subframe].send_harq_status>0) { // we have downlink transmission + ulsch->harq_processes[harq_pid]->O_ACK = 1; + } else { + ulsch->harq_processes[harq_pid]->O_ACK = 0; + } + /*LOG_I(PHY,"DCI 0 Processing: dl_subframe %d send_harq_status Odd %d send_harq_status Even %d harq_pid %d O_ACK %d\n", dl_subframe, + ue->dlsch[0][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, + ue->dlsch[1][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, + harq_pid, + ulsch->harq_processes[harq_pid]->O_ACK);*/ + + } else { + if (ulsch->bundling) + ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; + else + ulsch->harq_processes[harq_pid]->O_ACK = (dai >= 2)? 2 : (dai+1)&3; //(dai+1)&3; + + // ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; + } + + dlsch[0]->harq_ack[subframe].vDAI_UL = dai+1; + + + LOG_D(PHY, "[PUSCH %d] Format0 DCI %s, CQI_req=%d, cshift=%d, TPC=%d, DAI=%d, vDAI_UL[sf#%d]=%d, NDI=%d, MCS=%d, RBalloc=%d, first_rb=%d, harq_pid=%d, nb_rb=%d, subframe_scheduling_flag=%d" + " ulsch->bundling %d, O_ACK %d \n", + harq_pid, + (frame_parms->frame_type == TDD? "TDD" : "FDD"), + cqi_req, cshift, TPC, dai, subframe, dlsch[0]->harq_ack[subframe].vDAI_UL, ndi, mcs, rballoc, + ulsch->harq_processes[harq_pid]->first_rb, harq_pid, ulsch->harq_processes[harq_pid]->nb_rb, + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, + ulsch->bundling, + ulsch->harq_processes[harq_pid]->O_ACK); + + LOG_D(PHY,"Setting beta_offset_cqi_times8 to %d, index %d\n", + beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index], + ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index); + + ulsch->beta_offset_cqi_times8 = beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index];//18; + ulsch->beta_offset_ri_times8 = beta_ri[ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index];//10; + ulsch->beta_offset_harqack_times8 = beta_ack[ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index];//16; + + ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); + ulsch->srs_active = use_srs; + + if ((rnti >= cba_rnti) && (rnti < p_rnti)) + ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; + else + ulsch->harq_processes[harq_pid]->status = ACTIVE; + + ulsch->harq_processes[harq_pid]->rvidx = 0; + + // ulsch->harq_processes[harq_pid]->calibration_flag =0; + if (mcs < 29) { + ulsch->harq_processes[harq_pid]->mcs = mcs; + // ulsch->harq_processes[harq_pid]->round = 0; + } else { + ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; + if (ulsch->harq_processes[harq_pid]->round == 0) { + LOG_W(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); + } else { + LOG_D(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); + } + //LOG_E(PHY,"Fatal: mcs(%d) > 28!!! and round == 0\n", mcs); + } + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + + /* + else if (ulsch->harq_processes[harq_pid]->mcs == 29) { + ulsch->harq_processes[harq_pid]->mcs = 4; + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + // ulsch->harq_processes[harq_pid]->calibration_flag =1; + // printf("Auto-Calibration (UE): mcs %d, TBS %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->TBS,ulsch->harq_processes[harq_pid]->nb_rb); + }*/ + ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; + ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->Nsymb_pusch; + + // a Ndi=1 automatically acknowledges previous PUSCH transmission + if (ue->ulsch_Msg3_active[eNB_id] == 1) + ue->ulsch_Msg3_active[eNB_id] = 0; + + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d), nb_rb %d, first_rb %d, mcs %d, round %d, rv %d, ulsch_ue_Msg3_active %d, cqi_req %d => O %d\n", + ue->Mod_id,harq_pid, + proc->frame_rx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift,ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb, + ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->round,ulsch->harq_processes[harq_pid]->rvidx, ue->ulsch_Msg3_active[eNB_id],cqi_req,ulsch->O); + + // ulsch->n_DMRS2 = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + +#ifdef UE_DEBUG_TRACE + + LOG_D(PHY,"Format 0 DCI : ulsch (ue): AbsSubframe %d.%d\n",proc->frame_rx%1024,subframe); + LOG_D(PHY,"Format 0 DCI : ulsch (ue): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): rballoc %d\n",rballoc); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): harq_pid %d\n",harq_pid); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_tx %d\n",ulsch->harq_processes[harq_pid]->first_tx); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): DCINdi %d\n",ulsch->harq_processes[harq_pid]->DCINdi); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): round %d\n",ulsch->harq_processes[harq_pid]->round); + //LOG_I(PHY,"Format 0 DCI :ulsch (ue): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); + //LOG_I(PHY,"Format 0 DCI :ulsch (ue): O %d\n",ulsch->O); + //LOG_I(PHY,"Format 0 DCI :ulsch (ue): cqiReq %d\n",cqi_req); + //if (frame_parms->frame_type == TDD) + // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK/DAI %d/%d\n",ulsch->harq_processes[harq_pid]->O_ACK,dai); + //else + // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK %d\n",ulsch->harq_processes[harq_pid]->O_ACK); + + LOG_D(PHY,"Format 0 DCI :ulsch (ue): Nsymb_pusch %d\n",ulsch->Nsymb_pusch); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); + LOG_D(PHY,"Format 0 DCI :ulsch (ue): phich status %d\n",ulsch->harq_processes[harq_pid]->status); +#else + UNUSED_VARIABLE(dai); +#endif + return(0); + } else { + LOG_E(PHY,"frame %d, subframe %d: FATAL ERROR, generate_ue_ulsch_params_from_dci, Illegal dci_format %d\n", + proc->frame_rx, subframe,dci_format); + return(-1); + } + +} + +/* +int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *eNB, + eNB_rxtx_proc_t *proc, + void *dci_pdu, + uint16_t rnti, + DCI_format_t dci_format, + uint8_t UE_id, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint16_t cba_rnti, + uint8_t use_srs) +{ + + uint8_t harq_pid; + uint32_t rb_alloc; + uint8_t transmission_mode=eNB->transmission_mode[UE_id]; + ANFBmode_t AckNackFBMode = eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode; + LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id]; + LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; + int subframe = proc->subframe_tx; + + uint32_t cqi_req = 0; + uint32_t dai = 0; + uint32_t cshift = 0; + uint32_t TPC = 0; + uint32_t mcs = 0; + uint32_t rballoc = UINT32_MAX; + uint32_t RIV_max = 0; + // uint32_t hopping; + // uint32_t type; + +#ifdef DEBUG_DCI + printf("filling eNB ulsch params for rnti %x, dci format %d, dci %x, subframe %d\n", + rnti,dci_format,*(uint32_t*)dci_pdu,subframe); +#endif + + if (dci_format == format0) { + + harq_pid = subframe2harq_pid(frame_parms, + pdcch_alloc2ul_frame(frame_parms, + proc->frame_tx, + subframe), + pdcch_alloc2ul_subframe(frame_parms,subframe)); + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping=hopping; + // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max6; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT6[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT6[rballoc]; + + break; + + case 25: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping; + // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping; + // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max25; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT25[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT25[rballoc]; + + break; + + case 50: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping; + // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping; + // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max50; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT50[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT50[rballoc]; + + break; + + case 100: + if (frame_parms->frame_type == TDD) { + cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; + dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; + cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; + mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping; + // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; + } else { + cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; + cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; + TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; + mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; + rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; + // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping; + // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; + } + + RIV_max = RIV_max100; + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT100[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT100[rballoc]; + + //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc); + break; + + default: + LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); + DevParam (frame_parms->N_RB_DL, 0, 0); + break; + } + + + rb_alloc = rballoc; + AssertFatal(rb_alloc>RIV_max, + "Format 0: rb_alloc (%d) > RIV_max (%d)\n",rb_alloc,RIV_max); +#ifdef DEBUG_DCI + printf("generate_eNB_ulsch_params_from_dci: subframe %d, rnti %x,harq_pid %d,cqi_req %d\n",subframe,rnti,harq_pid,cqi_req); +#endif + + ulsch->harq_processes[harq_pid]->dci_alloc = 1; + ulsch->harq_processes[harq_pid]->rar_alloc = 0; + ulsch->harq_processes[harq_pid]->TPC = TPC; + ulsch->harq_processes[harq_pid]->n_DMRS = cshift; + + + if (cqi_req == 1) { + // 36.213 7.2.1 (release 10) says: + // "RI is only reported for transmission modes 3 and 4, + // as well as transmission modes 8 and 9 with PMI/RI reporting" + // This is for aperiodic reporting. + // TODO: deal with TM 8&9 correctly when they are implemented. + // TODO: deal with periodic reporting if we implement it. + // + if (transmission_mode == 3 || transmission_mode == 4) + ulsch->harq_processes[harq_pid]->O_RI = 1; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table + else + ulsch->harq_processes[harq_pid]->O_RI = 0; + + switch(transmission_mode) { + // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling + case 1: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + break; + + case 2: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + break; + + case 3: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + break; + + case 4: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + + } + + ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; + } + + break; + + case 5: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; + } + + break; + + case 6: + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; + } else { + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; + ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; + } + + break; + + case 7: + ulsch->harq_processes[harq_pid]->Or2 = 0; + + switch (frame_parms->N_RB_DL) { + case 6: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; + break; + + case 25: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; + break; + + case 50: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; + break; + + case 100: + ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; + break; + } + + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + break; + + default: + LOG_E(PHY,"Incorrect Transmission Mode \n"); + break; + } + } else { + ulsch->harq_processes[harq_pid]->O_RI = 0; + ulsch->harq_processes[harq_pid]->Or2 = 0; + ulsch->harq_processes[harq_pid]->Or1 = 0; + ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; + } + + ulsch->bundling = 1-AckNackFBMode; + + if (frame_parms->frame_type == FDD) { + int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); + + if (eNB->dlsch[UE_id][0]->subframe_tx[dl_subframe]>0) { // we have downlink transmission + ulsch->harq_processes[harq_pid]->O_ACK = 1; + } else { + ulsch->harq_processes[harq_pid]->O_ACK = 0; + } + } else { + if (ulsch->bundling) + ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; + else + ulsch->harq_processes[harq_pid]->O_ACK = (dai+1)&3; + + ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; + } + + ulsch->beta_offset_cqi_times8 = beta_cqi[eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index];//18; + ulsch->beta_offset_ri_times8 = beta_ri[eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index];//10; + ulsch->beta_offset_harqack_times8 = beta_ack[eNB->pusch_config_dedicated[UE_id].betaOffset_ACK_Index];//16; + + ulsch->harq_processes[harq_pid]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); + ulsch->harq_processes[harq_pid]->srs_active = use_srs; + + //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) + if(cshift == 0) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; + else if(cshift == 1) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; + else if(cshift == 2) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; + else if(cshift == 3) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; + else if(cshift == 4) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; + else if(cshift == 5) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; + else if(cshift == 6) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; + else if(cshift == 7) + ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; + + + LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d)\n", + eNB->Mod_id,harq_pid,proc->frame_tx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift); + + + + if (ulsch->harq_processes[harq_pid]->round == 0) { + if ((rnti >= cba_rnti) && (rnti < p_rnti)) + ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; + else + ulsch->harq_processes[harq_pid]->status = ACTIVE; + + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->mcs = mcs; + // ulsch->harq_processes[harq_pid]->calibration_flag = 0; + //if (ulsch->harq_processes[harq_pid]->mcs) + // + //if (ulsch->harq_processes[harq_pid]->mcs == 29) { + //ulsch->harq_processes[harq_pid]->mcs = 4; + // ulsch->harq_processes[harq_pid]->calibration_flag = 1; + // printf("Auto-Calibration (eNB): mcs %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->nb_rb); + //} + + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + + ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; + ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->harq_processes[harq_pid]->Nsymb_pusch; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + if (mcs>28) + ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; + else { + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->mcs = mcs; + } + + // ulsch->harq_processes[harq_pid]->round++; + } + + if ((rnti >= cba_rnti) && (rnti < p_rnti)) { + ulsch->cba_rnti[0] = rnti; + } else { + ulsch->rnti = rnti; + } + + //ulsch->n_DMRS2 = cshift; + +#ifdef DEBUG_DCI + printf("ulsch (eNB): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); + printf("ulsch (eNB): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); + printf("ulsch (eNB): harq_pid %d\n",harq_pid); + printf("ulsch (eNB): round %d\n",ulsch->harq_processes[harq_pid]->round); + printf("ulsch (eNB): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); + printf("ulsch (eNB): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); + printf("ulsch (eNB): Or1 %d\n",ulsch->harq_processes[harq_pid]->Or1); + printf("ulsch (eNB): Nsymb_pusch %d\n",ulsch->harq_processes[harq_pid]->Nsymb_pusch); + printf("ulsch (eNB): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); +#else + UNUSED_VARIABLE(dai); +#endif + return(0); + } else { + LOG_E(PHY,"generate_eNB_ulsch_params_from_dci, Illegal dci_format %d\n",dci_format); + return(-1); + } + +} +*/ + +double sinr_eff_cqi_calc(PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe) +{ + uint8_t transmission_mode = ue->transmission_mode[eNB_id]; + PHY_MEASUREMENTS *meas = &ue->measurements; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + int32_t **dl_channel_est = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id]; + double *s_dB; + s_dB = ue->sinr_CQI_dB; + // LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + //for the calculation of SINR_eff for CQI calculation + int count,a_rx,a_tx; + double abs_channel=0; + double channelx=0; + double channely=0; + double channelx_i=0; + double channely_i=0; + uint16_t q = quantize_subband_pmi(meas,eNB_id,7); + uint8_t qq; + + switch(transmission_mode) { + case 1: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + s_dB[count] = 10*log10(pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2], + 2)) - meas->n0_power_avg_dB; + } + } + } + + break; + + case 2: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + abs_channel=0; + + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + abs_channel += (pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2],2)); + } + } + + s_dB[count] = 10*log10(abs_channel/2) - meas->n0_power_avg_dB; + } + + break; + + case 5: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + channelx=0; + channely=0; + channelx_i=0; + channely_i=0; + qq = (q>>(((count/12)>>2)<<1))&3; + + //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + switch(qq) { + case 0: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 1: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 2: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 3: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + default: + printf("Problem in SINR Calculation for TM5 \n"); + break; + }//switch(qq) + }//a_rx + }//a_tx + + s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - 10 * log10 ((pow(channelx_i,2) + pow(channely_i,2))/2) - meas->n0_power_avg_dB; + }//count + + break; + + case 6: + for (count=0; count<frame_parms->N_RB_DL*12; count++) { + channelx=0; + channely=0; + qq = (q>>(((count/12)>>2)<<1))&3; + + //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); + for(a_tx=0; a_tx<frame_parms->nb_antenna_ports_eNB; a_tx++) { + for (a_rx=0; a_rx<frame_parms->nb_antennas_rx; a_rx++) { + switch(qq) { + case 0: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 1: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 2: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + case 3: + if (channelx==0 || channely==0) { + channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + } else { + channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; + channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; + } + + break; + + default: + printf("Problem in SINR Calculation for TM6 \n"); + break; + }//switch(qq) + }//a_rx + }//a_tx + + s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - meas->n0_power_avg_dB; + }//count + + break; + + default: + printf("Problem in SINR Calculation for CQI \n"); + break; + } + + int ii; + double sinr_eff = 0; + double sinr_eff_qpsk=0; + double sinr_eff_qam16=0; + double sinr_eff_qam64=0; + double x = 0; + double I_qpsk=0; + double I_qam16=0; + double I_qam64=0; + double I_qpsk_avg=0; + double I_qam16_avg=0; + double I_qam64_avg=0; + double qpsk_max=12.2; + double qam16_max=19.2; + double qam64_max=25.2; + double sinr_min = -20; + int offset=0; + + + for (offset = 0; offset <= 24; offset++) { + for(ii=0; ii<12; ii++) { + //x is the sinr_dB in dB + x = s_dB[(offset*12)+ii]; + + if(x<sinr_min) { + I_qpsk +=0; + I_qam16 +=0; + I_qam64 +=0; + } else { + if(x>qpsk_max) + I_qpsk += 1; + else + I_qpsk += (q_qpsk[0]*pow(x,7) + q_qpsk[1]*pow(x,6) + q_qpsk[2]*pow(x,5) + q_qpsk[3]*pow(x,4) + q_qpsk[4]*pow(x,3) + q_qpsk[5]*pow(x,2) + q_qpsk[6]*x + q_qpsk[7]); + + if(x>qam16_max) + I_qam16 += 1; + else + I_qam16 += (q_qam16[0]*pow(x,7) + q_qam16[1]*pow(x,6) + q_qam16[2]*pow(x,5) + q_qam16[3]*pow(x,4) + q_qam16[4]*pow(x,3) + q_qam16[5]*pow(x,2) + q_qam16[6]*x + q_qam16[7]); + + if(x>qam64_max) + I_qam64 += 1; + else + I_qam64 += (q_qam64[0]*pow(x,7) + q_qam64[1]*pow(x,6) + q_qam64[2]*pow(x,5) + q_qam64[3]*pow(x,4) + q_qam64[4]*pow(x,3) + q_qam64[5]*pow(x,2) + q_qam64[6]*x + q_qam64[7]); + + } + } + } + + // averaging of accumulated MI + I_qpsk_avg = I_qpsk/(12*frame_parms->N_RB_DL); + I_qam16_avg = I_qam16/(12*frame_parms->N_RB_DL); + I_qam64_avg = I_qam64/(12*frame_parms->N_RB_DL); + + // I->SINR_effective Mapping + + sinr_eff_qpsk = (p_qpsk[0]*pow(I_qpsk_avg,7) + p_qpsk[1]*pow(I_qpsk_avg,6) + p_qpsk[2]*pow(I_qpsk_avg,5) + p_qpsk[3]*pow(I_qpsk_avg,4) + p_qpsk[4]*pow(I_qpsk_avg,3) + p_qpsk[5]*pow(I_qpsk_avg, + 2) + p_qpsk[6]*I_qpsk_avg + p_qpsk[7]); + + sinr_eff_qam16 = (p_qam16[0]*pow(I_qam16_avg,7) + p_qam16[1]*pow(I_qam16_avg,6) + p_qam16[2]*pow(I_qam16_avg,5) + p_qam16[3]*pow(I_qam16_avg,4) + p_qam16[4]*pow(I_qam16_avg, + 3) + p_qam16[5]*pow(I_qam16_avg,2) + p_qam16[6]*I_qam16_avg + p_qam16[7]); + + sinr_eff_qam64 = (p_qam64[0]*pow(I_qam64_avg,7) + p_qam64[1]*pow(I_qam64_avg,6) + p_qam64[2]*pow(I_qam64_avg,5) + p_qam64[3]*pow(I_qam64_avg,4) + p_qam64[4]*pow(I_qam64_avg, + 3) + p_qam64[5]*pow(I_qam64_avg,2) + p_qam64[6]*I_qam64_avg + p_qam64[7]); + sinr_eff = cmax3(sinr_eff_qpsk,sinr_eff_qam16,sinr_eff_qam64); + + //printf("SINR_Eff = %e\n",sinr_eff); + + return(sinr_eff); +} +// + + + +#ifdef DEBUG_DLSCH_TOOLS +main() +{ + + int i; + uint8_t rah; + uint32_t rballoc; + + generate_RIV_tables(); + + rah = 0; + rballoc = 0x1fff; + printf("rballoc 0 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rah = 1; + + rballoc = 0x1678; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + + rballoc = 0xfffc; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rballoc = 0xfffd; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rballoc = 0xffff; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); + rballoc = 0xfffe; + printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); +} + +#endif + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c new file mode 100755 index 0000000000000000000000000000000000000000..f7afb08286ddb8f58e359bec492d0bdbfca0258d --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c @@ -0,0 +1,3245 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/dci.c +* \brief Implements PDCCH physical channel TX/RX procedures (36.211) and DCI encoding/decoding (36.212/36.213). Current LTE compliance V8.6 2009-03. +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "PHY/defs_UE.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "SIMULATION/TOOLS/sim.h" // for taus +#include "PHY/sse_intrin.h" +#include "PHY/LTE_TRANSPORT/transport_extern.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "SCHED/sched_common.h" + +#include "assertions.h" +#include "T.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +//#define DEBUG_DCI_ENCODING 1 +//#define DEBUG_DCI_DECODING 1 +//#define DEBUG_PHY + +//#undef ALL_AGGREGATION + + +uint16_t extract_crc(uint8_t *dci,uint8_t dci_len) +{ + + uint16_t crc16; + // uint8_t i; + + /* + uint8_t crc; + crc = ((uint16_t *)dci)[DCI_LENGTH>>4]; + printf("crc1: %x, shift %d (DCI_LENGTH %d)\n",crc,DCI_LENGTH&0xf,DCI_LENGTH); + crc = (crc>>(DCI_LENGTH&0xf)); + // clear crc bits + ((uint16_t *)dci)[DCI_LENGTH>>4] &= (0xffff>>(16-(DCI_LENGTH&0xf))); + printf("crc2: %x, dci0 %x\n",crc,((int16_t *)dci)[DCI_LENGTH>>4]); + crc |= (((uint16_t *)dci)[1+(DCI_LENGTH>>4)])<<(16-(DCI_LENGTH&0xf)); + // clear crc bits + (((uint16_t *)dci)[1+(DCI_LENGTH>>4)]) = 0; + printf("extract_crc: crc %x\n",crc); + */ +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"dci_crc (%x,%x,%x), dci_len&0x7=%d\n",dci[dci_len>>3],dci[1+(dci_len>>3)],dci[2+(dci_len>>3)], + dci_len&0x7); +#endif + + if ((dci_len&0x7) > 0) { + ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]<<(dci_len&0x7) | dci[2+(dci_len>>3)]>>(8-(dci_len&0x7)); + ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]<<(dci_len&0x7) | dci[1+(dci_len>>3)]>>(8-(dci_len&0x7)); + } else { + ((uint8_t *)&crc16)[0] = dci[1+(dci_len>>3)]; + ((uint8_t *)&crc16)[1] = dci[(dci_len>>3)]; + } + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"dci_crc =>%x\n",crc16); +#endif + + // dci[(dci_len>>3)]&=(0xffff<<(dci_len&0xf)); + // dci[(dci_len>>3)+1] = 0; + // dci[(dci_len>>3)+2] = 0; + return((uint16_t)crc16); + +} + + + +void pdcch_demapping(uint16_t *llr,uint16_t *wbar,LTE_DL_FRAME_PARMS *frame_parms,uint8_t num_pdcch_symbols,uint8_t mi) +{ + + uint32_t i, lprime; + uint16_t kprime,kprime_mod12,mprime,symbol_offset,tti_offset,tti_offset0; + int16_t re_offset,re_offset0; + uint32_t Msymb=(DCI_BITS_MAX/2); + + // This is the REG allocation algorithm from 36-211, second part of Section 6.8.5 + + int Msymb2; + + switch (frame_parms->N_RB_DL) { + case 100: + Msymb2 = Msymb; + break; + + case 75: + Msymb2 = 3*Msymb/4; + break; + + case 50: + Msymb2 = Msymb>>1; + break; + + case 25: + Msymb2 = Msymb>>2; + break; + + case 15: + Msymb2 = Msymb*15/100; + break; + + case 6: + Msymb2 = Msymb*6/100; + break; + + default: + Msymb2 = Msymb>>2; + break; + } + + mprime=0; + + + re_offset = 0; + re_offset0 = 0; // counter for symbol with pilots (extracted outside!) + + for (kprime=0; kprime<frame_parms->N_RB_DL*12; kprime++) { + for (lprime=0; lprime<num_pdcch_symbols; lprime++) { + + symbol_offset = (uint32_t)frame_parms->N_RB_DL*12*lprime; + + tti_offset = symbol_offset + re_offset; + tti_offset0 = symbol_offset + re_offset0; + + // if REG is allocated to PHICH, skip it + if (check_phich_reg(frame_parms,kprime,lprime,mi) == 1) { +// printf("dci_demapping : skipping REG %d (RE %d)\n",(lprime==0)?kprime/6 : kprime>>2,kprime); + if ((lprime == 0)&&((kprime%6)==0)) + re_offset0+=4; + } else { // not allocated to PHICH/PCFICH + // printf("dci_demapping: REG %d\n",(lprime==0)?kprime/6 : kprime>>2); + if (lprime == 0) { + // first symbol, or second symbol+4 TX antennas skip pilots + kprime_mod12 = kprime%12; + + if ((kprime_mod12 == 0) || (kprime_mod12 == 6)) { + // kprime represents REG + + for (i=0; i<4; i++) { + wbar[mprime] = llr[tti_offset0+i]; +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset0+i,symbol_offset,re_offset0,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); +#endif + mprime++; + re_offset0++; + } + } + } else if ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4)) { + // LATER!!!! + } else { // no pilots in this symbol + kprime_mod12 = kprime%12; + + if ((kprime_mod12 == 0) || (kprime_mod12 == 4) || (kprime_mod12 == 8)) { + // kprime represents REG + for (i=0; i<4; i++) { + wbar[mprime] = llr[tti_offset+i]; +#ifdef DEBUG_DCI_DECODING +// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset+i,symbol_offset,re_offset+i,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); +#endif + mprime++; + } + } // is representative + } // no pilots case + } // not allocated to PHICH/PCFICH + + // Stop when all REGs are copied in + if (mprime>=Msymb2) + break; + } //lprime loop + + re_offset++; + + } // kprime loop +} + + +void pdcch_deinterleaving(LTE_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t *wbar,uint8_t number_pdcch_symbols,uint8_t mi) +{ + + uint16_t *wptr,*zptr,*wptr2; + uint32_t Msymb=(DCI_BITS_MAX/2); + uint16_t wtemp_rx[Msymb]; + uint16_t Mquad=get_nquad(number_pdcch_symbols,frame_parms,mi); + uint32_t RCC = (Mquad>>5), ND; + uint32_t row,col,Kpi,index; + int32_t i,k; + + + // printf("Mquad %d, RCC %d\n",Mquad,RCC); + + AssertFatal(z!=NULL,"dci.c: pdcch_deinterleaving: FATAL z is Null\n"); + + // undo permutation + for (i=0; i<Mquad; i++) { + wptr = &wtemp_rx[((i+frame_parms->Nid_cell)%Mquad)<<2]; + wptr2 = &wbar[i<<2]; + + wptr[0] = wptr2[0]; + wptr[1] = wptr2[1]; + wptr[2] = wptr2[2]; + wptr[3] = wptr2[3]; + /* + printf("pdcch_deinterleaving (%p,%p): quad %d (%d) -> (%d,%d %d,%d %d,%d %d,%d)\n",wptr,wptr2,i,(i+frame_parms->Nid_cell)%Mquad, + ((char*)wptr2)[0], + ((char*)wptr2)[1], + ((char*)wptr2)[2], + ((char*)wptr2)[3], + ((char*)wptr2)[4], + ((char*)wptr2)[5], + ((char*)wptr2)[6], + ((char*)wptr2)[7]); + */ + + } + + if ((Mquad&0x1f) > 0) + RCC++; + + Kpi = (RCC<<5); + ND = Kpi - Mquad; + + k=0; + + for (col=0; col<32; col++) { + index = bitrev_cc_dci[col]; + + for (row=0; row<RCC; row++) { + // printf("row %d, index %d, Nd %d\n",row,index,ND); + if (index>=ND) { + + + + wptr = &wtemp_rx[k<<2]; + zptr = &z[(index-ND)<<2]; + + zptr[0] = wptr[0]; + zptr[1] = wptr[1]; + zptr[2] = wptr[2]; + zptr[3] = wptr[3]; + + /* + printf("deinterleaving ; k %d, index-Nd %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",k,(index-ND), + ((int8_t *)wptr)[0], + ((int8_t *)wptr)[1], + ((int8_t *)wptr)[2], + ((int8_t *)wptr)[3], + ((int8_t *)wptr)[4], + ((int8_t *)wptr)[5], + ((int8_t *)wptr)[6], + ((int8_t *)wptr)[7]); + */ + k++; + } + + index+=32; + + } + } + + for (i=0; i<Mquad; i++) { + zptr = &z[i<<2]; + /* + printf("deinterleaving ; quad %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",i, + ((int8_t *)zptr)[0], + ((int8_t *)zptr)[1], + ((int8_t *)zptr)[2], + ((int8_t *)zptr)[3], + ((int8_t *)zptr)[4], + ((int8_t *)zptr)[5], + ((int8_t *)zptr)[6], + ((int8_t *)zptr)[7]); + */ + } + +} + + + +int32_t pdcch_llr(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + char *pdcch_llr, + uint8_t symbol) +{ + + int16_t *rxF= (int16_t*) &rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + int32_t i; + char *pdcch_llr8; + + pdcch_llr8 = &pdcch_llr[2*symbol*frame_parms->N_RB_DL*12]; + + if (!pdcch_llr8) { + printf("pdcch_qpsk_llr: llr is null, symbol %d\n",symbol); + return(-1); + } + + // printf("pdcch qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llr8-pdcch_llr); + + for (i=0; i<(frame_parms->N_RB_DL*((symbol==0) ? 16 : 24)); i++) { + + if (*rxF>31) + *pdcch_llr8=31; + else if (*rxF<-32) + *pdcch_llr8=-32; + else + *pdcch_llr8 = (char)(*rxF); + + // printf("rxF->llr : %d %d => %d\n",i,*rxF,*pdcch_llr8); + rxF++; + pdcch_llr8++; + } + + return(0); + +} + +//__m128i avg128P; + +//compute average channel_level on each (TX,RX) antenna pair +void pdcch_channel_level(int32_t **dl_ch_estimates_ext, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t *avg, + uint8_t nb_rb) +{ + + int16_t rb; + uint8_t aatx,aarx; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128; + __m128i avg128P; +#elif defined(__arm__) + int16x8_t *dl_ch128; + int32x4_t *avg128P; +#endif + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + //clear average level +#if defined(__x86_64__) || defined(__i386__) + avg128P = _mm_setzero_si128(); + dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][0]; +#elif defined(__arm__) + +#endif + for (rb=0; rb<nb_rb; rb++) { + +#if defined(__x86_64__) || defined(__i386__) + avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); + avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); + avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); +#elif defined(__arm__) + +#endif + dl_ch128+=3; + /* + if (rb==0) { + print_shorts("dl_ch128",&dl_ch128[0]); + print_shorts("dl_ch128",&dl_ch128[1]); + print_shorts("dl_ch128",&dl_ch128[2]); + } + */ + } + + DevAssert( nb_rb ); + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128P)[0] + + ((int32_t*)&avg128P)[1] + + ((int32_t*)&avg128P)[2] + + ((int32_t*)&avg128P)[3])/(nb_rb*12); + + // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + +} + + + +void pdcch_detection_mrc_i(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + int32_t **rxdataF_comp_i, + int32_t **rho, + int32_t **rho_i, + uint8_t symbol) +{ + + uint8_t aatx; + +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1; +#endif + int32_t i; + + if (frame_parms->nb_antennas_rx>1) { + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { + //if (frame_parms->mode1_flag && (aatx>0)) break; + +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#endif + // MRC on each re of rb on MF output + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); +#endif + } + } + +#if defined(__x86_64__) || defined(__i386__) + rho128_0 = (__m128i *) &rho[0][symbol*frame_parms->N_RB_DL*12]; + rho128_1 = (__m128i *) &rho[1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rho128_0 = (int16x8_t *) &rho[0][symbol*frame_parms->N_RB_DL*12]; + rho128_1 = (int16x8_t *) &rho[1][symbol*frame_parms->N_RB_DL*12]; +#endif + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1)); +#elif defined(__arm__) + rho128_0[i] = vhaddq_s16(rho128_0[i],rho128_1[i]); +#endif + } + +#if defined(__x86_64__) || defined(__i386__) + rho128_i0 = (__m128i *) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; + rho128_i1 = (__m128i *) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i0 = (__m128i *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i1 = (__m128i *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rho128_i0 = (int16x8_t*) &rho_i[0][symbol*frame_parms->N_RB_DL*12]; + rho128_i1 = (int16x8_t*) &rho_i[1][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i0 = (int16x8_t *)&rxdataF_comp_i[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_i1 = (int16x8_t *)&rxdataF_comp_i[1][symbol*frame_parms->N_RB_DL*12]; + +#endif + // MRC on each re of rb on MF and rho + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_i0[i],1),_mm_srai_epi16(rxdataF_comp128_i1[i],1)); + rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_i0[i] = vhaddq_s16(rxdataF_comp128_i0[i],rxdataF_comp128_i1[i]); + rho128_i0[i] = vhaddq_s16(rho128_i0[i],rho128_i1[i]); + +#endif + } + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + + +void pdcch_extract_rbs_single(int32_t **rxdataF, + int32_t **dl_ch_estimates, + int32_t **rxdataF_ext, + int32_t **dl_ch_estimates_ext, + uint8_t symbol, + uint32_t high_speed_flag, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + + uint16_t rb,nb_rb=0; + uint8_t i,j,aarx; + int32_t *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; + + + int nushiftmod3 = frame_parms->nushift%3; + uint8_t symbol_mod; + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod); +#endif + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (high_speed_flag == 1) + dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; + else + dl_ch0 = &dl_ch_estimates[aarx][5]; + + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + + rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + + rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; + + if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + // For second half of RBs skip DC carrier + if (rb==(frame_parms->N_RB_DL>>1)) { + rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; + + //dl_ch0++; + } + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + + for (i=0; i<12; i++) { + + rxF_ext[i]=rxF[i]; + + } + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j]=rxF[i]; + //printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j++]=dl_ch0[i]; + //printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + } + } + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + rxF+=12; + } + } + } else { // Odd number of RBs + for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j++]=dl_ch0[i]; + // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + } + } + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + rxF+=12; + } + } + + // Do middle RB (around DC) + // printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]); + + if (symbol_mod==0) { + j=0; + + for (i=0; i<6; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3))) { + 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 = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + if ((i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+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])); + } + } + + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + dl_ch0+=12; + rxF+=7; + rb++; + } else { + for (i=0; i<6; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + rxF_ext[i]=rxF[i]; + } + + rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + rxF_ext[i]=rxF[(1+i-6)]; + } + + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + dl_ch0+=12; + rxF+=7; + rb++; + } + + for (; rb<frame_parms->N_RB_DL; rb++) { + if (symbol_mod > 0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=(nushiftmod3)) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j++]=dl_ch0[i]; + } + } + + nb_rb++; + dl_ch0_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + rxF+=12; + } + } + } + } +} + +void pdcch_extract_rbs_dual(int32_t **rxdataF, + int32_t **dl_ch_estimates, + int32_t **rxdataF_ext, + int32_t **dl_ch_estimates_ext, + uint8_t symbol, + uint32_t high_speed_flag, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + + uint16_t rb,nb_rb=0; + uint8_t i,aarx,j; + int32_t *dl_ch0,*dl_ch0_ext,*dl_ch1,*dl_ch1_ext,*rxF,*rxF_ext; + uint8_t symbol_mod; + int nushiftmod3 = frame_parms->nushift%3; + + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY, "extract_rbs_dual: symbol_mod %d\n",symbol_mod); +#endif + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (high_speed_flag==1) { + dl_ch0 = &dl_ch_estimates[aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; + dl_ch1 = &dl_ch_estimates[2+aarx][5+(symbol*(frame_parms->ofdm_symbol_size))]; + } else { + dl_ch0 = &dl_ch_estimates[aarx][5]; + dl_ch1 = &dl_ch_estimates[2+aarx][5]; + } + + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(frame_parms->N_RB_DL*12)]; + + // printf("pdcch extract_rbs: rxF_ext pos %d\n",symbol*(frame_parms->N_RB_DL*12)); + rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)]; + + rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; + + if ((frame_parms->N_RB_DL&1) == 0) // even number of RBs + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + // For second half of RBs skip DC carrier + if (rb==(frame_parms->N_RB_DL>>1)) { + rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; + // dl_ch0++; + //dl_ch1++; + } + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); + + /* + printf("rb %d\n",rb); + for (i=0;i<12;i++) + printf("(%d %d)",((int16_t *)dl_ch0)[i<<1],((int16_t*)dl_ch0)[1+(i<<1)]); + printf("\n"); + */ + for (i=0; i<12; i++) { + rxF_ext[i]=rxF[i]; + // printf("%d : (%d,%d)\n",(rxF+(2*i)-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))*2])/2, + // ((int16_t*)&rxF[i<<1])[0],((int16_t*)&rxF[i<<1])[0]); + } + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3) && + (i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j] =dl_ch0[i]; + dl_ch1_ext[j++]=dl_ch1[i]; + } + } + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + } + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } + + else { // Odd number of RBs + for (rb=0; rb<frame_parms->N_RB_DL>>1; rb++) { + + // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); + + if (symbol_mod>0) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3) && + (i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j++]=dl_ch1[i]; + // printf("ch %d => (%d,%d)\n",i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + } + } + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } + } + + // Do middle RB (around DC) + + if (symbol_mod > 0) { + for (i=0; i<6; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + dl_ch1_ext[i]=dl_ch1[i]; + rxF_ext[i]=rxF[i]; + } + + rxF = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + dl_ch0_ext[i]=dl_ch0[i]; + dl_ch1_ext[i]=dl_ch1[i]; + rxF_ext[i]=rxF[(1+i)]; + } + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=7; + rb++; + } else { + j=0; + + for (i=0; i<6; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3)) { + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j]=dl_ch1[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 = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))]; + + for (; i<12; i++) { + if ((i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j]=dl_ch1[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])); + } + } + + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + dl_ch0+=12; + dl_ch1+=12; + rxF+=7; + rb++; + } + + for (; rb<frame_parms->N_RB_DL; rb++) { + + if (symbol_mod>0) { + // printf("rb %d: %d\n",rb,rxF-&rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))*2]); + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int32_t)); + memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int32_t)); + + for (i=0; i<12; i++) + rxF_ext[i]=rxF[i]; + + nb_rb++; + dl_ch0_ext+=12; + dl_ch1_ext+=12; + rxF_ext+=12; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=nushiftmod3+3) && + (i!=nushiftmod3+6) && + (i!=nushiftmod3+9)) { + rxF_ext[j]=rxF[i]; + // printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); + dl_ch0_ext[j]=dl_ch0[i]; + dl_ch1_ext[j++]=dl_ch1[i]; + } + } + + nb_rb++; + dl_ch0_ext+=8; + dl_ch1_ext+=8; + rxF_ext+=8; + + dl_ch0+=12; + dl_ch1+=12; + rxF+=12; + } + } + } + } +} + + +void pdcch_channel_compensation(int32_t **rxdataF_ext, + int32_t **dl_ch_estimates_ext, + int32_t **rxdataF_comp, + int32_t **rho, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t symbol, + uint8_t output_shift) +{ + + uint16_t rb; + +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; + __m128i *dl_ch128_2, *rho128; + __m128i mmtmpPD0,mmtmpPD1,mmtmpPD2,mmtmpPD3; +#elif defined(__arm__) + +#endif + uint8_t aatx,aarx,pilots=0; + + + + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY, "PDCCH comp: symbol %d\n",symbol); +#endif + + if (symbol==0) + pilots=1; + + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { + //if (frame_parms->mode1_flag && aatx>0) break; //if mode1_flag is set then there is only one stream to extract, independent of nb_antenna_ports_eNB + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; + +#elif defined(__arm__) + +#endif + + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + +#if defined(__x86_64__) || defined(__i386__) + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpPD0); + + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpPD1); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[0]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + // print_ints("re(shift)",&mmtmpPD0); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + // print_ints("im(shift)",&mmtmpPD1); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + // print_ints("c0",&mmtmpPD2); + // print_ints("c1",&mmtmpPD3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",dl_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[1]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",dl_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + // multiply by conjugated channel + if (pilots == 0) { + mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[2]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + rxdataF_comp128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + } + + // print_shorts("rx:",rxdataF128+2); + // print_shorts("ch:",dl_ch128+2); + // print_shorts("pack:",rxdataF_comp128+2); + + if (pilots==0) { + dl_ch128+=3; + rxdataF128+=3; + rxdataF_comp128+=3; + } else { + dl_ch128+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + } +#elif defined(__arm__) + +#endif + } + } + } + + + if (rho) { + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12]; + +#elif defined(__arm__) + +#endif + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { +#if defined(__x86_64__) || defined(__i386__) + + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128_2[0]); + // print_ints("re",&mmtmpD0); + + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpPD1); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[0]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + // print_ints("re(shift)",&mmtmpD0); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + // print_ints("im(shift)",&mmtmpD1); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + // print_ints("c0",&mmtmpPD2); + // print_ints("c1",&mmtmpPD3); + rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + + //print_shorts("rx:",dl_ch128_2); + //print_shorts("ch:",dl_ch128); + //print_shorts("pack:",rho128); + + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128_2[1]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[1]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + + rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); + //print_shorts("rx:",dl_ch128_2+1); + //print_shorts("ch:",dl_ch128+1); + //print_shorts("pack:",rho128+1); + // multiply by conjugated channel + mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128_2[2]); + // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); + mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[2]); + // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); + mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); + mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); + mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); + + rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); + //print_shorts("rx:",dl_ch128_2+2); + //print_shorts("ch:",dl_ch128+2); + //print_shorts("pack:",rho128+2); + + dl_ch128+=3; + dl_ch128_2+=3; + rho128+=3; + +#elif defined(__arm_) + + +#endif + } + } + + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void pdcch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + uint8_t symbol) +{ + + uint8_t aatx; + +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; +#endif + int32_t i; + + if (frame_parms->nb_antennas_rx>1) { + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12]; +#endif + // MRC on each re of rb + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); +#endif + } + } + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + +} + +void pdcch_siso(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + uint8_t l) +{ + + + uint8_t rb,re,jj,ii; + + jj=0; + ii=0; + + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + for (re=0; re<12; re++) { + + rxdataF_comp[0][jj++] = rxdataF_comp[0][ii]; + ii++; + } + } +} + + +void pdcch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, + int32_t **rxdataF_comp, + uint8_t symbol) +{ + + + int16_t *rxF0,*rxF1; + uint8_t rb,re; + int32_t jj=(symbol*frame_parms->N_RB_DL*12); + + rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y + rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y + + for (rb=0; rb<frame_parms->N_RB_DL; rb++) { + + for (re=0; re<12; re+=2) { + + // Alamouti RX combining + + rxF0[0] = rxF0[0] + rxF1[2]; + rxF0[1] = rxF0[1] - rxF1[3]; + + rxF0[2] = rxF0[2] - rxF1[0]; + rxF0[3] = rxF0[3] + rxF1[1]; + + rxF0+=4; + rxF1+=4; + } + } + + +} + +int32_t avgP[4]; + +int32_t rx_pdcch(PHY_VARS_UE *ue, + uint32_t frame, + uint8_t subframe, + uint8_t eNB_id, + MIMO_mode_t mimo_mode, + uint32_t high_speed_flag) +{ + + LTE_UE_COMMON *common_vars = &ue->common_vars; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; + + uint8_t log2_maxh,aatx,aarx; + int32_t avgs; + uint8_t n_pdcch_symbols; + uint8_t mi = get_mi(frame_parms,subframe); + + // printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d, handling symbol 0 \n",subframe,eNB_id,pdcch_vars); + // procress ofdm symbol 0 + if (frame_parms->nb_antenna_ports_eNB>1) { + pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + 0, + high_speed_flag, + frame_parms); + } else { + pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + 0, + high_speed_flag, + frame_parms); + } + + + // compute channel level based on ofdm symbol 0 + pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, + frame_parms, + avgP, + frame_parms->N_RB_DL); + + avgs = 0; + + for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) + avgs = cmax(avgs,avgP[(aarx<<1)+aatx]); + + log2_maxh = (log2_approx(avgs)/2) + 5; //+frame_parms->nb_antennas_rx; +#ifdef UE_DEBUG_TRACE + LOG_I(PHY,"subframe %d: pdcch log2_maxh = %d (%d,%d)\n",subframe,log2_maxh,avgP[0],avgs); +#endif + + T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(frame%1024), T_INT(subframe), + T_INT(avgP[0]), T_INT(avgP[1]), T_INT(avgP[2]), T_INT(avgP[3])); + + // compute LLRs for ofdm symbol 0 only + pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + pdcch_vars[eNB_id]->rxdataF_comp, + (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, + frame_parms, + 0, + log2_maxh); // log2_maxh+I0_shift + + +#ifdef DEBUG_PHY + + if (subframe==5) { + printf("Writing output s0\n"); + write_output("rxF_comp_d0.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][0*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); + } +#endif + + if (frame_parms->nb_antennas_rx > 1) { + pdcch_detection_mrc(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + 0); + } + + if (mimo_mode == SISO) + pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); + else + pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,0); + + pdcch_llr(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + (char *)pdcch_vars[eNB_id]->llr, + 0); + + + // decode pcfich here and find out pdcch ofdm symbol number + n_pdcch_symbols = rx_pcfich(frame_parms, + subframe, + pdcch_vars[eNB_id], + mimo_mode); + + // printf("In rx_pdcch, subframe %d, num_pdcch_symbols %d \n",subframe,n_pdcch_symbols); + + if (n_pdcch_symbols>3) + n_pdcch_symbols=1; + +#if T_TRACER + T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), + T_INT(n_pdcch_symbols), + T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4)); +#endif + + +#ifdef DEBUG_DCI_DECODING + + if (subframe==5) LOG_I(PHY,"demapping: subframe %d, num_pdcch_symbols %d\n",subframe,n_pdcch_symbols); +#endif + + // process pdcch ofdm symbol 1 and 2 if necessary + for (int s=1; s<n_pdcch_symbols; s++){ + // printf("In rx_pdcch, subframe %d, eNB_id %d, pdcch_vars %d, handling symbol %d \n",subframe,eNB_id,pdcch_vars,s); + if (frame_parms->nb_antenna_ports_eNB>1) { + pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + s, + high_speed_flag, + frame_parms); + } else { + pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + s, + high_speed_flag, + frame_parms); + } + + + pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, + pdcch_vars[eNB_id]->dl_ch_estimates_ext, + pdcch_vars[eNB_id]->rxdataF_comp, + (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, + frame_parms, + s, + log2_maxh); // log2_maxh+I0_shift + + +#ifdef DEBUG_PHY + + if (subframe==5) { + write_output("rxF_comp_ds.m","rxF_c_ds",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1); + } +#endif + + + + if (frame_parms->nb_antennas_rx > 1) { + pdcch_detection_mrc(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + s); + + } + + if (mimo_mode == SISO) + pdcch_siso(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); + else + pdcch_alamouti(frame_parms,pdcch_vars[eNB_id]->rxdataF_comp,s); + + + // printf("subframe %d computing llrs for symbol %d : %p\n",subframe,s,pdcch_vars[eNB_id]->llr); + pdcch_llr(frame_parms, + pdcch_vars[eNB_id]->rxdataF_comp, + (char *)pdcch_vars[eNB_id]->llr, + s); + /*#ifdef DEBUG_PHY + write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); + #endif*/ + } + + pdcch_demapping(pdcch_vars[eNB_id]->llr, + pdcch_vars[eNB_id]->wbar, + frame_parms, + n_pdcch_symbols, + get_mi(frame_parms,subframe)); + + pdcch_deinterleaving(frame_parms, + (uint16_t*)pdcch_vars[eNB_id]->e_rx, + pdcch_vars[eNB_id]->wbar, + n_pdcch_symbols, + mi); + + pdcch_unscrambling(frame_parms, + subframe, + pdcch_vars[eNB_id]->e_rx, + get_nCCE(n_pdcch_symbols,frame_parms,mi)*72); + + pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols; + + // if ((frame&1) ==0 && subframe==5) exit(-1); + return(0); +} + + +void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + int8_t* llr, + uint32_t length) +{ + + int i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in first call to lte_gold_generic + + x2 = (subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 + + for (i=0; i<length; i++) { + if ((i&0x1f)==0) { + s = lte_gold_generic(&x1, &x2, reset); + // printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + + // if (subframe == 5) printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); + if (((s>>(i%32))&1)==0) + llr[i] = -llr[i]; + // if (subframe == 5) printf("%d\n",llr[i]); + + } +} + +/* +uint8_t get_num_pdcch_symbols(uint8_t num_dci, + DCI_ALLOC_t *dci_alloc, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe) +{ + + uint16_t numCCE = 0; + uint8_t i; + uint8_t nCCEmin = 0; + uint16_t CCE_max_used_index = 0; + uint16_t firstCCE_max = dci_alloc[0].firstCCE; + uint8_t L = dci_alloc[0].L; + + // check pdcch duration imposed by PHICH duration (Section 6.9 of 36-211) + if (frame_parms->Ncp==1) { // extended prefix + if ((frame_parms->frame_type == TDD) && + ((frame_parms->tdd_config<3)||(frame_parms->tdd_config==6)) && + ((subframe==1) || (subframe==6))) // subframes 1 and 6 (S-subframes) for 5ms switching periodicity are 2 symbols + nCCEmin = 2; + else { // 10ms switching periodicity is always 3 symbols, any DL-only subframe is 3 symbols + nCCEmin = 3; + } + } + + // compute numCCE + for (i=0; i<num_dci; i++) { + // printf("dci %d => %d\n",i,dci_alloc[i].L); + numCCE += (1<<(dci_alloc[i].L)); + + if(firstCCE_max < dci_alloc[i].firstCCE) { + firstCCE_max = dci_alloc[i].firstCCE; + L = dci_alloc[i].L; + } + } + CCE_max_used_index = firstCCE_max + (1<<L) - 1; + + //if ((9*numCCE) <= (frame_parms->N_RB_DL*2)) + if (CCE_max_used_index < get_nCCE(1, frame_parms, get_mi(frame_parms, subframe))) + return(cmax(1,nCCEmin)); + //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 4 : 5))) + else if (CCE_max_used_index < get_nCCE(2, frame_parms, get_mi(frame_parms, subframe))) + return(cmax(2,nCCEmin)); + //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 7 : 8))) + else if (CCE_max_used_index < get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))) + return(cmax(3,nCCEmin)); + else if (frame_parms->N_RB_DL<=10) { + if (frame_parms->Ncp == 0) { // normal CP + printf("numCCE %d, N_RB_DL = %d : should be returning 4 PDCCH symbols (%d,%d,%d)\n",numCCE,frame_parms->N_RB_DL, + get_nCCE(1, frame_parms, get_mi(frame_parms, subframe)), + get_nCCE(2, frame_parms, get_mi(frame_parms, subframe)), + get_nCCE(3, frame_parms, get_mi(frame_parms, subframe))); + + if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 10 : 11))) + return(4); + } else { // extended CP + if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 9 : 10))) + return(4); + } + } + + + + // LOG_I(PHY," dci.c: get_num_pdcch_symbols subframe %d FATAL, illegal numCCE %d (num_dci %d)\n",subframe,numCCE,num_dci); + //for (i=0;i<num_dci;i++) { + // printf("dci_alloc[%d].L = %d\n",i,dci_alloc[i].L); + //} + //exit(-1); +exit(1); + return(0); +} +*/ + + + +void dci_decoding(uint8_t DCI_LENGTH, + uint8_t aggregation_level, + int8_t *e, + uint8_t *decoded_output) +{ + + uint8_t dummy_w_rx[3*(MAX_DCI_SIZE_BITS+16+64)]; + int8_t w_rx[3*(MAX_DCI_SIZE_BITS+16+32)],d_rx[96+(3*(MAX_DCI_SIZE_BITS+16))]; + + uint16_t RCC; + + uint16_t D=(DCI_LENGTH+16+64); + uint16_t coded_bits; +#ifdef DEBUG_DCI_DECODING + int32_t i; +#endif + + AssertFatal(aggregation_level<4, + "dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); + + coded_bits = 72 * (1<<aggregation_level); + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY," Doing DCI decoding for %d bits, DCI_LENGTH %d,coded_bits %d, e %p\n",3*(DCI_LENGTH+16),DCI_LENGTH,coded_bits,e); +#endif + + // now do decoding + memset((void*)dummy_w_rx,0,3*D); + RCC = generate_dummy_w_cc(DCI_LENGTH+16, + dummy_w_rx); + + + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY," Doing DCI Rate Matching RCC %d, w %p\n",RCC,w_rx); +#endif + + lte_rate_matching_cc_rx(RCC,coded_bits,w_rx,dummy_w_rx,e); + + sub_block_deinterleaving_cc((uint32_t)(DCI_LENGTH+16), + &d_rx[96], + &w_rx[0]); + +#ifdef DEBUG_DCI_DECODING + if (DCI_LENGTH==27 && ((1<<aggregation_level) == 4)) + for (int i=0; i<16+DCI_LENGTH; i++) + LOG_I(PHY," DCI %d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); + +#endif + memset(decoded_output,0,2+((16+DCI_LENGTH)>>3)); + +#ifdef DEBUG_DCI_DECODING + printf("Before Viterbi\n"); + + for (i=0; i<16+DCI_LENGTH; i++) + printf("%d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); + +#endif + //debug_printf("Doing DCI Viterbi \n"); + phy_viterbi_lte_sse2(d_rx+96,decoded_output,16+DCI_LENGTH); + //debug_printf("Done DCI Viterbi \n"); +} + + +static uint8_t dci_decoded_output[RX_NB_TH][(MAX_DCI_SIZE_BITS+64)/8]; + + + + +int get_nCCE_offset_l1(int *CCE_table, + const unsigned char L, + const int nCCE, + const int common_dci, + const unsigned short rnti, + const unsigned char subframe) +{ + + int search_space_free,m,nb_candidates = 0,l,i; + unsigned int Yk; + /* + printf("CCE Allocation: "); + for (i=0;i<nCCE;i++) + printf("%d.",CCE_table[i]); + printf("\n"); + */ + if (common_dci == 1) { + // check CCE(0 ... L-1) + nb_candidates = (L==4) ? 4 : 2; + nb_candidates = min(nb_candidates,nCCE/L); + + // printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); + + for (m = nb_candidates-1 ; m >=0 ; m--) { + + search_space_free = 1; + for (l=0; l<L; l++) { + + // printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]); + if (CCE_table[(m*L) + l] == 1) { + search_space_free = 0; + break; + } + } + + if (search_space_free == 1) { + + // printf("returning %d\n",m*L); + + for (l=0; l<L; l++) + CCE_table[(m*L)+l]=1; + return(m*L); + } + } + + return(-1); + + } else { // Find first available in ue specific search space + // according to procedure in Section 9.1.1 of 36.213 (v. 8.6) + // compute Yk + Yk = (unsigned int)rnti; + + for (i=0; i<=subframe; i++) + Yk = (Yk*39827)%65537; + + Yk = Yk % (nCCE/L); + + + switch (L) { + case 1: + case 2: + nb_candidates = 6; + break; + + case 4: + case 8: + nb_candidates = 2; + break; + + default: + DevParam(L, nCCE, rnti); + break; + } + + + LOG_D(MAC,"rnti %x, Yk = %d, nCCE %d (nCCE/L %d),nb_cand %d\n",rnti,Yk,nCCE,nCCE/L,nb_candidates); + + for (m = 0 ; m < nb_candidates ; m++) { + search_space_free = 1; + + for (l=0; l<L; l++) { + int cce = (((Yk+m)%(nCCE/L))*L) + l; + if (cce >= nCCE || CCE_table[cce] == 1) { + search_space_free = 0; + break; + } + } + + if (search_space_free == 1) { + for (l=0; l<L; l++) + CCE_table[(((Yk+m)%(nCCE/L))*L)+l]=1; + + return(((Yk+m)%(nCCE/L))*L); + } + } + + return(-1); + } +} + + +void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars, + int do_common, + dci_detect_mode_t mode, + uint8_t subframe, + DCI_ALLOC_t *dci_alloc, + int16_t eNB_id, + uint8_t current_thread_id, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t mi, + uint16_t si_rnti, + uint16_t ra_rnti, + uint16_t p_rnti, + uint8_t L, + uint8_t format_si, + uint8_t format_p, + uint8_t format_ra, + uint8_t format_c, + uint8_t sizeof_bits, + uint8_t sizeof_bytes, + uint8_t *dci_cnt, + uint8_t *format0_found, + uint8_t *format_c_found, + uint32_t *CCEmap0, + uint32_t *CCEmap1, + uint32_t *CCEmap2) +{ + + uint16_t crc,CCEind,nCCE; + uint32_t *CCEmap=NULL,CCEmap_mask=0; + int L2=(1<<L); + unsigned int Yk,nb_candidates = 0,i,m; + unsigned int CCEmap_cand; + + nCCE = get_nCCE(pdcch_vars[eNB_id]->num_pdcch_symbols,frame_parms,mi); + + if (nCCE > get_nCCE(3,frame_parms,1)) { + LOG_D(PHY,"skip DCI decoding: nCCE=%d > get_nCCE(3,frame_parms,1)=%d\n", nCCE, get_nCCE(3,frame_parms,1)); + return; + } + + if (nCCE<L2) { + LOG_D(PHY,"skip DCI decoding: nCCE=%d < L2=%d\n", nCCE, L2); + return; + } + + if (mode == NO_DCI) { + LOG_D(PHY, "skip DCI decoding: expect no DCIs at subframe %d\n", subframe); + return; + } + + if (do_common == 1) { + nb_candidates = (L2==4) ? 4 : 2; + Yk=0; + } else { + // Find first available in ue specific search space + // according to procedure in Section 9.1.1 of 36.213 (v. 8.6) + // compute Yk + Yk = (unsigned int)pdcch_vars[eNB_id]->crnti; + + for (i=0; i<=subframe; i++) + Yk = (Yk*39827)%65537; + + Yk = Yk % (nCCE/L2); + + switch (L2) { + case 1: + case 2: + nb_candidates = 6; + break; + + case 4: + case 8: + nb_candidates = 2; + break; + + default: + DevParam(L2, do_common, eNB_id); + break; + } + } + + /* for (CCEind=0; + CCEind<nCCE2; + CCEind+=(1<<L)) {*/ + + if (nb_candidates*L2 > nCCE) + nb_candidates = nCCE/L2; + + for (m=0; m<nb_candidates; m++) { + + CCEind = (((Yk+m)%(nCCE/L2))*L2); + + if (CCEind<32) + CCEmap = CCEmap0; + else if (CCEind<64) + CCEmap = CCEmap1; + else if (CCEind<96) + CCEmap = CCEmap2; + else { + AssertFatal(1==0, + "Illegal CCEind %d (Yk %d, m %d, nCCE %d, L2 %d\n",CCEind,Yk,m,nCCE,L2); + } + + switch (L2) { + case 1: + CCEmap_mask = (1<<(CCEind&0x1f)); + break; + + case 2: + CCEmap_mask = (3<<(CCEind&0x1f)); + break; + + case 4: + CCEmap_mask = (0xf<<(CCEind&0x1f)); + break; + + case 8: + CCEmap_mask = (0xff<<(CCEind&0x1f)); + break; + + default: + AssertFatal(1==0, + "Illegal L2 value %d\n", L2 ); + } + + CCEmap_cand = (*CCEmap)&CCEmap_mask; + + // CCE is not allocated yet + + if (CCEmap_cand == 0) { + + if (do_common == 1) + LOG_D(PHY,"[DCI search nPdcch %d - common] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n", + pdcch_vars[eNB_id]->num_pdcch_symbols,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask); + else + LOG_D(PHY,"[DCI search nPdcch %d - ue spec %x] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x) format %d\n", + pdcch_vars[eNB_id]->num_pdcch_symbols,pdcch_vars[eNB_id]->crnti,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask,format_c); + + dci_decoding(sizeof_bits, + L, + &pdcch_vars[eNB_id]->e_rx[CCEind*72], + &dci_decoded_output[current_thread_id][0]); + /* + for (i=0;i<3+(sizeof_bits>>3);i++) + printf("dci_decoded_output[%d][%d] => %x\n",current_thread_id,i,dci_decoded_output[current_thread_id][i]); + */ + + crc = (crc16(&dci_decoded_output[current_thread_id][0],sizeof_bits)>>16) ^ extract_crc(&dci_decoded_output[current_thread_id][0],sizeof_bits); +#ifdef DEBUG_DCI_DECODING + printf("crc =>%x\n",crc); +#endif + + if (((L>1) && ((crc == si_rnti)|| + (crc == p_rnti)|| + (crc == ra_rnti)))|| + (crc == pdcch_vars[eNB_id]->crnti)) { + dci_alloc[*dci_cnt].dci_length = sizeof_bits; + dci_alloc[*dci_cnt].rnti = crc; + dci_alloc[*dci_cnt].L = L; + dci_alloc[*dci_cnt].firstCCE = CCEind; + + //printf("DCI FOUND !!! crc =>%x, sizeof_bits %d, sizeof_bytes %d \n",crc, sizeof_bits, sizeof_bytes); + if (sizeof_bytes<=4) { + dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0]; + dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1]; + dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2]; + dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3]; +#ifdef DEBUG_DCI_DECODING + printf("DCI => %x,%x,%x,%x\n",dci_decoded_output[current_thread_id][0], + dci_decoded_output[current_thread_id][1], + dci_decoded_output[current_thread_id][2], + dci_decoded_output[current_thread_id][3]); +#endif + } else { + dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0]; + dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[current_thread_id][1]; + dci_alloc[*dci_cnt].dci_pdu[5] = dci_decoded_output[current_thread_id][2]; + dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3]; + dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][4]; + dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][5]; + dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][6]; + dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][7]; +#ifdef DEBUG_DCI_DECODING + printf("DCI => %x,%x,%x,%x,%x,%x,%x,%x\n", + dci_decoded_output[current_thread_id][0],dci_decoded_output[current_thread_id][1],dci_decoded_output[current_thread_id][2],dci_decoded_output[current_thread_id][3], + dci_decoded_output[current_thread_id][4],dci_decoded_output[current_thread_id][5],dci_decoded_output[current_thread_id][6],dci_decoded_output[current_thread_id][7]); +#endif + } + + if (crc==si_rnti) { + dci_alloc[*dci_cnt].format = format_si; + *dci_cnt = *dci_cnt+1; + } else if (crc==p_rnti) { + dci_alloc[*dci_cnt].format = format_p; + *dci_cnt = *dci_cnt+1; + } else if (crc==ra_rnti) { + dci_alloc[*dci_cnt].format = format_ra; + // store first nCCE of group for PUCCH transmission of ACK/NAK + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + *dci_cnt = *dci_cnt+1; + } else if (crc==pdcch_vars[eNB_id]->crnti) { + + if ((mode&UL_DCI)&&(format_c == format0)&&((dci_decoded_output[current_thread_id][0]&0x80)==0)) {// check if pdu is format 0 or 1A + if (*format0_found == 0) { + dci_alloc[*dci_cnt].format = format0; + *format0_found = 1; + *dci_cnt = *dci_cnt+1; + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + } + } else if (format_c == format0) { // this is a format 1A DCI + dci_alloc[*dci_cnt].format = format1A; + *dci_cnt = *dci_cnt+1; + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + } else { + // store first nCCE of group for PUCCH transmission of ACK/NAK + if (*format_c_found == 0) { + dci_alloc[*dci_cnt].format = format_c; + *dci_cnt = *dci_cnt+1; + *format_c_found = 1; + pdcch_vars[eNB_id]->nCCE[subframe]=CCEind; + } + } + } + + //LOG_I(PHY,"DCI decoding CRNTI [format: %d, nCCE[subframe: %d]: %d ], AggregationLevel %d \n",format_c, subframe, pdcch_vars[eNB_id]->nCCE[subframe],L2); + // memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_decoded_output,sizeof_bytes); + + + + switch (1<<L) { + case 1: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + + case 2: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + + case 4: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + + case 8: + *CCEmap|=(1<<(CCEind&0x1f)); + break; + } + +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY,"[DCI search] Found DCI %d rnti %x Aggregation %d length %d format %s in CCE %d (CCEmap %x) candidate %d / %d \n", + *dci_cnt,crc,1<<L,sizeof_bits,dci_format_strings[dci_alloc[*dci_cnt-1].format],CCEind,*CCEmap,m,nb_candidates ); + dump_dci(frame_parms,&dci_alloc[*dci_cnt-1]); + +#endif + return; + } // rnti match + } // CCEmap_cand == 0 +/* + if ( agregationLevel != 0xFF && + (format_c == format0 && m==0 && si_rnti != SI_RNTI)) + { + //Only valid for OAI : Save some processing time when looking for DCI format0. From the log we see the DCI only on candidate 0. + return; + } +*/ + } // candidate loop +} + +uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_UE *ue, + DCI_ALLOC_t *dci_alloc, + uint8_t DCIFormat, + uint8_t agregationLevel, + int16_t eNB_id, + uint8_t subframe) +{ + + uint8_t dci_cnt=0,old_dci_cnt=0; + uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; + LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + uint8_t mi = get_mi(&ue->frame_parms,subframe); + uint16_t ra_rnti=99; + uint8_t format0_found=0,format_c_found=0; + uint8_t tmode = ue->transmission_mode[eNB_id]; + uint8_t frame_type = frame_parms->frame_type; + uint8_t format0_size_bits=0,format0_size_bytes=0; + uint8_t format1_size_bits=0,format1_size_bytes=0; + dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); + + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); + + } else { + format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); + } + + break; + + case 25: + default: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); + } else { + format0_size_bits = sizeof_DCI0_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); + } + + break; + + case 50: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_10MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); + + } else { + format0_size_bits = sizeof_DCI0_10MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); + format1_size_bits = sizeof_DCI1_10MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); + } + + break; + + case 100: + if (frame_type == TDD) { + format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_20MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); + } else { + format0_size_bits = sizeof_DCI0_20MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); + format1_size_bits = sizeof_DCI1_20MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); + } + + break; + } + + if (ue->prach_resources[eNB_id]) + ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; + + // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + agregationLevel, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (DCIFormat == format1) + { + if ((tmode < 3) || (tmode == 7)) { + //printf("Crnti decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); + + // Now check UE_SPEC format 1 search spaces at aggregation 1 + + //printf("[DCI search] Format 1/1A aggregation 1\n"); + + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff) || + (format_c_found==1)) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //printf("Crnti 1 decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat); + + } + else if (DCIFormat == format1A) + { + AssertFatal(0,"Other Transmission mode not yet coded\n"); + } + } + else + { + LOG_W(PHY,"DCI format %d wrong or not yet implemented \n",DCIFormat); + } + + return(dci_cnt); + +} + +uint16_t dci_decoding_procedure(PHY_VARS_UE *ue, + DCI_ALLOC_t *dci_alloc, + int do_common, + int16_t eNB_id, + uint8_t subframe) +{ + + uint8_t dci_cnt=0,old_dci_cnt=0; + uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; + LTE_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[subframe]]; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + uint8_t mi = get_mi(&ue->frame_parms,subframe); + uint16_t ra_rnti=99; + uint8_t format0_found=0,format_c_found=0; + uint8_t tmode = ue->transmission_mode[eNB_id]; + uint8_t frame_type = frame_parms->frame_type; + uint8_t format1A_size_bits=0,format1A_size_bytes=0; + uint8_t format1C_size_bits=0,format1C_size_bytes=0; + uint8_t format0_size_bits=0,format0_size_bytes=0; + uint8_t format1_size_bits=0,format1_size_bytes=0; + uint8_t format2_size_bits=0,format2_size_bytes=0; + uint8_t format2A_size_bits=0,format2A_size_bytes=0; + dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,subframe); + + switch (frame_parms->N_RB_DL) { + case 6: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_1_5MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_1_5MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_1_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); + format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_1_5MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_1_5MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_1_5MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_1_5MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_1_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); + format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_1_5MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_1_5MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_1_5MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_FDD_t); + } + } + + break; + + case 25: + default: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_5MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_5MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_5MHz_t); + format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_5MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_5MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_5MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_5MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_5MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_5MHz_t; + format1C_size_bytes = sizeof(DCI1C_5MHz_t); + format0_size_bits = sizeof_DCI0_5MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); + format1_size_bits = sizeof_DCI1_5MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_5MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_5MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_5MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_5MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_5MHz_4A_FDD_t); + } + } + + break; + + case 50: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_10MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_10MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_10MHz_t; + format1C_size_bytes = sizeof(DCI1C_10MHz_t); + format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_10MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_10MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_10MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_10MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_10MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_10MHz_t; + format1C_size_bytes = sizeof(DCI1C_10MHz_t); + format0_size_bits = sizeof_DCI0_10MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); + format1_size_bits = sizeof_DCI1_10MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_10MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_10MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_10MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_10MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_10MHz_4A_FDD_t); + } + } + + break; + + case 100: + if (frame_type == TDD) { + format1A_size_bits = sizeof_DCI1A_20MHz_TDD_1_6_t; + format1A_size_bytes = sizeof(DCI1A_20MHz_TDD_1_6_t); + format1C_size_bits = sizeof_DCI1C_20MHz_t; + format1C_size_bytes = sizeof(DCI1C_20MHz_t); + format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; + format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); + format1_size_bits = sizeof_DCI1_20MHz_TDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_20MHz_2A_TDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_2A_TDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_2A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_2A_TDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_20MHz_4A_TDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_4A_TDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_4A_TDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_4A_TDD_t); + } + } else { + format1A_size_bits = sizeof_DCI1A_20MHz_FDD_t; + format1A_size_bytes = sizeof(DCI1A_20MHz_FDD_t); + format1C_size_bits = sizeof_DCI1C_20MHz_t; + format1C_size_bytes = sizeof(DCI1C_20MHz_t); + format0_size_bits = sizeof_DCI0_20MHz_FDD_t; + format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); + format1_size_bits = sizeof_DCI1_20MHz_FDD_t; + format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); + + if (frame_parms->nb_antenna_ports_eNB == 2) { + format2_size_bits = sizeof_DCI2_20MHz_2A_FDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_2A_FDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_2A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_2A_FDD_t); + } else if (frame_parms->nb_antenna_ports_eNB == 4) { + format2_size_bits = sizeof_DCI2_20MHz_4A_FDD_t; + format2_size_bytes = sizeof(DCI2_20MHz_4A_FDD_t); + format2A_size_bits = sizeof_DCI2A_20MHz_4A_FDD_t; + format2A_size_bytes = sizeof(DCI2A_20MHz_4A_FDD_t); + } + } + + break; + } + + if (do_common == 1) { +#ifdef DEBUG_DCI_DECODING + printf("[DCI search] subframe %d: doing common search/format0 aggregation 4\n",subframe); +#endif + + if (ue->prach_resources[eNB_id]) + ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; + + // First check common search spaces at aggregation 4 (SI_RNTI, P_RNTI and RA_RNTI format 0/1A), + // and UE_SPEC format0 (PUSCH) too while we're at it + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0) , + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format0, + format1A_size_bits, + format1A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff) || + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + // Now check common search spaces at aggregation 4 (SI_RNTI,P_RNTI and RA_RNTI and C-RNTI format 1C), + // and UE_SPEC format0 (PUSCH) too while we're at it + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1C, + format1C, + format1C, + format1C, + format1C_size_bits, + format1C_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff) || + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + // Now check common search spaces at aggregation 8 (SI_RNTI,P_RNTI and RA_RNTI format 1A), + // and UE_SPEC format0 (PUSCH) too while we're at it + // printf("[DCI search] doing common search/format0 aggregation 3\n"); +#ifdef DEBUG_DCI_DECODING + printf("[DCI search] doing common search/format0 aggregation 8\n"); +#endif + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + P_RNTI, + ra_rnti, + 3, + format1A, + format1A, + format1A, + format0, + format1A_size_bits, + format1A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + // Now check common search spaces at aggregation 8 (SI_RNTI and RA_RNTI and C-RNTI format 1C), + // and UE_SPEC format0 (PUSCH) too while we're at it + dci_decoding_procedure0(pdcch_vars,1,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1C, + format1C, + format1C, + format1C, + format1C_size_bits, + format1C_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //#endif + + } + + if (ue->UE_mode[eNB_id] <= PRACH) + return(dci_cnt); + + if (ue->prach_resources[eNB_id]) + ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; + + // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 + // printf("[DCI search] Format 0/1A aggregation 8\n"); + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + //printf("[DCI search] Format 0 aggregation 1 dci_cnt %d\n",dci_cnt); + + if (dci_cnt == 0) + { + // Now check UE_SPEC format 0 search spaces at aggregation 4 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + + //printf("[DCI search] Format 0 aggregation 2 dci_cnt %d\n",dci_cnt); + } + + if (dci_cnt == 0) + { + // Now check UE_SPEC format 0 search spaces at aggregation 2 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + //printf("[DCI search] Format 0 aggregation 4 dci_cnt %d\n",dci_cnt); + } + + if (dci_cnt == 0) + { + // Now check UE_SPEC format 0 search spaces at aggregation 1 + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format0, + format0_size_bits, + format0_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + //printf("[DCI search] Format 0 aggregation 8 dci_cnt %d\n",dci_cnt); + + } + // These are for CRNTI based on transmission mode + if ((tmode < 3) || (tmode == 7)) { + // Now check UE_SPEC format 1 search spaces at aggregation 1 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 1 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff) || + (format_c_found==1)) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1 search spaces at aggregation 2 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 2 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff)|| + (format_c_found==1)) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1 search spaces at aggregation 4 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 4 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + // Now check UE_SPEC format 1 search spaces at aggregation 8 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode,subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format1, + format1_size_bits, + format1_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //printf("[DCI search] Format 1 aggregation 8 dci_cnt %d\n",dci_cnt); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#endif //ALL_AGGREGATION + } else if (tmode == 3) { + + + // LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 1 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); + // Now check UE_SPEC format 2A_2A search spaces at aggregation 1 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + LOG_D(PHY," format 2A_2A search CCEmap0 %x, format0_found %d, format_c_found %d \n", CCEmap0, format0_found, format_c_found); + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2 search spaces at aggregation 2 + LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 2 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2_2A search spaces at aggregation 4 + // LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 4 \n"); + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + // Now check UE_SPEC format 2_2A search spaces at aggregation 8 + LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 8 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format2A, + format2A_size_bits, + format2A_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //#endif + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + } else if (tmode == 4) { + + // Now check UE_SPEC format 2_2A search spaces at aggregation 1 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2 search spaces at aggregation 2 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 2_2A search spaces at aggregation 4 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + // Now check UE_SPEC format 2_2A search spaces at aggregation 8 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format2, + format2_size_bits, + format2_size_bytes, + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + //#endif + } else if ((tmode==5) || (tmode==6)) { // This is MU-MIMO + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 1 +#ifdef DEBUG_DCI_DECODING + LOG_I(PHY," MU-MIMO check UE_SPEC format 1E_2A_M10PRB\n"); +#endif + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 0, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 2 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 1, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 4 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 2, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#ifdef ALL_AGGREGATION + + // Now check UE_SPEC format 1E_2A_M10PRB search spaces at aggregation 8 + old_dci_cnt=dci_cnt; + dci_decoding_procedure0(pdcch_vars,0,mode, + subframe, + dci_alloc, + eNB_id, + ue->current_thread_id[subframe], + frame_parms, + mi, + ((ue->decode_SIB == 1) ? SI_RNTI : 0), + ra_rnti, + P_RNTI, + 3, + format1A, + format1A, + format1A, + format1E_2A_M10PRB, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + &dci_cnt, + &format0_found, + &format_c_found, + &CCEmap0, + &CCEmap1, + &CCEmap2); + + if ((CCEmap0==0xffff)|| + ((format0_found==1)&&(format_c_found==1))) + return(dci_cnt); + + if (dci_cnt>old_dci_cnt) + return(dci_cnt); + + //#endif //ALL_AGGREGATION + + } + + return(dci_cnt); +} diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c similarity index 77% rename from openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c index 4020056e6f68043a591f4792c287202e49a76ab0..30f7733be24ad0459eacc25df2d2e0a385a6bb1e 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_decoding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c @@ -31,11 +31,12 @@ */ //#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/extern.h" -#include "SCHED/extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "PHY/defs_UE.h" +#include "PHY/CODING/coding_extern.h" +#include "SCHED/sched_common_extern.h" +#include "SIMULATION/TOOLS/sim.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" //#define DEBUG_DLSCH_DECODING //#define UE_DEBUG_TRACE 1 @@ -746,3 +747,183 @@ decoder_if_t tc; return(ret); } +int dlsch_encoding_SIC(PHY_VARS_UE *ue, + unsigned char *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *i_stats) +{ + + unsigned int G; + unsigned int crc=1; + unsigned short iind; + + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + unsigned char harq_pid = ue->dlsch[subframe&2][0][0]->rnti; + unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; + unsigned int A; + unsigned char mod_order; + unsigned int Kr=0,Kr_bytes,r,r_offset=0; + // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; + uint8_t beamforming_mode=0; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); + + A = dlsch->harq_processes[harq_pid]->TBS; //6228 + // printf("Encoder: A: %d\n",A); + mod_order = dlsch->harq_processes[harq_pid]->Qm; + + if(dlsch->harq_processes[harq_pid]->mimo_mode == TM7) + beamforming_mode = 7; + else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM8) + beamforming_mode = 8; + else if(dlsch->harq_processes[harq_pid]->mimo_mode == TM9_10) + beamforming_mode = 9; + G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe,beamforming_mode); + + + // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet + if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet +#ifdef DEBUG_DLSCH_CODING + printf("SIC encoding thinks this is a new packet \n"); +#endif + /* + int i; + printf("dlsch (tx): \n"); + for (i=0;i<(A>>3);i++) + printf("%02x.",a[i]); + printf("\n"); + */ + // Add 24-bit crc (polynomial A) to payload + crc = crc24a(a, + A)>>8; + a[A>>3] = ((uint8_t*)&crc)[2]; + a[1+(A>>3)] = ((uint8_t*)&crc)[1]; + a[2+(A>>3)] = ((uint8_t*)&crc)[0]; + // printf("CRC %x (A %d)\n",crc,A); + + dlsch->harq_processes[harq_pid]->B = A+24; + // dlsch->harq_processes[harq_pid]->b = a; + memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); + + if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, + dlsch->harq_processes[harq_pid]->c, + dlsch->harq_processes[harq_pid]->B, + &dlsch->harq_processes[harq_pid]->C, + &dlsch->harq_processes[harq_pid]->Cplus, + &dlsch->harq_processes[harq_pid]->Cminus, + &dlsch->harq_processes[harq_pid]->Kplus, + &dlsch->harq_processes[harq_pid]->Kminus, + &dlsch->harq_processes[harq_pid]->F)<0) + return(-1); + + for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { + + if (r<dlsch->harq_processes[harq_pid]->Cminus) + Kr = dlsch->harq_processes[harq_pid]->Kminus; + else + Kr = dlsch->harq_processes[harq_pid]->Kplus; + + Kr_bytes = Kr>>3; + + // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) + if (Kr_bytes<=64) + iind = (Kr_bytes-5); + else if (Kr_bytes <=128) + iind = 59 + ((Kr_bytes-64)>>1); + else if (Kr_bytes <= 256) + iind = 91 + ((Kr_bytes-128)>>2); + else if (Kr_bytes <= 768) + iind = 123 + ((Kr_bytes-256)>>3); + else { + printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); + return(-1); + } + + +#ifdef DEBUG_DLSCH_CODING + printf("Generating Code Segment %d (%d bits)\n",r,Kr); + // generate codewords + + printf("bits_per_codeword (Kr)= %d, A %d\n",Kr,A); + printf("N_RB = %d\n",nb_rb); + printf("Ncp %d\n",frame_parms->Ncp); + printf("mod_order %d\n",mod_order); +#endif + + +#ifdef DEBUG_DLSCH_CODING + printf("Encoding ... iind %d f1 %d, f2 %d\n",iind,f1f2mat_old[iind*2],f1f2mat_old[(iind*2)+1]); +#endif + start_meas(te_stats); + encoder(dlsch->harq_processes[harq_pid]->c[r], + Kr>>3, + &dlsch->harq_processes[harq_pid]->d[r][96], + (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, + f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) + f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) + ); + stop_meas(te_stats); +#ifdef DEBUG_DLSCH_CODING + + if (r==0) + write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[r][96],(3*8*Kr_bytes)+12,1,4); + +#endif + start_meas(i_stats); + dlsch->harq_processes[harq_pid]->RTC[r] = + sub_block_interleaving_turbo(4+(Kr_bytes*8), + &dlsch->harq_processes[harq_pid]->d[r][96], + dlsch->harq_processes[harq_pid]->w[r]); + stop_meas(i_stats); + } + + } + + // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the + // outputs for each code segment, see Section 5.1.5 p.20 + + for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { +#ifdef DEBUG_DLSCH_CODING + printf("Rate Matching, Code segment %d (coded bits (G) %d,unpunctured/repeated bits per code segment %d,mod_order %d, nb_rb %d)...\n", + r, + G, + Kr*3, + mod_order,nb_rb); +#endif + + start_meas(rm_stats); +#ifdef DEBUG_DLSCH_CODING + printf("rvidx in SIC encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx); +#endif + r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], + G, //G + dlsch->harq_processes[harq_pid]->w[r], + dlsch->harq_processes[harq_pid]->e+r_offset, + dlsch->harq_processes[harq_pid]->C, // C + dlsch->Nsoft, // Nsoft, + dlsch->Mdlharq, + dlsch->Kmimo, + dlsch->harq_processes[harq_pid]->rvidx, + dlsch->harq_processes[harq_pid]->Qm, + dlsch->harq_processes[harq_pid]->Nl, + r, + nb_rb); + // m); // r + stop_meas(rm_stats); +#ifdef DEBUG_DLSCH_CODING + + if (r==dlsch->harq_processes[harq_pid]->C-1) + write_output("enc_output.m","enc",dlsch->harq_processes[harq_pid]->e,r_offset,1,4); + +#endif + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); + + return(0); +} diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index 6284f279d895d04590cf44ca3d792c1fcda40f47..665d5cead04d59a18aaebce0701066b9f1861600 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -29,11 +29,11 @@ * \note * \warning */ -//#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "transport_ue.h" +#include "transport_proto_ue.h" #include "PHY/sse_intrin.h" #include "T.h" @@ -48,7 +48,7 @@ int16_t interf_unaw_shift = 13; //#define DEBUG_HARQ -#define DEBUG_PHY 1 +//#define DEBUG_PHY 1 //#define DEBUG_DLSCH_DEMOD 1 //#define DISABLE_LOG_X @@ -842,7 +842,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pllr_symbol_cw1 = (int8_t*)pdsch_vars[eNB_id]->llr[1]; pllr_symbol_cw0 += llr_offset_symbol; pllr_symbol_cw1 += llr_offset_symbol; - + /* LOG_I(PHY,"compute LLRs [AbsSubframe %d.%d-%d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %p @LLR Buff(symb) %p\n", frame, subframe,symbol, nb_rb,dlsch0_harq->Qm, @@ -850,7 +850,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->llr_offset[symbol], (int16_t*)pdsch_vars[eNB_id]->llr[0], pllr_symbol_cw0); - + */ switch (dlsch0_harq->Qm) { case 2 : if ((rx_type==rx_standard) || (codeword_TB1 == -1)) { diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c index 7682045ae1307ca6a10ee83ef071091f7e28528d..525c8db676b1e60f76e751fee197ff56352e18c1 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c @@ -30,11 +30,12 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/TOOLS/defs.h" -#include "PHY/extern.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/TOOLS/tools_defs.h" +#include "PHY/phy_extern_ue.h" +#include "transport_ue.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" +#include "transport_proto_ue.h" #include "PHY/sse_intrin.h" //#define DEBUG_LLR_SIC diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c rename to openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c index 588adfbc55c65f736444797013a08ab37ade4a65..81cd18c954f647ceb9bd58c50a828fdf94a35b14 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c @@ -30,11 +30,10 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/TOOLS/defs.h" -#include "PHY/extern.h" -#include "defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/TOOLS/tools_defs.h" +#include "PHY/phy_extern_ue.h" +#include "transport_ue.h" #include "PHY/sse_intrin.h" int16_t ones256[16] __attribute__ ((aligned(32))) = {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff}; diff --git a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c similarity index 98% rename from openair1/PHY/LTE_TRANSPORT/drs_modulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c index a0bde219b57706e59b5d5746f8408bc1307f46be..96ff82ba162d2cd6278c54a77a4129a65f7c186a 100644 --- a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c @@ -29,9 +29,11 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "PHY/sse_intrin.h" +#include "transport_proto_ue.h" + //#define DEBUG_DRS int generate_drs_pusch(PHY_VARS_UE *ue, diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c similarity index 98% rename from openair1/PHY/LTE_TRANSPORT/initial_sync.c rename to openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c index 918696968b373ce1830f4abe081fa01505e4e7ae..b1d5b9b70e3b50dc3ca03ddbbdeddaff6d629b1e 100644 --- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/initial_sync.c @@ -30,18 +30,20 @@ * \warning */ #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "defs.h" -#include "extern.h" - - +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "transport_proto_ue.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" +#include "openair2/LAYER2/MAC/mac_proto.h" #include "common_lib.h" +#include "PHY/INIT/phy_init.h" + extern openair0_config_t openair0_cfg[]; -#define DEBUG_INITIAL_SYNCH +//#define DEBUG_INITIAL_SYNCH int pbch_detection(PHY_VARS_UE *ue, runmode_t mode) { diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pbch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pbch_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..a6acec9ca3762499a8c7fbed3032f253c3f1a7cf --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pbch_ue.c @@ -0,0 +1,632 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/pbch.c +* \brief Top-level routines for generating and decoding the PBCH/BCH physical/transport channel V8.6 2009-03 +* \author R. Knopp, F. Kaltenberger +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr,florian.kaltenberger.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/CODING/lte_interleaver_inline.h" +#include "transport_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/sse_intrin.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +//#define DEBUG_PBCH 1 +//#define DEBUG_PBCH_ENCODING +//#define INTERFERENCE_MITIGATION 1 + + +#define PBCH_A 24 + +uint16_t pbch_extract(int **rxdataF, + int **dl_ch_estimates, + int **rxdataF_ext, + int **dl_ch_estimates_ext, + uint32_t symbol, + uint32_t high_speed_flag, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + + uint16_t rb,nb_rb=6; + uint8_t i,j,aarx,aatx; + int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext; + + uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; + uint32_t symbol_mod = symbol % nsymb; + + int rx_offset = frame_parms->ofdm_symbol_size-3*12; + int ch_offset = frame_parms->N_RB_DL*6-3*12; + int nushiftmod3 = frame_parms->nushift%3; + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + /* + printf("extract_rbs (nushift %d): symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",frame_parms->nushift,symbol_mod, + (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, + LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); + */ + + rxF = &rxdataF[aarx][(rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))]; + rxF_ext = &rxdataF_ext[aarx][symbol_mod*(6*12)]; + + for (rb=0; rb<nb_rb; rb++) { + // skip DC carrier + if (rb==3) { + rxF = &rxdataF[aarx][(1 + (symbol*(frame_parms->ofdm_symbol_size)))]; + } + + if ((symbol_mod==0) || (symbol_mod==1)) { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + rxF_ext[j++]=rxF[i]; + } + } + + rxF+=12; + rxF_ext+=8; + } else { + for (i=0; i<12; i++) { + rxF_ext[i]=rxF[i]; + } + + rxF+=12; + rxF_ext+=12; + } + } + + for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { + if (high_speed_flag == 1) + dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset+(symbol*(frame_parms->ofdm_symbol_size))]; + else + dl_ch0 = &dl_ch_estimates[(aatx<<1)+aarx][LTE_CE_OFFSET+ch_offset]; + + dl_ch0_ext = &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*(6*12)]; + + for (rb=0; rb<nb_rb; rb++) { + // skip DC carrier + // if (rb==3) dl_ch0++; + if (symbol_mod>1) { + memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int)); + dl_ch0+=12; + dl_ch0_ext+=12; + } else { + j=0; + + for (i=0; i<12; i++) { + if ((i!=nushiftmod3) && + (i!=(nushiftmod3+3)) && + (i!=(nushiftmod3+6)) && + (i!=(nushiftmod3+9))) { + // printf("PBCH extract i %d j %d => (%d,%d)\n",i,j,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); + dl_ch0_ext[j++]=dl_ch0[i]; + } + } + + dl_ch0+=12; + dl_ch0_ext+=8; + } + } + } //tx antenna loop + + } + + return(0); +} + +//__m128i avg128; + +//compute average channel_level on each (TX,RX) antenna pair +int pbch_channel_level(int **dl_ch_estimates_ext, + LTE_DL_FRAME_PARMS *frame_parms, + uint32_t symbol) +{ + + int16_t rb, nb_rb=6; + uint8_t aatx,aarx; + +#if defined(__x86_64__) || defined(__i386__) + __m128i avg128; + __m128i *dl_ch128; +#elif defined(__arm__) + int32x4_t avg128; + int16x8_t *dl_ch128; +#endif + int avg1=0,avg2=0; + + uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6; + uint32_t symbol_mod = symbol % nsymb; + + for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + //clear average level + +#if defined(__x86_64__) || defined(__i386__) + avg128 = _mm_setzero_si128(); + dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; +#elif defined(__arm__) + avg128 = vdupq_n_s32(0); + dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; + +#endif + for (rb=0; rb<nb_rb; rb++) { +#if defined(__x86_64__) || defined(__i386__) + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); +#elif defined(__arm__) +// to be filled in +#endif + dl_ch128+=3; + /* + if (rb==0) { + print_shorts("dl_ch128",&dl_ch128[0]); + print_shorts("dl_ch128",&dl_ch128[1]); + print_shorts("dl_ch128",&dl_ch128[2]); + } + */ + } + + avg1 = (((int*)&avg128)[0] + + ((int*)&avg128)[1] + + ((int*)&avg128)[2] + + ((int*)&avg128)[3])/(nb_rb*12); + + if (avg1>avg2) + avg2 = avg1; + + //msg("Channel level : %d, %d\n",avg1, avg2); + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + return(avg2); + +} + +#if defined(__x86_64__) || defined(__i386__) +__m128i mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; +#elif defined(__arm__) +int16x8_t mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; +#endif +void pbch_channel_compensation(int **rxdataF_ext, + int **dl_ch_estimates_ext, + int **rxdataF_comp, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t symbol, + uint8_t output_shift) +{ + + uint16_t rb,nb_rb=6; + uint8_t aatx,aarx,symbol_mod; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; +#elif defined(__arm__) + +#endif + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++) + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol_mod*6*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol_mod*6*12]; + +#elif defined(__arm__) +// to be filled in +#endif + + for (rb=0; rb<nb_rb; rb++) { + //printf("rb %d\n",rb); +#if defined(__x86_64__) || defined(__i386__) + // multiply by conjugated channel + mmtmpP0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpP0); + // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) + mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpP1); + mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[0]); + // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); + // print_ints("re(shift)",&mmtmpP0); + mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); + // print_ints("im(shift)",&mmtmpP1); + mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); + mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); + // print_ints("c0",&mmtmpP2); + // print_ints("c1",&mmtmpP3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpP2,mmtmpP3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",dl_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpP0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); + // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) + mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); + mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[1]); + // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); + mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); + mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); + mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpP2,mmtmpP3); + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",dl_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + + if (symbol_mod>1) { + // multiply by conjugated channel + mmtmpP0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); + // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) + mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1)); + mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]); + mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[2]); + // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift); + mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift); + mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); + mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); + rxdataF_comp128[2] = _mm_packs_epi32(mmtmpP2,mmtmpP3); + // print_shorts("rx:",rxdataF128+2); + // print_shorts("ch:",dl_ch128+2); + // print_shorts("pack:",rxdataF_comp128+2); + + dl_ch128+=3; + rxdataF128+=3; + rxdataF_comp128+=3; + } else { + dl_ch128+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + } +#elif defined(__arm__) +// to be filled in +#endif + } + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void pbch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + uint8_t symbol) +{ + + uint8_t aatx, symbol_mod; + int i, nb_rb=6; +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1; +#endif + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + if (frame_parms->nb_antennas_rx>1) { + for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12]; + +#endif + // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) + for (i=0; i<nb_rb*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); + +#endif + } + } + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void pbch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + int8_t* llr, + uint32_t length, + uint8_t frame_mod4) +{ + int i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in first call to lte_gold_generic + x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1 + // msg("pbch_unscrambling: Nid_cell = %d\n",x2); + + for (i=0; i<length; i++) { + if (i%32==0) { + s = lte_gold_generic(&x1, &x2, reset); + // printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + // take the quarter of the PBCH that corresponds to this frame + if ((i>=(frame_mod4*(length>>2))) && (i<((1+frame_mod4)*(length>>2)))) { + + if (((s>>(i%32))&1)==0) + llr[i] = -llr[i]; + } + } +} + +void pbch_alamouti(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + uint8_t symbol) +{ + + + int16_t *rxF0,*rxF1; + // __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b; + uint8_t rb,re,symbol_mod; + int jj; + + // printf("Doing alamouti\n"); + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + jj = (symbol_mod*6*12); + + rxF0 = (int16_t*)&rxdataF_comp[0][jj]; //tx antenna 0 h0*y + rxF1 = (int16_t*)&rxdataF_comp[2][jj]; //tx antenna 1 h1*y + + for (rb=0; rb<6; rb++) { + + for (re=0; re<12; re+=2) { + + // Alamouti RX combining + + rxF0[0] = rxF0[0] + rxF1[2]; + rxF0[1] = rxF0[1] - rxF1[3]; + + rxF0[2] = rxF0[2] - rxF1[0]; + rxF0[3] = rxF0[3] + rxF1[1]; + + rxF0+=4; + rxF1+=4; + } + + } + +} + +void pbch_quantize(int8_t *pbch_llr8, + int16_t *pbch_llr, + uint16_t len) +{ + + uint16_t i; + + for (i=0; i<len; i++) { + if (pbch_llr[i]>7) + pbch_llr8[i]=7; + else if (pbch_llr[i]<-8) + pbch_llr8[i]=-8; + else + pbch_llr8[i] = (char)(pbch_llr[i]); + + } +} + +static unsigned char dummy_w_rx[3*3*(16+PBCH_A)]; +static int8_t pbch_w_rx[3*3*(16+PBCH_A)],pbch_d_rx[96+(3*(16+PBCH_A))]; + + +uint16_t rx_pbch(LTE_UE_COMMON *lte_ue_common_vars, + LTE_UE_PBCH *lte_ue_pbch_vars, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t eNB_id, + MIMO_mode_t mimo_mode, + uint32_t high_speed_flag, + uint8_t frame_mod4) +{ + + uint8_t log2_maxh;//,aatx,aarx; + int max_h=0; + + int symbol,i; + uint32_t nsymb = (frame_parms->Ncp==0) ? 14:12; + uint16_t pbch_E; + uint8_t pbch_a[8]; + uint8_t RCC; + + int8_t *pbch_e_rx; + uint8_t *decoded_output = lte_ue_pbch_vars->decoded_output; + uint16_t crc; + + + // pbch_D = 16+PBCH_A; + + pbch_E = (frame_parms->Ncp==0) ? 1920 : 1728; //RE/RB * #RB * bits/RB (QPSK) + pbch_e_rx = <e_ue_pbch_vars->llr[frame_mod4*(pbch_E>>2)]; +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode); +#endif + + // clear LLR buffer + memset(lte_ue_pbch_vars->llr,0,pbch_E); + + for (symbol=(nsymb>>1); symbol<(nsymb>>1)+4; symbol++) { + +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] starting extract\n"); +#endif + pbch_extract(lte_ue_common_vars->common_vars_rx_data_per_thread[0].rxdataF, + lte_ue_common_vars->common_vars_rx_data_per_thread[0].dl_ch_estimates[eNB_id], + lte_ue_pbch_vars->rxdataF_ext, + lte_ue_pbch_vars->dl_ch_estimates_ext, + symbol, + high_speed_flag, + frame_parms); +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PHY] PBCH Symbol %d\n",symbol); + LOG_D(PHY,"[PHY] PBCH starting channel_level\n"); +#endif + + max_h = pbch_channel_level(lte_ue_pbch_vars->dl_ch_estimates_ext, + frame_parms, + symbol); + log2_maxh = 3+(log2_approx(max_h)/2); + +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",log2_maxh,max_h); +#endif + + pbch_channel_compensation(lte_ue_pbch_vars->rxdataF_ext, + lte_ue_pbch_vars->dl_ch_estimates_ext, + lte_ue_pbch_vars->rxdataF_comp, + frame_parms, + symbol, + log2_maxh); // log2_maxh+I0_shift + + if (frame_parms->nb_antennas_rx > 1) + pbch_detection_mrc(frame_parms, + lte_ue_pbch_vars->rxdataF_comp, + symbol); + + + if (mimo_mode == ALAMOUTI) { + pbch_alamouti(frame_parms,lte_ue_pbch_vars->rxdataF_comp,symbol); + } else if (mimo_mode != SISO) { + LOG_D(PHY,"[PBCH][RX] Unsupported MIMO mode\n"); + return(-1); + } + + if (symbol>(nsymb>>1)+1) { + pbch_quantize(pbch_e_rx, + (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), + 144); + + pbch_e_rx+=144; + } else { + pbch_quantize(pbch_e_rx, + (short*)&(lte_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]), + 96); + + pbch_e_rx+=96; + } + + + } + + pbch_e_rx = lte_ue_pbch_vars->llr; + + + + //un-scrambling +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] doing unscrambling\n"); +#endif + + + pbch_unscrambling(frame_parms, + pbch_e_rx, + pbch_E, + frame_mod4); + + + + //un-rate matching +#ifdef DEBUG_PBCH + LOG_D(PHY,"[PBCH] doing un-rate-matching\n"); +#endif + + + memset(dummy_w_rx,0,3*3*(16+PBCH_A)); + RCC = generate_dummy_w_cc(16+PBCH_A, + dummy_w_rx); + + + lte_rate_matching_cc_rx(RCC,pbch_E,pbch_w_rx,dummy_w_rx,pbch_e_rx); + + sub_block_deinterleaving_cc((unsigned int)(PBCH_A+16), + &pbch_d_rx[96], + &pbch_w_rx[0]); + + memset(pbch_a,0,((16+PBCH_A)>>3)); + + + + + phy_viterbi_lte_sse2(pbch_d_rx+96,pbch_a,16+PBCH_A); + + // Fix byte endian of PBCH (bit 23 goes in first) + for (i=0; i<(PBCH_A>>3); i++) + decoded_output[(PBCH_A>>3)-i-1] = pbch_a[i]; + +#ifdef DEBUG_PBCH + + for (i=0; i<(PBCH_A>>3); i++) + LOG_I(PHY,"[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]); + +#endif //DEBUG_PBCH + +#ifdef DEBUG_PBCH + LOG_I(PHY,"PBCH CRC %x : %x\n", + crc16(pbch_a,PBCH_A), + ((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); +#endif + + crc = (crc16(pbch_a,PBCH_A)>>16) ^ + (((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]); + + if (crc == 0x0000) + return(1); + else if (crc == 0xffff) + return(2); + else if (crc == 0x5555) + return(4); + else + return(-1); + + +} diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..82bb0a2659ed9ff4e4ea8a09fc4d068f2c516092 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c @@ -0,0 +1,162 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/pcfich.c +* \brief Top-level routines for generating and decoding the PCFICH/CFI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +//#define DEBUG_PCFICH + +extern uint8_t pcfich_b[4][32]; + + + + +void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + int16_t *d) +{ + + uint32_t i; + uint8_t reset; + uint32_t x1, x2, s=0; + + reset = 1; + // x1 is set in lte_gold_generic + x2 = ((((2*frame_parms->Nid_cell)+1)*(1+subframe))<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.7.1 + + for (i=0; i<32; i++) { + if ((i&0x1f)==0) { + s = lte_gold_generic(&x1, &x2, reset); + //printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + if (((s>>(i&0x1f))&1) == 1) + d[i]=-d[i]; + + } +} + +uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t subframe, + LTE_UE_PDCCH *lte_ue_pdcch_vars, + MIMO_mode_t mimo_mode) +{ + + uint8_t pcfich_quad; + uint8_t i,j; + uint16_t reg_offset; + + int32_t **rxdataF_comp = lte_ue_pdcch_vars->rxdataF_comp; + int16_t pcfich_d[32],*pcfich_d_ptr; + int32_t metric,old_metric=-16384; + uint8_t num_pdcch_symbols=3; + uint16_t *pcfich_reg = frame_parms->pcfich_reg; + + // demapping + // loop over 4 quadruplets and lookup REGs + // m=0; + pcfich_d_ptr = pcfich_d; + + for (pcfich_quad=0; pcfich_quad<4; pcfich_quad++) { + reg_offset = (pcfich_reg[pcfich_quad]*4); + + for (i=0; i<4; i++) { + + pcfich_d_ptr[0] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0]; // RE component + pcfich_d_ptr[1] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1]; // IM component +#ifdef DEBUG_PCFICH + printf("rx_pcfich: quad %d, i %d, offset %d => (%d,%d) => pcfich_d_ptr[0] %d \n",pcfich_quad,i,reg_offset+i, + ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0], + ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1], + pcfich_d_ptr[0]); +#endif + pcfich_d_ptr+=2; + } + + /* + } + else { // ALAMOUTI + for (i=0;i<4;i+=2) { + pcfich_d_ptr[0] = 0; + pcfich_d_ptr[1] = 0; + pcfich_d_ptr[2] = 0; + pcfich_d_ptr[3] = 0; + for (j=0;j<frame_parms->nb_antennas_rx;j++) { + + pcfich_d_ptr[0] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[0]+ + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[0]); // RE component + pcfich_d_ptr[1] += (((int16_t*)&rxdataF_comp[j][reg_offset+i])[1] - + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i+1])[1]);// IM component + + pcfich_d_ptr[2] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[0]- + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[0]); // RE component + pcfich_d_ptr[3] += (((int16_t*)&rxdataF_comp[j][reg_offset+i+1])[1] + + ((int16_t*)&rxdataF_comp[j+2][reg_offset+i])[1]);// IM component + + + } + + pcfich_d_ptr+=4; + + } + */ + } + + // pcfhich unscrambling + + pcfich_unscrambling(frame_parms,subframe,pcfich_d); + + // pcfich detection + + for (i=0; i<3; i++) { + metric = 0; + + for (j=0; j<32; j++) { + // printf("pcfich_b[%d][%d] %d => pcfich_d[%d] %d\n",i,j,pcfich_b[i][j],j,pcfich_d[j]); + metric += (int32_t)(((pcfich_b[i][j]==0) ? (pcfich_d[j]) : (-pcfich_d[j]))); + } + +#ifdef DEBUG_PCFICH + printf("metric %d : %d\n",i,metric); +#endif + + if (metric > old_metric) { + num_pdcch_symbols = 1+i; + old_metric = metric; + } + } + +#ifdef DEBUG_PCFICH + printf("[PHY] PCFICH detected for %d PDCCH symbols\n",num_pdcch_symbols); +#endif + return(num_pdcch_symbols); +} diff --git a/openair1/PHY/LTE_TRANSPORT/pch.c b/openair1/PHY/LTE_UE_TRANSPORT/pch_ue.c similarity index 97% rename from openair1/PHY/LTE_TRANSPORT/pch.c rename to openair1/PHY/LTE_UE_TRANSPORT/pch_ue.c index 600c5215bdd5c4bbde741ff86b4dad7196620633..aed3ddabc15b6279393c7405961edde780c51cd2 100644 --- a/openair1/PHY/LTE_TRANSPORT/pch.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/pch_ue.c @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "assertions.h" const unsigned int Ttab[4] = {32,64,128,256}; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..669e0937c6c57bc559d4e2f87c546fd550419ac5 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/phich_ue.c @@ -0,0 +1,489 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/phich_ue.c +* \brief Top-level routines for decoding the PHICH/HI physical/transport channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ + +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "transport_ue.h" +#include "transport_proto_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +#include "LAYER2/MAC/mac.h" + +#include "T.h" + +//#define DEBUG_PHICH 1 + +//extern unsigned short pcfich_reg[4]; +//extern unsigned char pcfich_first_reg_idx; + +//unsigned short phich_reg[MAX_NUM_PHICH_GROUPS][3]; + + +uint8_t rv_table[4] = {0, 2, 3, 1}; + + + + + + +// This routine demodulates the PHICH and updates PUSCH/ULSCH parameters + +void rx_phich(PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, + uint8_t subframe, + uint8_t eNB_id) +{ + + + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + LTE_UE_PDCCH **pdcch_vars = &ue->pdcch_vars[ue->current_thread_id[subframe]][eNB_id]; + + // uint8_t HI; + uint8_t harq_pid = phich_subframe_to_harq_pid(frame_parms,proc->frame_rx,subframe); + LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + int16_t phich_d[24],*phich_d_ptr,HI16; + // unsigned int i,aa; + int8_t d[24],*dp; + uint16_t reg_offset; + + // scrambling + uint32_t x1, x2, s=0; + uint8_t reset = 1; + int16_t cs[12]; + uint32_t i,i2,i3,phich_quad; + int32_t **rxdataF_comp = pdcch_vars[eNB_id]->rxdataF_comp; + uint8_t Ngroup_PHICH,ngroup_PHICH,nseq_PHICH; + uint8_t NSF_PHICH = 4; + uint8_t pusch_subframe; + + int8_t delta_PUSCH_acc[4] = {-1,0,1,3}; + + // check if we're expecting a PHICH in this subframe + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); + + if (!ulsch) + return; + + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX Status: %d \n",ue->Mod_id,harq_pid,proc->frame_rx,subframe, ulsch->harq_processes[harq_pid]->status); + + if (ulsch->harq_processes[harq_pid]->status == ACTIVE) { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX ACTIVE\n",ue->Mod_id,harq_pid,proc->frame_rx,subframe); + Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; + + if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) + Ngroup_PHICH++; + + if (frame_parms->Ncp == 1) + NSF_PHICH = 2; + + + ngroup_PHICH = (ulsch->harq_processes[harq_pid]->first_rb + + ulsch->harq_processes[harq_pid]->n_DMRS)%Ngroup_PHICH; + + if ((frame_parms->tdd_config == 0) && (frame_parms->frame_type == TDD) ) { + pusch_subframe = phich_subframe2_pusch_subframe(frame_parms,subframe); + + if ((pusch_subframe == 4) || (pusch_subframe == 9)) + ngroup_PHICH += Ngroup_PHICH; + } + + nseq_PHICH = ((ulsch->harq_processes[harq_pid]->first_rb/Ngroup_PHICH) + + ulsch->harq_processes[harq_pid]->n_DMRS)%(2*NSF_PHICH); + } else { + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH RX %s\n", + ue->Mod_id, + harq_pid, + proc->frame_rx, + subframe, + (ulsch->harq_processes[harq_pid]->status==SCH_IDLE? "SCH_IDLE" : + (ulsch->harq_processes[harq_pid]->status==ACTIVE? "ACTIVE" : + (ulsch->harq_processes[harq_pid]->status==CBA_ACTIVE? "CBA_ACTIVE": + (ulsch->harq_processes[harq_pid]->status==DISABLED? "DISABLED" : "UNKNOWN"))))); + + return; + } + + memset(d,0,24*sizeof(int8_t)); + phich_d_ptr = phich_d; + + // x1 is set in lte_gold_generic + x2 = (((subframe+1)*((frame_parms->Nid_cell<<1)+1))<<9) + frame_parms->Nid_cell; + + s = lte_gold_generic(&x1, &x2, reset); + + // compute scrambling sequence + for (i=0; i<12; i++) { + cs[i] = 1-(((s>>(i&0x1f))&1)<<1); + } + + if (frame_parms->Ncp == 0) { // Normal Cyclic Prefix + + + // 12 output symbols (Msymb) + + for (i=0,i2=0,i3=0; i<3; i++,i2+=4,i3+=8) { + switch (nseq_PHICH) { + case 0: // +1 +1 +1 +1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = cs[1+i2]; + d[3+i3] = cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[5+i3] = cs[2+i2]; + d[6+i3] = cs[3+i2]; + d[7+i3] = cs[3+i2]; + break; + + case 1: // +1 -1 +1 -1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = -cs[1+i2]; + d[3+i3] = -cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[5+i3] = cs[2+i2]; + d[6+i3] = -cs[3+i2]; + d[7+i3] = -cs[3+i2]; + break; + + case 2: // +1 +1 -1 -1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = cs[1+i2]; + d[3+i3] = cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[5+i3] = -cs[2+i2]; + d[6+i3] = -cs[3+i2]; + d[7+i3] = -cs[3+i2]; + break; + + case 3: // +1 -1 -1 +1 + d[i3] = cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = -cs[1+i2]; + d[3+i3] = -cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[5+i3] = -cs[2+i2]; + d[6+i3] = cs[3+i2]; + d[7+i3] = cs[3+i2]; + break; + + case 4: // +j +j +j +j + d[i3] = -cs[i2]; + d[1+i3] = cs[i2]; + d[2+i3] = -cs[1+i2]; + d[3+i3] = cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[5+i3] = cs[2+i2]; + d[6+i3] = -cs[3+i2]; + d[7+i3] = cs[3+i2]; + break; + + case 5: // +j -j +j -j + d[1+i3] = cs[i2]; + d[3+i3] = -cs[1+i2]; + d[5+i3] = cs[2+i2]; + d[7+i3] = -cs[3+i2]; + d[i3] = -cs[i2]; + d[2+i3] = cs[1+i2]; + d[4+i3] = -cs[2+i2]; + d[6+i3] = cs[3+i2]; + break; + + case 6: // +j +j -j -j + d[1+i3] = cs[i2]; + d[3+i3] = cs[1+i2]; + d[5+i3] = -cs[2+i2]; + d[7+i3] = -cs[3+i2]; + d[i3] = -cs[i2]; + d[2+i3] = -cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[6+i3] = cs[3+i2]; + break; + + case 7: // +j -j -j +j + d[1+i3] = cs[i2]; + d[3+i3] = -cs[1+i2]; + d[5+i3] = -cs[2+i2]; + d[7+i3] = cs[3+i2]; + d[i3] = -cs[i2]; + d[2+i3] = cs[1+i2]; + d[4+i3] = cs[2+i2]; + d[6+i3] = -cs[3+i2]; + break; + + default: + AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); + } // nseq_PHICH + } + +#ifdef DEBUG_PHICH + LOG_D(PHY,"PHICH =>"); + + for (i=0; i<24; i++) { + LOG_D(PHY,"%2d,",d[i]); + } + + LOG_D(PHY,"\n"); +#endif + // demodulation here + + + } else { // extended prefix + + // 6 output symbols + if ((ngroup_PHICH & 1) == 1) + dp = &d[4]; + else + dp = d; + + switch (nseq_PHICH) { + case 0: // +1 +1 + dp[0] = cs[0]; + dp[2] = cs[1]; + dp[8] = cs[2]; + dp[10] = cs[3]; + dp[16] = cs[4]; + dp[18] = cs[5]; + dp[1] = cs[0]; + dp[3] = cs[1]; + dp[9] = cs[2]; + dp[11] = cs[3]; + dp[17] = cs[4]; + dp[19] = cs[5]; + break; + + case 1: // +1 -1 + dp[0] = cs[0]; + dp[2] = -cs[1]; + dp[8] = cs[2]; + dp[10] = -cs[3]; + dp[16] = cs[4]; + dp[18] = -cs[5]; + dp[1] = cs[0]; + dp[3] = -cs[1]; + dp[9] = cs[2]; + dp[11] = -cs[3]; + dp[17] = cs[4]; + dp[19] = -cs[5]; + break; + + case 2: // +j +j + dp[1] = cs[0]; + dp[3] = cs[1]; + dp[9] = cs[2]; + dp[11] = cs[3]; + dp[17] = cs[4]; + dp[19] = cs[5]; + dp[0] = -cs[0]; + dp[2] = -cs[1]; + dp[8] = -cs[2]; + dp[10] = -cs[3]; + dp[16] = -cs[4]; + dp[18] = -cs[5]; + + break; + + case 3: // +j -j + dp[1] = cs[0]; + dp[3] = -cs[1]; + dp[9] = cs[2]; + dp[11] = -cs[3]; + dp[17] = cs[4]; + dp[19] = -cs[5]; + dp[0] = -cs[0]; + dp[2] = cs[1]; + dp[8] = -cs[2]; + dp[10] = cs[3]; + dp[16] = -cs[4]; + dp[18] = cs[5]; + break; + + default: + AssertFatal(1==0,"phich_coding.c: Illegal PHICH Number\n"); + } + } + + HI16 = 0; + + //#ifdef DEBUG_PHICH + + //#endif + /* + for (i=0;i<200;i++) + printf("re %d: %d %d\n",i,((int16_t*)&rxdataF_comp[0][i])[0],((int16_t*)&rxdataF_comp[0][i])[1]); + */ + for (phich_quad=0; phich_quad<3; phich_quad++) { + if (frame_parms->Ncp == 1) + reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4)+ (phich_quad*frame_parms->N_RB_DL*12); + else + reg_offset = (frame_parms->phich_reg[ngroup_PHICH][phich_quad]*4); + + // msg("\n[PUSCH 0]PHICH (RX) quad %d (%d)=>",phich_quad,reg_offset); + dp = &d[phich_quad*8];; + + for (i=0; i<8; i++) { + phich_d_ptr[i] = ((int16_t*)&rxdataF_comp[0][reg_offset])[i]; + +#ifdef DEBUG_PHICH + LOG_D(PHY,"%d,",((int16_t*)&rxdataF_comp[0][reg_offset])[i]); +#endif + + HI16 += (phich_d_ptr[i] * dp[i]); + } + } + +#ifdef DEBUG_PHICH + LOG_D(PHY,"\n"); + LOG_D(PHY,"HI16 %d\n",HI16); +#endif + + if (HI16>0) { //NACK + if (ue->ulsch_Msg3_active[eNB_id] == 1) { + LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received NAK (%d) nseq %d, ngroup %d\n", + ue->Mod_id,harq_pid, + proc->frame_rx, + subframe, + HI16, + nseq_PHICH, + ngroup_PHICH); + + ulsch->f_pusch += delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC]; + + LOG_D(PHY,"[PUSCH %d] AbsSubframe %d.%d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", + harq_pid,proc->frame_rx,subframe,ulsch->f_pusch, + delta_PUSCH_acc[ulsch->harq_processes[harq_pid]->TPC], + ulsch->harq_processes[harq_pid]->TPC); + + + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + // ulsch->harq_processes[harq_pid]->Ndi = 0; + ulsch->harq_processes[harq_pid]->round++; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + + if (ulsch->harq_processes[harq_pid]->round>=ue->frame_parms.maxHARQ_Msg3Tx) { + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag =0; + ulsch->harq_processes[harq_pid]->status = SCH_IDLE; + // inform MAC that Msg3 transmission has failed + ue->ulsch_Msg3_active[eNB_id] = 0; + } + } else { +#ifdef UE_DEBUG_TRACE + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received NAK (%d) nseq %d, ngroup %d round %d (Mlimit %d)\n", + ue->Mod_id,harq_pid, + proc->frame_rx%1024, + subframe, + HI16, + nseq_PHICH, + ngroup_PHICH, + ulsch->harq_processes[harq_pid]->round, + ulsch->Mlimit); +#endif + + // ulsch->harq_processes[harq_pid]->Ndi = 0; + ulsch->harq_processes[harq_pid]->round++; + + if ( ulsch->harq_processes[harq_pid]->round >= (ulsch->Mlimit - 1) ) + { + // this is last push re transmission + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + + // disable phich decoding since it is the last retransmission + ulsch->harq_processes[harq_pid]->status = SCH_IDLE; + + //ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + //ulsch->harq_processes[harq_pid]->round = 0; + + //LOG_I(PHY,"PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->Mlimit, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); + } + else + { + // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; + ulsch->O_RI = 0; + ulsch->O = 0; + ulsch->uci_format = HLC_subband_cqi_nopmi; + //LOG_I(PHY,"[HARQ-UL harqId: %d] PHICH NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); + } + } +#if T_TRACER + T(T_UE_PHY_ULSCH_UE_NACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), + T_INT(harq_pid)); +#endif + + } else { //ACK + if (ue->ulsch_Msg3_active[eNB_id] == 1) { + LOG_D(PHY,"[UE %d][PUSCH %d][RAPROC] Frame %d subframe %d Msg3 PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", + ue->Mod_id,harq_pid, + proc->frame_rx, + subframe, + HI16, + nseq_PHICH,ngroup_PHICH); + } else { +#ifdef UE_DEBUG_TRACE + LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d PHICH, received ACK (%d) nseq %d, ngroup %d\n\n", + ue->Mod_id,harq_pid, + proc->frame_rx%1024, + subframe, HI16, + nseq_PHICH,ngroup_PHICH); +#endif + } + + // LOG_I(PHY,"[HARQ-UL harqId: %d] subframe_scheduling_flag = %d \n",harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag); + + // Incase of adaptive retransmission, PHICH is always decoded as ACK (at least with OAI-eNB) + // Workaround: + // rely only on DCI0 decoding and check if NDI has toggled + // save current harq_processes content in temporary struct + // harqId-8 corresponds to the temporary struct. In total we have 8 harq process(0 ..7) + 1 temporary harq process() + //ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; + + + ulsch->harq_processes[harq_pid]->status = SCH_IDLE; + ulsch->harq_processes[harq_pid]->round = 0; + ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + // inform MAC? + ue->ulsch_Msg3_active[eNB_id] = 0; + +#if T_TRACER + T(T_UE_PHY_ULSCH_UE_ACK, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(subframe), T_INT(ulsch->rnti), + T_INT(harq_pid)); +#endif + + } + +} + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pmch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pmch_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..d944491b6399ead88d0c3d163f22c2e300787376 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pmch_ue.c @@ -0,0 +1,844 @@ +/* + * 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 "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/sse_intrin.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" + +// Mask for identifying subframe for MBMS +#define MBSFN_TDD_SF3 0x80// for TDD +#define MBSFN_TDD_SF4 0x40 +#define MBSFN_TDD_SF7 0x20 +#define MBSFN_TDD_SF8 0x10 +#define MBSFN_TDD_SF9 0x08 + +#define MBSFN_FDD_SF1 0x80// for FDD +#define MBSFN_FDD_SF2 0x40 +#define MBSFN_FDD_SF3 0x20 +#define MBSFN_FDD_SF6 0x10 +#define MBSFN_FDD_SF7 0x08 +#define MBSFN_FDD_SF8 0x04 + + + +void dump_mch(PHY_VARS_UE *ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe) +{ + + unsigned int nsymb_pmch=12; + char fname[32],vname[32]; + int N_RB_DL=ue->frame_parms.N_RB_DL; + + sprintf(fname,"mch_rxF_ext0.m"); + sprintf(vname,"pmch_rxF_ext0"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb_pmch,1,1); + sprintf(fname,"mch_ch_ext00.m"); + sprintf(vname,"pmch_ch_ext00"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb_pmch,1,1); + /* + write_output("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb_pmch,1,1); + write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb_pmch,1,1); + write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb_pmch,1,1); + write_output("dlsch%d_rho.m","dl_rho",pdsch_vars[eNB_id]->rho[0],12*N_RB_DL*nsymb_pmch,1,1); + */ + sprintf(fname,"mch_rxF_comp0.m"); + sprintf(vname,"pmch_rxF_comp0"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb_pmch,1,1); + sprintf(fname,"mch_rxF_llr.m"); + sprintf(vname,"pmch_llr"); + write_output(fname,vname, ue->pdsch_vars_MCH[eNB_id]->llr[0],coded_bits_per_codeword,1,0); + sprintf(fname,"mch_mag1.m"); + sprintf(vname,"pmch_mag1"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_mag0[0],12*N_RB_DL*nsymb_pmch,1,1); + sprintf(fname,"mch_mag2.m"); + sprintf(vname,"pmch_mag2"); + write_output(fname,vname,ue->pdsch_vars_MCH[eNB_id]->dl_ch_magb0[0],12*N_RB_DL*nsymb_pmch,1,1); + + write_output("mch00_ch0.m","pmch00_ch0", + &(ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id][0][0]), + ue->frame_parms.ofdm_symbol_size*12,1,1); + + write_output("rxsig_mch.m","rxs_mch", + &ue->common_vars.rxdata[0][subframe*ue->frame_parms.samples_per_tti], + ue->frame_parms.samples_per_tti,1,1); + + /* + if (PHY_vars_eNB_g) + write_output("txsig_mch.m","txs_mch", + &PHY_vars_eNB_g[0][0]->common_vars.txdata[0][0][subframe*ue->frame_parms.samples_per_tti], + ue->frame_parms.samples_per_tti,1,1);*/ +} + + +void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id) +{ + + LTE_UE_DLSCH_t *dlsch = ue->dlsch_MCH[eNB_id]; + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + + // dlsch->rnti = M_RNTI; + dlsch->harq_processes[0]->mcs = mcs; + dlsch->harq_processes[0]->rvidx = rvidx; + // dlsch->harq_processes[0]->Ndi = ndi; + dlsch->harq_processes[0]->Nl = 1; + dlsch->harq_processes[0]->TBS = TBStable[get_I_TBS(dlsch->harq_processes[0]->mcs)][frame_parms->N_RB_DL-1]; + dlsch->current_harq_pid = 0; + dlsch->harq_processes[0]->nb_rb = frame_parms->N_RB_DL; + + switch(frame_parms->N_RB_DL) { + case 6: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0x3f; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x3f; + break; + + case 25: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0x1ffffff; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0x1ffffff; + break; + + case 50: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[1] = 0x3ffff; + dlsch->harq_processes[0]->rb_alloc_odd[1] = 0x3ffff; + break; + + case 100: + dlsch->harq_processes[0]->rb_alloc_even[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[0] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[1] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[1] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[2] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_odd[2] = 0xffffffff; + dlsch->harq_processes[0]->rb_alloc_even[3] = 0xf; + dlsch->harq_processes[0]->rb_alloc_odd[3] = 0xf; + break; + } +} + + + +void mch_extract_rbs(int **rxdataF, + int **dl_ch_estimates, + int **rxdataF_ext, + int **dl_ch_estimates_ext, + unsigned char symbol, + unsigned char subframe, + LTE_DL_FRAME_PARMS *frame_parms) +{ + + int pilots=0,i,j,offset,aarx; + + // printf("Extracting PMCH: symbol %d\n",symbol); + if ((symbol==2)|| + (symbol==10)) { + pilots = 1; + offset = 1; + } else if (symbol==6) { + pilots = 1; + offset = 0; + } + + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (pilots==1) { + for (i=offset,j=0; i<frame_parms->N_RB_DL*6; i+=2,j++) { + /* printf("MCH with pilots: i %d, j %d => %d,%d\n",i,j, + *(int16_t*)&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], + *(int16_t*)(1+&rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)])); + */ + rxdataF_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)]; + rxdataF_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = rxdataF[aarx][i+1+ (symbol*frame_parms->ofdm_symbol_size)]; + dl_ch_estimates_ext[aarx][j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(symbol*frame_parms->ofdm_symbol_size)]; + dl_ch_estimates_ext[aarx][(frame_parms->N_RB_DL*3)+j+symbol*(frame_parms->N_RB_DL*12)] = dl_ch_estimates[aarx][i+(frame_parms->N_RB_DL*6)+(symbol*frame_parms->ofdm_symbol_size)]; + } + } else { + + memcpy((void*)&rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], + (void*)&rxdataF[aarx][frame_parms->first_carrier_offset + (symbol*frame_parms->ofdm_symbol_size)], + frame_parms->N_RB_DL*24); + memcpy((void*)&rxdataF_ext[aarx][(frame_parms->N_RB_DL*6) + symbol*(frame_parms->N_RB_DL*12)], + (void*)&rxdataF[aarx][1 + (symbol*frame_parms->ofdm_symbol_size)], + frame_parms->N_RB_DL*24); + memcpy((void*)&dl_ch_estimates_ext[aarx][symbol*(frame_parms->N_RB_DL*12)], + (void*)&dl_ch_estimates[aarx][(symbol*frame_parms->ofdm_symbol_size)], + frame_parms->N_RB_DL*48); + + } + + } + + + +} + +void mch_channel_level(int **dl_ch_estimates_ext, + LTE_DL_FRAME_PARMS *frame_parms, + int *avg, + uint8_t symbol, + unsigned short nb_rb) +{ + + int i,aarx,nre; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,avg128; +#elif defined(__arm__) + int32x4_t avg128; +#endif + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { +#if defined(__x86_64__) || defined(__i386__) + //clear average level + avg128 = _mm_setzero_si128(); + // 5 is always a symbol with no pilots for both normal and extended prefix + + dl_ch128=(__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + + +#endif + if ((symbol == 2) || (symbol == 6) || (symbol == 10)) + nre = (frame_parms->N_RB_DL*6); + else + nre = (frame_parms->N_RB_DL*12); + + for (i=0; i<(nre>>2); i++) { +#if defined(__x86_64__) || defined(__i386__) + avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); +#elif defined(__arm__) + +#endif + } + + avg[aarx] = (((int*)&avg128)[0] + + ((int*)&avg128)[1] + + ((int*)&avg128)[2] + + ((int*)&avg128)[3])/nre; + + // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +void mch_channel_compensation(int **rxdataF_ext, + int **dl_ch_estimates_ext, + int **dl_ch_mag, + int **dl_ch_magb, + int **rxdataF_comp, + LTE_DL_FRAME_PARMS *frame_parms, + unsigned char symbol, + unsigned char mod_order, + unsigned char output_shift) +{ + + int aarx,nre,i; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; +#elif defined(__arm__) + +#endif + if ((symbol == 2) || (symbol == 6) || (symbol == 10)) + nre = frame_parms->N_RB_DL*6; + else + nre = frame_parms->N_RB_DL*12; + +#if defined(__x86_64__) || defined(__i386__) + if (mod_order == 4) { + QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) + QAM_amp128b = _mm_setzero_si128(); + } else if (mod_order == 6) { + QAM_amp128 = _mm_set1_epi16(QAM64_n1); // + QAM_amp128b = _mm_set1_epi16(QAM64_n2); + } +#elif defined(__arm__) + +#endif + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128 = (__m128i *)&dl_ch_mag[aarx][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128b = (__m128i *)&dl_ch_magb[aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[aarx][symbol*frame_parms->N_RB_DL*12]; +#elif defined(__arm__) + +#endif + + for (i=0; i<(nre>>2); i+=2) { + if (mod_order>2) { + // get channel amplitude if not QPSK +#if defined(__x86_64__) || defined(__i386__) + + mmtmpD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128[0]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + + mmtmpD1 = _mm_madd_epi16(dl_ch128[1],dl_ch128[1]); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + + mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1); + + // store channel magnitude here in a new field of dlsch + + dl_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0); + dl_ch_mag128b[0] = dl_ch_mag128[0]; + dl_ch_mag128[0] = _mm_mulhi_epi16(dl_ch_mag128[0],QAM_amp128); + dl_ch_mag128[0] = _mm_slli_epi16(dl_ch_mag128[0],1); + + dl_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0); + dl_ch_mag128b[1] = dl_ch_mag128[1]; + dl_ch_mag128[1] = _mm_mulhi_epi16(dl_ch_mag128[1],QAM_amp128); + dl_ch_mag128[1] = _mm_slli_epi16(dl_ch_mag128[1],1); + + + dl_ch_mag128b[0] = _mm_mulhi_epi16(dl_ch_mag128b[0],QAM_amp128b); + dl_ch_mag128b[0] = _mm_slli_epi16(dl_ch_mag128b[0],1); + + + dl_ch_mag128b[1] = _mm_mulhi_epi16(dl_ch_mag128b[1],QAM_amp128b); + dl_ch_mag128b[1] = _mm_slli_epi16(dl_ch_mag128b[1],1); + +#elif defined(__arm__) + +#endif + } + +#if defined(__x86_64__) || defined(__i386__) + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpD0); + + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpD1); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + // print_ints("re(shift)",&mmtmpD0); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + // print_ints("im(shift)",&mmtmpD1); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + // print_ints("c0",&mmtmpD2); + // print_ints("c1",&mmtmpD3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",dl_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",dl_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + + dl_ch128+=2; + dl_ch_mag128+=2; + dl_ch_mag128b+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + +#elif defined(__arm__) + +#endif + } + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + +} + +void mch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + int **dl_ch_mag, + int **dl_ch_magb, + unsigned char symbol) +{ + + + int i; +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; +#elif defined(__arm__) + int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b; +#endif + if (frame_parms->nb_antennas_rx>1) { + +#if defined(__x86_64__) || defined(__i386__) + + rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; + +#elif defined(__arm__) + rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; + rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0 = (int16x8_t *)&dl_ch_mag[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1 = (int16x8_t *)&dl_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_0b = (int16x8_t *)&dl_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; + dl_ch_mag128_1b = (int16x8_t *)&dl_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; + +#endif + // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) + for (i=0; i<frame_parms->N_RB_DL*3; i++) { +#if defined(__x86_64__) || defined(__i386__) + rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1)); + dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1)); + dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1)); +#elif defined(__arm__) + rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]); + dl_ch_mag128_0[i] = vhaddq_s16(dl_ch_mag128_0[i],dl_ch_mag128_1[i]); + dl_ch_mag128_0b[i] = vhaddq_s16(dl_ch_mag128_0b[i],dl_ch_mag128_1b[i]); +#endif + } + } +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +int mch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + short *dlsch_llr, + unsigned char symbol, + short **llr32p) +{ + + uint32_t *rxF = (uint32_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + uint32_t *llr32; + int i,len; + + if (symbol==2) { + llr32 = (uint32_t*)dlsch_llr; + } else { + llr32 = (uint32_t*)(*llr32p); + } + + AssertFatal(llr32!=NULL,"dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32); + + + if ((symbol==2) || (symbol==6) || (symbol==10)) { + len = frame_parms->N_RB_DL*6; + } else { + len = frame_parms->N_RB_DL*12; + } + + // printf("dlsch_qpsk_llr: symbol %d,len %d,pbch_pss_sss_adjust %d\n",symbol,len,pbch_pss_sss_adjust); + for (i=0; i<len; i++) { + *llr32 = *rxF; + rxF++; + llr32++; + } + + *llr32p = (short *)llr32; + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif + + return(0); +} + +//---------------------------------------------------------------------------------------------- +// 16-QAM +//---------------------------------------------------------------------------------------------- + +void mch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + short *dlsch_llr, + int **dl_ch_mag, + unsigned char symbol, + int16_t **llr32p) +{ + +#if defined(__x86_64__) || defined(__i386__) + __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + __m128i *ch_mag; + __m128i llr128[2],xmm0; + uint32_t *llr32; +#elif defined(__arm__) + int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; + int16x8_t *ch_mag; + int16x8_t llr128[2],xmm0; + int16_t *llr16; +#endif + int i,len; + unsigned char len_mod4=0; + +#if defined(__x86_64__) || defined(__i386__) + if (symbol==2) { + llr32 = (uint32_t*)dlsch_llr; + } else { + llr32 = (uint32_t*)*llr32p; + } +#elif defined(__arm__) + if (symbol==2) { + llr16 = (int16_t*)dlsch_llr; + } else { + llr16 = (int16_t*)*llr32p; + } +#endif +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; +#endif + if ((symbol==2) || (symbol==6) || (symbol==10)) { + len = frame_parms->N_RB_DL*6; + } else { + len = frame_parms->N_RB_DL*12; + } + + + + // update output pointer according to number of REs in this symbol (<<2 because 4 bits per RE) + if (symbol==2) + *llr32p = dlsch_llr + (len<<2); + else + *llr32p += (len<<2); + + len_mod4 = len&3; + len>>=2; // length in quad words (4 REs) + len+=(len_mod4==0 ? 0 : 1); + + for (i=0; i<len; i++) { + +#if defined(__x86_64__) || defined(__i386__) + xmm0 = _mm_abs_epi16(rxF[i]); + xmm0 = _mm_subs_epi16(ch_mag[i],xmm0); + + // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 + llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0); + llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0); + llr32[0] = ((uint32_t *)&llr128[0])[0]; + llr32[1] = ((uint32_t *)&llr128[0])[1]; + llr32[2] = ((uint32_t *)&llr128[0])[2]; + llr32[3] = ((uint32_t *)&llr128[0])[3]; + llr32[4] = ((uint32_t *)&llr128[1])[0]; + llr32[5] = ((uint32_t *)&llr128[1])[1]; + llr32[6] = ((uint32_t *)&llr128[1])[2]; + llr32[7] = ((uint32_t *)&llr128[1])[3]; + llr32+=8; + +#elif defined(__arm__) + xmm0 = vabsq_s16(rxF[i]); + xmm0 = vsubq_s16(ch_mag[i],xmm0); + + // lambda_1=y_R, lambda_2=|y_R|-|h|^2, lamda_3=y_I, lambda_4=|y_I|-|h|^2 + + llr16[0] = vgetq_lane_s16(rxF[i],0); + llr16[1] = vgetq_lane_s16(xmm0,0); + llr16[2] = vgetq_lane_s16(rxF[i],1); + llr16[3] = vgetq_lane_s16(xmm0,1); + llr16[4] = vgetq_lane_s16(rxF[i],2); + llr16[5] = vgetq_lane_s16(xmm0,2); + llr16[6] = vgetq_lane_s16(rxF[i],2); + llr16[7] = vgetq_lane_s16(xmm0,3); + llr16[8] = vgetq_lane_s16(rxF[i],4); + llr16[9] = vgetq_lane_s16(xmm0,4); + llr16[10] = vgetq_lane_s16(rxF[i],5); + llr16[11] = vgetq_lane_s16(xmm0,5); + llr16[12] = vgetq_lane_s16(rxF[i],6); + llr16[13] = vgetq_lane_s16(xmm0,6); + llr16[14] = vgetq_lane_s16(rxF[i],7); + llr16[15] = vgetq_lane_s16(xmm0,7); + llr16+=16; +#endif + + } + +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +//---------------------------------------------------------------------------------------------- +// 64-QAM +//---------------------------------------------------------------------------------------------- + +void mch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, + int **rxdataF_comp, + short *dlsch_llr, + int **dl_ch_mag, + int **dl_ch_magb, + unsigned char symbol, + short **llr_save) +{ + +#if defined(__x86_64__) || defined(__i386__) + __m128i xmm1,xmm2,*ch_mag,*ch_magb; + __m128i *rxF = (__m128i*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; +#elif defined(__arm__) + int16x8_t xmm1,xmm2,*ch_mag,*ch_magb; + int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; +#endif + + int i,len,len2; + // int j=0; + unsigned char len_mod4; + short *llr; + int16_t *llr2; + + if (symbol==2) + llr = dlsch_llr; + else + llr = *llr_save; + +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; + ch_magb = (__m128i*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; + ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; +#endif + if ((symbol==2) || (symbol==6) || (symbol==10)) { + len = frame_parms->N_RB_DL*6; + } else { + len = frame_parms->N_RB_DL*12; + } + + + llr2 = llr; + llr += (len*6); + + len_mod4 =len&3; + len2=len>>2; // length in quad words (4 REs) + len2+=(len_mod4?0:1); + + + for (i=0; i<len2; i++) { +#if defined(__x86_64__) || defined(__i386__) + xmm1 = _mm_abs_epi16(rxF[i]); + xmm1 = _mm_subs_epi16(ch_mag[i],xmm1); + xmm2 = _mm_abs_epi16(xmm1); + xmm2 = _mm_subs_epi16(ch_magb[i],xmm2); +#elif defined(__arm__) + xmm1 = vabsq_s16(rxF[i]); + xmm1 = vsubq_s16(ch_mag[i],xmm1); + xmm2 = vabsq_s16(xmm1); + xmm2 = vsubq_s16(ch_magb[i],xmm2); +#endif + + /* + printf("pmch i: %d => mag (%d,%d) (%d,%d)\n",i,((short *)&ch_mag[i])[0],((short *)&ch_magb[i])[0], + ((short *)&rxF[i])[0],((short *)&rxF[i])[1]); + */ + // loop over all LLRs in quad word (24 coded bits) + /* + for (j=0;j<8;j+=2) { + llr2[0] = ((short *)&rxF[i])[j]; + llr2[1] = ((short *)&rxF[i])[j+1]; + llr2[2] = _mm_extract_epi16(xmm1,j); + llr2[3] = _mm_extract_epi16(xmm1,j+1);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,j);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,j+1);//((short *)&xmm2)[j+1]; + + llr2+=6; + } + */ + llr2[0] = ((short *)&rxF[i])[0]; + llr2[1] = ((short *)&rxF[i])[1]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,0); + llr2[3] = _mm_extract_epi16(xmm1,1);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,0);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,1);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,0); + llr2[3] = vgetq_lane_s16(xmm1,1);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,0);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,1);//((short *)&xmm2)[j+1]; +#endif + + llr2+=6; + llr2[0] = ((short *)&rxF[i])[2]; + llr2[1] = ((short *)&rxF[i])[3]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,2); + llr2[3] = _mm_extract_epi16(xmm1,3);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,2);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,3);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,2); + llr2[3] = vgetq_lane_s16(xmm1,3);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,2);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,3);//((short *)&xmm2)[j+1]; +#endif + llr2+=6; + llr2[0] = ((short *)&rxF[i])[4]; + llr2[1] = ((short *)&rxF[i])[5]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,4); + llr2[3] = _mm_extract_epi16(xmm1,5);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,4);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,5);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,4); + llr2[3] = vgetq_lane_s16(xmm1,5);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,4);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,5);//((short *)&xmm2)[j+1]; +#endif + llr2+=6; + llr2[0] = ((short *)&rxF[i])[6]; + llr2[1] = ((short *)&rxF[i])[7]; +#if defined(__x86_64__) || defined(__i386__) + llr2[2] = _mm_extract_epi16(xmm1,6); + llr2[3] = _mm_extract_epi16(xmm1,7);//((short *)&xmm1)[j+1]; + llr2[4] = _mm_extract_epi16(xmm2,6);//((short *)&xmm2)[j]; + llr2[5] = _mm_extract_epi16(xmm2,7);//((short *)&xmm2)[j+1]; +#elif defined(__arm__) + llr2[2] = vgetq_lane_s16(xmm1,6); + llr2[3] = vgetq_lane_s16(xmm1,7);//((short *)&xmm1)[j+1]; + llr2[4] = vgetq_lane_s16(xmm2,6);//((short *)&xmm2)[j]; + llr2[5] = vgetq_lane_s16(xmm2,7);//((short *)&xmm2)[j+1]; +#endif + llr2+=6; + } + + *llr_save = llr; +#if defined(__x86_64__) || defined(__i386__) + _mm_empty(); + _m_empty(); +#endif +} + +int avg_pmch[4]; +int rx_pmch(PHY_VARS_UE *ue, + unsigned char eNB_id, + uint8_t subframe, + unsigned char symbol) +{ + + LTE_UE_COMMON *common_vars = &ue->common_vars; + LTE_UE_PDSCH **pdsch_vars = &ue->pdsch_vars_MCH[eNB_id]; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + LTE_UE_DLSCH_t **dlsch = &ue->dlsch_MCH[eNB_id]; + int avgs,aarx; + + //printf("*********************mch: symbol %d\n",symbol); + + mch_extract_rbs(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF, + common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].dl_ch_estimates[eNB_id], + pdsch_vars[eNB_id]->rxdataF_ext, + pdsch_vars[eNB_id]->dl_ch_estimates_ext, + symbol, + subframe, + frame_parms); + + if (symbol == 2) { + mch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext, + frame_parms, + avg_pmch, + symbol, + frame_parms->N_RB_DL); + } + + avgs = 0; + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) + avgs = cmax(avgs,avg_pmch[aarx]); + + if (get_Qm(dlsch[0]->harq_processes[0]->mcs)==2) + pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) ;// + 2 + else + pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2); // + 5;// + 2 + + mch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext, + pdsch_vars[eNB_id]->dl_ch_estimates_ext, + pdsch_vars[eNB_id]->dl_ch_mag0, + pdsch_vars[eNB_id]->dl_ch_magb0, + pdsch_vars[eNB_id]->rxdataF_comp0, + frame_parms, + symbol, + get_Qm(dlsch[0]->harq_processes[0]->mcs), + pdsch_vars[eNB_id]->log2_maxh); + + + if (frame_parms->nb_antennas_rx > 1) + mch_detection_mrc(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->dl_ch_mag0, + pdsch_vars[eNB_id]->dl_ch_magb0, + symbol); + + switch (get_Qm(dlsch[0]->harq_processes[0]->mcs)) { + case 2 : + mch_qpsk_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->llr[0], + symbol, + pdsch_vars[eNB_id]->llr128); + break; + + case 4: + mch_16qam_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->llr[0], + pdsch_vars[eNB_id]->dl_ch_mag0, + symbol, + pdsch_vars[eNB_id]->llr128); + break; + + case 6: + mch_64qam_llr(frame_parms, + pdsch_vars[eNB_id]->rxdataF_comp0, + pdsch_vars[eNB_id]->llr[0], + pdsch_vars[eNB_id]->dl_ch_mag0, + pdsch_vars[eNB_id]->dl_ch_magb0, + symbol, + pdsch_vars[eNB_id]->llr128); + break; + } + + return(0); +} + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..02d0c9aa4f51a78bfcb8bacb4f319d0294086559 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c @@ -0,0 +1,534 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/prach_ue.c + * \brief Top-level routines for decoding the PRACH physical channel V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#include "PHY/sse_intrin.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +//#include "prach.h" +#include "PHY/LTE_TRANSPORT/if4_tools.h" + +#include "SCHED_UE/sched_UE.h" +#include "SCHED/sched_common_extern.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +#include "../LTE_TRANSPORT/prach_extern.h" + +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; + //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; + uint8_t Ncs_config = ue->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig; + uint8_t restricted_set = ue->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag; + //uint8_t n_ra_prboffset = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; + uint8_t preamble_index = ue->prach_resources[eNB_id]->ra_PreambleIndex; + uint8_t tdd_mapindex = ue->prach_resources[eNB_id]->ra_TDD_map_index; + int16_t *prachF = ue->prach_vars[eNB_id]->prachF; + static int16_t prach_tmp[45600*2] __attribute__((aligned(32))); + int16_t *prach = prach_tmp; + int16_t *prach2; + int16_t amp = ue->prach_vars[eNB_id]->amp; + int16_t Ncp; + uint8_t n_ra_prb; + uint16_t NCS; + uint16_t *prach_root_sequence_map; + uint16_t preamble_offset,preamble_shift; + uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar; + uint16_t d_start,numshift; + + uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); + //uint8_t Nsp=2; + //uint8_t f_ra,t1_ra; + uint16_t N_ZC = (prach_fmt<4)?839:139; + uint8_t not_found; + int k; + int16_t *Xu; + uint16_t u; + int32_t Xu_re,Xu_im; + uint16_t offset,offset2; + int prach_start; + int i, prach_len; + uint16_t first_nonzero_root_idx=0; + +#if defined(EXMIMO) || defined(OAI_USRP) + 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); +#endif + + 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_D(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 + + + // First compute physical root sequence + if (restricted_set == 0) { + AssertFatal(Ncs_config <= 15, + "[PHY] FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", Ncs_config ); + NCS = NCS_unrestricted[Ncs_config]; + } else { + AssertFatal(Ncs_config <= 14, + "[PHY] FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", Ncs_config ); + NCS = NCS_restricted[Ncs_config]; + } + + n_ra_prb = get_prach_prb_offset(&(ue->frame_parms), + ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset, + tdd_mapindex, Nf); + prach_root_sequence_map = (prach_fmt<4) ? prach_root_sequence_map0_3 : prach_root_sequence_map4; + + /* + // this code is not part of get_prach_prb_offset + if (frame_type == TDD) { // TDD + + if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { + LOG_E( PHY, "[PHY][UE %"PRIu8"] Illegal prach_ConfigIndex %"PRIu8" for ", ue->Mod_id, prach_ConfigIndex ); + } + + // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) + f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; + + if (prach_fmt < 4) { + if ((f_ra&1) == 0) { + n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); + } else { + n_ra_prb = ue->frame_parms.N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); + } + } else { + if ((tdd_config >2) && (tdd_config<6)) + Nsp = 2; + + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + + if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { + n_ra_prb = 6*f_ra; + } else { + n_ra_prb = ue->frame_parms.N_RB_UL - 6*(f_ra+1); + } + } + } + */ + + // This is the relative offset (for unrestricted case) in the root sequence table (5.7.2-4 from 36.211) for the given preamble index + preamble_offset = ((NCS==0)? preamble_index : (preamble_index/(N_ZC/NCS))); + + if (restricted_set == 0) { + // This is the \nu corresponding to the preamble index + preamble_shift = (NCS==0)? 0 : (preamble_index % (N_ZC/NCS)); + preamble_shift *= NCS; + } else { // This is the high-speed case + +#ifdef PRACH_DEBUG + LOG_I(PHY,"[UE %d] High-speed mode, NCS_config %d\n",ue->Mod_id,Ncs_config); +#endif + + not_found = 1; + preamble_index0 = preamble_index; + // set preamble_offset to initial rootSequenceIndex and look if we need more root sequences for this + // preamble index and find the corresponding cyclic shift + preamble_offset = 0; // relative rootSequenceIndex; + + while (not_found == 1) { + // current root depending on rootSequenceIndex and preamble_offset + int index = (rootSequenceIndex + preamble_offset) % N_ZC; + + if (prach_fmt<4) { + // prach_root_sequence_map points to prach_root_sequence_map0_3 + DevAssert( index < sizeof(prach_root_sequence_map0_3) / sizeof(prach_root_sequence_map0_3[0]) ); + } else { + // prach_root_sequence_map points to prach_root_sequence_map4 + DevAssert( index < sizeof(prach_root_sequence_map4) / sizeof(prach_root_sequence_map4[0]) ); + } + + u = prach_root_sequence_map[index]; + + uint16_t n_group_ra = 0; + + if ( (du[u]<(N_ZC/3)) && (du[u]>=NCS) ) { + n_shift_ra = du[u]/NCS; + d_start = (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = N_ZC/d_start; + n_shift_ra_bar = max(0,(N_ZC-(du[u]<<1)-(n_group_ra*d_start))/N_ZC); + } else if ( (du[u]>=(N_ZC/3)) && (du[u]<=((N_ZC - NCS)>>1)) ) { + n_shift_ra = (N_ZC - (du[u]<<1))/NCS; + d_start = N_ZC - (du[u]<<1) + (n_shift_ra * NCS); + n_group_ra = du[u]/d_start; + n_shift_ra_bar = min(n_shift_ra,max(0,(du[u]- (n_group_ra*d_start))/NCS)); + } else { + n_shift_ra = 0; + n_shift_ra_bar = 0; + } + + // This is the number of cyclic shifts for the current root u + numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar; + + if (numshift>0 && preamble_index0==preamble_index) + first_nonzero_root_idx = preamble_offset; + + if (preamble_index0 < numshift) { + not_found = 0; + preamble_shift = (d_start * (preamble_index0/n_shift_ra)) + ((preamble_index0%n_shift_ra)*NCS); + + } else { // skip to next rootSequenceIndex and recompute parameters + preamble_offset++; + preamble_index0 -= numshift; + } + } + } + + // now generate PRACH signal +#ifdef PRACH_DEBUG + + if (NCS>0) + LOG_I(PHY,"Generate PRACH for RootSeqIndex %d, Preamble Index %d, NCS %d (NCS_config %d, N_ZC/NCS %d) n_ra_prb %d: Preamble_offset %d, Preamble_shift %d\n", + rootSequenceIndex,preamble_index,NCS,Ncs_config,N_ZC/NCS,n_ra_prb, + preamble_offset,preamble_shift); + +#endif + + // nsymb = (frame_parms->Ncp==0) ? 14:12; + // subframe_offset = (unsigned int)frame_parms->ofdm_symbol_size*subframe*nsymb; + + k = (12*n_ra_prb) - 6*ue->frame_parms.N_RB_UL; + + if (k<0) + k+=ue->frame_parms.ofdm_symbol_size; + + k*=12; + k+=13; + + Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; + + /* + k+=(12*ue->frame_parms.first_carrier_offset); + if (k>(12*ue->frame_parms.ofdm_symbol_size)) + k-=(12*ue->frame_parms.ofdm_symbol_size); + */ + k*=2; + + switch (ue->frame_parms.N_RB_UL) { + case 6: + memset((void*)prachF,0,4*1536); + break; + + case 15: + memset((void*)prachF,0,4*3072); + break; + + case 25: + memset((void*)prachF,0,4*6144); + break; + + case 50: + memset((void*)prachF,0,4*12288); + break; + + case 75: + memset((void*)prachF,0,4*18432); + break; + + case 100: + if (ue->frame_parms.threequarter_fs == 0) + memset((void*)prachF,0,4*24576); + else + memset((void*)prachF,0,4*18432); + break; + } + + for (offset=0,offset2=0; offset<N_ZC; offset++,offset2+=preamble_shift) { + + if (offset2 >= N_ZC) + offset2 -= N_ZC; + + Xu_re = (((int32_t)Xu[offset<<1]*amp)>>15); + Xu_im = (((int32_t)Xu[1+(offset<<1)]*amp)>>15); + prachF[k++]= ((Xu_re*ru[offset2<<1]) - (Xu_im*ru[1+(offset2<<1)]))>>15; + prachF[k++]= ((Xu_im*ru[offset2<<1]) + (Xu_re*ru[1+(offset2<<1)]))>>15; + + if (k==(12*2*ue->frame_parms.ofdm_symbol_size)) + k=0; + } + + switch (prach_fmt) { + case 0: + Ncp = 3168; + break; + + case 1: + case 3: + Ncp = 21024; + break; + + case 2: + Ncp = 6240; + break; + + case 4: + Ncp = 448; + break; + + default: + Ncp = 3168; + break; + } + + switch (ue->frame_parms.N_RB_UL) { + case 6: + Ncp>>=4; + prach+=4; // makes prach2 aligned to 128-bit + break; + + case 15: + Ncp>>=3; + break; + + case 25: + Ncp>>=2; + break; + + case 50: + Ncp>>=1; + break; + + case 75: + Ncp=(Ncp*3)>>2; + break; + } + + if (ue->frame_parms.threequarter_fs == 1) + Ncp=(Ncp*3)>>2; + + prach2 = prach+(Ncp<<1); + + // do IDFT + switch (ue->frame_parms.N_RB_UL) { + case 6: + if (prach_fmt == 4) { + idft256(prachF,prach2,1); + memmove( prach, prach+512, Ncp<<2 ); + prach_len = 256+Ncp; + } else { + idft1536(prachF,prach2,1); + memmove( prach, prach+3072, Ncp<<2 ); + prach_len = 1536+Ncp; + + if (prach_fmt>1) { + memmove( prach2+3072, prach2, 6144 ); + prach_len = 2*1536+Ncp; + } + } + + break; + + case 15: + if (prach_fmt == 4) { + idft512(prachF,prach2,1); + //TODO: account for repeated format in dft output + memmove( prach, prach+1024, Ncp<<2 ); + prach_len = 512+Ncp; + } else { + idft3072(prachF,prach2); + memmove( prach, prach+6144, Ncp<<2 ); + prach_len = 3072+Ncp; + + if (prach_fmt>1) { + memmove( prach2+6144, prach2, 12288 ); + prach_len = 2*3072+Ncp; + } + } + + break; + + case 25: + default: + if (prach_fmt == 4) { + idft1024(prachF,prach2,1); + memmove( prach, prach+2048, Ncp<<2 ); + prach_len = 1024+Ncp; + } else { + idft6144(prachF,prach2); + /*for (i=0;i<6144*2;i++) + prach2[i]<<=1;*/ + memmove( prach, prach+12288, Ncp<<2 ); + prach_len = 6144+Ncp; + + if (prach_fmt>1) { + memmove( prach2+12288, prach2, 24576 ); + prach_len = 2*6144+Ncp; + } + } + + break; + + case 50: + if (prach_fmt == 4) { + idft2048(prachF,prach2,1); + memmove( prach, prach+4096, Ncp<<2 ); + prach_len = 2048+Ncp; + } else { + idft12288(prachF,prach2); + memmove( prach, prach+24576, Ncp<<2 ); + prach_len = 12288+Ncp; + + if (prach_fmt>1) { + memmove( prach2+24576, prach2, 49152 ); + prach_len = 2*12288+Ncp; + } + } + + break; + + case 75: + if (prach_fmt == 4) { + idft3072(prachF,prach2); + //TODO: account for repeated format in dft output + memmove( prach, prach+6144, Ncp<<2 ); + prach_len = 3072+Ncp; + } else { + idft18432(prachF,prach2); + memmove( prach, prach+36864, Ncp<<2 ); + prach_len = 18432+Ncp; + + if (prach_fmt>1) { + memmove( prach2+36834, prach2, 73728 ); + prach_len = 2*18432+Ncp; + } + } + + break; + + case 100: + if (ue->frame_parms.threequarter_fs == 0) { + if (prach_fmt == 4) { + idft4096(prachF,prach2,1); + memmove( prach, prach+8192, Ncp<<2 ); + prach_len = 4096+Ncp; + } else { + idft24576(prachF,prach2); + memmove( prach, prach+49152, Ncp<<2 ); + prach_len = 24576+Ncp; + + if (prach_fmt>1) { + memmove( prach2+49152, prach2, 98304 ); + prach_len = 2* 24576+Ncp; + } + } + } + else { + if (prach_fmt == 4) { + idft3072(prachF,prach2); + //TODO: account for repeated format in dft output + memmove( prach, prach+6144, Ncp<<2 ); + prach_len = 3072+Ncp; + } else { + idft18432(prachF,prach2); + memmove( prach, prach+36864, Ncp<<2 ); + prach_len = 18432+Ncp; + printf("Generated prach for 100 PRB, 3/4 sampling\n"); + if (prach_fmt>1) { + memmove( prach2+36834, prach2, 73728 ); + prach_len = 2*18432+Ncp; + } + } + } + + break; + } + + //LOG_I(PHY,"prach_len=%d\n",prach_len); + + AssertFatal(prach_fmt<4, + "prach_fmt4 not fully implemented" ); +#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) + 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; i<min(ue->frame_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; i<overflow; 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]; + } +#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) ; k<prach_start ; k++) { + if (k<0) + ue->common_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 + + for (i=0; i<prach_len; i++) { + ((int16_t*)(&ue->common_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]; + } + +#endif + + + +#if defined(PRACH_WRITE_OUTPUT_DEBUG) + write_output("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1); + write_output("prach_tx0.m","prachtx0",prach+(Ncp<<1),prach_len-Ncp,1,1); + write_output("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][0]),2*ue->frame_parms.samples_per_tti,1,1); + exit(-1); +#endif + + return signal_energy( (int*)prach, 256 ); +} + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..c3bbd0fb1caafe229a22a5660e7991385f663515 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/pucch_ue.c @@ -0,0 +1,843 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/pucch.c +* \brief Top-level routines for generating and decoding the PUCCH physical channel V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" + +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" + +#include "T.h" + +#include "../LTE_TRANSPORT/pucch_extern.h" + + + +void generate_pucch1x(int32_t **txdataF, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t ncs_cell[20][7], + PUCCH_FMT_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint16_t n1_pucch, + uint8_t shortened_format, + uint8_t *payload, + int16_t amp, + uint8_t subframe) +{ + + uint32_t u,v,n; + uint32_t z[12*14],*zptr; + int16_t d0; + uint8_t ns,N_UL_symb,nsymb,n_oc,n_oc0,n_oc1; + uint8_t c = (frame_parms->Ncp==0) ? 3 : 2; + uint16_t nprime,nprime0,nprime1; + uint16_t i,j,re_offset,thres,h; + uint8_t Nprime_div_deltaPUCCH_Shift,Nprime,d; + uint8_t m,l,refs; + uint8_t n_cs,S,alpha_ind,rem; + int16_t tmp_re,tmp_im,ref_re,ref_im,W_re=0,W_im=0; + int32_t *txptr; + uint32_t symbol_offset; + + uint8_t deltaPUCCH_Shift = frame_parms->pucch_config_common.deltaPUCCH_Shift; + uint8_t NRB2 = frame_parms->pucch_config_common.nRB_CQI; + uint8_t Ncs1 = frame_parms->pucch_config_common.nCS_AN; + uint8_t Ncs1_div_deltaPUCCH_Shift = Ncs1/deltaPUCCH_Shift; + + LOG_D(PHY,"generate_pucch Start [deltaPUCCH_Shift %d, NRB2 %d, Ncs1_div_deltaPUCCH_Shift %d, n1_pucch %d]\n", deltaPUCCH_Shift, NRB2, Ncs1_div_deltaPUCCH_Shift,n1_pucch); + + + uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; + uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; + uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; + uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + + if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { + printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); + return; + } + + if (Ncs1_div_deltaPUCCH_Shift > 7) { + printf("[PHY] generate_pucch: Illegal Ncs1_div_deltaPUCCH_Shift %d (should be 0...7)\n",Ncs1_div_deltaPUCCH_Shift); + return; + } + + zptr = z; + thres = (c*Ncs1_div_deltaPUCCH_Shift); + Nprime_div_deltaPUCCH_Shift = (n1_pucch < thres) ? Ncs1_div_deltaPUCCH_Shift : (12/deltaPUCCH_Shift); + Nprime = Nprime_div_deltaPUCCH_Shift * deltaPUCCH_Shift; + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: cNcs1/deltaPUCCH_Shift %d, Nprime %d, n1_pucch %d\n",thres,Nprime,n1_pucch); +#endif + + LOG_D(PHY,"[PHY] PUCCH: n1_pucch %d, thres %d Ncs1_div_deltaPUCCH_Shift %d (12/deltaPUCCH_Shift) %d Nprime_div_deltaPUCCH_Shift %d \n", + n1_pucch, thres, Ncs1_div_deltaPUCCH_Shift, (int)(12/deltaPUCCH_Shift), Nprime_div_deltaPUCCH_Shift); + LOG_D(PHY,"[PHY] PUCCH: deltaPUCCH_Shift %d, Nprime %d\n",deltaPUCCH_Shift,Nprime); + + + N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; + + if (n1_pucch < thres) + nprime0=n1_pucch; + else + nprime0 = (n1_pucch - thres)%(12*c/deltaPUCCH_Shift); + + if (n1_pucch >= thres) + nprime1= ((c*(nprime0+1))%((12*c/deltaPUCCH_Shift)+1))-1; + else { + d = (frame_parms->Ncp==0) ? 2 : 0; + h= (nprime0+d)%(c*Nprime_div_deltaPUCCH_Shift); +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: h %d, d %d\n",h,d); +#endif + nprime1 = (h/c) + (h%c)*Nprime_div_deltaPUCCH_Shift; + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: nprime0 %d nprime1 %d, %s, payload (%d,%d)\n",nprime0,nprime1,pucch_format_string[fmt],payload[0],payload[1]); +#endif + + n_oc0 = nprime0/Nprime_div_deltaPUCCH_Shift; + + if (frame_parms->Ncp==1) + n_oc0<<=1; + + n_oc1 = nprime1/Nprime_div_deltaPUCCH_Shift; + + if (frame_parms->Ncp==1) // extended CP + n_oc1<<=1; + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: noc0 %d noc1 %d\n",n_oc0,n_oc1); +#endif + + nprime=nprime0; + n_oc =n_oc0; + + // loop over 2 slots + for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { + + if ((nprime&1) == 0) + S=0; // 1 + else + S=1; // j + + //loop over symbols in slot + for (l=0; l<N_UL_symb; l++) { + // Compute n_cs (36.211 p. 18) + n_cs = ncs_cell[ns][l]; + + if (frame_parms->Ncp==0) { // normal CP + n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc%deltaPUCCH_Shift))%Nprime)%12; + } else { + n_cs = ((uint16_t)n_cs + (nprime*deltaPUCCH_Shift + (n_oc>>1))%Nprime)%12; + } + + + refs=0; + + // Comput W_noc(m) (36.211 p. 19) + if ((ns==(1+(subframe<<1))) && (shortened_format==1)) { // second slot and shortened format + + if (l<2) { // data + W_re=W3_re[n_oc][l]; + W_im=W3_im[n_oc][l]; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP + W_re=W3_re[n_oc][l-2]; + W_im=W3_im[n_oc][l-2]; + refs=1; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP + W_re=W4[n_oc][l-2]; + W_im=0; + refs=1; + } else if ((l>=N_UL_symb-2)) { // data + W_re=W3_re[n_oc][l-N_UL_symb+4]; + W_im=W3_im[n_oc][l-N_UL_symb+4]; + } + } else { + if (l<2) { // data + W_re=W4[n_oc][l]; + W_im=0; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==0)) { // reference and normal CP + W_re=W3_re[n_oc][l-2]; + W_im=W3_im[n_oc][l-2]; + refs=1; + } else if ((l<N_UL_symb-2)&&(frame_parms->Ncp==1)) { // reference and extended CP + W_re=W4[n_oc][l-2]; + W_im=0; + refs=1; + } else if ((l>=N_UL_symb-2)) { // data + W_re=W4[n_oc][l-N_UL_symb+4]; + W_im=0; + } + } + + // multiply W by S(ns) (36.211 p.17). only for data, reference symbols do not have this factor + if ((S==1)&&(refs==0)) { + tmp_re = W_re; + W_re = -W_im; + W_im = tmp_re; + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: ncs[%d][%d]=%d, W_re %d, W_im %d, S %d, refs %d\n",ns,l,n_cs,W_re,W_im,S,refs); +#endif + alpha_ind=0; + // compute output sequence + + for (n=0; n<12; n++) { + + // this is r_uv^alpha(n) + tmp_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); + tmp_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); + + // this is S(ns)*w_noc(m)*r_uv^alpha(n) + ref_re = (tmp_re*W_re - tmp_im*W_im)>>15; + ref_im = (tmp_re*W_im + tmp_im*W_re)>>15; + + if ((l<2)||(l>=(N_UL_symb-2))) { //these are PUCCH data symbols + switch (fmt) { + case pucch_format1: //OOK 1-bit + + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; + + break; + + case pucch_format1a: //BPSK 1-bit + d0 = (payload[0]&1)==0 ? amp : -amp; + ((int16_t *)&zptr[n])[0] = ((int32_t)d0*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)d0*ref_im)>>15; + // printf("d0 %d\n",d0); + break; + + case pucch_format1b: //QPSK 2-bits (Table 5.4.1-1 from 36.211, pg. 18) + if (((payload[0]&1)==0) && ((payload[1]&1)==0)) {// 1 + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; + } else if (((payload[0]&1)==0) && ((payload[1]&1)==1)) { // -j + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_im)>>15; + ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_re)>>15; + } else if (((payload[0]&1)==1) && ((payload[1]&1)==0)) { // j + ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_im)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_re)>>15; + } else { // -1 + ((int16_t *)&zptr[n])[0] = (-(int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = (-(int32_t)amp*ref_im)>>15; + } + + break; + case pucch_format1b_csA2: + case pucch_format1b_csA3: + case pucch_format1b_csA4: + AssertFatal(1==0,"PUCCH format 1b_csX not supported yet\n"); + break; + case pucch_format2: + case pucch_format2a: + case pucch_format2b: + AssertFatal(1==0,"should not go here\n"); + break; + + case pucch_format3: + fprintf(stderr, "PUCCH format 3 not handled\n"); + abort(); + } // switch fmt + } else { // These are PUCCH reference symbols + + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im)>>15; + // printf("ref\n"); + } + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH subframe %d z(%d,%d) => %d,%d, alpha(%d) => %d,%d\n",subframe,l,n,((int16_t *)&zptr[n])[0],((int16_t *)&zptr[n])[1], + alpha_ind,alpha_re[alpha_ind],alpha_im[alpha_ind]); +#endif + alpha_ind = (alpha_ind + n_cs)%12; + } // n + + zptr+=12; + } // l + + nprime=nprime1; + n_oc =n_oc1; + } // ns + + rem = ((((12*Ncs1_div_deltaPUCCH_Shift)>>3)&7)>0) ? 1 : 0; + + m = (n1_pucch < thres) ? NRB2 : (((n1_pucch-thres)/(12*c/deltaPUCCH_Shift))+NRB2+((deltaPUCCH_Shift*Ncs1_div_deltaPUCCH_Shift)>>3)+rem); + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH: m %d\n",m); +#endif + nsymb = N_UL_symb<<1; + + //for (j=0,l=0;l<(nsymb-1);l++) { + for (j=0,l=0; l<(nsymb); l++) { + if ((l<(nsymb>>1)) && ((m&1) == 0)) + re_offset = (m*6) + frame_parms->first_carrier_offset; + else if ((l<(nsymb>>1)) && ((m&1) == 1)) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else if ((m&1) == 0) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else + re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; + + if (re_offset > frame_parms->ofdm_symbol_size) + re_offset -= (frame_parms->ofdm_symbol_size); + + symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb)); + txptr = &txdataF[0][symbol_offset]; + + for (i=0; i<12; i++,j++) { + txptr[re_offset++] = z[j]; + + if (re_offset==frame_parms->ofdm_symbol_size) + re_offset = 0; + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); +#endif + } + } + +} + + + + +inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) __attribute__((always_inline)); +inline void pucch2x_scrambling(LTE_DL_FRAME_PARMS *fp,int subframe,uint16_t rnti,uint32_t B,uint8_t *btilde) { + + uint32_t x1, x2, s=0; + int i; + uint8_t c; + + x2 = (rnti) + ((uint32_t)(1+subframe)<<16)*(1+(fp->Nid_cell<<1)); //this is c_init in 36.211 Sec 6.3.1 + s = lte_gold_generic(&x1, &x2, 1); + for (i=0;i<19;i++) { + c = (uint8_t)((s>>i)&1); + btilde[i] = (((B>>i)&1) ^ c); + } +} + +inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) __attribute__((always_inline)); +inline void pucch2x_modulation(uint8_t *btilde,int16_t *d,int16_t amp) { + + int i; + + for (i=0;i<20;i++) + d[i] = btilde[i] == 1 ? -amp : amp; + +} + + + +uint32_t pucch_code[13] = {0xFFFFF,0x5A933,0x10E5A,0x6339C,0x73CE0, + 0xFFC00,0xD8E64,0x4F6B0,0x218EC,0x1B746, + 0x0FFFF,0x33FFF,0x3FFFC}; + + +void generate_pucch2x(int32_t **txdataF, + LTE_DL_FRAME_PARMS *fp, + uint8_t ncs_cell[20][7], + PUCCH_FMT_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint16_t n2_pucch, + uint8_t *payload, + int A, + int B2, + int16_t amp, + uint8_t subframe, + uint16_t rnti) { + + int i,j; + uint32_t B=0; + uint8_t btilde[20]; + int16_t d[22]; + uint8_t deltaPUCCH_Shift = fp->pucch_config_common.deltaPUCCH_Shift; + uint8_t NRB2 = fp->pucch_config_common.nRB_CQI; + uint8_t Ncs1 = fp->pucch_config_common.nCS_AN; + + uint32_t u0 = fp->pucch_config_common.grouphop[subframe<<1]; + uint32_t u1 = fp->pucch_config_common.grouphop[1+(subframe<<1)]; + uint32_t v0 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; + uint32_t v1 = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + + uint32_t z[12*14],*zptr; + uint32_t u,v,n; + uint8_t ns,N_UL_symb,nsymb_slot0,nsymb_pertti; + uint32_t nprime,l,n_cs; + int alpha_ind,data_ind; + int16_t ref_re,ref_im; + int m,re_offset,symbol_offset; + int32_t *txptr; + + if ((deltaPUCCH_Shift==0) || (deltaPUCCH_Shift>3)) { + printf("[PHY] generate_pucch: Illegal deltaPUCCH_shift %d (should be 1,2,3)\n",deltaPUCCH_Shift); + return; + } + + if (Ncs1 > 7) { + printf("[PHY] generate_pucch: Illegal Ncs1 %d (should be 0...7)\n",Ncs1); + return; + } + + // pucch2x_encoding + for (i=0;i<A;i++) + if ((*payload & (1<<i)) > 0) + B=B^pucch_code[i]; + + // scrambling + pucch2x_scrambling(fp,subframe,rnti,B,btilde); + // modulation + pucch2x_modulation(btilde,d,amp); + + // add extra symbol for 2a/2b + d[20]=0; + d[21]=0; + if (fmt==pucch_format2a) + d[20] = (B2 == 0) ? amp : -amp; + else if (fmt==pucch_format2b) { + switch (B2) { + case 0: + d[20] = amp; + break; + case 1: + d[21] = -amp; + break; + case 2: + d[21] = amp; + break; + case 3: + d[20] = -amp; + break; + default: + AssertFatal(1==0,"Illegal modulation symbol %d for PUCCH %s\n",B2,pucch_format_string[fmt]); + break; + } + } + + +#ifdef DEBUG_PUCCH_TX + printf("[PHY] PUCCH2x: n2_pucch %d\n",n2_pucch); +#endif + + N_UL_symb = (fp->Ncp==0) ? 7 : 6; + data_ind = 0; + zptr = z; + nprime = 0; + for (ns=(subframe<<1),u=u0,v=v0; ns<(2+(subframe<<1)); ns++,u=u1,v=v1) { + + if ((ns&1) == 0) + nprime = (n2_pucch < 12*NRB2) ? + n2_pucch % 12 : + (n2_pucch+Ncs1 + 1)%12; + else { + nprime = (n2_pucch < 12*NRB2) ? + ((12*(nprime+1)) % 13)-1 : + (10-n2_pucch)%12; + } + //loop over symbols in slot + for (l=0; l<N_UL_symb; l++) { + // Compute n_cs (36.211 p. 18) + n_cs = (ncs_cell[ns][l]+nprime)%12; + + alpha_ind = 0; + for (n=0; n<12; n++) + { + // this is r_uv^alpha(n) + ref_re = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][n<<1] - (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)])>>15); + ref_im = (int16_t)(((int32_t)alpha_re[alpha_ind] * ul_ref_sigs[u][v][0][1+(n<<1)] + (int32_t)alpha_im[alpha_ind] * ul_ref_sigs[u][v][0][n<<1])>>15); + + if ((l!=1)&&(l!=5)) { //these are PUCCH data symbols + ((int16_t *)&zptr[n])[0] = ((int32_t)d[data_ind]*ref_re - (int32_t)d[data_ind+1]*ref_im)>>15; + ((int16_t *)&zptr[n])[1] = ((int32_t)d[data_ind]*ref_im + (int32_t)d[data_ind+1]*ref_re)>>15; + //LOG_I(PHY,"slot %d ofdm# %d ==> d[%d,%d] \n",ns,l,data_ind,n); + } + else { + if ((l==1) || ( (l==5) && (fmt==pucch_format2) )) + { + ((int16_t *)&zptr[n])[0] = ((int32_t)amp*ref_re>>15); + ((int16_t *)&zptr[n])[1] = ((int32_t)amp*ref_im>>15); + } + // l == 5 && pucch format 2a + else if (fmt==pucch_format2a) + { + ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); + ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); + } + // l == 5 && pucch format 2b + else if (fmt==pucch_format2b) + { + ((int16_t *)&zptr[n])[0] = ((int32_t)d[20]*ref_re>>15); + ((int16_t *)&zptr[n])[1] = ((int32_t)d[21]*ref_im>>15); + } + } // l==1 || l==5 + alpha_ind = (alpha_ind + n_cs)%12; + } // n + zptr+=12; + + if ((l!=1)&&(l!=5)) //these are PUCCH data symbols so increment data index + data_ind+=2; + } // l + } //ns + + m = n2_pucch/12; + +#ifdef DEBUG_PUCCH_TX + LOG_D(PHY,"[PHY] PUCCH: n2_pucch %d m %d\n",n2_pucch,m); +#endif + + nsymb_slot0 = ((fp->Ncp==0) ? 7 : 6); + nsymb_pertti = nsymb_slot0 << 1; + + //nsymb = nsymb_slot0<<1; + + //for (j=0,l=0;l<(nsymb-1);l++) { + for (j=0,l=0; l<(nsymb_pertti); l++) { + + if ((l<nsymb_slot0) && ((m&1) == 0)) + re_offset = (m*6) + fp->first_carrier_offset; + else if ((l<nsymb_slot0) && ((m&1) == 1)) + re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; + else if ((m&1) == 0) + re_offset = fp->first_carrier_offset + (fp->N_RB_DL - (m>>1) - 1)*12; + else + re_offset = ((m-1)*6) + fp->first_carrier_offset; + + if (re_offset > fp->ofdm_symbol_size) + re_offset -= (fp->ofdm_symbol_size); + + + + symbol_offset = (unsigned int)fp->ofdm_symbol_size*(l+(subframe*nsymb_pertti)); + txptr = &txdataF[0][symbol_offset]; + + //LOG_I(PHY,"ofdmSymb %d/%d, firstCarrierOffset %d, symbolOffset[sfn %d] %d, reOffset %d, &txptr: %x \n", l, nsymb, fp->first_carrier_offset, subframe, symbol_offset, re_offset, &txptr[0]); + + for (i=0; i<12; i++,j++) { + txptr[re_offset] = z[j]; + + re_offset++; + + if (re_offset==fp->ofdm_symbol_size) + re_offset -= (fp->ofdm_symbol_size); + +#ifdef DEBUG_PUCCH_TX + LOG_D(PHY,"[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); +#endif + } + } +} + +/* PUCCH format3 >> */ +/* DFT */ +void pucchfmt3_Dft( int16_t *x, int16_t *y ) +{ + int16_t i, k; + int16_t tmp[2]; + int16_t calctmp[D_NSC1RB*2]={0}; + + for (i=0; i<D_NSC1RB; i++) { + for(k=0; k<D_NSC1RB; k++) { + tmp[0] = alphaTBL_re[(12-((i*k)%12))%12]; + tmp[1] = alphaTBL_im[(12-((i*k)%12))%12]; + + calctmp[2*i] += (((int32_t)x[2*k] * tmp[0] - (int32_t)x[2*k+1] * tmp[1])>>15); + calctmp[2*i+1] += (((int32_t)x[2*k+1] * tmp[0] + (int32_t)x[2*k] * tmp[1])>>15); + } + y[2*i] = (int16_t)( (double) calctmp[2*i] / sqrt(D_NSC1RB)); + y[2*i+1] = (int16_t)((double) calctmp[2*i+1] / sqrt(D_NSC1RB)); + } +} + +void generate_pucch3x(int32_t **txdataF, + LTE_DL_FRAME_PARMS *frame_parms, + uint8_t ncs_cell[20][7], + PUCCH_FMT_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint16_t n3_pucch, + uint8_t shortened_format, + uint8_t *payload, + int16_t amp, + uint8_t subframe, + uint16_t rnti) +{ + + uint32_t u, v; + uint16_t i, j, re_offset; + uint32_t z[12*14], *zptr; + uint32_t y_tilda[12*14]={}, *y_tilda_ptr; + uint8_t ns, nsymb, n_oc, n_oc0, n_oc1; + uint8_t N_UL_symb = (frame_parms->Ncp==0) ? 7 : 6; + uint8_t m, l; + uint8_t n_cs; + int16_t tmp_re, tmp_im, W_re=0, W_im=0; + int32_t *txptr; + uint32_t symbol_offset; + + uint32_t u0 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]) % 30; + uint32_t u1 = (frame_parms->Nid_cell + frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]) % 30; + uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; + uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + + // variables for channel coding + uint8_t chcod_tbl_idx = 0; + //uint8_t chcod_dt[48] = {}; + + // variables for Scrambling + uint32_t cinit = 0; + uint32_t x1; + uint32_t s,s0,s1; + uint8_t C[48] ={}; + uint8_t scr_dt[48]={}; + + // variables for Modulation + int16_t d_re[24]={}; + int16_t d_im[24]={}; + + // variables for orthogonal sequence selection + uint8_t N_PUCCH_SF0 = 5; + uint8_t N_PUCCH_SF1 = (shortened_format==0)? 5:4; + uint8_t first_slot = 0; + int16_t rot_re=0; + int16_t rot_im=0; + + uint8_t dt_offset; + uint8_t sym_offset; + int16_t y_re[14][12]; //={0}; + int16_t y_im[14][12]; //={0}; + + // DMRS + uint8_t alpha_idx=0; + uint8_t m_alpha_idx=0; + + // TODO + // "SR+ACK/NACK" length is only 7 bits. + // This restriction will be lifted in the future. + // "CQI/PMI/RI+ACK/NACK" will be supported in the future. + + // Channel Coding + for (uint8_t i=0; i<7; i++) { + chcod_tbl_idx += (payload[i]<<i); + } + + // Scrambling + cinit = (subframe + 1) * ((2 * frame_parms->Nid_cell + 1)<<16) + rnti; + s0 = lte_gold_generic(&x1,&cinit,1); + s1 = lte_gold_generic(&x1,&cinit,0); + + for (i=0; i<48; i++) { + s = (i<32)? s0:s1; + j = (i<32)? i:(i-32); + C[i] = ((s>>j)&1); + } + + for (i=0; i<48; i++) { + scr_dt[i] = chcod_tbl[chcod_tbl_idx][i] ^ C[i]; + } + + // Modulation + for (uint8_t i=0; i<48; i+=2){ + if (scr_dt[i]==0 && scr_dt[i+1]==0){ + d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); + d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); + } else if (scr_dt[i]==0 && scr_dt[i+1]==1) { + d_re[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp) >>15); + d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp) >>15); + } else if (scr_dt[i]==1 && scr_dt[i+1]==0) { + d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); + d_im[ i>>1] = ((ONE_OVER_SQRT2_Q15 * amp)>>15); + } else if (scr_dt[i]==1 && scr_dt[i+1]==1) { + d_re[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); + d_im[ i>>1] = -1 * ((ONE_OVER_SQRT2_Q15 * amp)>>15); + } else { + //***log Modulation Error! + } + } + + // Calculate Orthogonal Sequence index + n_oc0 = n3_pucch % N_PUCCH_SF1; + if (N_PUCCH_SF1 == 5) { + n_oc1 = (3 * n_oc0) % N_PUCCH_SF1; + } else { + n_oc1 = n_oc0 % N_PUCCH_SF1; + } + + y_tilda_ptr = y_tilda; + zptr = z; + + // loop over 2 slots + for (ns=(subframe<<1), u=u0, v=v0; ns<(2+(subframe<<1)); ns++, u=u1, v=v1) { + first_slot = (ns==(subframe<<1))?1:0; + + //loop over symbols in slot + for (l=0; l<N_UL_symb; l++) { + rot_re = RotTBL_re[(uint8_t) ncs_cell[ns][l]/64] ; + rot_im = RotTBL_im[(uint8_t) ncs_cell[ns][l]/64] ; + + // Comput W_noc(m) (36.211 p. 19) + if ( first_slot == 0 && shortened_format==1) { // second slot and shortened format + n_oc = n_oc1; + + if (l<1) { // data + W_re=W4_fmt3[n_oc][l]; + W_im=0; + } else if (l==1) { // DMRS + W_re=W2[0]; + W_im=0; + } else if (l>=2 && l<5) { // data + W_re=W4_fmt3[n_oc][l-1]; + W_im=0; + } else if (l==5) { // DMRS + W_re=W2[1]; + W_im=0; + } else if ((l>=N_UL_symb-2)) { // data + ; + } else { + //***log W Select Error! + } + } else { + if (first_slot == 1) { // 1st slot or 2nd slot and not shortened + n_oc=n_oc0; + } else { + n_oc=n_oc1; + } + + if (l<1) { // data + W_re=W5_fmt3_re[n_oc][l]; + W_im=W5_fmt3_im[n_oc][l]; + } else if (l==1) { // DMRS + W_re=W2[0]; + W_im=0; + } else if (l>=2 && l<5) { // data + W_re=W5_fmt3_re[n_oc][l-1]; + W_im=W5_fmt3_im[n_oc][l-1]; + } else if (l==5) { // DMRS + W_re=W2[1]; + W_im=0; + } else if ((l>=N_UL_symb-1)) { // data + W_re=W5_fmt3_re[n_oc][l-N_UL_symb+5]; + W_im=W5_fmt3_im[n_oc][l-N_UL_symb+5]; + } else { + //***log W Select Error! + } + } // W Selection end + + // Compute n_cs (36.211 p. 18) + n_cs = ncs_cell[ns][l]; + if (N_PUCCH_SF1 == 5) { + alpha_idx = (n_cs + Np5_TBL[n_oc]) % 12; + } else { + alpha_idx = (n_cs + Np4_TBL[n_oc]) % 12; + } + + // generate pucch data + dt_offset = (first_slot == 1) ? 0:12; + sym_offset = (first_slot == 1) ? 0:7; + + for (i=0; i<12; i++) { + // Calculate yn(i) + tmp_re = (((int32_t) (W_re*rot_re - W_im*rot_im)) >>15); + tmp_im = (((int32_t) (W_re*rot_im + W_im*rot_re)) >>15); + y_re[l+sym_offset][i] = (((int32_t) (tmp_re*d_re[i+dt_offset] - tmp_im*d_im[i+dt_offset]))>>15); + y_im[l+sym_offset][i] = (((int32_t) (tmp_re*d_im[i+dt_offset] + tmp_im*d_re[i+dt_offset]))>>15); + + // cyclic shift + ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[0] = y_re[l+sym_offset][i]; + ((int16_t *)&y_tilda_ptr[(l+sym_offset)*12+(i-(ncs_cell[ns][l]%12)+12)%12])[1] = y_im[l+sym_offset][i]; + + // DMRS + m_alpha_idx = (alpha_idx * i) % 12; + if (l==1 || l==5) { + ((int16_t *)&zptr[(l+sym_offset)*12+i])[0] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][i<<1] - (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][1+(i<<1)])>>15) * (int32_t)amp)>>15); + ((int16_t *)&zptr[(l+sym_offset)*12+i])[1] =(((((int32_t) alphaTBL_re[m_alpha_idx]*ul_ref_sigs[u][v][0][1+(i<<1)] + (int32_t) alphaTBL_im[m_alpha_idx] * ul_ref_sigs[u][v][0][i<<1])>>15) * (int32_t)amp)>>15); + } + } + + } // l loop + } // ns + + // DFT for pucch-data + for (l=0; l<14; l++) { + if (l==1 || l==5 || l==8 || l==12) { + ; + } else { + pucchfmt3_Dft((int16_t*)&y_tilda_ptr[l*12],(int16_t*)&zptr[l*12]); + } + } + + + // Mapping + m = n3_pucch / N_PUCCH_SF0; + + if (shortened_format == 1) { + nsymb = (N_UL_symb<<1) - 1; + } else { + nsymb = (N_UL_symb<<1); + } + + for (j=0,l=0; l<(nsymb); l++) { + + if ((l<7) && ((m&1) == 0)) + re_offset = (m*6) + frame_parms->first_carrier_offset; + else if ((l<7) && ((m&1) == 1)) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else if ((m&1) == 0) + re_offset = frame_parms->first_carrier_offset + (frame_parms->N_RB_DL - (m>>1) - 1)*12; + else + re_offset = ((m-1)*6) + frame_parms->first_carrier_offset; + + if (re_offset > frame_parms->ofdm_symbol_size) + re_offset -= (frame_parms->ofdm_symbol_size); + + symbol_offset = (unsigned int)frame_parms->ofdm_symbol_size*(l+(subframe*14)); + txptr = &txdataF[0][symbol_offset]; + + for (i=0; i<12; i++,j++) { + txptr[re_offset++] = z[j]; + + if (re_offset==frame_parms->ofdm_symbol_size) + re_offset = 0; + +#ifdef DEBUG_PUCCH_TX + msg("[PHY] PUCCH subframe %d (%d,%d,%d,%d) => %d,%d\n",subframe,l,i,re_offset-1,m,((int16_t *)&z[j])[0],((int16_t *)&z[j])[1]); +#endif + } + } + +} + + + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..03df4e7f690e86b00cd8d39e3d58a9ddf1db267c --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/rar_tools_ue.c @@ -0,0 +1,207 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_UE_TRANSPORT/rar_tools_ue.c +* \brief Routine for filling the PUSCH/ULSCH data structures based on a random-access response (RAR) SDU from MAC. Note this is for UE +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "LAYER2/MAC/mac.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "transport_proto_ue.h" + +#include "assertions.h" + +extern uint16_t RIV2nb_rb_LUT6[32]; +extern uint16_t RIV2first_rb_LUT6[32]; +extern uint16_t RIV2nb_rb_LUT25[512]; +extern uint16_t RIV2first_rb_LUT25[512]; +extern uint16_t RIV2nb_rb_LUT50[1600]; +extern uint16_t RIV2first_rb_LUT50[1600]; +extern uint16_t RIV2nb_rb_LUT100[6000]; +extern uint16_t RIV2first_rb_LUT100[600]; + +extern uint16_t RIV_max6,RIV_max25,RIV_max50,RIV_max100; + +int8_t delta_PUSCH_msg2[8] = {-6,-4,-2,0,2,4,6,8}; + +int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, + unsigned char eNB_id ) +{ + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_IN); + + // RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)rar_pdu; + uint8_t transmission_mode = ue->transmission_mode[eNB_id]; + unsigned char *rar_pdu = ue->dlsch_ra[eNB_id]->harq_processes[0]->b; + unsigned char subframe = ue->ulsch_Msg3_subframe[eNB_id]; + LTE_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; + PHY_MEASUREMENTS *meas = &ue->measurements; + + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + // int current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; + + uint8_t *rar = (uint8_t *)(rar_pdu+1); + uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_tx,subframe); + uint16_t rballoc; + uint8_t cqireq; + uint16_t *RIV2nb_rb_LUT, *RIV2first_rb_LUT; + uint16_t RIV_max = 0; + + LOG_D(PHY,"[eNB][RAPROC] Frame %d: generate_ue_ulsch_params_from_rar: subframe %d (harq_pid %d)\n",proc->frame_tx,subframe,harq_pid); + + switch (frame_parms->N_RB_DL) { + case 6: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT6[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT6[0]; + RIV_max = RIV_max6; + break; + + case 25: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT25[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT25[0]; + RIV_max = RIV_max25; + break; + + case 50: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT50[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT50[0]; + RIV_max = RIV_max50; + break; + + case 100: + RIV2nb_rb_LUT = &RIV2nb_rb_LUT100[0]; + RIV2first_rb_LUT = &RIV2first_rb_LUT100[0]; + RIV_max = RIV_max100; + break; + + default: + DevParam(frame_parms->N_RB_DL, eNB_id, harq_pid); + break; + } + + + + ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7;//rar->TPC; + + rballoc = (((uint16_t)(rar[1]&7))<<7)|(rar[2]>>1); + cqireq=rar[3]&1; + + if (rballoc>RIV_max) { + LOG_D(PHY,"rar_tools.c: ERROR: rb_alloc (%x) > RIV_max\n",rballoc); + return(-1); + } + + ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; + ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; + + AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb >0, "nb_rb == 0\n"); + + ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb]; + + AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb <= 6,"unlikely rb count for RAR grant : nb_rb > 6\n"); + + // ulsch->harq_processes[harq_pid]->Ndi = 1; + if (ulsch->harq_processes[harq_pid]->round == 0) + ulsch->harq_processes[harq_pid]->status = ACTIVE; + + if (cqireq==1) { + ulsch->O_RI = 1; + + if (meas->rank[eNB_id] == 1) { + ulsch->uci_format = wideband_cqi_rank2_2A; + ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch->o_RI[0] = 1; + } else { + ulsch->uci_format = wideband_cqi_rank1_2A; + ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; + ulsch->o_RI[0] = 0; + } + + ulsch->uci_format = HLC_subband_cqi_nopmi; + fill_CQI(ulsch,meas,eNB_id,0,ue->frame_parms.N_RB_DL,0, transmission_mode,ue->sinr_eff); + + if (((proc->frame_tx % 100) == 0) || (proc->frame_tx < 10)) + print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); + } else { + ulsch->O_RI = 0; + ulsch->O = 0; + } + + ulsch->harq_processes[harq_pid]->O_ACK = 0;//2; + + ulsch->beta_offset_cqi_times8 = 18; + ulsch->beta_offset_ri_times8 = 10; + ulsch->beta_offset_harqack_times8 = 16; + + ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1); + ulsch->rnti = (((uint16_t)rar[4])<<8)+rar[5]; //rar->t_crnti; + + if (ulsch->harq_processes[harq_pid]->round == 0) { + ulsch->harq_processes[harq_pid]->status = ACTIVE; + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->mcs = ((rar[2]&1)<<3)|(rar[3]>>5); + ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7; + //ulsch->harq_processes[harq_pid]->TBS = dlsch_tbs25[ulsch->harq_processes[harq_pid]->mcs][ulsch->harq_processes[harq_pid]->nb_rb-1]; + ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; + ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; + ulsch->harq_processes[harq_pid]->Nsymb_initial = 9; + ulsch->harq_processes[harq_pid]->round = 0; + } else { + ulsch->harq_processes[harq_pid]->rvidx = 0; + ulsch->harq_processes[harq_pid]->round++; + } + + // initialize power control based on PRACH power + ulsch->f_pusch = delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC] + + get_deltaP_rampup(ue->Mod_id,ue->CC_id); + LOG_D(PHY,"[UE %d][PUSCH PC] Initializing f_pusch to %d dB, TPC %d (delta_PUSCH_msg2 %d dB), deltaP_rampup %d dB\n", + ue->Mod_id,ulsch->f_pusch,ulsch->harq_processes[harq_pid]->TPC,delta_PUSCH_msg2[ulsch->harq_processes[harq_pid]->TPC], + get_deltaP_rampup(ue->Mod_id,ue->CC_id)); + + + //#ifdef DEBUG_RAR + LOG_D(PHY,"ulsch ra (UE): harq_pid %d\n",harq_pid); + LOG_D(PHY,"ulsch ra (UE): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); + LOG_D(PHY,"ulsch ra (UE): first_rb %x\n",ulsch->harq_processes[harq_pid]->first_rb); + LOG_D(PHY,"ulsch ra (UE): nb_rb %d\n",ulsch->harq_processes[harq_pid]->nb_rb); + LOG_D(PHY,"ulsch ra (UE): round %d\n",ulsch->harq_processes[harq_pid]->round); + LOG_D(PHY,"ulsch ra (UE): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); + LOG_D(PHY,"ulsch ra (UE): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); + LOG_D(PHY,"ulsch ra (UE): TPC %d\n",ulsch->harq_processes[harq_pid]->TPC); + LOG_D(PHY,"ulsch ra (UE): O %d\n",ulsch->O); + LOG_D(PHY,"ulsch ra (UE): ORI %d\n",ulsch->O_RI); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_RAR,VCD_FUNCTION_OUT); + + //#endif + return(0); +} + diff --git a/openair1/PHY/LTE_UE_TRANSPORT/sldch.c b/openair1/PHY/LTE_UE_TRANSPORT/sldch.c new file mode 100644 index 0000000000000000000000000000000000000000..9c9d36c9746f5a8143544a21de67b5512210dd50 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/sldch.c @@ -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 + */ + +/*! \file PHY/LTE_TRANSPORT/slss.c + * \brief Functions to Generate and Receive PSDCH + * \author R. Knopp + * \date 2017 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#ifndef __LTE_TRANSPORT_SLSS__C__ +#define __LTE_TRANSPORT_SLSS__C__ +#include "PHY/defs_UE.h" + +extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); + +void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx) { + + UE_tport_t pdu; + size_t sldch_header_len = sizeof(UE_tport_header_t); + + pdu.header.packet_type = SLDCH; + pdu.header.absSF = (frame_tx*10)+subframe_tx; + + + AssertFatal((sldch->payload_length <=1500-sldch_header_len - sizeof(SLDCH_t) + sizeof(uint8_t*)), + "SLDCH payload length > %zd\n", + 1500-sldch_header_len - sizeof(SLDCH_t) + sizeof(uint8_t*)); + memcpy((void*)&pdu.sldch, + (void*)sldch, + sizeof(SLDCH_t)); + + LOG_I(PHY,"SLDCH configuration %zd bytes, TBS payload %d bytes => %zd bytes\n", + sizeof(SLDCH_t)-sizeof(uint8_t*), + sldch->payload_length, + sldch_header_len+sizeof(SLDCH_t)-sizeof(uint8_t*)+sldch->payload_length); + + multicast_link_write_sock(0, + (char *)&pdu, + sldch_header_len+sizeof(SLDCH_t)); + +} + + +#endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/slsch.c b/openair1/PHY/LTE_UE_TRANSPORT/slsch.c new file mode 100644 index 0000000000000000000000000000000000000000..e51e33626df38a277c41922b6150bfd392bff901 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/slsch.c @@ -0,0 +1,70 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/slss.c + * \brief Functions to Generate and Receive PSSCH + * \author R. Knopp + * \date 2017 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#ifndef __LTE_TRANSPORT_SLSS__C__ +#define __LTE_TRANSPORT_SLSS__C__ +#include "PHY/defs_UE.h" + +extern int +multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); + + +void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slsch,int frame_tx,int subframe_tx) { + + UE_tport_t pdu; + size_t slsch_header_len = sizeof(UE_tport_header_t); + + if (slsch->rvidx==0) { + pdu.header.packet_type = SLSCH; + pdu.header.absSF = (frame_tx*10)+subframe_tx; + + memcpy((void*)&pdu.slsch,(void*)slsch,sizeof(SLSCH_t)-sizeof(uint8_t*)); + + AssertFatal(slsch->payload_length <=1500-slsch_header_len - sizeof(SLSCH_t) + sizeof(uint8_t*), + "SLSCH payload length > %zd\n", + 1500-slsch_header_len - sizeof(SLSCH_t) + sizeof(uint8_t*)); + memcpy((void*)&pdu.payload[0], + (void*)slsch->payload, + slsch->payload_length); + + LOG_I(PHY,"SLSCH configuration %zd bytes, TBS payload %d bytes => %zd bytes\n", + sizeof(SLSCH_t)-sizeof(uint8_t*), + slsch->payload_length, + slsch_header_len+sizeof(SLSCH_t)-sizeof(uint8_t*)+slsch->payload_length); + + multicast_link_write_sock(0, + (char *)&pdu, + slsch_header_len+sizeof(SLSCH_t)-sizeof(uint8_t*)+slsch->payload_length); + + } +} + +#endif diff --git a/openair1/PHY/MODULATION/vars.h b/openair1/PHY/LTE_UE_TRANSPORT/slss.c similarity index 68% rename from openair1/PHY/MODULATION/vars.h rename to openair1/PHY/LTE_UE_TRANSPORT/slss.c index a05999afe1661142ecb9fbbce6c5f1d46bce0f4b..18bc5a28dec8826a63ebef68eec43654561bf6da 100644 --- a/openair1/PHY/MODULATION/vars.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/slss.c @@ -19,13 +19,25 @@ * contact@openairinterface.org */ -mod_sym_t qpsk_table[4]; -mod_sym_t qam16_table[16]; -mod_sym_t qam64_table[64]; +/*! \file PHY/LTE_TRANSPORT/slss.c + * \brief Functions to Generate and Received Sidelink PSS,SSS and PSBCH + * \author R. Knopp + * \date 2017 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ +#ifndef __LTE_TRANSPORT_SLSS__C__ +#define __LTE_TRANSPORT_SLSS__C__ +#include "PHY/defs_UE.h" + + +void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss,int frame_tx,int subframe_tx) { + + AssertFatal(1==0,"Should get here yet for UE %d\n",ue->Mod_id); + +} -int16_t kHz75_25PRB[1024] = {}; -int16_t kHz75_6PRB = {}; -int16_t kHz75_15PRB = {}; -int16_t kHz75_50PRB = {}; -int16_t kHz75_75PRB = {}; -int16_t kHz75_100PRB = {}; +#endif diff --git a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/srs_modulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c index c4c02e631279a3833da27c1b2aedceb431e55b7d..45508fcff27eb5ee25e6694b8903f114e2edcb19 100644 --- a/openair1/PHY/LTE_TRANSPORT/srs_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/srs_modulation.c @@ -29,8 +29,8 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include "UTIL/LOG/log.h" unsigned short msrsb_6_40[8][4] = {{36,12,4,4}, diff --git a/openair1/PHY/LTE_UE_TRANSPORT/sss_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/sss_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..aee5d6bcf91a37fc50710f63c8cfb4d6048a8153 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/sss_ue.c @@ -0,0 +1,421 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/sss_ue.c +* \brief Top-level routines for decoding the secondary synchronization signal (SSS) V8.6 2009-03 +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "transport_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/MODULATION/modulation_UE.h" + +//#define DEBUG_SSS + + + + +int pss_ch_est(PHY_VARS_UE *ue, + int32_t pss_ext[4][72], + int32_t sss_ext[4][72]) +{ + + int16_t *pss; + int16_t *pss_ext2,*sss_ext2,*sss_ext3,tmp_re,tmp_im,tmp_re2,tmp_im2; + uint8_t aarx,i; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + + switch (ue->common_vars.eNb_id) { + + case 0: + pss = &primary_synch0[10]; + break; + + case 1: + pss = &primary_synch1[10]; + break; + + case 2: + pss = &primary_synch2[10]; + break; + + default: + pss = &primary_synch0[10]; + break; + } + + sss_ext3 = (int16_t*)&sss_ext[0][5]; + + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + sss_ext2 = (int16_t*)&sss_ext[aarx][5]; + pss_ext2 = (int16_t*)&pss_ext[aarx][5]; + + for (i=0; i<62; i++) { + + // This is H*(PSS) = R* \cdot PSS + tmp_re = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[i<<1])>>15) + ((pss_ext2[1+(i<<1)] * (int32_t)pss[1+(i<<1)])>>15)); + tmp_im = (int16_t)(((pss_ext2[i<<1] * (int32_t)pss[1+(i<<1)])>>15) - ((pss_ext2[1+(i<<1)] * (int32_t)pss[(i<<1)])>>15)); + // printf("H*(%d,%d) : (%d,%d)\n",aarx,i,tmp_re,tmp_im); + // This is R(SSS) \cdot H*(PSS) + tmp_re2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[i<<1])>>15) - ((tmp_im * (int32_t)sss_ext2[1+(i<<1)]>>15))); + tmp_im2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[1+(i<<1)])>>15) + ((tmp_im * (int32_t)sss_ext2[(i<<1)]>>15))); + + // printf("SSSi(%d,%d) : (%d,%d)\n",aarx,i,sss_ext2[i<<1],sss_ext2[1+(i<<1)]); + // printf("SSSo(%d,%d) : (%d,%d)\n",aarx,i,tmp_re2,tmp_im2); + // MRC on RX antennas + if (aarx==0) { + sss_ext3[i<<1] = tmp_re2; + sss_ext3[1+(i<<1)] = tmp_im2; + } else { + sss_ext3[i<<1] += tmp_re2; + sss_ext3[1+(i<<1)] += tmp_im2; + } + } + } + + // sss_ext now contains the compensated SSS + return(0); +} + + +int _do_pss_sss_extract(PHY_VARS_UE *ue, + int32_t pss_ext[4][72], + int32_t sss_ext[4][72], + uint8_t doPss, uint8_t doSss, + uint8_t subframe) // add flag to indicate extracting only PSS, only SSS, or both +{ + + + + uint16_t rb,nb_rb=6; + uint8_t i,aarx; + int32_t *pss_rxF,*pss_rxF_ext; + int32_t *sss_rxF,*sss_rxF_ext; + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + uint8_t next_thread_id = ue->current_thread_id[subframe]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[subframe]+1); + + int rx_offset = frame_parms->ofdm_symbol_size-3*12; + uint8_t pss_symb,sss_symb; + + int32_t **rxdataF; + + //LOG_I(PHY,"do_pss_sss_extract subframe %d \n",subframe); + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { + + if (frame_parms->frame_type == FDD) { + pss_symb = 6-frame_parms->Ncp; + sss_symb = pss_symb-1; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + + } else { + pss_symb = 2; + sss_symb = frame_parms->symbols_per_tti-1; + + if(subframe==5 || subframe==0) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else if(subframe==6 || subframe==1) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else + { + AssertFatal(0,""); + } + + } + //printf("extract_rbs: symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",symbol_mod, + // (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2, + // LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size))); + + pss_rxF_ext = &pss_ext[aarx][0]; + sss_rxF_ext = &sss_ext[aarx][0]; + + for (rb=0; rb<nb_rb; rb++) { + // skip DC carrier + if (rb==3) { + if(frame_parms->frame_type == FDD) + { + sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else + { + if(subframe==5 || subframe==0) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + sss_rxF = &rxdataF[aarx][(1 + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + pss_rxF = &rxdataF[aarx][(1 + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else if(subframe==6 || subframe==1) + { + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF; + pss_rxF = &rxdataF[aarx][(rx_offset + (pss_symb*(frame_parms->ofdm_symbol_size)))]; + + rxdataF = ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF; + sss_rxF = &rxdataF[aarx][(rx_offset + (sss_symb*(frame_parms->ofdm_symbol_size)))]; + } + else + { + AssertFatal(0,""); + } + } + } + + for (i=0; i<12; i++) { + if (doPss) {pss_rxF_ext[i]=pss_rxF[i];} + if (doSss) {sss_rxF_ext[i]=sss_rxF[i];} + } + + pss_rxF+=12; + sss_rxF+=12; + pss_rxF_ext+=12; + sss_rxF_ext+=12; + } + + } + + return(0); +} + +int pss_sss_extract(PHY_VARS_UE *phy_vars_ue, + int32_t pss_ext[4][72], + int32_t sss_ext[4][72], + uint8_t subframe) +{ + return _do_pss_sss_extract(phy_vars_ue, pss_ext, sss_ext, 1 /* doPss */, 1 /* doSss */, subframe); +} + +int pss_only_extract(PHY_VARS_UE *phy_vars_ue, + int32_t pss_ext[4][72], + uint8_t subframe) +{ + static int32_t dummy[4][72]; + return _do_pss_sss_extract(phy_vars_ue, pss_ext, dummy, 1 /* doPss */, 0 /* doSss */, subframe); +} + + +int sss_only_extract(PHY_VARS_UE *phy_vars_ue, + int32_t sss_ext[4][72], + uint8_t subframe) +{ + static int32_t dummy[4][72]; + return _do_pss_sss_extract(phy_vars_ue, dummy, sss_ext, 0 /* doPss */, 1 /* doSss */, subframe); +} + + +int16_t phase_re[7] = {16383, 25101, 30791, 32767, 30791, 25101, 16383}; +int16_t phase_im[7] = {-28378, -21063, -11208, 0, 11207, 21062, 28377}; + + +int rx_sss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *flip_max,uint8_t *phase_max) +{ + + uint8_t i; + int32_t pss_ext[4][72]; + int32_t sss0_ext[4][72],sss5_ext[4][72]; + uint8_t Nid2 = ue->common_vars.eNb_id; + uint8_t flip,phase; + uint16_t Nid1; + int16_t *sss0,*sss5; + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + int32_t metric; + int16_t *d0,*d5; + + if (frame_parms->frame_type == FDD) { +#ifdef DEBUG_SSS + + if (frame_parms->Ncp == NORMAL) + msg("[PHY][UE%d] Doing SSS for FDD Normal Prefix\n",ue->Mod_id); + else + msg("[PHY][UE%d] Doing SSS for FDD Extended Prefix\n",ue->Mod_id); + +#endif + // Do FFTs for SSS/PSS + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-2, // second to last symbol of + 0, // slot 0 + ue->rx_offset, + 0, + 1); + // PSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-1, // last symbol of + 0, // slot 0 + ue->rx_offset, + 0, + 1); + } else { // TDD +#ifdef DEBUG_SSS + if (ue->frame_parms->Ncp == NORMAL) + msg("[PHY][UE%d] Doing SSS for TDD Normal Prefix\n",ue->Mod_id); + else + msg("[PHY][UE%d] Doing SSS for TDD Extended Prefix\n",ue->Mod_id); + +#endif + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti>>1)-1, // last symbol of + 1, // slot 1 + ue->rx_offset, + 0, + 1); + // PSS + slot_fep(ue, + 2, // symbol 2 of + 2, // slot 2 + ue->rx_offset, + 0, + 1); + } + // pss sss extract for subframe 0 + pss_sss_extract(ue, + pss_ext, + sss0_ext,0); + /* + write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata[0][0],ue->frame_parms.samples_per_tti,1,1); + write_output("rxdataF0.m","rxF0",&ue->common_vars.rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,2,1); + write_output("pss_ext0.m","pssext0",pss_ext,72,1,1); + write_output("sss0_ext0.m","sss0ext0",sss0_ext,72,1,1); + */ + + // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS + // and do channel estimation and compensation based on PSS + + pss_ch_est(ue, + pss_ext, + sss0_ext); + + // write_output("sss0_comp0.m","sss0comp0",sss0_ext,72,1,1); + + if (ue->frame_parms.frame_type == FDD) { // FDD + + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-2, + 10, + ue->rx_offset, + 0,1); + // PSS + slot_fep(ue, + (frame_parms->symbols_per_tti/2)-1, + 10, + ue->rx_offset, + 0,1); + } else { // TDD + // SSS + slot_fep(ue, + (frame_parms->symbols_per_tti>>1)-1, + 11, + ue->rx_offset, + 0, + 1); + // PSS + slot_fep(ue, + 2, + 12, + ue->rx_offset, + 0, + 1); + } + + // pss sss extract for subframe 5 + pss_sss_extract(ue, + pss_ext, + sss5_ext,5); + + // write_output("sss5_ext0.m","sss5ext0",sss5_ext,72,1,1); + // get conjugated channel estimate from PSS (symbol 6), H* = R* \cdot PSS + // and do channel estimation and compensation based on PSS + + pss_ch_est(ue, + pss_ext, + sss5_ext); + + + + // now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h + + *tot_metric = -99999999; + + + sss0 = (int16_t*)&sss0_ext[0][5]; + sss5 = (int16_t*)&sss5_ext[0][5]; + + for (flip=0; flip<2; flip++) { // d0/d5 flip in RX frame + for (phase=0; phase<7; phase++) { // phase offset between PSS and SSS + for (Nid1 = 0 ; Nid1 <= 167; Nid1++) { // 168 possible Nid1 values + metric = 0; + + if (flip==0) { + d0 = &d0_sss[62*(Nid2 + (Nid1*3))]; + d5 = &d5_sss[62*(Nid2 + (Nid1*3))]; + } else { + d5 = &d0_sss[62*(Nid2 + (Nid1*3))]; + d0 = &d5_sss[62*(Nid2 + (Nid1*3))]; + } + + // This is the inner product using one particular value of each unknown parameter + for (i=0; i<62; i++) { + metric += (int16_t)(((d0[i]*((((phase_re[phase]*(int32_t)sss0[i<<1])>>19)-((phase_im[phase]*(int32_t)sss0[1+(i<<1)])>>19)))) + + (d5[i]*((((phase_re[phase]*(int32_t)sss5[i<<1])>>19)-((phase_im[phase]*(int32_t)sss5[1+(i<<1)])>>19)))))); + } + + // if the current metric is better than the last save it + if (metric > *tot_metric) { + *tot_metric = metric; + ue->frame_parms.Nid_cell = Nid2+(3*Nid1); + *phase_max = phase; + *flip_max=flip; +#ifdef DEBUG_SSS + msg("(flip,phase,Nid1) (%d,%d,%d), metric_phase %d tot_metric %d, phase_max %d, flip_max %d\n",flip,phase,Nid1,metric,*tot_metric,*phase_max,*flip_max); +#endif + + } + } + } + } + + return(0); +} + diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h similarity index 74% rename from openair1/PHY/LTE_TRANSPORT/proto.h rename to openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h index 0e1a60c0b9ac1bc5105c73ebfe5b253769eb9d94..9b3a95a14a9f0814e8fc0ea81b78dda0427ca868 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -/*! \file PHY/LTE_TRANSPORT/proto.h +/*! \file PHY/LTE_UE_TRANSPORT/transport_proto_ue.h * \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03 * \author R. Knopp, F. Kaltenberger * \date 2011 @@ -29,9 +29,10 @@ * \note * \warning */ -#ifndef __LTE_TRANSPORT_PROTO__H__ -#define __LTE_TRANSPORT_PROTO__H__ -#include "PHY/defs.h" +#ifndef __LTE_TRANSPORT_PROTO_UE__H__ +#define __LTE_TRANSPORT_PROTO_UE__H__ +#include "PHY/defs_UE.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" #include <math.h> #include "nfapi_interface.h" @@ -41,26 +42,6 @@ * @{ */ -/** \fn free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch,unsigned char N_RB_DL) - \brief This function frees memory allocated for a particular DLSCH at eNB - @param dlsch Pointer to DLSCH to be removed -*/ -void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch); - -void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); - -/** \fn new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms) - \brief This function allocates structures for a particular DLSCH at eNB - @returns Pointer to DLSCH to be removed - @param Kmimo Kmimo factor from 36-212/36-213 - @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) - @param Nsoft Soft-LLR buffer size from UE-Category - @params N_RB_DL total number of resource blocks (determine the operating BW) - @param abstraction_flag Flag to indicate abstracted interface - @param frame_parms Pointer to frame descriptor structure -*/ -LTE_eNB_DLSCH_t *new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms); - /** \fn free_ue_dlsch(LTE_UE_DLSCH_t *dlsch) \brief This function frees memory allocated for a particular DLSCH at UE @param dlsch Pointer to DLSCH to be removed @@ -68,7 +49,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch); /** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag) - \brief This function allocates structures for a particular DLSCH at eNB + \brief This function allocates structures for a particular DLSCH at UE @returns Pointer to DLSCH to be removed @param Kmimo Kmimo factor from 36-212/36-213 @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) @@ -79,278 +60,13 @@ void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch); LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag); -void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); - void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch); -/** \fn free_eNB_ulsch(LTE_eNB_DLSCH_t *dlsch) - \brief This function frees memory allocated for a particular ULSCH at eNB - @param ulsch Pointer to ULSCH to be removed -*/ -void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch); - -LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag); -/** \fn dlsch_encoding(PHY_VARS_eNB *eNB, - uint8_t *input_buffer, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe) - \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). The implemented functions are: - - CRC computation and addition - - Code block segmentation and sub-block CRC addition - - Channel coding (Turbo coding) - - Rate matching (sub-block interleaving, bit collection, selection and transmission - - Code block concatenation - @param eNB Pointer to eNB PHY context - @param input_buffer Pointer to input buffer for sub-frame - @param frame_parms Pointer to frame descriptor structure - @param num_pdcch_symbols Number of PDCCH symbols in this subframe - @param dlsch Pointer to dlsch to be encoded - @param frame Frame number - @param subframe Subframe number - @param rm_stats Time statistics for rate-matching - @param te_stats Time statistics for turbo-encoding - @param i_stats Time statistics for interleaving - @returns status -*/ -int32_t dlsch_encoding(PHY_VARS_eNB *eNB, - uint8_t *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *i_stats); - -int32_t dlsch_encoding_SIC(PHY_VARS_UE *ue, - uint8_t *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *i_stats); - - - -/** \fn dlsch_encoding_2threads(PHY_VARS_eNB *eNB, - uint8_t *input_buffer, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe) - \brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). This version spawns 1 worker thread. The implemented functions are: - - CRC computation and addition - - Code block segmentation and sub-block CRC addition - - Channel coding (Turbo coding) - - Rate matching (sub-block interleaving, bit collection, selection and transmission - - Code block concatenation - @param eNB Pointer to eNB PHY context - @param input_buffer Pointer to input buffer for sub-frame - @param num_pdcch_symbols Number of PDCCH symbols in this subframe - @param dlsch Pointer to dlsch to be encoded - @param frame Frame number - @param subframe Subframe number - @param rm_stats Time statistics for rate-matching - @param te_stats Time statistics for turbo-encoding - @param i_stats Time statistics for interleaving - @returns status -*/ -int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, - uint8_t *a, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch, - int frame, - uint8_t subframe, - time_stats_t *rm_stats, - time_stats_t *te_stats, - time_stats_t *i_stats); - -void dlsch_encoding_emul(PHY_VARS_eNB *phy_vars_eNB, - uint8_t *DLSCH_pdu, - LTE_eNB_DLSCH_t *dlsch); - - -// Functions below implement 36-211 - -/** \fn allocate_REs_in_RB(int32_t **txdataF, - uint32_t *jj, - uint32_t *jj2, - uint16_t re_offset, - uint32_t symbol_offset, - LTE_DL_eNB_HARQ_t *dlsch0_harq, - LTE_DL_eNB_HARQ_t *dlsch1_harq, - uint8_t pilots, - int16_t amp, - int16_t *qam_table_s, - uint32_t *re_allocated, - uint8_t skip_dc, - uint8_t skip_half, - uint8_t use2ndpilots, - LTE_DL_FRAME_PARMS *frame_parms); - - \brief Fills RB with data - \param txdataF pointer to output data (frequency domain signal) - \param jj index to output (from CW 1) - \param jj2 index to output (from CW 2) - \param re_offset index of the first RE of the RB - \param symbol_offset index to the OFDM symbol - \param dlsch0_harq Pointer to Transport block 0 HARQ structure - \param dlsch0_harq Pointer to Transport block 1 HARQ structure - \param pilots =1 if symbol_offset is an OFDM symbol that contains pilots, 0 otherwise - \param amp Amplitude for symbols - \param qam_table_s0 pointer to scaled QAM table for Transport Block 0 (by rho_a or rho_b) - \param qam_table_s1 pointer to scaled QAM table for Transport Block 1 (by rho_a or rho_b) - \param re_allocated pointer to allocation counter - \param skip_dc offset for positive RBs - \param skip_half indicate that first or second half of RB must be skipped for PBCH/PSS/SSS - \param ue_spec_rs UE specific RS indicator - \param nb_antennas_tx_phy Physical antenna elements which can be different with antenna port number, especially in beamforming case - \param use2ndpilots Set to use the pilots from antenna port 1 for PDSCH - \param frame_parms Frame parameter descriptor -*/ - -// Functions below implement 36-211 - -/** \fn allocate_REs_in_RB(int32_t **txdataF, - uint32_t *jj, - uint32_t *jj2, - uint16_t re_offset, - uint32_t symbol_offset, - LTE_DL_eNB_HARQ_t *dlsch0_harq, - LTE_DL_eNB_HARQ_t *dlsch1_harq, - uint8_t pilots, - int16_t amp, - int16_t *qam_table_s, - uint32_t *re_allocated, - uint8_t skip_dc, - uint8_t skip_half, - uint8_t use2ndpilots, - LTE_DL_FRAME_PARMS *frame_parms); - - \brief Fills RB with data - \param txdataF pointer to output data (frequency domain signal) - \param jj index to output (from CW 1) - \param jj index to output (from CW 2) - \param re_offset index of the first RE of the RB - \param symbol_offset index to the OFDM symbol - \param dlsch0_harq Pointer to Transport block 0 HARQ structure - \param dlsch0_harq Pointer to Transport block 1 HARQ structure - \param pilots =1 if symbol_offset is an OFDM symbol that contains pilots, 0 otherwise - \param amp Amplitude for symbols - \param qam_table_s0 pointer to scaled QAM table for Transport Block 0 (by rho_a or rho_b) - \param qam_table_s1 pointer to scaled QAM table for Transport Block 1 (by rho_a or rho_b) - \param re_allocated pointer to allocation counter - \param skip_dc offset for positive RBs - \param skip_half indicate that first or second half of RB must be skipped for PBCH/PSS/SSS - \param use2ndpilots Set to use the pilots from antenna port 1 for PDSCH - \param frame_parms Frame parameter descriptor -*/ - -int32_t allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, - int32_t **txdataF, - uint32_t *jj, - uint32_t *jj2, - uint16_t re_offset, - uint32_t symbol_offset, - LTE_DL_eNB_HARQ_t *dlsch0_harq, - LTE_DL_eNB_HARQ_t *dlsch1_harq, - uint8_t pilots, - int16_t amp, - uint8_t precoder_index, - int16_t *qam_table_s0, - int16_t *qam_table_s1, - uint32_t *re_allocated, - uint8_t skip_dc, - uint8_t skip_half, - uint8_t lprime, - uint8_t mprime, - uint8_t Ns, - int *P1_SHIFT, - int *P2_SHIFT); - - -/** \fn int32_t dlsch_modulation(int32_t **txdataF, - int16_t amp, - uint32_t sub_frame_offset, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch); - - \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for DLSCH. - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param sub_frame_offset Offset of this subframe in units of subframes (usually 0) - @param frame_parms Pointer to frame descriptor - @param num_pdcch_symbols Number of PDCCH symbols in this subframe - @param dlsch0 Pointer to Transport Block 0 DLSCH descriptor for this allocation - @param dlsch1 Pointer to Transport Block 0 DLSCH descriptor for this allocation -*/ -int32_t dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint32_t sub_frame_offset, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch0, - LTE_eNB_DLSCH_t *dlsch1); - -int32_t dlsch_modulation_SIC(int32_t **sic_buffer, - uint32_t sub_frame_offset, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t num_pdcch_symbols, - LTE_eNB_DLSCH_t *dlsch0, - int G); -/* - \brief This function is the top-level routine for generation of the sub-frame signal (frequency-domain) for MCH. - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param subframe_offset Offset of this subframe in units of subframes (usually 0) - @param frame_parms Pointer to frame descriptor - @param dlsch Pointer to DLSCH descriptor for this allocation -*/ -int mch_modulation(int32_t **txdataF, - int16_t amp, - uint32_t subframe_offset, - LTE_DL_FRAME_PARMS *frame_parms, - LTE_eNB_DLSCH_t *dlsch); - -/** \brief Top-level generation function for eNB TX of MBSFN - @param phy_vars_eNB Pointer to eNB variables - @param a Pointer to transport block - @param abstraction_flag +void fill_UE_dlsch_MCH(PHY_VARS_UE *ue,int mcs,int ndi,int rvidx,int eNB_id); -*/ -void generate_mch(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,uint8_t *a); - -/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) - @param phy_vars_eNB Pointer to eNB variables - @param proc Pointer to RXn-TXnp4 proc information - @param mcs MCS for MBSFN - @param ndi new data indicator - @param rdvix -*/ -void fill_eNB_dlsch_MCH(PHY_VARS_eNB *phy_vars_eNB,int mcs,int ndi,int rvidx); - -/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) - @param phy_vars_ue Pointer to UE variables - @param mcs MCS for MBSFN - @param eNB_id index of eNB in ue variables -*/ -void fill_UE_dlsch_MCH(PHY_VARS_UE *phy_vars_ue,int mcs,int ndi,int rvidx,int eNB_id); - -/** \brief Receiver processing for MBSFN, symbols can be done separately for time/CPU-scheduling purposes - @param phy_vars_ue Pointer to UE variables - @param eNB_id index of eNB in ue variables - @param subframe Subframe index of PMCH - @param symbol Symbol index on which to act -*/ int rx_pmch(PHY_VARS_UE *phy_vars_ue, unsigned char eNB_id, uint8_t subframe, @@ -366,66 +82,6 @@ int rx_pmch(PHY_VARS_UE *phy_vars_ue, void dump_mch(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe); -/** \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) - for N subframes. - @param phy_vars_eNB Pointer to eNB variables - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param N Number of sub-frames to generate -*/ -void generate_pilots(PHY_VARS_eNB *phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint16_t N); - -/** - \brief This function generates the frequency-domain pilots (cell-specific downlink reference signals) for one slot only - @param phy_vars_eNB Pointer to eNB variables - @param txdataF Table of pointers for frequency-domain TX signals - @param amp Amplitude of signal - @param slot index (0..19) - @param first_pilot_only (0 no) -*/ -int32_t generate_pilots_slot(PHY_VARS_eNB *phy_vars_eNB, - int32_t **txdataF, - int16_t amp, - uint16_t slot, - int first_pilot_only); - -int32_t generate_mbsfn_pilot(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - int32_t **txdataF, - int16_t amp); - -void generate_ue_spec_pilots(PHY_VARS_eNB *phy_vars_eNB, - uint8_t UE_id, - int32_t **txdataF, - int16_t amp, - uint16_t Ntti, - uint8_t beamforming_mode); - -int32_t generate_pss(int32_t **txdataF, - int16_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - uint16_t l, - uint16_t Ns); - -int32_t generate_pss_emul(PHY_VARS_eNB *phy_vars_eNB,uint8_t sect_id); - -int32_t generate_sss(int32_t **txdataF, - short amp, - LTE_DL_FRAME_PARMS *frame_parms, - unsigned short symbol, - unsigned short slot_offset); - -int32_t generate_pbch(LTE_eNB_PBCH *eNB_pbch, - int32_t **txdataF, - int32_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - uint8_t *pbch_pdu, - uint8_t frame_mod4); - -int32_t generate_pbch_emul(PHY_VARS_eNB *phy_vars_eNB,uint8_t *pbch_pdu); /** \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 @@ -1332,6 +988,7 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, uint8_t is_crnti, uint8_t llr8_flag); + uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue, uint8_t subframe, PDSCH_t dlsch_id, @@ -1371,8 +1028,7 @@ int32_t rx_pdcch(PHY_VARS_UE *ue, uint8_t subframe, uint8_t eNB_id, MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t is_secondary_ue); + uint32_t high_speed_flag); /*! \brief Extract PSS and SSS resource elements @param phy_vars_ue Pointer to UE variables @@ -1428,13 +1084,6 @@ uint16_t rx_pbch_emul(PHY_VARS_UE *phy_vars_ue, uint8_t eNB_id, uint8_t pbch_phase); -/*! \brief PBCH scrambling. Applies 36.211 PBCH scrambling procedure. - \param frame_parms Pointer to frame descriptor - \param coded_data Output of the coding and rate matching - \param length Length of the sequence*/ -void pbch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t* coded_data, - uint32_t length); /*! \brief PBCH unscrambling This is similar to pbch_scrabling with the difference that inputs are signed s16s (llr values) and instead of flipping bits we change signs. @@ -1447,47 +1096,33 @@ void pbch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, uint32_t length, uint8_t frame_mod4); -/*! \brief DCI Encoding. This routine codes an arbitrary DCI PDU after appending the 8-bit 3GPP CRC. It then applied sub-block interleaving and rate matching. - \param a Pointer to DCI PDU (coded in bytes) - \param A Length of DCI PDU in bits - \param E Length of DCI PDU in coded bits - \param e Pointer to sequence - \param rnti RNTI for CRC scrambling*/ -void dci_encoding(uint8_t *a, - uint8_t A, - uint16_t E, - uint8_t *e, - uint16_t rnti); - -/*! \brief Top-level DCI entry point. This routine codes an set of DCI PDUs and performs PDCCH modulation, interleaving and mapping. - \param num_dci Number of pdcch symbols - \param num_dci Number of DCI pdus to encode - \param dci_alloc Allocation vectors for each DCI pdu - \param n_rnti n_RNTI (see ) - \param amp Amplitude of QPSK symbols - \param frame_parms Pointer to DL Frame parameter structure - \param txdataF Pointer to tx signal buffers - \param sub_frame_offset subframe offset in frame - @returns Number of PDCCH symbols +/*! \brief Top-level generation route for Sidelink BCH,PSS and SSS + \param ue pointer to UE descriptor + \param slss pointer to SLSS configuration and payload + \param frame_tx Frame number + \param subframe_tx subframe number */ +void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss,int frame_tx,int subframe_tx); -uint8_t generate_dci_top(uint8_t num_pdcch_symbols, - uint8_t num_dci, - DCI_ALLOC_t *dci_alloc, - uint32_t n_rnti, - int16_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t **txdataF, - uint32_t sub_frame_offset); - -uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, - int num_dci, - DCI_ALLOC_t *dci_alloc, - uint8_t subframe); +/*! \brief Top-level generation route for Sidelink Discovery Channel + \param ue pointer to UE descriptor + \param sldch pointer to SLDCH configuration and payload + \param frame_tx Frame number + \param subframe_tx subframe number +*/ +void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx); +/*! \brief Top-level generation route for Sidelink Shared Channel + \param ue pointer to UE descriptor + \param slsch pointer to SLSCH configuration and payload + \param frame_tx Frame number + \param subframe_tx subframe number +*/ +void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slss,int frame_tx,int subframe_tx); void generate_64qam_table(void); void generate_16qam_table(void); +void generate_qpsk_table(void); uint16_t extract_crc(uint8_t *dci,uint8_t DCI_LENGTH); @@ -1640,8 +1275,6 @@ int generate_srs(LTE_DL_FRAME_PARMS *frame_parms, int16_t amp, uint32_t subframe); -int32_t generate_srs_tx_emul(PHY_VARS_UE *phy_vars_ue, - uint8_t subframe); /*! \brief This function is similar to generate_srs_tx but generates a conjugate sequence for channel estimation. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence. @@ -1694,16 +1327,9 @@ void ulsch_modulation(int32_t **txdataF, LTE_UE_ULSCH_t *ulsch); -void ulsch_extract_rbs_single(int32_t **rxdataF, - int32_t **rxdataF_ext, - uint32_t first_rb, - uint32_t nb_rb, - uint8_t l, - uint8_t Ns, - LTE_DL_FRAME_PARMS *frame_parms); -uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); -uint8_t subframe2harq_pid_eNBrx(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + + int generate_ue_dlsch_params_from_dci(int frame, uint8_t subframe, @@ -1721,38 +1347,6 @@ int generate_ue_dlsch_params_from_dci(int frame, uint8_t beamforming_mode, uint16_t tc_rnti); -void fill_dci_and_dlsch(PHY_VARS_eNB *eNB, - int frame, - int subframe, - eNB_rxtx_proc_t *proc, - DCI_ALLOC_t *dci_alloc, - nfapi_dl_config_dci_dl_pdu *pdu); - -void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *dci_alloc,nfapi_dl_config_mpdcch_pdu *pdu); - -void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, - nfapi_hi_dci0_dci_pdu *pdu); - -void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe); - -int32_t generate_eNB_dlsch_params_from_dci(int frame, - uint8_t subframe, - void *dci_pdu, - rnti_t rnti, - DCI_format_t dci_format, - LTE_eNB_DLSCH_t **dlsch_eNB, - LTE_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t DL_pmi_single, - uint8_t beamforming_mode); - -int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, - unsigned char *rar_pdu, - uint32_t frame, - unsigned char subframe); int generate_ue_ulsch_params_from_dci(void *dci_pdu, rnti_t rnti, @@ -1776,44 +1370,20 @@ double sinr_eff_cqi_calc(PHY_VARS_UE *phy_vars_ue, uint8_t sinr2cqi(double sinr,uint8_t trans_mode); -int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *PHY_vars_eNB, - eNB_rxtx_proc_t *proc, - void *dci_pdu, - rnti_t rnti, - DCI_format_t dci_format, - uint8_t UE_id, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t use_srs); - - -void dump_ulsch(PHY_VARS_eNB *phy_vars_eNB,int frame, int subframe, uint8_t UE_id,int round); int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci); int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, UE_rxtx_proc_t *proc, char* buffer, int length, runmode_t mode, int input_level_dBm); -int dump_eNB_stats(PHY_VARS_eNB *phy_vars_eNB, char* buffer, int length); void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms); -void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - uint8_t *b, - uint8_t *bt); void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, uint8_t subframe, int16_t *d); -void generate_pcfich(uint8_t num_pdcch_symbols, - int16_t amp, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t **txdataF, - uint8_t subframe); uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms, uint8_t subframe, @@ -1836,14 +1406,6 @@ void generate_RIV_tables(void); */ int initial_sync(PHY_VARS_UE *phy_vars_ue, runmode_t mode); -void rx_ulsch(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_id); - - -void rx_ulsch_emul(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_index); /*! \brief Encoding of PUSCH/ACK/RI/ACK from 36-212. @@ -1864,73 +1426,8 @@ uint32_t ulsch_encoding(uint8_t *a, uint8_t control_only_flag, uint8_t Nbundled); -/*! - \brief Encoding of PUSCH/ACK/RI/ACK from 36-212 for emulation - @param ulsch_buffer Pointer to ulsch SDU - @param phy_vars_ue Pointer to UE top-level descriptor - @param eNB_id ID of eNB receiving this PUSCH - @param harq_pid HARQ process ID - @param control_only_flag Generate PUSCH with control information only -*/ -int32_t ulsch_encoding_emul(uint8_t *ulsch_buffer, - PHY_VARS_UE *phy_vars_ue, - uint8_t eNB_id, - uint8_t subframe_rx, - uint8_t harq_pid, - uint8_t control_only_flag); - -/*! - \brief Decoding of PUSCH/ACK/RI/ACK from 36-212. - @param phy_vars_eNB Pointer to eNB top-level descriptor - @param proc Pointer to RXTX proc variables - @param UE_id ID of UE transmitting this PUSCH - @param subframe Index of subframe for PUSCH - @param control_only_flag Receive PUSCH with control information only - @param Nbundled Nbundled parameter for ACK/NAK scrambling from 36-212/36-213 - @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used - @returns 0 on success -*/ -unsigned int ulsch_decoding(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_id, - uint8_t control_only_flag, - uint8_t Nbundled, - uint8_t llr8_flag); - -/*! - \brief Decoding of ULSCH data component from 36-212. This one spawns 1 worker thread in parallel,half of the segments in each thread. - @param phy_vars_eNB Pointer to eNB top-level descriptor - @param UE_id ID of UE transmitting this PUSCH - @param harq_pid HARQ process ID - @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used - @returns 0 on success -*/ -int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB, - int UE_id, - int harq_pid, - int llr8_flag); - -/*! - \brief Decoding of ULSCH data component from 36-212. This one is single thread. - @param phy_vars_eNB Pointer to eNB top-level descriptor - @param UE_id ID of UE transmitting this PUSCH - @param harq_pid HARQ process ID - @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used - @returns 0 on success -*/ -int ulsch_decoding_data(PHY_VARS_eNB *eNB, - int UE_id, - int harq_pid, - int llr8_flag); -uint32_t ulsch_decoding_emul(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_index, - uint16_t *crnti); -void generate_phich_top(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - int16_t amp); /* \brief This routine demodulates the PHICH and updates PUSCH/ULSCH parameters. @param phy_vars_ue Pointer to UE variables @@ -1962,8 +1459,6 @@ int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int sub void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL); -void extract_CQI(void *o,UCI_format_t uci_format,LTE_eNB_UE_stats *stats,uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode); - void fill_CQI(LTE_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id, uint8_t harq_pid,int N_RB_DL, rnti_t rnti, uint8_t trans_mode,double sinr_eff); void reset_cba_uci(void *o); @@ -1980,21 +1475,12 @@ int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb); uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands); -uint64_t pmi2hex_2Ar1(uint32_t pmi); -uint64_t pmi2hex_2Ar2(uint32_t pmi); uint64_t cqi2hex(uint32_t cqi); uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); -/** \brief This routine expands a single (wideband) PMI to subband PMI bitmap similar to the one used in the UCI and in the dlsch_modulation routine - @param frame_parms Pointer to DL frame configuration parameters - @param wideband_pmi (0,1,2,3 for rank 0 and 0,1 for rank 1) - @param rank (0 or 1) - @returns subband PMI bitmap -*/ -uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank); /** \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 @@ -2029,19 +1515,7 @@ void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, int8_t* llr, uint32_t length); -void pdcch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t subframe, - uint8_t *e, - uint32_t length); - -void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, - int mbsfn_flag, - LTE_eNB_DLSCH_t *dlsch, - int hard_pid, - int G, - uint8_t q, - uint16_t frame, - uint8_t Ns); + void dlsch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, int mbsfn_flag, @@ -2089,33 +1563,6 @@ void generate_pucch3x(int32_t **txdataF, uint8_t subframe, uint16_t rnti); -void generate_pucch_emul(PHY_VARS_UE *phy_vars_ue, - UE_rxtx_proc_t *proc, - PUCCH_FMT_t format, - uint8_t ncs1, - uint8_t *pucch_ack_payload, - uint8_t sr); - - - -uint32_t rx_pucch(PHY_VARS_eNB *phy_vars_eNB, - PUCCH_FMT_t fmt, - uint8_t UE_id, - uint16_t n1_pucch, - uint16_t n2_pucch, - uint8_t shortened_format, - uint8_t *payload, - int frame, - uint8_t subframe, - uint8_t pucch1_thres); - -int32_t rx_pucch_emul(PHY_VARS_eNB *phy_vars_eNB, - eNB_rxtx_proc_t *proc, - uint8_t UE_index, - PUCCH_FMT_t fmt, - uint8_t n1_pucch_sel, - uint8_t *payload); - void init_ulsch_power_LUT(void); @@ -2140,29 +1587,7 @@ int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t sub */ int32_t generate_prach(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,uint16_t Nf); -/*! - \brief Process PRACH waveform - @param phy_vars_eNB Pointer to eNB top-level descriptor. If NULL, then this is an RRU - @param ru Pointer to RU top-level descriptor. If NULL, then this is an eNB and we make use of the RU_list - @param max_preamble most likely preamble - @param max_preamble_energy Estimated Energy of most likely preamble - @param max_preamble_delay Estimated Delay of most likely preamble - @param Nf System frame number - @param tdd_mapindex Index of PRACH resource in Table 5.7.1-4 (TDD) - @param br_flag indicator to act on eMTC PRACH - @returns 0 on success -*/ -void rx_prach(PHY_VARS_eNB *phy_vars_eNB,RU_t *ru, - uint16_t *max_preamble, - uint16_t *max_preamble_energy, - uint16_t *max_preamble_delay, - uint16_t Nf, uint8_t tdd_mapindex -#ifdef Rel14 - , - uint8_t br_flag -#endif - ); /*! \brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index @param frame_parms Pointer to LTE_DL_FRAME_PARMS structure @@ -2229,16 +1654,6 @@ uint32_t dlsch_decoding_abstraction(double *dlsch_MIPB, // DL power control functions double get_pa_dB(uint8_t pa); -double computeRhoA_eNB(uint8_t pa, - LTE_eNB_DLSCH_t *dlsch_eNB, - int dl_power_off, - uint8_t n_antenna_port); - -double computeRhoB_eNB(uint8_t pa, - uint8_t pb, - uint8_t n_antenna_port, - LTE_eNB_DLSCH_t *dlsch_eNB, - int dl_power_off); double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, LTE_UE_DLSCH_t *dlsch_ue, @@ -2262,14 +1677,9 @@ uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, uint8_t n_ra_prboffset, uint8_t tdd_mapindex, uint16_t Nf); -uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); - -int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); -int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); -int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); /**@}*/ #endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h new file mode 100644 index 0000000000000000000000000000000000000000..e97353a902868b1417240dfc2bc97e168db4e883 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h @@ -0,0 +1,336 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/defs.h +* \brief data structures for PDSCH/DLSCH/PUSCH/ULSCH physical and transport channel descriptors (TX/RX) +* \author R. Knopp +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: raymond.knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it +* \note +* \warning +*/ +#ifndef __TRANSPORT_UE__H__ +#define __TRANSPORT_UE__H__ +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_lte.h" +#include "../LTE_TRANSPORT/dci.h" +#include "../LTE_TRANSPORT/mdci.h" +#include "../LTE_TRANSPORT/uci_common.h" +#include "../LTE_TRANSPORT/transport_common.h" +#ifndef STANDALONE_COMPILE +#include "UTIL/LISTS/list.h" +#endif + +#include "../LTE_TRANSPORT/transport_common.h" + +// structures below implement 36-211 and 36-212 + +/** @addtogroup _PHY_TRANSPORT_ + * @{ + */ + + + +typedef struct { + /// Indicator of first transmission + uint8_t first_tx; + /// Last Ndi received for this process on DCI (used for C-RNTI only) + uint8_t DCINdi; + /// Flag indicating that this ULSCH has a new packet (start of new round) + // uint8_t Ndi; + /// Status Flag indicating for this ULSCH (idle,active,disabled) + SCH_status_t status; + /// Subframe scheduling indicator (i.e. Transmission opportunity indicator) + uint8_t subframe_scheduling_flag; + /// Subframe cba scheduling indicator (i.e. Transmission opportunity indicator) + uint8_t subframe_cba_scheduling_flag; + /// First Allocated RB + uint16_t first_rb; + /// Current Number of RBs + uint16_t nb_rb; + /// Last TPC command + uint8_t TPC; + /// Transport block size + uint32_t TBS; + /// The payload + CRC size in bits, "B" from 36-212 + uint32_t B; + /// Length of ACK information (bits) + uint8_t O_ACK; + /// Pointer to the payload + uint8_t *b; + /// Pointers to transport block segments + uint8_t *c[MAX_NUM_ULSCH_SEGMENTS]; + /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) + uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS]; + /// Index of current HARQ round for this ULSCH + uint8_t round; + /// MCS format of this ULSCH + uint8_t mcs; + /// Redundancy-version of the current sub-frame + uint8_t rvidx; + /// Turbo-code outputs (36-212 V8.6 2009-03, p.12 + uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))]; + /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17) + uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144]; + /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) + uint32_t C; + /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cminus; + /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cplus; + /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kminus; + /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kplus; + /// Total number of bits across all segments + uint32_t sumKr; + /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t F; + /// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27) + uint16_t Msc_initial; + /// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27) + uint8_t Nsymb_initial; + /// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) + uint8_t n_DMRS; + /// n_DMRS2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1) + uint8_t n_DMRS2; + /// Flag to indicate that this is a control only ULSCH (i.e. no MAC SDU) + uint8_t control_only; + /// Flag to indicate that this is a calibration ULSCH (i.e. no MAC SDU and filled with TDD calibration information) + // int calibration_flag; + /// Number of soft channel bits + uint32_t G; + + // decode phich + uint8_t decode_phich; +} LTE_UL_UE_HARQ_t; + +typedef struct { + /// Current Number of Symbols + uint8_t Nsymb_pusch; + /// SRS active flag + uint8_t srs_active; + /// Pointers to 8 HARQ processes for the ULSCH + LTE_UL_UE_HARQ_t *harq_processes[8]; + /// 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 "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) + uint8_t e[MAX_NUM_CHANNEL_BITS]; + /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18) + 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) + 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 + uint16_t beta_offset_ri_times8; + /// beta_offset_harqack times 8 + uint16_t beta_offset_harqack_times8; + /// power_offset + uint8_t power_offset; + // for cooperative communication + uint8_t cooperation_flag; + /// RNTI attributed to this ULSCH + uint16_t rnti; + /// f_PUSCH parameter for PUSCH power control + int16_t f_pusch; + /// Po_PUSCH - target output power for PUSCH + int16_t Po_PUSCH; + /// PHR - current power headroom (based on last PUSCH transmission) + int16_t PHR; + /// Po_SRS - target output power for SRS + int16_t Po_SRS; + /// num active cba group + uint8_t num_active_cba_groups; + /// num dci found for cba + uint8_t num_cba_dci[10]; + /// allocated CBA RNTI + uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; + /// UL max-harq-retransmission + uint8_t Mlimit; +} LTE_UE_ULSCH_t; + + + + +typedef struct { + /// Indicator of first transmission + uint8_t first_tx; + /// Last Ndi received for this process on DCI (used for C-RNTI only) + uint8_t DCINdi; + /// DLSCH status flag indicating + SCH_status_t status; + /// Transport block size + uint32_t TBS; + /// The payload + CRC size in bits + uint32_t B; + /// Pointer to the payload + uint8_t *b; + /// Pointers to transport block segments + uint8_t *c[MAX_NUM_DLSCH_SEGMENTS]; + /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15) + uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS]; + /// Index of current HARQ round for this DLSCH + uint8_t round; + /// MCS format for this DLSCH + uint8_t mcs; + /// Qm (modulation order) for this DLSCH + uint8_t Qm; + /// Redundancy-version of the current sub-frame + uint8_t rvidx; + /// MIMO mode for this DLSCH + MIMO_mode_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_DLSCH_SEGMENTS][3*(6144+64)]; + /// 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_DLSCH_SEGMENTS][3*(6144+64)]; + /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + int16_t *d[MAX_NUM_DLSCH_SEGMENTS]; + /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9) + uint32_t C; + /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cminus; + /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Cplus; + /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kminus; + /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t Kplus; + /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10) + uint32_t F; + /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17) + uint8_t Nl; + /// current delta_pucch + int8_t delta_PUCCH; + /// Number of soft channel bits + uint32_t G; + /// Current Number of RBs + uint16_t nb_rb; + /// Current subband PMI allocation + uint16_t pmi_alloc; + /// Current RB allocation (even slots) + uint32_t rb_alloc_even[4]; + /// Current RB allocation (odd slots) + uint32_t rb_alloc_odd[4]; + /// distributed/localized flag + vrb_t vrb_type; + /// downlink power offset field + uint8_t dl_power_off; + /// trials per round statistics + uint32_t trials[8]; + /// error statistics per round + uint32_t errors[8]; + /// codeword this transport block is mapped to + uint8_t codeword; +} LTE_DL_UE_HARQ_t; + + +typedef struct { + /// HARQ process id + uint8_t harq_id; + /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX + uint8_t ack; + /// send status (for PUCCH) + uint8_t send_harq_status; + /// nCCE (for PUCCH) + uint8_t nCCE; + /// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched + uint8_t vDAI_DL; + /// DAI value detected from DCI0/4. 0xff indicates not touched + uint8_t vDAI_UL; +} harq_status_t; + +typedef struct { + /// RNTI + uint16_t rnti; + /// Active flag for DLSCH demodulation + uint8_t active; + /// Transmission mode + uint8_t mode1_flag; + /// amplitude of PDSCH (compared to RS) in symbols without pilots + int16_t sqrt_rho_a; + /// amplitude of PDSCH (compared to RS) in symbols containing pilots + int16_t sqrt_rho_b; + /// Current HARQ process id threadRx Odd and threadRx Even + uint8_t current_harq_pid; + /// Current subband antenna selection + uint32_t antenna_alloc; + /// Current subband RI allocation + uint32_t ri_alloc; + /// Current subband CQI1 allocation + uint32_t cqi_alloc1; + /// Current subband CQI2 allocation + uint32_t cqi_alloc2; + /// saved subband PMI allocation from last PUSCH/PUCCH report + uint16_t pmi_alloc; + /// HARQ-ACKs + harq_status_t harq_ack[10]; + /// Pointers to up to 8 HARQ processes + LTE_DL_UE_HARQ_t *harq_processes[8]; + /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17 + uint8_t Mdlharq; + /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17) + uint8_t Kmimo; + /// Nsoft parameter related to UE Category + uint32_t Nsoft; + /// Maximum number of Turbo iterations + uint8_t max_turbo_iterations; + /// number of iterations used in last turbo decoding + uint8_t last_iteration_cnt; + /// accumulated tx power adjustment for PUCCH + int8_t g_pucch; +} LTE_UE_DLSCH_t; + + + + +/**@}*/ +#endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..e687ccfd049f2704fd072e5ff0c196be3855f161 --- /dev/null +++ b/openair1/PHY/LTE_UE_TRANSPORT/uci_tools_ue.c @@ -0,0 +1,244 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/LTE_TRANSPORT/phich.c +* \brief Routines for generation of and computations regarding the uplink control information (UCI) for PUSCH. V8.6 2009-03 +* \author R. Knopp, F. Kaltenberger, A. Bhamri +* \date 2011 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, ankit.bhamri@eurecom.fr +* \note +* \warning +*/ +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#ifdef DEBUG_UCI_TOOLS +#include "PHY/phy_vars.h" +#endif + +//#define DEBUG_UCI 1 + + +uint64_t cqi2hex(uint32_t cqi) +{ + + uint64_t cqil = (uint64_t)cqi; + return ((cqil&3) + (((cqil>>2)&3)<<4) + (((cqil>>4)&3)<<8) + (((cqil>>6)&3)<<12) + + (((cqil>>8)&3)<<16) + (((cqil>>10)&3)<<20) + (((cqil>>12)&3)<<24) + + (((cqil>>14)&3)<<28) + (((cqil>>16)&3)<<32) + (((cqil>>18)&3)<<36) + + (((cqil>>20)&3)<<40) + (((cqil>>22)&3)<<44) + (((cqil>>24)&3)<<48)); +} + + +void print_CQI(void *o,UCI_format_t uci_format,unsigned char eNB_id,int N_RB_DL) +{ + + + switch(uci_format) { + case wideband_cqi_rank1_2A: +#ifdef DEBUG_UCI + LOG_D(PHY,"[PRINT CQI] flat_LA %d\n", flag_LA); + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi)); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_5MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_5MHz *)o)->pmi)); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_10MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_10MHz *)o)->pmi)); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, cqi %d\n",eNB_id, + ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 1: eNB %d, pmi (%x) %8x\n",eNB_id, + ((wideband_cqi_rank1_2A_20MHz *)o)->pmi, + pmi2hex_2Ar1(((wideband_cqi_rank1_2A_20MHz *)o)->pmi)); + break; + } + +#endif //DEBUG_UCI + break; + + case wideband_cqi_rank2_2A: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi)); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_5MHz *)o)->pmi)); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_10MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_10MHz *)o)->pmi)); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((wideband_cqi_rank2_2A_20MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] wideband_cqi rank 2: eNB %d, pmi %8x\n",eNB_id,pmi2hex_2Ar2(((wideband_cqi_rank2_2A_20MHz *)o)->pmi)); + break; + } + +#endif //DEBUG_UCI + break; + + case HLC_subband_cqi_nopmi: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1)); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1)); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi (no pmi) : eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1)); + break; + } + +#endif //DEBUG_UCI + break; + + case HLC_subband_cqi_rank1_2A: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 1: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi); + break; + } + +#endif //DEBUG_UCI + break; + + case HLC_subband_cqi_rank2_2A: +#ifdef DEBUG_UCI + switch(N_RB_DL) { + case 6: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi); + break; + + case 25: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi); + break; + + case 50: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi); + break; + + case 100: + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi1 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, cqi2 %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi1 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, diffcqi2 %8x\n",eNB_id,cqi2hex(((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2)); + LOG_I(PHY,"[PRINT CQI] hlc_cqi rank 2: eNB %d, pmi %d\n",eNB_id,((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi); + break; + } + +#endif //DEBUG_UCI + break; + + case ue_selected: +#ifdef DEBUG_UCI + LOG_W(PHY,"[PRINT CQI] ue_selected CQI not supported yet!!!\n"); +#endif //DEBUG_UCI + break; + + default: +#ifdef DEBUG_UCI + LOG_E(PHY,"[PRINT CQI] unsupported CQI mode (%d)!!!\n",uci_format); +#endif //DEBUG_UCI + break; + } + +} + + + + + + diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c similarity index 99% rename from openair1/PHY/LTE_TRANSPORT/ulsch_coding.c rename to openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c index 09420f48ab1a7029fdbbb2015fd7f28f47ffcd8c..d913a6f77902bb33f657be1a5ea45cf64ba3b801 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_coding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_coding.c @@ -30,16 +30,13 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" -#include "extern.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_ue.h" #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_ULSCH_CODING @@ -107,7 +104,7 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) case 50: bw_scaling =2; break; - + default: bw_scaling =1; break; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c similarity index 97% rename from openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c rename to openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c index d1718f6e90f600927f5d93f3a18e93213bea86f8..92a8d16b44ad59045d890b4ad0e39634f3cfeb8f 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/ulsch_modulation.c @@ -29,14 +29,15 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_ue.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" - +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_ULSCH_MODULATION @@ -381,7 +382,7 @@ void ulsch_modulation(int32_t **txdataF, DevAssert(frame_parms); - int re_offset,re_offset0,i,Msymb,j,k,nsymb,Msc_PUSCH,l; + int re_offset,re_offset0,i,ulsch_Msymb,j,k,nsymb,Msc_PUSCH,l; // uint8_t harq_pid = (rag_flag == 1) ? 0 : subframe2harq_pid_tdd(frame_parms->tdd_config,subframe); uint8_t harq_pid = subframe2harq_pid(frame_parms,frame,subframe); uint8_t Q_m; @@ -470,12 +471,12 @@ void ulsch_modulation(int32_t **txdataF, // Modulation - Msymb = G/Q_m; + ulsch_Msymb = G/Q_m; if(ulsch->cooperation_flag == 2) // For Distributed Alamouti Scheme in Collabrative Communication { - for (i=0,j=Q_m; i<Msymb; i+=2,j+=2*Q_m) { + for (i=0,j=Q_m; i<ulsch_Msymb; i+=2,j+=2*Q_m) { switch (Q_m) { @@ -609,7 +610,7 @@ void ulsch_modulation(int32_t **txdataF, }//for }//cooperation_flag == 2 else { - for (i=0,j=0; i<Msymb; i++,j+=Q_m) { + for (i=0,j=0; i<ulsch_Msymb; i++,j+=Q_m) { switch (Q_m) { @@ -685,7 +686,7 @@ void ulsch_modulation(int32_t **txdataF, #ifdef OFDMA_ULSCH - for (i=0; i<Msymb; i++) { + for (i=0; i<ulsch_Msymb; i++) { ulsch->z[i] = ulsch->d[i]; } diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 84863c81e89ce8c6742e8ca10896cd81ed3fa92c..e2ab0cd33b827307b8a004956177f5c2545dd19f 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -29,13 +29,14 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "PHY/CODING/defs.h" -#include "PHY/CODING/extern.h" +#include "PHY/defs_common.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" -#include "PHY/LTE_TRANSPORT/defs.h" -#include "defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" +#include "modulation_eNB.h" #include "UTIL/LOG/vcd_signal_dumper.h" int beam_precoding(int32_t **txdataF, diff --git a/openair1/PHY/MODULATION/compute_bf_weights.c b/openair1/PHY/MODULATION/compute_bf_weights.c index 4ef8e88ca6652433efbad3ce761463bd41836325..89d76058e6d2b1859124a14408704403fc9f778b 100644 --- a/openair1/PHY/MODULATION/compute_bf_weights.c +++ b/openair1/PHY/MODULATION/compute_bf_weights.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <stdlib.h> #include "PHY/impl_defs_lte.h" +#include "PHY/defs_common.h" int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coeffs){ diff --git a/openair1/PHY/MODULATION/defs.h b/openair1/PHY/MODULATION/defs.h deleted file mode 100644 index f9bbdcd27156e82cd7e41d010f406a58a905d6ca..0000000000000000000000000000000000000000 --- a/openair1/PHY/MODULATION/defs.h +++ /dev/null @@ -1,134 +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 __MODULATION_DEFS__H__ -#define __MODULATION_DEFS__H__ -#include "PHY/defs.h" -/** @addtogroup _PHY_MODULATION_ - * @{ -*/ - -/** -\fn void PHY_ofdm_mod(int *input,int *output,int fftsize,unsigned char nb_symbols,unsigned short nb_prefix_samples,Extension_t etype) -This function performs OFDM modulation with cyclic extension or zero-padding. - -@param input The sequence input samples in the frequency-domain. This is a concatenation of the input symbols in SIMD redundant format -@param output The time-domain output signal -@param fftsize size of OFDM symbol size (\f$N_d\f$) -@param nb_symbols The number of OFDM symbols in the block -@param nb_prefix_samples The number of prefix/suffix/zero samples -@param etype Type of extension (CYCLIC_PREFIX,CYCLIC_SUFFIX,ZEROS) - -*/ -void PHY_ofdm_mod(int *input, - int *output, - int fftsize, - unsigned char nb_symbols, - unsigned short nb_prefix_samples, - Extension_t etype - ); - -#ifdef OPENAIR_LTE - -/*! -\brief This function implements the OFDM front end processor on reception (FEP) -\param phy_vars_ue Pointer to PHY variables -\param l symbol within slot (0..6/7) -\param Ns Slot number (0..19) -\param sample_offset offset within rxdata (points to beginning of subframe) -\param no_prefix if 1 prefix is removed by HW -\param reset_freq_est if non-zero it resets the frequency offset estimation loop -*/ - -int slot_fep(PHY_VARS_UE *phy_vars_ue, - unsigned char l, - unsigned char Ns, - int sample_offset, - int no_prefix, - int reset_freq_est); - -int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, - unsigned char l, - int subframe, - int sample_offset, - int no_prefix); - -int slot_fep_ul(RU_t *ru, - unsigned char l, - unsigned char Ns, - int no_prefix); - -int front_end_fft(PHY_VARS_UE *ue, - unsigned char l, - unsigned char Ns, - int sample_offset, - int no_prefix); - -int front_end_chanEst(PHY_VARS_UE *ue, - unsigned char l, - unsigned char Ns, - int reset_freq_est); - -void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms); - -void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); - -void do_OFDM_mod_symbol(LTE_eNB_COMMON *eNB_common_vars, RU_COMMON *common, uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms,int do_precoding); - -void remove_7_5_kHz(RU_t *ru,uint8_t subframe); - -void apply_7_5_kHz(PHY_VARS_UE *phy_vars_ue,int32_t*txdata,uint8_t subframe); - -void init_prach625(LTE_DL_FRAME_PARMS *frame_parms); - -void remove_625_Hz(PHY_VARS_eNB *phy_vars_eNB,int16_t *prach); - -void apply_625_Hz(PHY_VARS_UE *phy_vars_ue,int16_t *prach); - -/** \brief This function performs beamforming precoding for common - * data - @param txdataF Table of pointers for frequency-domain TX signals - @param txdataF_BF Table of pointers for frequency-domain TX signals - @param frame_parms Frame descriptor structure -after beamforming - @param beam_weights Beamforming weights applied on each -antenna element and each carrier - @param slot Slot number - @param symbol Symbol index on which to act - @param aa physical antenna index*/ -int beam_precoding(int32_t **txdataF, - int32_t **txdataF_BF, - LTE_DL_FRAME_PARMS *frame_parms, - int32_t ***beam_weights, - int slot, - int symbol, - int aa); - -int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coeffs); - -int estimate_DLCSI_from_ULCSI(int32_t **calib_dl_ch_estimates, int32_t **ul_ch_estimates, int32_t **tdd_calib_coeffs, int nb_ant, int nb_freq); - -int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates, PRECODE_TYPE_t precode_type, int nb_ant, int nb_freq); - - -#endif -/** @}*/ -#endif diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h new file mode 100644 index 0000000000000000000000000000000000000000..7e2a3c8a27778f75b59866ea60392916baf9c684 --- /dev/null +++ b/openair1/PHY/MODULATION/modulation_UE.h @@ -0,0 +1,74 @@ +/* + * 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 __MODULATION_DEFS__H__ +#define __MODULATION_DEFS__H__ +#include "PHY/defs_common.h" +#include "modulation_common.h" +/** @addtogroup _PHY_MODULATION_ + * @{ +*/ + + + +/*! +\brief This function implements the OFDM front end processor on reception (FEP) +\param phy_vars_ue Pointer to PHY variables +\param l symbol within slot (0..6/7) +\param Ns Slot number (0..19) +\param sample_offset offset within rxdata (points to beginning of subframe) +\param no_prefix if 1 prefix is removed by HW +\param reset_freq_est if non-zero it resets the frequency offset estimation loop +*/ + +int slot_fep(PHY_VARS_UE *phy_vars_ue, + unsigned char l, + unsigned char Ns, + int sample_offset, + int no_prefix, + int reset_freq_est); + +int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, + unsigned char l, + int subframe, + int sample_offset, + int no_prefix); + +int front_end_fft(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int sample_offset, + int no_prefix); + +int front_end_chanEst(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int reset_freq_est); + +void apply_7_5_kHz(PHY_VARS_UE *phy_vars_ue,int32_t*txdata,uint8_t subframe); + + +int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates, PRECODE_TYPE_t precode_type, int nb_ant, int nb_freq); + + + +/** @}*/ +#endif diff --git a/openair1/PHY/MODULATION/modulation_common.h b/openair1/PHY/MODULATION/modulation_common.h new file mode 100644 index 0000000000000000000000000000000000000000..2ac0dc23b3012b5bc76aa8ad7acbdf9f4fedd318 --- /dev/null +++ b/openair1/PHY/MODULATION/modulation_common.h @@ -0,0 +1,56 @@ +/* + * 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 __MODULATION_COMMON__H__ +#define __MODULATION_COMMON__H__ +#include "PHY/defs_common.h" +/** @addtogroup _PHY_MODULATION_ + * @{ +*/ + +/** +\fn void PHY_ofdm_mod(int *input,int *output,int fftsize,unsigned char nb_symbols,unsigned short nb_prefix_samples,Extension_t etype) +This function performs OFDM modulation with cyclic extension or zero-padding. + +@param input The sequence input samples in the frequency-domain. This is a concatenation of the input symbols in SIMD redundant format +@param output The time-domain output signal +@param fftsize size of OFDM symbol size (\f$N_d\f$) +@param nb_symbols The number of OFDM symbols in the block +@param nb_prefix_samples The number of prefix/suffix/zero samples +@param etype Type of extension (CYCLIC_PREFIX,CYCLIC_SUFFIX,ZEROS) + +*/ +void PHY_ofdm_mod(int *input, + int *output, + int fftsize, + unsigned char nb_symbols, + unsigned short nb_prefix_samples, + Extension_t etype + ); + + +void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms); + +void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); + + +/** @}*/ +#endif diff --git a/openair1/PHY/MODULATION/modulation_eNB.h b/openair1/PHY/MODULATION/modulation_eNB.h new file mode 100644 index 0000000000000000000000000000000000000000..360861088721af9893767520af4af5cbc81a3f88 --- /dev/null +++ b/openair1/PHY/MODULATION/modulation_eNB.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 __MODULATION_ENB__H__ +#define __MODULATION_ENB__H__ +#include "PHY/defs_common.h" +#include "modulation_common.h" + +/** @addtogroup _PHY_MODULATION_ + * @{ +*/ + +int slot_fep_ul(RU_t *ru, + unsigned char l, + unsigned char Ns, + int no_prefix); + +void remove_7_5_kHz(RU_t *ru,uint8_t subframe); + +/** \brief This function performs beamforming precoding for common + * data + @param txdataF Table of pointers for frequency-domain TX signals + @param txdataF_BF Table of pointers for frequency-domain TX signals + @param frame_parms Frame descriptor structure +after beamforming + @param beam_weights Beamforming weights applied on each +antenna element and each carrier + @param slot Slot number + @param symbol Symbol index on which to act + @param aa physical antenna index*/ +int beam_precoding(int32_t **txdataF, + int32_t **txdataF_BF, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t ***beam_weights, + int slot, + int symbol, + int aa); + +int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coeffs); + +int estimate_DLCSI_from_ULCSI(int32_t **calib_dl_ch_estimates, int32_t **ul_ch_estimates, int32_t **tdd_calib_coeffs, int nb_ant, int nb_freq); + +int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates, PRECODE_TYPE_t precode_type, int nb_ant, int nb_freq); + + + +/** @}*/ +#endif diff --git a/openair1/PHY/MODULATION/modulation_extern.h b/openair1/PHY/MODULATION/modulation_extern.h new file mode 100644 index 0000000000000000000000000000000000000000..2834aa00f503113987b5fa27a52f631ff1d235c5 --- /dev/null +++ b/openair1/PHY/MODULATION/modulation_extern.h @@ -0,0 +1,38 @@ +/* + * 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 + */ + +extern int16_t s6n_kHz_7_5[1920]; +extern int16_t s6e_kHz_7_5[1920]; +extern int16_t s15n_kHz_7_5[3840]; +extern int16_t s15e_kHz_7_5[3840]; +extern int16_t s25n_kHz_7_5[7680]; +extern int16_t s25e_kHz_7_5[7680]; +extern int16_t s50n_kHz_7_5[15360]; +extern int16_t s50e_kHz_7_5[15360]; +extern int16_t s75n_kHz_7_5[23040]; +extern int16_t s75e_kHz_7_5[23040]; +extern int16_t s100n_kHz_7_5[30720]; +extern int16_t s100e_kHz_7_5[30720]; + + +extern short conjugate75[8]; +extern short conjugate75_2[8]; +extern short negate[8]; diff --git a/openair1/SCHED/vars.h b/openair1/PHY/MODULATION/modulation_vars.h similarity index 80% rename from openair1/SCHED/vars.h rename to openair1/PHY/MODULATION/modulation_vars.h index 4dac375f18d0973167228192c7371f75b89d5eea..dbea92ab3f5e3e9998bab0bb417a8e7a11c629eb 100644 --- a/openair1/SCHED/vars.h +++ b/openair1/PHY/MODULATION/modulation_vars.h @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -#include "defs.h" - - - +#include "kHz_7_5.h" +short conjugate75[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; +short conjugate75_2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; +short negate[8]__attribute__((aligned(16))) = {-1,-1,-1,-1,-1,-1,-1,-1}; diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c index 37d1a483119cda97b5e455787d51bada349b83fc..dfb6c85f33abe7f7309a7b23173506fd125490bc 100644 --- a/openair1/PHY/MODULATION/ofdm_mod.c +++ b/openair1/PHY/MODULATION/ofdm_mod.c @@ -29,10 +29,12 @@ This section deals with basic functions for OFDM Modulation. */ -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/impl_defs_top.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" - +#include "modulation_common.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" //#define DEBUG_OFDM_MOD diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c index 39ae90217f9b336d2afc397bd60106adc4ecb50f..b01979431dcf88212604aa71cf0d0470eb177d06 100644 --- a/openair1/PHY/MODULATION/slot_fep.c +++ b/openair1/PHY/MODULATION/slot_fep.c @@ -19,8 +19,10 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "defs.h" +#include "PHY/defs_UE.h" +#include "modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + //#define DEBUG_FEP #define SOFFSET 0 diff --git a/openair1/PHY/MODULATION/slot_fep_mbsfn.c b/openair1/PHY/MODULATION/slot_fep_mbsfn.c index 7b902bb8f1524199980c08a7b9dc3bf1208ed403..272cbc5d60b0566562fb9d838c54f3396ac37b7e 100644 --- a/openair1/PHY/MODULATION/slot_fep_mbsfn.c +++ b/openair1/PHY/MODULATION/slot_fep_mbsfn.c @@ -19,8 +19,10 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "defs.h" +#include "PHY/defs_UE.h" +#include "modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + //#define DEBUG_FEP #define SOFFSET 0 diff --git a/openair1/PHY/MODULATION/slot_fep_ul.c b/openair1/PHY/MODULATION/slot_fep_ul.c index 5beb7eccfdc14880ee953d10b198422a8b30a525..fe5488c73c7f29c136bb9730ca10e1f11149521c 100644 --- a/openair1/PHY/MODULATION/slot_fep_ul.c +++ b/openair1/PHY/MODULATION/slot_fep_ul.c @@ -19,9 +19,9 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "modulation_eNB.h" //#define DEBUG_FEP diff --git a/openair1/PHY/MODULATION/ul_7_5_kHz.c b/openair1/PHY/MODULATION/ul_7_5_kHz.c index d92dc1c8b3203bf5c0d103ec3d7fd09ce220f138..3d1d9c2b0470ad2a46c0b6534e4463d558d5d0ae 100644 --- a/openair1/PHY/MODULATION/ul_7_5_kHz.c +++ b/openair1/PHY/MODULATION/ul_7_5_kHz.c @@ -19,121 +19,11 @@ * contact@openairinterface.org */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "extern.h" -#include "kHz_7_5.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" #include <math.h> #include "PHY/sse_intrin.h" - -short conjugate75[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; -short conjugate75_2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ; -short negate[8]__attribute__((aligned(16))) = {-1,-1,-1,-1,-1,-1,-1,-1}; - -void apply_7_5_kHz(PHY_VARS_UE *ue,int32_t*txdata,uint8_t slot) -{ - - - uint16_t len; - uint32_t *kHz7_5ptr; -#if defined(__x86_64__) || defined(__i386__) - __m128i *txptr128,*kHz7_5ptr128,mmtmp_re,mmtmp_im,mmtmp_re2,mmtmp_im2; -#elif defined(__arm__) - int16x8_t *txptr128,*kHz7_5ptr128; - int32x4_t mmtmp_re,mmtmp_im; - int32x4_t mmtmp0,mmtmp1; -#endif - uint32_t slot_offset; - // uint8_t aa; - uint32_t i; - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - - switch (frame_parms->N_RB_UL) { - - case 6: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s6n_kHz_7_5 : (uint32_t*)s6e_kHz_7_5; - break; - - case 15: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s15n_kHz_7_5 : (uint32_t*)s15e_kHz_7_5; - break; - - case 25: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; - break; - - case 50: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s50n_kHz_7_5 : (uint32_t*)s50e_kHz_7_5; - break; - - case 75: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s75n_kHz_7_5 : (uint32_t*)s75e_kHz_7_5; - break; - - case 100: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s100n_kHz_7_5 : (uint32_t*)s100e_kHz_7_5; - break; - - default: - kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; - break; - } - - slot_offset = (uint32_t)slot * frame_parms->samples_per_tti/2; - len = frame_parms->samples_per_tti/2; - -#if defined(__x86_64__) || defined(__i386__) - txptr128 = (__m128i *)&txdata[slot_offset]; - kHz7_5ptr128 = (__m128i *)kHz7_5ptr; -#elif defined(__arm__) - txptr128 = (int16x8_t*)&txdata[slot_offset]; - kHz7_5ptr128 = (int16x8_t*)kHz7_5ptr; -#endif - // apply 7.5 kHz - - for (i=0; i<(len>>2); i++) { -#if defined(__x86_64__) || defined(__i386__) - mmtmp_re = _mm_madd_epi16(*txptr128,*kHz7_5ptr128); - // Real part of complex multiplication (note: 7_5kHz signal is conjugated for this to work) - mmtmp_im = _mm_shufflelo_epi16(*kHz7_5ptr128,_MM_SHUFFLE(2,3,0,1)); - mmtmp_im = _mm_shufflehi_epi16(mmtmp_im,_MM_SHUFFLE(2,3,0,1)); - mmtmp_im = _mm_sign_epi16(mmtmp_im,*(__m128i*)&conjugate75[0]); - mmtmp_im = _mm_madd_epi16(mmtmp_im,txptr128[0]); - mmtmp_re = _mm_srai_epi32(mmtmp_re,15); - mmtmp_im = _mm_srai_epi32(mmtmp_im,15); - mmtmp_re2 = _mm_unpacklo_epi32(mmtmp_re,mmtmp_im); - mmtmp_im2 = _mm_unpackhi_epi32(mmtmp_re,mmtmp_im); - - txptr128[0] = _mm_packs_epi32(mmtmp_re2,mmtmp_im2); - txptr128++; - kHz7_5ptr128++; -#elif defined(__arm__) - - mmtmp0 = vmull_s16(((int16x4_t*)txptr128)[0],((int16x4_t*)kHz7_5ptr128)[0]); - //mmtmp0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] - mmtmp1 = vmull_s16(((int16x4_t*)txptr128)[1],((int16x4_t*)kHz7_5ptr128)[1]); - //mmtmp1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] - mmtmp_re = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), - vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); - //mmtmp_re = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] - - mmtmp0 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[0],*(int16x4_t*)conjugate75_2)),((int16x4_t*)kHz7_5ptr128)[0]); - //mmtmp0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] - mmtmp1 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[1],*(int16x4_t*)conjugate75_2)), ((int16x4_t*)kHz7_5ptr128)[1]); - //mmtmp0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] - mmtmp_im = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), - vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); - //mmtmp_im = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] - - txptr128[0] = vcombine_s16(vmovn_s32(mmtmp_re),vmovn_s32(mmtmp_im)); - txptr128++; - kHz7_5ptr128++; -#endif - } - - //} -} - +#include "modulation_extern.h" void remove_7_5_kHz(RU_t *ru,uint8_t slot) { diff --git a/openair1/PHY/MODULATION/ul_7_5_kHz_ue.c b/openair1/PHY/MODULATION/ul_7_5_kHz_ue.c new file mode 100644 index 0000000000000000000000000000000000000000..3e3a839521b3e5be66c530b0af89172ac0d76ce6 --- /dev/null +++ b/openair1/PHY/MODULATION/ul_7_5_kHz_ue.c @@ -0,0 +1,136 @@ +/* + * 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 "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" +#include "modulation_extern.h" +#include <math.h> +#include "PHY/sse_intrin.h" + +extern short conjugate75[8]; +extern short conjugate75_2[8]; +extern short negate[8]; + +void apply_7_5_kHz(PHY_VARS_UE *ue,int32_t*txdata,uint8_t slot) +{ + + + uint16_t len; + uint32_t *kHz7_5ptr; +#if defined(__x86_64__) || defined(__i386__) + __m128i *txptr128,*kHz7_5ptr128,mmtmp_re,mmtmp_im,mmtmp_re2,mmtmp_im2; +#elif defined(__arm__) + int16x8_t *txptr128,*kHz7_5ptr128; + int32x4_t mmtmp_re,mmtmp_im; + int32x4_t mmtmp0,mmtmp1; +#endif + uint32_t slot_offset; + // uint8_t aa; + uint32_t i; + LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; + + switch (frame_parms->N_RB_UL) { + + case 6: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s6n_kHz_7_5 : (uint32_t*)s6e_kHz_7_5; + break; + + case 15: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s15n_kHz_7_5 : (uint32_t*)s15e_kHz_7_5; + break; + + case 25: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; + break; + + case 50: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s50n_kHz_7_5 : (uint32_t*)s50e_kHz_7_5; + break; + + case 75: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s75n_kHz_7_5 : (uint32_t*)s75e_kHz_7_5; + break; + + case 100: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s100n_kHz_7_5 : (uint32_t*)s100e_kHz_7_5; + break; + + default: + kHz7_5ptr = (frame_parms->Ncp==0) ? (uint32_t*)s25n_kHz_7_5 : (uint32_t*)s25e_kHz_7_5; + break; + } + + slot_offset = (uint32_t)slot * frame_parms->samples_per_tti/2; + len = frame_parms->samples_per_tti/2; + +#if defined(__x86_64__) || defined(__i386__) + txptr128 = (__m128i *)&txdata[slot_offset]; + kHz7_5ptr128 = (__m128i *)kHz7_5ptr; +#elif defined(__arm__) + txptr128 = (int16x8_t*)&txdata[slot_offset]; + kHz7_5ptr128 = (int16x8_t*)kHz7_5ptr; +#endif + // apply 7.5 kHz + + for (i=0; i<(len>>2); i++) { +#if defined(__x86_64__) || defined(__i386__) + mmtmp_re = _mm_madd_epi16(*txptr128,*kHz7_5ptr128); + // Real part of complex multiplication (note: 7_5kHz signal is conjugated for this to work) + mmtmp_im = _mm_shufflelo_epi16(*kHz7_5ptr128,_MM_SHUFFLE(2,3,0,1)); + mmtmp_im = _mm_shufflehi_epi16(mmtmp_im,_MM_SHUFFLE(2,3,0,1)); + mmtmp_im = _mm_sign_epi16(mmtmp_im,*(__m128i*)&conjugate75[0]); + mmtmp_im = _mm_madd_epi16(mmtmp_im,txptr128[0]); + mmtmp_re = _mm_srai_epi32(mmtmp_re,15); + mmtmp_im = _mm_srai_epi32(mmtmp_im,15); + mmtmp_re2 = _mm_unpacklo_epi32(mmtmp_re,mmtmp_im); + mmtmp_im2 = _mm_unpackhi_epi32(mmtmp_re,mmtmp_im); + + txptr128[0] = _mm_packs_epi32(mmtmp_re2,mmtmp_im2); + txptr128++; + kHz7_5ptr128++; +#elif defined(__arm__) + + mmtmp0 = vmull_s16(((int16x4_t*)txptr128)[0],((int16x4_t*)kHz7_5ptr128)[0]); + //mmtmp0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] + mmtmp1 = vmull_s16(((int16x4_t*)txptr128)[1],((int16x4_t*)kHz7_5ptr128)[1]); + //mmtmp1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] + mmtmp_re = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), + vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); + //mmtmp_re = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] + + mmtmp0 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[0],*(int16x4_t*)conjugate75_2)),((int16x4_t*)kHz7_5ptr128)[0]); + //mmtmp0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] + mmtmp1 = vmull_s16(vrev32_s16(vmul_s16(((int16x4_t*)txptr128)[1],*(int16x4_t*)conjugate75_2)), ((int16x4_t*)kHz7_5ptr128)[1]); + //mmtmp0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] + mmtmp_im = vcombine_s32(vpadd_s32(vget_low_s32(mmtmp0),vget_high_s32(mmtmp0)), + vpadd_s32(vget_low_s32(mmtmp1),vget_high_s32(mmtmp1))); + //mmtmp_im = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] + + txptr128[0] = vcombine_s16(vmovn_s32(mmtmp_re),vmovn_s32(mmtmp_im)); + txptr128++; + kHz7_5ptr128++; +#endif + } + + //} +} + + diff --git a/openair1/PHY/NBIoT_TRANSPORT/README b/openair1/PHY/NBIoT_TRANSPORT/README new file mode 100644 index 0000000000000000000000000000000000000000..938b70815c5e7019b0ca89013a71855a032d6d1f --- /dev/null +++ b/openair1/PHY/NBIoT_TRANSPORT/README @@ -0,0 +1 @@ +NB-IoT transport channel procedures for NB-IoT are here diff --git a/openair1/PHY/NR_REFSIG/README b/openair1/PHY/NR_REFSIG/README new file mode 100644 index 0000000000000000000000000000000000000000..ea7e5013f9e3581965eba215f182b50a874e54a7 --- /dev/null +++ b/openair1/PHY/NR_REFSIG/README @@ -0,0 +1 @@ +Reference signal definitions for NR diff --git a/openair1/PHY/NR_TRANSPORT/README b/openair1/PHY/NR_TRANSPORT/README new file mode 100644 index 0000000000000000000000000000000000000000..fc7dd3a338c8bfd129e29409052284ee25c642ea --- /dev/null +++ b/openair1/PHY/NR_TRANSPORT/README @@ -0,0 +1 @@ +NR gNB transport channel procedures are here diff --git a/openair1/PHY/NR_UE_TRANSPORT/README b/openair1/PHY/NR_UE_TRANSPORT/README new file mode 100644 index 0000000000000000000000000000000000000000..62393afe9343c5c70ce98a48ffa2a7756ab05d34 --- /dev/null +++ b/openair1/PHY/NR_UE_TRANSPORT/README @@ -0,0 +1 @@ +UE NR transport/physical channel procedures are here diff --git a/openair1/PHY/TOOLS/cadd_vv.c b/openair1/PHY/TOOLS/cadd_vv.c index 34808552fcaab7966d46249853b2ed4a6c9093d8..77346a97f7facdcf1e68a78b7397a709d9af6b12 100644 --- a/openair1/PHY/TOOLS/cadd_vv.c +++ b/openair1/PHY/TOOLS/cadd_vv.c @@ -19,7 +19,8 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "PHY/defs_common.h" +#include "tools_defs.h" int add_vector16(short *x, diff --git a/openair1/PHY/TOOLS/cdot_prod.c b/openair1/PHY/TOOLS/cdot_prod.c index 91ba246bddf51afeb637976ace75c8decec83cae..60bdcf45dd722f98a3eccab80a76963e01f9db1a 100644 --- a/openair1/PHY/TOOLS/cdot_prod.c +++ b/openair1/PHY/TOOLS/cdot_prod.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "tools_defs.h" #include "PHY/sse_intrin.h" // returns the complex dot product of x and y diff --git a/openair1/PHY/TOOLS/cmult_sv.c b/openair1/PHY/TOOLS/cmult_sv.c index 61970ca2b69afa6d8ce38df8fe9d3bf3cc9c9636..013fedc6e9204ed042a7f1025434301532b93656 100644 --- a/openair1/PHY/TOOLS/cmult_sv.c +++ b/openair1/PHY/TOOLS/cmult_sv.c @@ -20,7 +20,7 @@ */ #include "PHY/sse_intrin.h" -#include "defs.h" +#include "tools_defs.h" #if defined(__x86_64__) || defined(__i386__) #define simd_q15_t __m128i diff --git a/openair1/PHY/TOOLS/cmult_vv.c b/openair1/PHY/TOOLS/cmult_vv.c index 13facf69077a165a0f6c05378bb1f847c6c4ab0b..ce3ebec65fe0e29f4bd34e816f484902e7531112 100644 --- a/openair1/PHY/TOOLS/cmult_vv.c +++ b/openair1/PHY/TOOLS/cmult_vv.c @@ -19,7 +19,8 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "PHY/defs_common.h" +#include "tools_defs.h" #include <stdio.h> #if defined(__x86_64__) || defined(__i386__) diff --git a/openair1/PHY/TOOLS/dB_routines.c b/openair1/PHY/TOOLS/dB_routines.c index c99703eaf3c6139682f098aa932691a6522bcfc5..572759a68ca14ed47c4ba785816dc3ddf99f27c2 100644 --- a/openair1/PHY/TOOLS/dB_routines.c +++ b/openair1/PHY/TOOLS/dB_routines.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "tools_defs.h" // Approximate 10*log10(x) in fixed point : x = 0...(2^32)-1 diff --git a/openair1/PHY/TOOLS/lte_dfts.c b/openair1/PHY/TOOLS/lte_dfts.c index 47b39ea7d2666154005d4086e0fdea4c82d8d628..9a5a504ec41eea3d6f69ecf84ed20e5d03c0ed9f 100644 --- a/openair1/PHY/TOOLS/lte_dfts.c +++ b/openair1/PHY/TOOLS/lte_dfts.c @@ -26,9 +26,9 @@ #include <stdint.h> #ifndef MR_MAIN -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "defs.h" +#include "PHY/defs_common.h" +#include "PHY/impl_defs_top.h" +#include "tools_defs.h" #else #include "time_meas.h" #include <math.h> diff --git a/openair1/PHY/TOOLS/lte_phy_scope.c b/openair1/PHY/TOOLS/lte_phy_scope.c index eb86af916597fe0869af11ada340788751f301be..9f2ec54744941e783e0cb27cabeb19b93c95e4d5 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.c +++ b/openair1/PHY/TOOLS/lte_phy_scope.c @@ -23,6 +23,8 @@ #include <stdlib.h> #include "lte_phy_scope.h" +#include "PHY/defs_common.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" #define TPUT_WINDOW_LENGTH 100 int otg_enabled; diff --git a/openair1/PHY/TOOLS/lte_phy_scope.h b/openair1/PHY/TOOLS/lte_phy_scope.h index 1d2b2ea1ed99c5b579aaa6f77b16bf5485108a7d..af9858ebad97796def7d13b4d007171fd61ca920 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.h +++ b/openair1/PHY/TOOLS/lte_phy_scope.h @@ -25,10 +25,9 @@ #define FD_lte_scope_h_ #include <forms.h> -#include "../impl_defs_lte.h" -#include "../impl_defs_top.h" -#include "../defs.h" -#include "../../SCHED/defs.h" // for OPENAIR_DAQ_VARS +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/impl_defs_top.h" /* Forms and Objects */ diff --git a/openair1/PHY/TOOLS/signal_energy.c b/openair1/PHY/TOOLS/signal_energy.c index 918d2e3ba0043c636dcd67a2a875f338e7234063..13f37c4c8dbe9de6362a63abe6bd0f174321c9ef 100644 --- a/openair1/PHY/TOOLS/signal_energy.c +++ b/openair1/PHY/TOOLS/signal_energy.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "tools_defs.h" #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c index d80832e243c9b0af7cea98e1d3da9fca0ff01b67..cb7775904099a769091795d62d23cc1b1d950b25 100644 --- a/openair1/PHY/TOOLS/time_meas.c +++ b/openair1/PHY/TOOLS/time_meas.c @@ -53,7 +53,7 @@ void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){ if (ts->trials>0) { //fprintf(file_name,"Name %25s: Processing %15.3f ms for SF %d, diff_now %15.3f \n", name,(ts->diff_now/(cpu_freq_GHz*1000000.0)),subframe,ts->diff_now); - fprintf(file_name,"%15.3f ms, diff_now %15.3f \n",(ts->diff_now/(cpu_freq_GHz*1000000.0)),(double)ts->diff_now); + fprintf(file_name,"%15.3f us, diff_now %15.3f \n",(ts->diff_now/(cpu_freq_GHz*1000.0)),(double)ts->diff_now); } } diff --git a/openair1/PHY/TOOLS/defs.h b/openair1/PHY/TOOLS/tools_defs.h similarity index 99% rename from openair1/PHY/TOOLS/defs.h rename to openair1/PHY/TOOLS/tools_defs.h index b92c2a42367b59acae680d167af8665f3de7093e..e3b04babdc8f2320f3a319914fbaefbaa20f4a2a 100644 --- a/openair1/PHY/TOOLS/defs.h +++ b/openair1/PHY/TOOLS/tools_defs.h @@ -30,7 +30,6 @@ */ #include <stdint.h> - #include "PHY/sse_intrin.h" diff --git a/openair1/PHY/MODULATION/extern.h b/openair1/PHY/TOOLS/tools_extern.h similarity index 100% rename from openair1/PHY/MODULATION/extern.h rename to openair1/PHY/TOOLS/tools_extern.h diff --git a/openair1/PHY/TOOLS/extern.h b/openair1/PHY/TOOLS/tools_vars.h similarity index 100% rename from openair1/PHY/TOOLS/extern.h rename to openair1/PHY/TOOLS/tools_vars.h diff --git a/openair1/PHY/TOOLS/vars.h b/openair1/PHY/TOOLS/vars.h deleted file mode 100644 index 4690bba42e5b91f4721d727b38d41da928e0c55a..0000000000000000000000000000000000000000 --- a/openair1/PHY/TOOLS/vars.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - diff --git a/openair1/PHY/defs_L1_NB_IoT.h b/openair1/PHY/defs_L1_NB_IoT.h index 25ee6465482012c0c42a9457cb6dbac02b075dd3..bb08d5122dd68033f1c7871a37faabd4a1355a68 100644 --- a/openair1/PHY/defs_L1_NB_IoT.h +++ b/openair1/PHY/defs_L1_NB_IoT.h @@ -40,7 +40,7 @@ #include <math.h> #include "common_lib.h" #include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h" - +#include "defs_eNB.h" //#include <complex.h> #include "assertions.h" #ifdef MEX @@ -341,8 +341,6 @@ typedef struct eNB_proc_NB_IoT_t_s { int instance_cnt_asynch_rxtx; /// pthread structure for FH processing thread pthread_t pthread_FH; - /// pthread structure for eNB single processing thread - pthread_t pthread_single; /// pthread structure for asychronous RX/TX processing thread pthread_t pthread_asynch_rxtx; /// flag to indicate first RX acquisition @@ -427,7 +425,7 @@ typedef struct eNB_proc_NB_IoT_t_s { int RU_mask; /// mask for RUs serving nbiot (PRACH) int RU_mask_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// mask for RUs serving eNB (PRACH) int RU_mask_prach_br; #endif diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h new file mode 100644 index 0000000000000000000000000000000000000000..e36b88c036b1f7426f9bcba8f4519f0b46c86d34 --- /dev/null +++ b/openair1/PHY/defs_UE.h @@ -0,0 +1,863 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/defs.h + \brief Top-level defines and structure definitions + \author R. Knopp, F. Kaltenberger + \date 2011 + \version 0.1 + \company Eurecom + \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr + \note + \warning +*/ +#ifndef __PHY_DEFS_UE_H__ +#define __PHY_DEFS_UE_H__ + + +#define _GNU_SOURCE +#include <sched.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/mman.h> +#include <linux/sched.h> +#include <signal.h> +#include <execinfo.h> +#include <getopt.h> +#include <sys/sysinfo.h> + + +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> +#include <string.h> +#include <math.h> +#include "common_lib.h" +#include "msc.h" + +#include "defs_common.h" +#include "impl_defs_top.h" + +#include "PHY/TOOLS/time_meas.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "platform_types.h" +#include "PHY/LTE_UE_TRANSPORT/transport_ue.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" // for SIC +#include <pthread.h> +#include "assertions.h" + + +/// Context data structure for RX/TX portion of subframe processing +typedef struct { + /// index of the current UE RX/TX proc + int proc_id; + /// Component Carrier index + uint8_t CC_id; + /// timestamp transmitted to HW + openair0_timestamp timestamp_tx; + /// subframe to act upon for transmission + int subframe_tx; + /// subframe to act upon for reception + int subframe_rx; + /// frame to act upon for transmission + int frame_tx; + /// frame to act upon for reception + int frame_rx; + /// \brief Instance count for RXn-TXnp4 processing thread. + /// \internal This variable is protected by \ref mutex_rxtx. + int instance_cnt_rxtx; + /// pthread structure for RXn-TXnp4 processing thread + pthread_t pthread_rxtx; + /// pthread attributes for RXn-TXnp4 processing thread + pthread_attr_t attr_rxtx; + /// condition variable for tx processing thread + pthread_cond_t cond_rxtx; + /// mutex for RXn-TXnp4 processing thread + pthread_mutex_t mutex_rxtx; + /// scheduling parameters for RXn-TXnp4 thread + struct sched_param sched_param_rxtx; + + /// internal This variable is protected by ref mutex_fep_slot1. + //int instance_cnt_slot0_dl_processing; + int instance_cnt_slot1_dl_processing; + /// pthread descriptor fep_slot1 thread + //pthread_t pthread_slot0_dl_processing; + pthread_t pthread_slot1_dl_processing; + /// pthread attributes for fep_slot1 processing thread + // pthread_attr_t attr_slot0_dl_processing; + pthread_attr_t attr_slot1_dl_processing; + /// condition variable for UE fep_slot1 thread; + //pthread_cond_t cond_slot0_dl_processing; + pthread_cond_t cond_slot1_dl_processing; + /// mutex for UE synch thread + //pthread_mutex_t mutex_slot0_dl_processing; + pthread_mutex_t mutex_slot1_dl_processing; + // + uint8_t chan_est_pilot0_slot1_available; + uint8_t chan_est_slot1_available; + uint8_t llr_slot1_available; + uint8_t dci_slot0_available; + uint8_t first_symbol_available; + //uint8_t channel_level; + /// scheduling parameters for fep_slot1 thread + struct sched_param sched_param_fep_slot1; + + int sub_frame_start; + int sub_frame_step; + unsigned long long gotIQs; +} UE_rxtx_proc_t; + +/// Context data structure for eNB subframe processing +typedef struct { + /// Component Carrier index + uint8_t CC_id; + /// Last RX timestamp + openair0_timestamp timestamp_rx; + /// pthread attributes for main UE thread + pthread_attr_t attr_ue; + /// scheduling parameters for main UE thread + struct sched_param sched_param_ue; + /// pthread descriptor main UE thread + pthread_t pthread_ue; + /// \brief Instance count for synch thread. + /// \internal This variable is protected by \ref mutex_synch. + int instance_cnt_synch; + /// pthread attributes for synch processing thread + pthread_attr_t attr_synch; + /// scheduling parameters for synch thread + struct sched_param sched_param_synch; + /// pthread descriptor synch thread + pthread_t pthread_synch; + /// condition variable for UE synch thread; + pthread_cond_t cond_synch; + /// mutex for UE synch thread + pthread_mutex_t mutex_synch; + /// instance count for eNBs + int instance_cnt_eNBs; + /// set of scheduling variables RXn-TXnp4 threads + UE_rxtx_proc_t proc_rxtx[RX_NB_TH]; +} UE_proc_t; + +/// Panos: Structure holding timer_thread related elements (phy_stub_UE mode) +typedef struct { + pthread_t pthread_timer; + /// Panos: mutex for waiting SF ticking + pthread_mutex_t mutex_ticking; + /// Panos: \brief ticking var for ticking thread. + /// \internal This variable is protected by \ref mutex_ticking. + int ticking_var; + /// condition variable for timer_thread; + pthread_cond_t cond_ticking; + //time_stats_t timer_stats; +} SF_ticking; + +typedef struct { + //unsigned int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (linear) + //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (dB) + //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //! estimated avg received signal power (dB) + + // RRC measurements + uint32_t rssi; + int n_adj_cells; + unsigned int adj_cell_id[6]; + uint32_t rsrq[7]; + uint32_t rsrp[7]; + float rsrp_filtered[7]; // after layer 3 filtering + float rsrq_filtered[7]; + // common measurements + //! estimated noise power (linear) + unsigned int n0_power[NB_ANTENNAS_RX]; + //! estimated noise power (dB) + unsigned short n0_power_dB[NB_ANTENNAS_RX]; + //! total estimated noise power (linear) + unsigned int n0_power_tot; + //! total estimated noise power (dB) + unsigned short n0_power_tot_dB; + //! average estimated noise power (linear) + unsigned int n0_power_avg; + //! average estimated noise power (dB) + unsigned short n0_power_avg_dB; + //! total estimated noise power (dBm) + short n0_power_tot_dBm; + + // UE measurements + //! estimated received spatial signal power (linear) + int rx_spatial_power[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; + //! estimated received spatial signal power (dB) + unsigned short rx_spatial_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; + + /// estimated received signal power (sum over all TX antennas) + //int wideband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + /// estimated received signal power (sum over all TX antennas) + //int wideband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + + /// estimated received signal power (sum over all TX/RX antennas) + int rx_power_tot[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW + /// estimated received signal power (sum over all TX/RX antennas) + unsigned short rx_power_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW + + //! estimated received signal power (sum of all TX/RX antennas, time average) + int rx_power_avg[NUMBER_OF_CONNECTED_eNB_MAX]; + //! estimated received signal power (sum of all TX/RX antennas, time average, in dB) + unsigned short rx_power_avg_dB[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// SINR (sum of all TX/RX antennas, in dB) + int wideband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX]; + /// SINR (sum of all TX/RX antennas, time average, in dB) + int wideband_cqi_avg[NUMBER_OF_CONNECTED_eNB_MAX]; + + //! estimated rssi (dBm) + short rx_rssi_dBm[NUMBER_OF_CONNECTED_eNB_MAX]; + //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) + int rx_correlation[NUMBER_OF_CONNECTED_eNB_MAX][2]; + //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) + int rx_correlation_dB[NUMBER_OF_CONNECTED_eNB_MAX][2]; + + /// Wideband CQI (sum of all RX antennas, in dB, for precoded transmission modes (3,4,5,6), up to 4 spatial streams) + int precoded_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX+1][4]; + /// Subband CQI per RX antenna (= SINR) + int subband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; + /// Total Subband CQI (= SINR) + int subband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; + /// Subband CQI in dB (= SINR dB) + int subband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; + /// Total Subband CQI + int subband_cqi_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; + /// Wideband PMI for each RX antenna + int wideband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + /// Wideband PMI for each RX antenna + int wideband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; + ///Subband PMI for each RX antenna + int subband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; + ///Subband PMI for each RX antenna + int subband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; + /// chosen RX antennas (1=Rx antenna 1, 2=Rx antenna 2, 3=both Rx antennas) + unsigned char selected_rx_antennas[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; + /// Wideband Rank indication + unsigned char rank[NUMBER_OF_CONNECTED_eNB_MAX]; + /// Number of RX Antennas + unsigned char nb_antennas_rx; + /// DLSCH error counter + // short dlsch_errors; + +} PHY_MEASUREMENTS; + +typedef struct { + + /// \brief Holds the received data in the frequency domain. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: symbol [0..28*ofdm_symbol_size[ + int32_t **rxdataF; + + /// \brief Hold the channel estimates in frequency domain. + /// - first index: eNB id [0..6] (hard coded) + /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - third index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ + int32_t **dl_ch_estimates[7]; + + /// \brief Hold the channel estimates in time domain (used for tracking). + /// - first index: eNB id [0..6] (hard coded) + /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - third index: samples? [0..2*ofdm_symbol_size[ + int32_t **dl_ch_estimates_time[7]; +}LTE_UE_COMMON_PER_THREAD; + +typedef struct { + /// \brief Holds the transmit data in time domain. + /// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER. + /// - first index: tx antenna [0..nb_antennas_tx[ + /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES[ + int32_t **txdata; + /// \brief Holds the transmit data in the frequency domain. + /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. + /// - first index: tx antenna [0..nb_antennas_tx[ + /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX[ + int32_t **txdataF; + + /// \brief Holds the received data in time domain. + /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES+2048[ + int32_t **rxdata; + + LTE_UE_COMMON_PER_THREAD common_vars_rx_data_per_thread[RX_NB_TH_MAX]; + + /// holds output of the sync correlator + int32_t *sync_corr; + /// estimated frequency offset (in radians) for all subcarriers + int32_t freq_offset; + /// eNb_id user is synched to + int32_t eNb_id; +} LTE_UE_COMMON; + +typedef struct { + /// \brief Received frequency-domain signal after extraction. + /// - 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 Received frequency-domain ue specific pilots. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..12*N_RB_DL[ + int32_t **rxdataF_uespec_pilots; + /// \brief Received frequency-domain signal after extraction and channel compensation. + /// - 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 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_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)[ + int32_t **dl_bf_ch_estimates; + /// \brief Downlink beamforming channel estimates. + /// - 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; + /// \brief Magnitude of Downlink Channel first layer (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_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 Cross-correlation of two eNB signals. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: symbol [0..] + int32_t **rho; + /// never used... always send dl_ch_rho_ext instead... + int32_t **rho_i; + /// \brief Pointers to llr vectors (2 TBs). + /// - first index: ? [0..1] (hard coded) + /// - second index: ? [0..1179743] (hard coded) + int16_t *llr[2]; + /// \f$\log_2(\max|H_i|^2)\f$ + int16_t log2_maxh; + /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer1 channel compensation + int16_t log2_maxh0; + /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer2 channel commpensation + int16_t log2_maxh1; + /// \brief LLR shifts for subband scaling. + /// - first index: ? [0..168*N_RB_DL[ + uint8_t *llr_shifts; + /// \brief Pointer to LLR shifts. + /// - first index: ? [0..168*N_RB_DL[ + uint8_t *llr_shifts_p; + /// \brief Pointers to llr vectors (128-bit alignment). + /// - first index: ? [0..0] (hard coded) + /// - second index: ? [0..] + int16_t **llr128; + /// \brief Pointers to llr vectors (128-bit alignment). + /// - first index: ? [0..0] (hard coded) + /// - second index: ? [0..] + int16_t **llr128_2ndstream; + //uint32_t *rb_alloc; + //uint8_t Qm[2]; + //MIMO_mode_t mimo_mode; + // llr offset per ofdm symbol + uint32_t llr_offset[14]; + // llr length per ofdm symbol + uint32_t llr_length[14]; +} LTE_UE_PDSCH; + +typedef struct { + /// \brief Received frequency-domain signal after extraction. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + int32_t **rxdataF_ext; + /// \brief Received frequency-domain signal after extraction and channel compensation. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + double **rxdataF_comp; + /// \brief Downlink channel estimates extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + int32_t **dl_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..] + double **dl_ch_rho_ext; + /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. + /// - first index: ressource block [0..N_RB_DL[ + uint8_t *pmi_ext; + /// \brief Magnitude of Downlink Channel (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + double **dl_ch_mag; + /// \brief Magnitude of Downlink Channel (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..] + double **dl_ch_magb; + /// \brief Cross-correlation of two eNB signals. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..] + double **rho; + /// never used... always send dl_ch_rho_ext instead... + double **rho_i; + /// \brief Pointers to llr vectors (2 TBs). + /// - first index: ? [0..1] (hard coded) + /// - second index: ? [0..1179743] (hard coded) + int16_t *llr[2]; + /// \f$\log_2(\max|H_i|^2)\f$ + uint8_t log2_maxh; + /// \brief Pointers to llr vectors (128-bit alignment). + /// - first index: ? [0..0] (hard coded) + /// - second index: ? [0..] + int16_t **llr128; + //uint32_t *rb_alloc; + //uint8_t Qm[2]; + //MIMO_mode_t mimo_mode; +} LTE_UE_PDSCH_FLP; + +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 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-eNB 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-eNB 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[ + uint16_t *llr; + /// \brief Pointer to llrs, 16-bit resolution. + /// - first index: ? [0..96*N_RB_DL[ + uint16_t *llr16; + /// \brief \f$\overline{w}\f$ from 36-211. + /// - first index: ? [0..48*N_RB_DL[ + uint16_t *wbar; + /// \brief PDCCH/DCI e-sequence (input to rate matching). + /// - first index: ? [0..96*N_RB_DL[ + int8_t *e_rx; + /// number of PDCCH symbols in current subframe + uint8_t num_pdcch_symbols; + /// Allocated CRNTI for UE + uint16_t crnti; + /// 1: the allocated crnti is Temporary C-RNTI / 0: otherwise + uint8_t crnti_is_temporary; + /// Total number of PDU errors (diagnostic mode) + uint32_t dci_errors; + /// 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 PUCCH per subframe + uint8_t nCCE[10]; + //Check for specific DCIFormat and AgregationLevel + uint8_t dciFormat; + uint8_t agregationLevel; +} LTE_UE_PDCCH; + + +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 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 Pointer to PBCH llrs. + /// - first index: ? [0..1919] (hard coded) + int8_t *llr; + /// \brief Pointer to PBCH decoded output. + /// - first index: ? [0..63] (hard coded) + uint8_t *decoded_output; + /// \brief Total number of PDU errors. + uint32_t pdu_errors; + /// \brief Total number of PDU errors 128 frames ago. + uint32_t pdu_errors_last; + /// \brief Total number of consecutive PDU errors. + uint32_t pdu_errors_conseq; + /// \brief FER (in percent) . + uint32_t pdu_fer; +} LTE_UE_PBCH; + +typedef struct { + int16_t amp; + int16_t *prachF; + int16_t *prach; +} LTE_UE_PRACH; + + + +typedef enum { + /// do not detect any DCIs in the current subframe + NO_DCI = 0x0, + /// detect only downlink DCIs in the current subframe + UL_DCI = 0x1, + /// detect only uplink DCIs in the current subframe + DL_DCI = 0x2, + /// detect both uplink and downlink DCIs in the current subframe + UL_DL_DCI = 0x3} dci_detect_mode_t; + +typedef struct UE_SCAN_INFO_s { + /// 10 best amplitudes (linear) for each pss signals + int32_t amp[3][10]; + /// 10 frequency offsets (kHz) corresponding to best amplitudes, with respect do minimum DL frequency in the band + int32_t freq_offset_Hz[3][10]; +} UE_SCAN_INFO_t; + +/// Top-level PHY Data Structure for UE +typedef struct { + /// \brief Module ID indicator for this instance + uint8_t Mod_id; + /// \brief Component carrier ID for this PHY instance + uint8_t CC_id; + /// \brief Mapping of CC_id antennas to cards + openair0_rf_map rf_map; + //uint8_t local_flag; + /// \brief Indicator of current run mode of UE (normal_txrx, rx_calib_ue, no_L2_connect, debug_prach) + runmode_t mode; + /// \brief Indicator that UE should perform band scanning + int UE_scan; + /// \brief Indicator that UE should perform coarse scanning around carrier + int UE_scan_carrier; + /// \brief Indicator that UE is synchronized to an eNB + int is_synchronized; + /// Data structure for UE process scheduling + UE_proc_t proc; + /// Flag to indicate the UE shouldn't do timing correction at all + int no_timing_correction; + /// \brief Total gain of the TX chain (16-bit baseband I/Q to antenna) + uint32_t tx_total_gain_dB; + /// \brief Total gain of the RX chain (antenna to baseband I/Q) This is a function of rx_gain_mode (and the corresponding gain) and the rx_gain of the card. + uint32_t rx_total_gain_dB; + /// \brief Total gains with maximum RF gain stage (ExpressMIMO2/Lime) + uint32_t rx_gain_max[4]; + /// \brief Total gains with medium RF gain stage (ExpressMIMO2/Lime) + uint32_t rx_gain_med[4]; + /// \brief Total gains with bypassed RF gain stage (ExpressMIMO2/Lime) + uint32_t rx_gain_byp[4]; + /// \brief Current transmit power + int16_t tx_power_dBm[10]; + /// \brief Total number of REs in current transmission + int tx_total_RE[10]; + /// \brief Maximum transmit power + int8_t tx_power_max_dBm; + /// \brief Number of eNB seen by UE + uint8_t n_connected_eNB; + /// \brief indicator that Handover procedure has been initiated + uint8_t ho_initiated; + /// \brief indicator that Handover procedure has been triggered + uint8_t ho_triggered; + /// \brief Measurement variables. + PHY_MEASUREMENTS measurements; + LTE_DL_FRAME_PARMS frame_parms; + /// \brief Frame parame before ho used to recover if ho fails. + LTE_DL_FRAME_PARMS frame_parms_before_ho; + LTE_UE_COMMON common_vars; + + // point to the current rxTx thread index + uint8_t current_thread_id[10]; + + LTE_UE_PDSCH *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX+1]; // two RxTx Threads + LTE_UE_PDSCH_FLP *pdsch_vars_flp[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_SI[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_ra[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_p[NUMBER_OF_CONNECTED_eNB_MAX+1]; + LTE_UE_PDSCH *pdsch_vars_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][2]; // two RxTx Threads + LTE_UE_ULSCH_t *ulsch[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_eNB_MAX]; + LTE_UE_DLSCH_t *dlsch_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; + // This is for SIC in the UE, to store the reencoded data + LTE_eNB_DLSCH_t *dlsch_eNB[NUMBER_OF_CONNECTED_eNB_MAX]; + + //Paging parameters + uint32_t IMSImod1024; + uint32_t PF; + uint32_t PO; + + // For abstraction-purposes only + uint8_t sr[10]; + uint8_t pucch_sel[10]; + uint8_t pucch_payload[22]; + + UE_MODE_t UE_mode[NUMBER_OF_CONNECTED_eNB_MAX]; + /// cell-specific reference symbols + uint32_t lte_gold_table[7][20][2][14]; + + /// UE-specific reference symbols (p=5), TM 7 + uint32_t lte_gold_uespec_port5_table[20][38]; + + /// ue-specific reference symbols + uint32_t lte_gold_uespec_table[2][20][2][21]; + + /// mbsfn reference symbols + uint32_t lte_gold_mbsfn_table[10][3][42]; + + uint32_t X_u[64][839]; + + uint32_t high_speed_flag; + uint32_t perfect_ce; + int16_t ch_est_alpha; + int generate_ul_signal[NUMBER_OF_CONNECTED_eNB_MAX]; + + UE_SCAN_INFO_t scan_info[NB_BANDS_MAX]; + + char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX]; + + + + unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_eNB_MAX]; + uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_eNB_MAX]; + unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_eNB_MAX]; + PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_eNB_MAX]; + int turbo_iterations, turbo_cntl_iterations; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t total_TBS[NUMBER_OF_CONNECTED_eNB_MAX]; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t total_TBS_last[NUMBER_OF_CONNECTED_eNB_MAX]; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t bitrate[NUMBER_OF_CONNECTED_eNB_MAX]; + /// \brief ?. + /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) + uint32_t total_received_bits[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_errors_last[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_received_last[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_fer[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_SI_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_SI_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_ra_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_ra_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_p_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_p_errors[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mch_received_sf[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mch_received[NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mcch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mtch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mcch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mtch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mcch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int dlsch_mtch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; + int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX]; + unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX]; + uint8_t generate_prach; + uint8_t prach_cnt; + uint8_t prach_PreambleIndex; + // uint8_t prach_timer; + uint8_t decode_SIB; + uint8_t decode_MIB; + int rx_offset; /// Timing offset + int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP + int time_sync_cell; + int timing_advance; ///timing advance signalled from eNB + int hw_timing_advance; + int N_TA_offset; ///timing offset used in TDD + /// Flag to tell if UE is secondary user (cognitive mode) + unsigned char is_secondary_ue; + /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from. + unsigned char has_valid_precoder; + /// hold the precoder for NULL beam to the primary eNB + int **ul_precoder_S_UE; + /// holds the maximum channel/precoder coefficient + char log2_maxp; + + /// if ==0 enables phy only test mode + int mac_enabled; + + /// Flag to initialize averaging of PHY measurements + int init_averaging; + + /// \brief sinr for all subcarriers of the current link (used only for abstraction). + /// - first index: ? [0..12*N_RB_DL[ + double *sinr_dB; + + /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. + /// - first index: ? [0..12*N_RB_DL[ + double *sinr_CQI_dB; + + /// sinr_effective used for CQI calulcation + double sinr_eff; + + /// N0 (used for abstraction) + double N0; + + /// PDSCH Varaibles + PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// PUSCH Varaibles + PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// PUSCH contention-based access vars + PUSCH_CA_CONFIG_DEDICATED pusch_ca_config_dedicated[NUMBER_OF_eNB_MAX]; // lola + + /// PUCCH variables + + PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + uint8_t ncs_cell[20][7]; + + /// UL-POWER-Control + UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// TPC + TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_CONNECTED_eNB_MAX]; + TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// CQI reporting + CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// SRS Variables + SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// Scheduling Request Config + SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX]; + + /// Transmission mode per eNB + uint8_t transmission_mode[NUMBER_OF_CONNECTED_eNB_MAX]; + + time_stats_t phy_proc[RX_NB_TH]; + time_stats_t phy_proc_tx; + time_stats_t phy_proc_rx[RX_NB_TH]; + + uint32_t use_ia_receiver; + + time_stats_t ofdm_mod_stats; + time_stats_t ulsch_encoding_stats; + time_stats_t ulsch_modulation_stats; + time_stats_t ulsch_segmentation_stats; + time_stats_t ulsch_rate_matching_stats; + time_stats_t ulsch_turbo_encoding_stats; + time_stats_t ulsch_interleaving_stats; + time_stats_t ulsch_multiplexing_stats; + + time_stats_t generic_stat; + time_stats_t generic_stat_bis[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t ue_front_end_stat[RX_NB_TH]; + time_stats_t ue_front_end_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t pdcch_procedures_stat[RX_NB_TH]; + time_stats_t pdsch_procedures_stat[RX_NB_TH]; + time_stats_t pdsch_procedures_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t dlsch_procedures_stat[RX_NB_TH]; + + time_stats_t ofdm_demod_stats; + time_stats_t dlsch_rx_pdcch_stats; + time_stats_t rx_dft_stats; + time_stats_t dlsch_channel_estimation_stats; + time_stats_t dlsch_freq_offset_estimation_stats; + time_stats_t dlsch_decoding_stats[2]; + time_stats_t dlsch_demodulation_stats; + time_stats_t dlsch_rate_unmatching_stats; + time_stats_t dlsch_turbo_decoding_stats; + time_stats_t dlsch_deinterleaving_stats; + time_stats_t dlsch_llr_stats; + time_stats_t dlsch_llr_stats_parallelization[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t dlsch_unscrambling_stats; + time_stats_t dlsch_rate_matching_stats; + time_stats_t dlsch_turbo_encoding_stats; + time_stats_t dlsch_interleaving_stats; + time_stats_t dlsch_tc_init_stats; + time_stats_t dlsch_tc_alpha_stats; + time_stats_t dlsch_tc_beta_stats; + time_stats_t dlsch_tc_gamma_stats; + time_stats_t dlsch_tc_ext_stats; + time_stats_t dlsch_tc_intl1_stats; + time_stats_t dlsch_tc_intl2_stats; + time_stats_t tx_prach; + time_stats_t timer_stats; + + pthread_mutex_t timer_mutex; + pthread_cond_t timer_cond; + int instance_cnt_timer; + + /// RF and Interface devices per CC + + openair0_device rfdevice; +} PHY_VARS_UE; + +/* this structure is used to pass both UE phy vars and + * proc to the function UE_thread_rxn_txnp4 + */ +struct rx_tx_thread_data { + PHY_VARS_UE *UE; + UE_rxtx_proc_t *proc; +}; + + +#endif // __PHY_DEFS__H__ diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h new file mode 100644 index 0000000000000000000000000000000000000000..c253488a200b687ea107541f2991fd7d12cafd3d --- /dev/null +++ b/openair1/PHY/defs_common.h @@ -0,0 +1,1082 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/defs.h + \brief Top-level defines and structure definitions + \author R. Knopp, F. Kaltenberger + \date 2011 + \version 0.1 + \company Eurecom + \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr + \note + \warning +*/ +#ifndef __PHY_DEFS_COMMON_H__ +#define __PHY_DEFS_COMMON_H__ + + +#define _GNU_SOURCE +#include <sched.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/mman.h> +#include <linux/sched.h> +#include <signal.h> +#include <execinfo.h> +#include <getopt.h> +#include <sys/sysinfo.h> + + +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> +#include <string.h> +#include <math.h> +#include "common_lib.h" +#include "msc.h" + + +//#include <complex.h> + + + + + + + +#include "PHY/TOOLS/time_meas.h" +#include "platform_types.h" +#define MAX_NUM_RU_PER_eNB 64 + +#include <pthread.h> + +#include "targets/ARCH/COMMON/common_lib.h" +#include "targets/COMMON/openairinterface5g_limits.h" + +#include "types.h" +#include "nfapi_interface.h" +//#include "defs.h" +#include "openair2/COMMON/platform_types.h" + +#define RX_NB_TH_MAX 2 +#define RX_NB_TH 2 + +#define LTE_SLOTS_PER_SUBFRAME 2 + +#define LTE_NUMBER_OF_SUBFRAMES_PER_FRAME 10 +#define LTE_SLOTS_PER_FRAME 20 +#define LTE_CE_FILTER_LENGTH 5 +#define LTE_CE_OFFSET LTE_CE_FILTER_LENGTH +#define TX_RX_SWITCH_SYMBOL (NUMBER_OF_SYMBOLS_PER_FRAME>>1) +#define PBCH_PDU_SIZE 3 //bytes + +#define PRACH_SYMBOL 3 //position of the UL PSS wrt 2nd slot of special subframe + +#define NUMBER_OF_FREQUENCY_GROUPS (lte_frame_parms->N_RB_DL) + +#define SSS_AMP 1148 + +#define MAX_NUM_PHICH_GROUPS 56 //110 RBs Ng=2, p.60 36-212, Sec. 6.9 + +#define MAX_MBSFN_AREA 8 + +#define NB_RX_ANTENNAS_MAX 64 + +#ifdef OCP_FRAMEWORK +#include "enums.h" +#else +typedef enum {TDD=1,FDD=0} lte_frame_type_t; + +typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t; + +typedef enum {LOCALIZED=0,DISTRIBUTED=1} vrb_t; + +/// Enumeration for parameter PHICH-Duration \ref PHICH_CONFIG_COMMON::phich_duration. +typedef enum { + normal=0, + extended=1 +} PHICH_DURATION_t; + +/// Enumeration for parameter Ng \ref PHICH_CONFIG_COMMON::phich_resource. +typedef enum { + oneSixth=1, + half=3, + one=6, + two=12 +} PHICH_RESOURCE_t; +#endif +/// PHICH-Config from 36.331 RRC spec +typedef struct { + /// Parameter: PHICH-Duration, see TS 36.211 (Table 6.9.3-1). + PHICH_DURATION_t phich_duration; + /// Parameter: Ng, see TS 36.211 (6.9). \details Value oneSixth corresponds to 1/6, half corresponds to 1/2 and so on. + PHICH_RESOURCE_t phich_resource; +} PHICH_CONFIG_COMMON; + +/// PRACH-ConfigInfo from 36.331 RRC spec +typedef struct { + /// Parameter: prach-ConfigurationIndex, see TS 36.211 (5.7.1). \vr{[0..63]} + uint8_t prach_ConfigIndex; + /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. + uint8_t highSpeedFlag; + /// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. + uint8_t zeroCorrelationZoneConfig; + /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. + uint8_t prach_FreqOffset; +} PRACH_CONFIG_INFO; + + + +/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec +typedef struct { + /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} + uint16_t rootSequenceIndex; + /// prach_Config_enabled=1 means enabled. \vr{[0..1]} + uint8_t prach_Config_enabled; + /// PRACH Configuration Information + PRACH_CONFIG_INFO prach_ConfigInfo; +} PRACH_CONFIG_COMMON; + +#ifdef Rel14 + +/// PRACH-eMTC-Config from 36.331 RRC spec +typedef struct { + /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. + uint8_t highSpeedFlag; +/// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. + uint8_t zeroCorrelationZoneConfig; + /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. + + /// PRACH starting subframe periodicity, expressed in number of subframes available for preamble transmission (PRACH opportunities), see TS 36.211. Value 2 corresponds to 2 subframes, 4 corresponds to 4 subframes and so on. EUTRAN configures the PRACH starting subframe periodicity larger than or equal to the Number of PRACH repetitions per attempt for each CE level (numRepetitionPerPreambleAttempt). + uint8_t prach_starting_subframe_periodicity[4]; + /// number of repetitions per preamble attempt per CE level + uint8_t prach_numRepetitionPerPreambleAttempt[4]; + /// prach configuration index for each CE level + uint8_t prach_ConfigIndex[4]; + /// indicator for CE level activation + uint8_t prach_CElevel_enable[4]; + /// prach frequency offset for each CE level + uint8_t prach_FreqOffset[4]; + /// indicator for CE level hopping activation + uint8_t prach_hopping_enable[4]; + /// indicator for CE level hopping activation + uint8_t prach_hopping_offset[4]; +} PRACH_eMTC_CONFIG_INFO; + +/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec +typedef struct { + /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} + uint16_t rootSequenceIndex; + /// prach_Config_enabled=1 means enabled. \vr{[0..1]} + uint8_t prach_Config_enabled; + /// PRACH Configuration Information +#ifdef Rel14 + PRACH_eMTC_CONFIG_INFO prach_ConfigInfo; +#endif +} PRACH_eMTC_CONFIG_COMMON; + +#endif + +/// Enumeration for parameter \f$N_\text{ANRep}\f$ \ref PUCCH_CONFIG_DEDICATED::repetitionFactor. +typedef enum { + n2=0, + n4, + n6 +} ACKNAKREP_t; + +/// Enumeration for \ref PUCCH_CONFIG_DEDICATED::tdd_AckNackFeedbackMode. +typedef enum { + bundling=0, + multiplexing +} ANFBmode_t; + +/// PUCCH-ConfigDedicated from 36.331 RRC spec +typedef struct { + /// Flag to indicate ACK NAK repetition activation, see TS 36.213 (10.1). \vr{[0..1]} + uint8_t ackNackRepetition; + /// Parameter: \f$N_\text{ANRep}\f$, see TS 36.213 (10.1). + ACKNAKREP_t repetitionFactor; + /// Parameter: \f$n^{(1)}_\text{PUCCH,ANRep}\f$, see TS 36.213 (10.1). \vr{[0..2047]} + uint16_t n1PUCCH_AN_Rep; + /// Feedback mode, see TS 36.213 (7.3). \details Applied to both PUCCH and PUSCH feedback. For TDD, should always be set to bundling. + ANFBmode_t tdd_AckNackFeedbackMode; +} PUCCH_CONFIG_DEDICATED; + +/// PUCCH-ConfigCommon from 36.331 RRC spec +typedef struct { + /// Parameter: \f$\Delta^\text{PUCCH}_\text{shift}\f$, see TS 36.211 (5.4.1). \vr{[1..3]} \note the specification sais it is an enumerated value. + uint8_t deltaPUCCH_Shift; + /// Parameter: \f$N^{(2)}_\text{RB}\f$, see TS 36.211 (5.4). \vr{[0..98]} + uint8_t nRB_CQI; + /// Parameter: \f$N^{(1)}_\text{CS}\f$, see TS 36.211 (5.4). \vr{[0..7]} + uint8_t nCS_AN; + /// Parameter: \f$N^{(1)}_\text{PUCCH}\f$ see TS 36.213 (10.1). \vr{[0..2047]} + uint16_t n1PUCCH_AN; + + /// group hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. + uint8_t grouphop[20]; + /// sequence hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. + uint8_t seqhop[20]; +} PUCCH_CONFIG_COMMON; + +/// UL-ReferenceSignalsPUSCH from 36.331 RRC spec +typedef struct { + /// Parameter: Group-hopping-enabled, see TS 36.211 (5.5.1.3). \vr{[0..1]} + uint8_t groupHoppingEnabled; + /// Parameter: \f$\Delta SS\f$, see TS 36.211 (5.5.1.3). \vr{[0..29]} + uint8_t groupAssignmentPUSCH; + /// Parameter: Sequence-hopping-enabled, see TS 36.211 (5.5.1.4). \vr{[0..1]} + uint8_t sequenceHoppingEnabled; + /// Parameter: cyclicShift, see TS 36.211 (Table 5.5.2.1.1-2). \vr{[0..7]} + uint8_t cyclicShift; + /// nPRS for cyclic shift of DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. + uint8_t nPRS[20]; + /// group hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. + uint8_t grouphop[20]; + /// sequence hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. + uint8_t seqhop[20]; +} UL_REFERENCE_SIGNALS_PUSCH_t; + +/// Enumeration for parameter Hopping-mode \ref PUSCH_CONFIG_COMMON::hoppingMode. +#ifndef OCP_FRAMEWORK +typedef enum { + interSubFrame=0, + intraAndInterSubFrame=1 +} PUSCH_HOPPING_t; +#endif + +/// PUSCH-ConfigCommon from 36.331 RRC spec. +typedef struct { + /// Parameter: \f$N_{sb}\f$, see TS 36.211 (5.3.4). \vr{[1..4]} + uint8_t n_SB; + /// Parameter: Hopping-mode, see TS 36.211 (5.3.4). + PUSCH_HOPPING_t hoppingMode; + /// Parameter: \f$N^{HO}_{RB}\f$, see TS 36.211 (5.3.4). \vr{[0..98]} + uint8_t pusch_HoppingOffset; + /// See TS 36.213 (8.6.1). \vr{[0..1]} 1 indicates 64QAM is allowed, 0 not allowed. + uint8_t enable64QAM; + /// Ref signals configuration + UL_REFERENCE_SIGNALS_PUSCH_t ul_ReferenceSignalsPUSCH; +} PUSCH_CONFIG_COMMON; + +/// UE specific PUSCH configuration. +typedef struct { + /// Parameter: \f$I^\text{HARQ-ACK}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-1). \vr{[0..15]} + uint16_t betaOffset_ACK_Index; + /// Parameter: \f$I^{RI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-2). \vr{[0..15]} + uint16_t betaOffset_RI_Index; + /// Parameter: \f$I^{CQI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-3). \vr{[0..15]} + uint16_t betaOffset_CQI_Index; +} PUSCH_CONFIG_DEDICATED; + +/// lola CBA information +typedef struct { + /// + uint16_t betaOffset_CA_Index; + /// + uint16_t cShift; +} PUSCH_CA_CONFIG_DEDICATED; + +/// PDSCH-ConfigCommon from 36.331 RRC spec +typedef struct { + /// Parameter: Reference-signal power, see TS 36.213 (5.2). \vr{[-60..50]}\n Provides the downlink reference-signal EPRE. The actual value in dBm. + int8_t referenceSignalPower; + /// Parameter: \f$P_B\f$, see TS 36.213 (Table 5.2-1). \vr{[0..3]} + uint8_t p_b; +} PDSCH_CONFIG_COMMON; + +/// Enumeration for Parameter \f$P_A\f$ \ref PDSCH_CONFIG_DEDICATED::p_a. +typedef enum { + dBm6=0, ///< (dB-6) corresponds to -6 dB + dBm477, ///< (dB-4dot77) corresponds to -4.77 dB + dBm3, ///< (dB-3) corresponds to -3 dB + dBm177, ///< (dB-1dot77) corresponds to -1.77 dB + dB0, ///< corresponds to 0 dB + dB1, ///< corresponds to 1 dB + dB2, ///< corresponds to 2 dB + dB3 ///< corresponds to 3 dB +} PA_t; + +/// PDSCH-ConfigDedicated from 36.331 RRC spec +typedef struct { + /// Parameter: \f$P_A\f$, see TS 36.213 (5.2). + PA_t p_a; +} PDSCH_CONFIG_DEDICATED; + +/// SoundingRS-UL-ConfigCommon Information Element from 36.331 RRC spec +typedef struct { + /// enabled flag=1 means SRS is enabled. \vr{[0..1]} + uint8_t enabled_flag; + /// Parameter: SRS Bandwidth Configuration, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..7]}\n Actual configuration depends on UL bandwidth. \note the specification sais it is an enumerated value. + uint8_t srs_BandwidthConfig; + /// Parameter: SRS SubframeConfiguration, see TS 36.211 (table 5.5.3.3-1 for FDD, table 5.5.3.3-2 for TDD). \vr{[0..15]} \note the specification sais it is an enumerated value. + uint8_t srs_SubframeConfig; + /// Parameter: Simultaneous-AN-and-SRS, see TS 36.213 (8.2). \vr{[0..1]} + uint8_t ackNackSRS_SimultaneousTransmission; + /// Parameter: srsMaxUpPts, see TS 36.211 (5.5.3.2). \details If this field is present, reconfiguration of \f$m^\text{max}_\text{SRS,0}\f$ applies for UpPts, otherwise reconfiguration does not apply. + uint8_t srs_MaxUpPts; +} SOUNDINGRS_UL_CONFIG_COMMON; + +/// \note UNUSED +typedef enum { + ulpc_al0=0, + ulpc_al04=1, + ulpc_al05=2, + ulpc_al06=3, + ulpc_al07=4, + ulpc_al08=5, + ulpc_al09=6, + ulpc_al11=7 +} UL_POWER_CONTROL_COMMON_alpha_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1. +typedef enum { + deltaF_PUCCH_Format1_deltaF_2 = 0, + deltaF_PUCCH_Format1_deltaF0 = 1, + deltaF_PUCCH_Format1_deltaF2 = 2 +} deltaF_PUCCH_Format1_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1b. +typedef enum { + deltaF_PUCCH_Format1b_deltaF1 = 0, + deltaF_PUCCH_Format1b_deltaF3 = 1, + deltaF_PUCCH_Format1b_deltaF5 = 2 +} deltaF_PUCCH_Format1b_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2. +typedef enum { + deltaF_PUCCH_Format2_deltaF_2 = 0, + deltaF_PUCCH_Format2_deltaF0 = 1, + deltaF_PUCCH_Format2_deltaF1 = 2, + deltaF_PUCCH_Format2_deltaF2 = 3 +} deltaF_PUCCH_Format2_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2a. +typedef enum { + deltaF_PUCCH_Format2a_deltaF_2 = 0, + deltaF_PUCCH_Format2a_deltaF0 = 1, + deltaF_PUCCH_Format2a_deltaF2 = 2 +} deltaF_PUCCH_Format2a_t; + +/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2b. +typedef enum { + deltaF_PUCCH_Format2b_deltaF_2 = 0, + deltaF_PUCCH_Format2b_deltaF0 = 1, + deltaF_PUCCH_Format2b_deltaF2 = 2 +} deltaF_PUCCH_Format2b_t; + +/// DeltaFList-PUCCH from 36.331 RRC spec +typedef struct { + deltaF_PUCCH_Format1_t deltaF_PUCCH_Format1; + deltaF_PUCCH_Format1b_t deltaF_PUCCH_Format1b; + deltaF_PUCCH_Format2_t deltaF_PUCCH_Format2; + deltaF_PUCCH_Format2a_t deltaF_PUCCH_Format2a; + deltaF_PUCCH_Format2b_t deltaF_PUCCH_Format2b; +} deltaFList_PUCCH_t; + +/// SoundingRS-UL-ConfigDedicated Information Element from 36.331 RRC spec +typedef struct { + /// This descriptor is active + uint8_t active; + /// This descriptor's frame + uint16_t frame; + /// This descriptor's subframe + uint8_t subframe; + /// rnti + uint16_t rnti; + /// Parameter: \f$B_\text{SRS}\f$, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..3]} \note the specification sais it is an enumerated value. + uint8_t srs_Bandwidth; + /// Parameter: SRS hopping bandwidth \f$b_\text{hop}\in\{0,1,2,3\}\f$, see TS 36.211 (5.5.3.2) \vr{[0..3]} \note the specification sais it is an enumerated value. + uint8_t srs_HoppingBandwidth; + /// Parameter: \f$n_\text{RRC}\f$, see TS 36.211 (5.5.3.2). \vr{[0..23]} + uint8_t freqDomainPosition; + /// Parameter: Duration, see TS 36.213 (8.2). \vr{[0..1]} 0 corresponds to "single" and 1 to "indefinite". + uint8_t duration; + /// Parameter: \f$k_\text{TC}\in\{0,1\}\f$, see TS 36.211 (5.5.3.2). \vr{[0..1]} + uint8_t transmissionComb; + /// Parameter: \f$I_\text{SRS}\f$, see TS 36.213 (table 8.2-1). \vr{[0..1023]} + uint16_t srs_ConfigIndex; + /// Parameter: \f$n^\text{CS}_\text{SRS}\f$. See TS 36.211 (5.5.3.1). \vr{[0..7]} \note the specification sais it is an enumerated value. + uint8_t cyclicShift; + // Parameter: internal implementation: UE SRS configured + uint8_t srsConfigDedicatedSetup; + // Parameter: cell srs subframe for internal implementation + uint8_t srsCellSubframe; + // Parameter: ue srs subframe for internal implementation + uint8_t srsUeSubframe; +} SOUNDINGRS_UL_CONFIG_DEDICATED; + +/// UplinkPowerControlDedicated Information Element from 36.331 RRC spec +typedef struct { + /// Parameter: \f$P_\text{0\_UE\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dB. \vr{[-8..7]}\n This field is applicable for non-persistent scheduling, only. + int8_t p0_UE_PUSCH; + /// Parameter: Ks, see TS 36.213 (5.1.1.1). \vr{[0..1]}\n en0 corresponds to value 0 corresponding to state “disabledâ€. en1 corresponds to value 1.25 corresponding to “enabledâ€. \note the specification sais it is an enumerated value. \warning the enumeration values do not correspond to the given values in the specification (en1 should be 1.25). + uint8_t deltaMCS_Enabled; + /// Parameter: Accumulation-enabled, see TS 36.213 (5.1.1.1). \vr{[0..1]} 1 corresponds to "enabled" whereas 0 corresponds to "disabled". + uint8_t accumulationEnabled; + /// Parameter: \f$P_\text{0\_UE\_PUCCH}(1)\f$, see TS 36.213 (5.1.2.1), unit dB. \vr{[-8..7]} + int8_t p0_UE_PUCCH; + /// Parameter: \f$P_\text{SRS\_OFFSET}\f$, see TS 36.213 (5.1.3.1). \vr{[0..15]}\n For Ks=1.25 (\ref deltaMCS_Enabled), the actual parameter value is pSRS_Offset value - 3. For Ks=0, the actual parameter value is -10.5 + 1.5*pSRS_Offset value. + int8_t pSRS_Offset; + /// Specifies the filtering coefficient for RSRP measurements used to calculate path loss, as specified in TS 36.213 (5.1.1.1).\details The same filtering mechanism applies as for quantityConfig described in 5.5.3.2. \note the specification sais it is an enumerated value. + uint8_t filterCoefficient; +} UL_POWER_CONTROL_DEDICATED; + +#ifndef OCP_FRAMEWORK +/// Enumeration for parameter \f$\alpha\f$ \ref UL_POWER_CONTROL_CONFIG_COMMON::alpha. +typedef enum { + al0=0, + al04=1, + al05=2, + al06=3, + al07=4, + al08=5, + al09=6, + al1=7 +} PUSCH_alpha_t; +#endif + +/// \note UNUSED +typedef enum { + deltaFm2=0, + deltaF0, + deltaF1, + deltaF2, + deltaF3, + deltaF5 +} deltaF_PUCCH_t; + +/// UplinkPowerControlCommon Information Element from 36.331 RRC spec \note this structure does not currently make use of \ref deltaFList_PUCCH_t. +typedef struct { + /// Parameter: \f$P_\text{0\_NOMINAL\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dBm. \vr{[-126..24]}\n This field is applicable for non-persistent scheduling, only. + int8_t p0_NominalPUSCH; + /// Parameter: \f$\alpha\f$, see TS 36.213 (5.1.1.1) \warning the enumeration values do not correspond to the given values in the specification (al04 should be 0.4, ...)! + PUSCH_alpha_t alpha; + /// Parameter: \f$P_\text{0\_NOMINAL\_PUCCH}\f$ See TS 36.213 (5.1.2.1), unit dBm. \vr{[-127..-96]} + int8_t p0_NominalPUCCH; + /// Parameter: \f$\Delta_\text{PREAMBLE\_Msg3}\f$ see TS 36.213 (5.1.1.1). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. + int8_t deltaPreambleMsg3; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format1; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format1a; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format1b; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2, see TS 36.213 (5.1.2). \vr{[0..3]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format2; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format2a; + /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. + long deltaF_PUCCH_Format2b; +} UL_POWER_CONTROL_CONFIG_COMMON; + +/// Union for \ref TPC_PDCCH_CONFIG::tpc_Index. +typedef union { + /// Index of N when DCI format 3 is used. See TS 36.212 (5.3.3.1.6). \vr{[1..15]} + uint8_t indexOfFormat3; + /// Index of M when DCI format 3A is used. See TS 36.212 (5.3.3.1.7). \vr{[1..31]} + uint8_t indexOfFormat3A; +} TPC_INDEX_t; + +/// TPC-PDCCH-Config Information Element from 36.331 RRC spec +typedef struct { + /// RNTI for power control using DCI format 3/3A, see TS 36.212. \vr{[0..65535]} + uint16_t rnti; + /// Index of N or M, see TS 36.212 (5.3.3.1.6 and 5.3.3.1.7), where N or M is dependent on the used DCI format (i.e. format 3 or 3a). + TPC_INDEX_t tpc_Index; +} TPC_PDCCH_CONFIG; + +/// Enumeration for parameter SR transmission \ref SCHEDULING_REQUEST_CONFIG::dsr_TransMax. +typedef enum { + sr_n4=0, + sr_n8=1, + sr_n16=2, + sr_n32=3, + sr_n64=4 +} DSR_TRANSMAX_t; + +/// SchedulingRequestConfig Information Element from 36.331 RRC spec +typedef struct { + /// Parameter: \f$n^{(1)}_\text{PUCCH,SRI}\f$, see TS 36.213 (10.1). \vr{[0..2047]} + uint16_t sr_PUCCH_ResourceIndex; + /// Parameter: \f$I_\text{SR}\f$, see TS 36.213 (10.1). \vr{[0..155]} + uint8_t sr_ConfigIndex; + /// Parameter for SR transmission in TS 36.321 (5.4.4). \details The value n4 corresponds to 4 transmissions, n8 corresponds to 8 transmissions and so on. + DSR_TRANSMAX_t dsr_TransMax; +} SCHEDULING_REQUEST_CONFIG; + +/// CQI-ReportPeriodic +typedef struct { + /// Parameter: \f$n^{(2)}_\text{PUCCH}\f$, see TS 36.213 (7.2). \vr{[0..1185]}, -1 indicates inactivity + int16_t cqi_PUCCH_ResourceIndex; + /// Parameter: CQI/PMI Periodicity and Offset Configuration Index \f$I_\text{CQI/PMI}\f$, see TS 36.213 (tables 7.2.2-1A and 7.2.2-1C). \vr{[0..1023]} + int16_t cqi_PMI_ConfigIndex; + /// Parameter: K, see 36.213 (4.2.2). \vr{[1..4]} + uint8_t K; + /// Parameter: RI Config Index \f$I_\text{RI}\f$, see TS 36.213 (7.2.2-1B). \vr{[0..1023]}, -1 indicates inactivity + int16_t ri_ConfigIndex; + /// Parameter: Simultaneous-AN-and-CQI, see TS 36.213 (10.1). \vr{[0..1]} 1 indicates that simultaneous transmission of ACK/NACK and CQI is allowed. + uint8_t simultaneousAckNackAndCQI; + /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C + uint16_t Npd; + /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C + uint16_t N_OFFSET_CQI; +} CQI_REPORTPERIODIC; + +/// Enumeration for parameter reporting mode \ref CQI_REPORT_CONFIG::cqi_ReportModeAperiodic. +typedef enum { + rm12=0, + rm20=1, + rm22=2, + rm30=3, + rm31=4 +} CQI_REPORTMODEAPERIODIC; + +/// CQI-ReportConfig Information Element from 36.331 RRC spec +typedef struct { + /// Parameter: reporting mode. Value rm12 corresponds to Mode 1-2, rm20 corresponds to Mode 2-0, rm22 corresponds to Mode 2-2 etc. PUSCH reporting modes are described in TS 36.213 [23, 7.2.1]. + CQI_REPORTMODEAPERIODIC cqi_ReportModeAperiodic; + /// Parameter: \f$\Delta_\text{offset}\f$, see TS 36.213 (7.2.3). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. + int8_t nomPDSCH_RS_EPRE_Offset; + CQI_REPORTPERIODIC CQI_ReportPeriodic; +} CQI_REPORT_CONFIG; + +/// MBSFN-SubframeConfig Information Element from 36.331 RRC spec \note deviates from specification. +typedef struct { + /// MBSFN subframe occurance. \details Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. \note the specification sais it is an enumerated value {n1, n2, n4, n8, n16, n32}. + int radioframeAllocationPeriod; + /// MBSFN subframe occurance. \vr{[0..7]}\n Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. + int radioframeAllocationOffset; + /// oneFrame or fourFrames. \vr{[0..1]} + int fourFrames_flag; + /// Subframe configuration. \vr{[0..63]} (\ref fourFrames_flag == 0) or \vr{[0..16777215]} (\ref fourFrames_flag == 1) + /// \par fourFrames_flag == 0 + /// "1" denotes that the corresponding subframe is allocated for MBSFN. The following mapping applies:\n FDD: The first/leftmost bit defines the MBSFN allocation for subframe #1, the second bit for #2, third bit for #3 , fourth bit for #6, fifth bit for #7, sixth bit for #8.\n TDD: The first/leftmost bit defines the allocation for subframe #3, the second bit for #4, third bit for #7, fourth bit for #8, fifth bit for #9. Uplink subframes are not allocated. The last bit is not used. + /// \par fourFrames_flag == 1 + /// A bit-map indicating MBSFN subframe allocation in four consecutive radio frames, "1" denotes that the corresponding subframe is allocated for MBSFN. The bitmap is interpreted as follows:\n FDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #1, #2, #3 , #6, #7, and #8 in the sequence of the four radio-frames.\n TDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #3, #4, #7, #8, and #9 in the sequence of the four radio-frames. The last four bits are not used. Uplink subframes are not allocated. + int mbsfn_SubframeConfig; +} MBSFN_config_t; + +typedef struct { + /// Number of resource blocks (RB) in DL + uint8_t N_RB_DL; + /// Number of resource blocks (RB) in UL + uint8_t N_RB_UL; + /// EUTRA Band + uint8_t eutra_band; + /// DL carrier frequency + uint32_t dl_CarrierFreq; + /// UL carrier frequency + uint32_t ul_CarrierFreq; + /// TX attenuation + uint32_t att_tx; + /// RX attenuation + uint32_t att_rx; + /// total Number of Resource Block Groups: this is ceil(N_PRB/P) + uint8_t N_RBG; + /// Total Number of Resource Block Groups SubSets: this is P + uint8_t N_RBGS; + /// Cell ID + uint16_t Nid_cell; + /// MBSFN Area ID + uint16_t Nid_cell_mbsfn; + /// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP) + lte_prefix_type_t Ncp; + /// Cyclic Prefix for UL (0=Normal CP, 1=Extended CP) + lte_prefix_type_t Ncp_UL; + /// shift of pilot position in one RB + uint8_t nushift; + /// Frame type (0 FDD, 1 TDD) + lte_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) + uint8_t tdd_config_S; + /// srs extra symbol flag for TDD + uint8_t srsX; + /// indicates if node is a UE (NODE=2) or eNB (PRIMARY_CH=0). + uint8_t node_id; + /// Indicator that 20 MHz channel uses 3/4 sampling frequency + uint8_t threequarter_fs; + /// Size of FFT + uint16_t ofdm_symbol_size; + /// Number of prefix samples in all but first symbol of slot + uint16_t nb_prefix_samples; + /// Number of prefix samples in first symbol of slot + uint16_t nb_prefix_samples0; + /// Carrier offset in FFT buffer for first RE in PRB0 + uint16_t first_carrier_offset; + /// Number of samples in a subframe + uint32_t samples_per_tti; + /// Number of OFDM/SC-FDMA symbols in one subframe (to be modified to account for potential different in UL/DL) + uint16_t symbols_per_tti; + /// Number of OFDM symbols in DL portion of S-subframe + uint16_t dl_symbols_in_S_subframe; + /// Number of SC-FDMA symbols in UL portion of S-subframe + uint16_t ul_symbols_in_S_subframe; + /// Number of Physical transmit antennas in node + uint8_t nb_antennas_tx; + /// Number of Receive antennas in node + uint8_t nb_antennas_rx; + /// Number of common transmit antenna ports in eNodeB (1 or 2) + uint8_t nb_antenna_ports_eNB; + /// PRACH_CONFIG + PRACH_CONFIG_COMMON prach_config_common; +#ifdef Rel14 + /// PRACH_eMTC_CONFIG + PRACH_eMTC_CONFIG_COMMON prach_emtc_config_common; +#endif + /// PUCCH Config Common (from 36-331 RRC spec) + PUCCH_CONFIG_COMMON pucch_config_common; + /// PDSCH Config Common (from 36-331 RRC spec) + PDSCH_CONFIG_COMMON pdsch_config_common; + /// PUSCH Config Common (from 36-331 RRC spec) + PUSCH_CONFIG_COMMON pusch_config_common; + /// PHICH Config (from 36-331 RRC spec) + PHICH_CONFIG_COMMON phich_config_common; + /// SRS Config (from 36-331 RRC spec) + SOUNDINGRS_UL_CONFIG_COMMON soundingrs_ul_config_common; + /// UL Power Control (from 36-331 RRC spec) + UL_POWER_CONTROL_CONFIG_COMMON ul_power_control_config_common; + /// Number of MBSFN Configurations + int num_MBSFN_config; + /// Array of MBSFN Configurations (max 8 (maxMBSFN-Allocations) elements as per 36.331) + MBSFN_config_t MBSFN_config[8]; + /// Maximum Number of Retransmissions of RRCConnectionRequest (from 36-331 RRC Spec) + uint8_t maxHARQ_Msg3Tx; + /// Size of SI windows used for repetition of one SI message (in frames) + uint8_t SIwindowsize; + /// Period of SI windows used for repetition of one SI message (in frames) + uint16_t SIPeriod; + /// REGs assigned to PCFICH + uint16_t pcfich_reg[4]; + /// Index of first REG assigned to PCFICH + uint8_t pcfich_first_reg_idx; + /// REGs assigned to PHICH + uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; + + struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[MAX_MBSFN_AREA]; + +} LTE_DL_FRAME_PARMS; + +typedef enum { + /// TM1 + SISO=0, + /// TM2 + ALAMOUTI=1, + /// TM3 + LARGE_CDD=2, + /// the next 6 entries are for TM5 + UNIFORM_PRECODING11=3, + UNIFORM_PRECODING1m1=4, + UNIFORM_PRECODING1j=5, + UNIFORM_PRECODING1mj=6, + PUSCH_PRECODING0=7, + PUSCH_PRECODING1=8, + /// the next 3 entries are for TM4 + DUALSTREAM_UNIFORM_PRECODING1=9, + DUALSTREAM_UNIFORM_PRECODINGj=10, + DUALSTREAM_PUSCH_PRECODING=11, + TM7=12, + TM8=13, + TM9_10=14 +} MIMO_mode_t; + + +typedef enum { + /// MRT + MRT=0, + /// ZF + ZF=1, + /// MMSE + MMSE=2 +} PRECODE_TYPE_t; + +typedef enum {format0, + format1, + format1A, + format1B, + format1C, + format1D, + format1E_2A_M10PRB, + format2, + format2A, + format2B, + format2C, + format2D, + format3, + format3A, + format4, + format5, + format6_0A, + format6_0B, + format6_1A, + format6_1B, + format6_2 + } DCI_format_t; + +typedef struct { + /// Length of DCI in bits + uint8_t dci_length; + /// Aggregation level + uint8_t L; + /// Position of first CCE of the dci + int firstCCE; + /// flag to indicate that this is a RA response + boolean_t ra_flag; + /// rnti + rnti_t rnti; + /// harq_pid + rnti_t harq_pid; + /// Format + DCI_format_t format; + /// DCI pdu + uint8_t dci_pdu[8]; +} DCI_ALLOC_t; + +#define MAX_EPDCCH_PRB 8 + +typedef struct { + /// Length of DCI in bits + uint8_t dci_length; + /// Aggregation level + uint8_t L; + /// Position of first CCE of the dci + int firstCCE; + /// flag to indicate that this is a RA response + boolean_t ra_flag; + /// rnti + rnti_t rnti; + /// Format + DCI_format_t format; + /// epdcch resource assignment (0=localized,1=distributed) + uint8_t epdcch_resource_assignment_flag; + /// epdcch index + uint16_t epdcch_id; + /// epdcch start symbol + uint8_t epdcch_start_symbol; + /// epdcch number of PRBs in set + uint8_t epdcch_num_prb; + /// vector of prb ids for set + uint8_t epdcch_prb_index[MAX_EPDCCH_PRB]; + /// LBT parameter for frame configuration + uint8_t dwpts_symbols; + /// LBT parameter for frame configuration + uint8_t initial_lbt_sf; + /// DCI pdu + uint8_t dci_pdu[8]; +} eDCI_ALLOC_t; + +typedef struct { + /// Length of DCI in bits + uint8_t dci_length; + /// Aggregation level + uint8_t L; + /// Position of first CCE of the dci + int firstCCE; + /// flag to indicate that this is a RA response + boolean_t ra_flag; + /// rnti + rnti_t rnti; + /// Format + DCI_format_t format; + /// harq process index + uint8_t harq_pid; + /// Narrowband index + uint8_t narrowband; + /// number of PRB pairs for MPDCCH + uint8_t number_of_prb_pairs; + /// mpdcch resource assignment (combinatorial index r) + uint8_t resource_block_assignment; + /// transmission type (0=localized,1=distributed) + uint8_t transmission_type; + /// mpdcch start symbol + uint8_t start_symbol; + /// CE mode (1=ModeA,2=ModeB) + uint8_t ce_mode; + /// 0-503 n_EPDCCHid_i + uint16_t dmrs_scrambling_init; + /// Absolute subframe of the initial transmission (0-10239) + uint16_t i0; + /// number of mdpcch repetitions + uint16_t reps; + /// current absolute subframe number + uint16_t absSF; + /// DCI pdu + uint8_t dci_pdu[8]; +} mDCI_ALLOC_t; + +typedef struct { + /// Preamble index for PRACH (0-63) + uint8_t ra_PreambleIndex; + /// RACH MaskIndex + uint8_t ra_RACH_MaskIndex; + /// Target received power at eNB (-120 ... -82 dBm) + int8_t ra_PREAMBLE_RECEIVED_TARGET_POWER; + /// PRACH index for TDD (0 ... 6) depending on TDD configuration and prachConfigIndex + uint8_t ra_TDD_map_index; + /// Corresponding RA-RNTI for UL-grant + uint16_t ra_RNTI; + /// Pointer to Msg3 payload for UL-grant + uint8_t *Msg3; +} PRACH_RESOURCES_t; + + +typedef struct { + /// Downlink Power offset field + uint8_t dl_pow_off; + ///Subband resource allocation field + uint8_t rballoc_sub[50]; + ///Total number of PRBs indicator + uint8_t pre_nb_available_rbs; +} MU_MIMO_mode; + +typedef enum { + NOT_SYNCHED=0, + PRACH=1, + RA_RESPONSE=2, + PUSCH=3, + RESYNCH=4 +} UE_MODE_t; + + + +typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; + +#define NUMBER_OF_SUBBANDS_MAX 13 +#define NUMBER_OF_HARQ_PID_MAX 8 + +#define MAX_FRAME_NUMBER 0x400 + + + +#define NUMBER_OF_RN_MAX 3 +typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_relay} relaying_type_t; + + + +#define MCS_COUNT 28 +#define MCS_TABLE_LENGTH_MAX 64 + + +#define NUM_DCI_MAX 32 + +#define NUMBER_OF_eNB_SECTORS_MAX 3 + +#define NB_BANDS_MAX 8 + +#define MAX_BANDS_PER_RRU 4 + + +#ifdef OCP_FRAMEWORK +#include <enums.h> +#else +typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t; + +/*! \brief Extension Type */ +typedef enum { + CYCLIC_PREFIX, + CYCLIC_SUFFIX, + ZEROS, + NONE +} Extension_t; + +enum transmission_access_mode { + NO_ACCESS=0, + POSTPONED_ACCESS, + CANCELED_ACCESS, + UNKNOWN_ACCESS, + SCHEDULED_ACCESS, + CBA_ACCESS}; + +typedef enum { + eNodeB_3GPP=0, // classical eNodeB function + NGFI_RAU_IF5, // RAU with NGFI IF5 + NGFI_RAU_IF4p5, // RAU with NFGI IF4p5 + NGFI_RRU_IF5, // NGFI_RRU (NGFI remote radio-unit,IF5) + NGFI_RRU_IF4p5, // NGFI_RRU (NGFI remote radio-unit,IF4p5) + MBP_RRU_IF5 // Mobipass RRU +} node_function_t; + +typedef enum { + + synch_to_ext_device=0, // synch to RF or Ethernet device + synch_to_other, // synch to another source_(timer, other RU) + synch_to_mobipass_standalone // special case for mobipass in standalone mode +} node_timing_t; +#endif + + +void exit_fun(const char* s); + +#include "UTIL/LOG/log_extern.h" +extern pthread_cond_t sync_cond; +extern pthread_mutex_t sync_mutex; +extern int sync_var; + + +#define MODE_DECODE_NONE 0 +#define MODE_DECODE_SSE 1 +#define MODE_DECODE_C 2 +#define MODE_DECODE_AVX2 3 + +#define DECODE_INITTD8_SSE_FPTRIDX 0 +#define DECODE_INITTD16_SSE_FPTRIDX 1 +#define DECODE_INITTD_AVX2_FPTRIDX 2 +#define DECODE_TD8_SSE_FPTRIDX 3 +#define DECODE_TD16_SSE_FPTRIDX 4 +#define DECODE_TD_C_FPTRIDX 5 +#define DECODE_TD16_AVX2_FPTRIDX 6 +#define DECODE_FREETD8_FPTRIDX 7 +#define DECODE_FREETD16_FPTRIDX 8 +#define DECODE_FREETD_AVX2_FPTRIDX 9 +#define ENCODE_SSE_FPTRIDX 10 +#define ENCODE_C_FPTRIDX 11 +#define ENCODE_INIT_SSE_FPTRIDX 12 +#define DECODE_NUM_FPTR 13 + + +typedef uint8_t(*decoder_if_t)(int16_t *y, + int16_t *y2, + uint8_t *decoded_bytes, + uint8_t *decoded_bytes2, + uint16_t n, + uint16_t f1, + uint16_t f2, + uint8_t max_iterations, + uint8_t crc_type, + uint8_t F, + time_stats_t *init_stats, + time_stats_t *alpha_stats, + time_stats_t *beta_stats, + time_stats_t *gamma_stats, + time_stats_t *ext_stats, + time_stats_t *intl1_stats, + time_stats_t *intl2_stats); + +typedef uint8_t(*encoder_if_t)(uint8_t *input, + uint16_t input_length_bytes, + uint8_t *output, + uint8_t F, + uint16_t interleaver_f1, + uint16_t interleaver_f2); + + +static inline void wait_sync(char *thread_name) { + + printf( "waiting for sync (%s)\n",thread_name); + pthread_mutex_lock( &sync_mutex ); + + while (sync_var<0) + pthread_cond_wait( &sync_cond, &sync_mutex ); + + pthread_mutex_unlock(&sync_mutex); + + printf( "got sync (%s)\n", thread_name); + +} + +static inline int wakeup_thread(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { + + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + *instance_cnt = *instance_cnt + 1; + // the thread can now be woken up + if (pthread_cond_signal(cond) != 0) { + LOG_E( PHY, "ERROR pthread_cond_signal\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock(mutex); + return(0); +} + +static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + + while (*instance_cnt < 0) { + // most of the time the thread is waiting here + // proc->instance_cnt_rxtx is -1 + pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again + } + + if (pthread_mutex_unlock(mutex) != 0) { + LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + return(0); +} + +static inline int wait_on_busy_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { + + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + + while (*instance_cnt == 0) { + // most of the time the thread will skip this + // waits only if proc->instance_cnt_rxtx is 0 + pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again + } + + if (pthread_mutex_unlock(mutex) != 0) { + LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + return(0); +} + +static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *name) { + + if (pthread_mutex_lock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + + *instance_cnt=*instance_cnt-1; + + if (pthread_mutex_unlock(mutex) != 0) { + LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for %s\n",name); + exit_fun("nothing to add"); + return(-1); + } + return(0); +} + + +#endif // __PHY_DEFS__H__ diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs_eNB.h similarity index 52% rename from openair1/PHY/defs.h rename to openair1/PHY/defs_eNB.h index 9ca33c9404d610cc29d4c1eac6f9210147db6790..828169030735f1781fda77f7d72f35e17badf325 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs_eNB.h @@ -19,8 +19,8 @@ * contact@openairinterface.org */ -/*! \file PHY/defs.h - \brief Top-level defines and structure definitions +/*! \file PHY/defs_eNB.h + \brief Top-level defines and structure definitions for eNB \author R. Knopp, F. Kaltenberger \date 2011 \version 0.1 @@ -29,8 +29,8 @@ \note \warning */ -#ifndef __PHY_DEFS__H__ -#define __PHY_DEFS__H__ +#ifndef __PHY_DEFS_ENB__H__ +#define __PHY_DEFS_ENB__H__ #define _GNU_SOURCE @@ -57,235 +57,20 @@ #include "common_lib.h" #include "msc.h" -#include "openair2/PHY_INTERFACE/IF_Module.h" - -//#include <complex.h> -#include "assertions.h" -#ifdef MEX -# define msg mexPrintf -#endif -//use msg in the real-time thread context -#define msg_nrt printf -//use msg_nrt in the non real-time context (for initialization, ...) -#ifndef malloc16 -# ifdef __AVX2__ -# define malloc16(x) memalign(32,x) -# else -# define malloc16(x) memalign(16,x) -# endif -#endif -#define free16(y,x) free(y) -#define bigmalloc malloc -#define bigmalloc16 malloc16 -#define openair_free(y,x) free((y)) -#define PAGE_SIZE 4096 -#define free_and_zero(PtR) do { \ - if (PtR) { \ - free(PtR); \ - PtR = NULL; \ - } \ - } while (0) - -#define RX_NB_TH_MAX 2 -#define RX_NB_TH 2 - - -//! \brief Allocate \c size bytes of memory on the heap with alignment 16 and zero it afterwards. -//! If no more memory is available, this function will terminate the program with an assertion error. -static inline void* malloc16_clear( size_t size ) -{ -#ifdef __AVX2__ - void* ptr = memalign(32, size); -#else - void* ptr = memalign(16, size); -#endif - DevAssert(ptr); - memset( ptr, 0, size ); - return ptr; -} - - - -#define PAGE_MASK 0xfffff000 -#define virt_to_phys(x) (x) - -#define openair_sched_exit() exit(-1) - - -#define max(a,b) ((a)>(b) ? (a) : (b)) -#define min(a,b) ((a)<(b) ? (a) : (b)) - - -#define bzero(s,n) (memset((s),0,(n))) - -#define cmax(a,b) ((a>b) ? (a) : (b)) -#define cmin(a,b) ((a<b) ? (a) : (b)) - -#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) - -/// suppress compiler warning for unused arguments -#define UNUSED(x) (void)x; - +#include "defs_common.h" #include "impl_defs_top.h" -#include "impl_defs_lte.h" - #include "PHY/TOOLS/time_meas.h" -#include "PHY/CODING/defs.h" -#include "PHY/TOOLS/defs.h" +//#include "PHY/CODING/coding_defs.h" +#include "PHY/TOOLS/tools_defs.h" #include "platform_types.h" -#define MAX_NUM_RU_PER_eNB 64 - -#include "PHY/LTE_TRANSPORT/defs.h" +#include "PHY/LTE_TRANSPORT/transport_common.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" #include <pthread.h> -#include "targets/ARCH/COMMON/common_lib.h" -#include "targets/COMMON/openairinterface5g_limits.h" - -#if defined(EXMIMO) || defined(OAI_USRP) -//#define NUMBER_OF_eNB_MAX 1 -//#define NUMBER_OF_UE_MAX 16 - -//#define NUMBER_OF_CONNECTED_eNB_MAX 3 -#else -#ifdef LARGE_SCALE -//#define NUMBER_OF_eNB_MAX 2 -//#define NUMBER_OF_UE_MAX 120 -//#define NUMBER_OF_CONNECTED_eNB_MAX 1 // to save some memory -#else -//#define NUMBER_OF_eNB_MAX 3 -//#define NUMBER_OF_UE_MAX 16 -//#define NUMBER_OF_RU_MAX 64 -//#define NUMBER_OF_CONNECTED_eNB_MAX 1 -#endif -#endif -#define NUMBER_OF_SUBBANDS_MAX 13 -#define NUMBER_OF_HARQ_PID_MAX 8 - -#define MAX_FRAME_NUMBER 0x400 - - - -#define NUMBER_OF_RN_MAX 3 -typedef enum {no_relay=1,unicast_relay_type1,unicast_relay_type2, multicast_relay} relaying_type_t; - - - -#define MCS_COUNT 28 -#define MCS_TABLE_LENGTH_MAX 64 - - -#define NUM_DCI_MAX 32 - -#define NUMBER_OF_eNB_SECTORS_MAX 3 - -#define NB_BANDS_MAX 8 - -#define MAX_BANDS_PER_RRU 4 - - -#ifdef OCP_FRAMEWORK -#include <enums.h> -#else -typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t; - -/*! \brief Extension Type */ -typedef enum { - CYCLIC_PREFIX, - CYCLIC_SUFFIX, - ZEROS, - NONE -} Extension_t; - -enum transmission_access_mode { - NO_ACCESS=0, - POSTPONED_ACCESS, - CANCELED_ACCESS, - UNKNOWN_ACCESS, - SCHEDULED_ACCESS, - CBA_ACCESS}; - -typedef enum { - eNodeB_3GPP=0, // classical eNodeB function - NGFI_RAU_IF5, // RAU with NGFI IF5 - NGFI_RAU_IF4p5, // RAU with NFGI IF4p5 - NGFI_RRU_IF5, // NGFI_RRU (NGFI remote radio-unit,IF5) - NGFI_RRU_IF4p5, // NGFI_RRU (NGFI remote radio-unit,IF4p5) - MBP_RRU_IF5 // Mobipass RRU -} node_function_t; - -typedef enum { - - synch_to_ext_device=0, // synch to RF or Ethernet device - synch_to_other, // synch to another source_(timer, other RU) - synch_to_mobipass_standalone // special case for mobipass in standalone mode -} node_timing_t; -#endif - -typedef struct UE_SCAN_INFO_s { - /// 10 best amplitudes (linear) for each pss signals - int32_t amp[3][10]; - /// 10 frequency offsets (kHz) corresponding to best amplitudes, with respect do minimum DL frequency in the band - int32_t freq_offset_Hz[3][10]; -} UE_SCAN_INFO_t; - -/// Top-level PHY Data Structure for RN -typedef struct { - /// Module ID indicator for this instance - uint8_t Mod_id; - uint32_t frame; - // phy_vars_eNB - // phy_vars ue - // cuurently only used to store and forward the PMCH - uint8_t mch_avtive[10]; - uint8_t sync_area[10]; // num SF - LTE_UE_DLSCH_t *dlsch_rn_MCH[10]; - -} PHY_VARS_RN; - -/// Context data structure for RX/TX portion of subframe processing -typedef struct { - /// Component Carrier index - uint8_t CC_id; - /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; - /// subframe to act upon for transmission - int subframe_tx; - /// subframe to act upon for reception - int subframe_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for reception - int frame_rx; - /// \brief Instance count for RXn-TXnp4 processing thread. - /// \internal This variable is protected by \ref mutex_rxtx. - int instance_cnt_rxtx; - /// pthread structure for RXn-TXnp4 processing thread - pthread_t pthread_rxtx; - /// pthread attributes for RXn-TXnp4 processing thread - pthread_attr_t attr_rxtx; - /// condition variable for tx processing thread - pthread_cond_t cond_rxtx; - /// mutex for RXn-TXnp4 processing thread - pthread_mutex_t mutex_rxtx; - /// scheduling parameters for RXn-TXnp4 thread - struct sched_param sched_param_rxtx; -} eNB_rxtx_proc_t; -typedef struct { - struct PHY_VARS_eNB_s *eNB; - int UE_id; - int harq_pid; - int llr8_flag; - int ret; -} td_params; +#include "openair2/PHY_INTERFACE/IF_Module.h" -typedef struct { - struct PHY_VARS_eNB_s *eNB; - LTE_eNB_DLSCH_t *dlsch; - int G; - int harq_pid; -} te_params; typedef struct RU_proc_t_s { /// Pointer to associated RU descriptor @@ -300,7 +85,7 @@ typedef struct RU_proc_t_s { int subframe_tx; /// subframe to act upon for reception of prach int subframe_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// subframe to act upon for reception of prach BL/CE UEs int subframe_prach_br; #endif @@ -312,7 +97,7 @@ typedef struct RU_proc_t_s { int frame_tx_unwrap; /// frame to act upon for reception of prach int frame_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// frame to act upon for reception of prach int frame_prach_br; #endif @@ -321,9 +106,10 @@ typedef struct RU_proc_t_s { /// \brief Instance count for FH processing thread. /// \internal This variable is protected by \ref mutex_FH. int instance_cnt_FH; + int instance_cnt_FH1; /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach_br; #endif @@ -336,13 +122,16 @@ typedef struct RU_proc_t_s { int instance_cnt_asynch_rxtx; /// \internal This variable is protected by \ref mutex_fep int instance_cnt_fep; - /// \internal This variable is protected by \ref mutex_fep + /// \internal This variable is protected by \ref mutex_feptx int instance_cnt_feptx; + /// This varible is protected by \ref mutex_emulatedRF + int instance_cnt_emulateRF; /// pthread structure for RU FH processing thread pthread_t pthread_FH; + pthread_t pthread_FH1; /// pthread structure for RU prach processing thread pthread_t pthread_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// pthread structure for RU prach processing thread BL/CE UEs pthread_t pthread_prach_br; #endif @@ -350,8 +139,10 @@ typedef struct RU_proc_t_s { pthread_t pthread_synch; /// pthread struct for RU RX FEP worker thread pthread_t pthread_fep; - /// pthread struct for RU RX FEPTX worker thread + /// pthread struct for RU TX FEP worker thread pthread_t pthread_feptx; + /// pthread struct for emulated RF + pthread_t pthread_emulateRF; /// pthread structure for asychronous RX/TX processing thread pthread_t pthread_asynch_rxtx; /// flag to indicate first RX acquisition @@ -360,9 +151,10 @@ typedef struct RU_proc_t_s { int first_tx; /// pthread attributes for RU FH processing thread pthread_attr_t attr_FH; + pthread_attr_t attr_FH1; /// pthread attributes for RU prach pthread_attr_t attr_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// pthread attributes for RU prach BL/CE UEs pthread_attr_t attr_prach_br; #endif @@ -374,11 +166,14 @@ typedef struct RU_proc_t_s { pthread_attr_t attr_fep; /// pthread attributes for worker feptx thread pthread_attr_t attr_feptx; + /// pthread attributes for emulated RF + pthread_attr_t attr_emulateRF; /// scheduling parameters for RU FH thread struct sched_param sched_param_FH; + struct sched_param sched_param_FH1; /// scheduling parameters for RU prach thread struct sched_param sched_param_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// scheduling parameters for RU prach thread BL/CE UEs struct sched_param sched_param_prach_br; #endif @@ -388,9 +183,10 @@ typedef struct RU_proc_t_s { struct sched_param sched_param_asynch_rxtx; /// condition variable for RU FH thread pthread_cond_t cond_FH; + pthread_cond_t cond_FH1; /// condition variable for RU prach thread pthread_cond_t cond_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// condition variable for RU prach thread BL/CE UEs pthread_cond_t cond_prach_br; #endif @@ -398,17 +194,20 @@ typedef struct RU_proc_t_s { pthread_cond_t cond_synch; /// condition variable for asynch RX/TX thread pthread_cond_t cond_asynch_rxtx; - /// condition varaible for RU RX FEP thread + /// condition varible for RU RX FEP thread pthread_cond_t cond_fep; - /// condition varaible for RU RX FEPTX thread + /// condition varible for RU TX FEP thread pthread_cond_t cond_feptx; + /// condition varible for emulated RF + pthread_cond_t cond_emulateRF; /// condition variable for eNB signal pthread_cond_t cond_eNBs; /// mutex for RU FH pthread_mutex_t mutex_FH; + pthread_mutex_t mutex_FH1; /// mutex for RU prach pthread_mutex_t mutex_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// mutex for RU prach BL/CE UEs pthread_mutex_t mutex_prach_br; #endif @@ -422,153 +221,391 @@ typedef struct RU_proc_t_s { pthread_mutex_t mutex_fep; /// mutex for fep TX worker thread pthread_mutex_t mutex_feptx; + /// mutex for emulated RF thread + pthread_mutex_t mutex_emulateRF; /// symbol mask for IF4p5 reception per subframe uint32_t symbol_mask[10]; /// number of slave threads int num_slaves; /// array of pointers to slaves struct RU_proc_t_s **slave_proc; + /// pipeline ready state + int ru_rx_ready; + int ru_tx_ready; } RU_proc_t; -/// Context data structure for eNB subframe processing -typedef struct eNB_proc_t_s { - /// Component Carrier index - uint8_t CC_id; - /// thread index - int thread_index; - /// timestamp received from HW - openair0_timestamp timestamp_rx; - /// timestamp to send to "slave rru" - openair0_timestamp timestamp_tx; - /// subframe to act upon for reception - int subframe_rx; - /// subframe to act upon for PRACH - int subframe_prach; -#ifdef Rel14 - /// subframe to act upon for reception of prach BL/CE UEs - int subframe_prach_br; -#endif - /// frame to act upon for reception - int frame_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for PRACH - int frame_prach; -#ifdef Rel14 - /// frame to act upon for PRACH BL/CE UEs - int frame_prach_br; -#endif - /// \internal This variable is protected by \ref mutex_td. - int instance_cnt_td; - /// \internal This variable is protected by \ref mutex_te. - int instance_cnt_te; - /// \internal This variable is protected by \ref mutex_prach. - int instance_cnt_prach; -#ifdef Rel14 - /// \internal This variable is protected by \ref mutex_prach for BL/CE UEs. - int instance_cnt_prach_br; -#endif - // instance count for over-the-air eNB 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 - pthread_t pthread_single; - /// pthread structure for asychronous RX/TX processing thread - pthread_t pthread_asynch_rxtx; - /// flag to indicate first RX acquisition - int first_rx; - /// flag to indicate first TX transmission - int first_tx; - /// pthread attributes for parallel turbo-decoder thread - pthread_attr_t attr_td; - /// pthread attributes for parallel turbo-encoder thread - pthread_attr_t attr_te; - /// pthread attributes for single eNB processing thread - pthread_attr_t attr_single; - /// pthread attributes for prach processing thread - pthread_attr_t attr_prach; +typedef enum { + LOCAL_RF =0, + REMOTE_IF5 =1, + REMOTE_MBP_IF5 =2, + REMOTE_IF4p5 =3, + REMOTE_IF1pp =4, + MAX_RU_IF_TYPES =5 + //EMULATE_RF =6 +} RU_if_south_t; + +typedef struct RU_t_s{ + /// index of this ru + uint32_t idx; + /// Pointer to configuration file + char *rf_config_file; + /// southbound interface + RU_if_south_t if_south; + /// timing + node_timing_t if_timing; + /// function + node_function_t function; + /// Ethernet parameters for fronthaul interface + eth_params_t eth_params; + /// flag to indicate the RU is in synch with a master reference + int in_synch; + /// timing offset + int rx_offset; + /// flag to indicate the RU is a slave to another source + int is_slave; + /// Total gain of receive chain + uint32_t rx_total_gain_dB; + /// number of bands that this device can support + int num_bands; + /// band list + int band[MAX_BANDS_PER_RRU]; + /// number of RX paths on device + int nb_rx; + /// number of TX paths on device + int nb_tx; + /// maximum PDSCH RS EPRE + int max_pdschReferenceSignalPower; + /// maximum RX gain + int max_rxgain; + /// Attenuation of RX paths on device + int att_rx; + /// Attenuation of TX paths on device + int att_tx; + /// flag to indicate precoding operation in RU + int do_precoding; + /// Frame parameters + LTE_DL_FRAME_PARMS frame_parms; + ///timing offset used in TDD + int N_TA_offset; + /// RF device descriptor + openair0_device rfdevice; + /// HW configuration + openair0_config_t openair0_cfg; + /// Number of eNBs using this RU + int num_eNB; + /// list of eNBs using this RU + struct PHY_VARS_eNB_s *eNB_list[NUMBER_OF_eNB_MAX]; + /// Mapping of antenna ports to RF chain index + openair0_rf_map rf_map; + /// IF device descriptor + openair0_device ifdevice; + /// Pointer for ifdevice buffer struct + if_buffer_t ifbuffer; + /// if prach processing is to be performed in RU + int do_prach; + /// function pointer to synchronous RX fronthaul function (RRU,3GPP_eNB) + void (*fh_south_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to synchronous TX fronthaul function + void (*fh_south_out)(struct RU_t_s *ru); + /// function pointer to synchronous RX fronthaul function (RRU) + void (*fh_north_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to synchronous RX fronthaul function (RRU) + void (*fh_north_out)(struct RU_t_s *ru); + /// function pointer to asynchronous fronthaul interface + void (*fh_north_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to asynchronous fronthaul interface + void (*fh_south_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); + /// function pointer to initialization function for radio interface + int (*start_rf)(struct RU_t_s *ru); + /// function pointer to release function for radio interface + int (*stop_rf)(struct RU_t_s *ru); + /// function pointer to initialization function for radio interface + int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); + /// function pointer to RX front-end processing routine (DFTs/prefix removal or NULL) + void (*feprx)(struct RU_t_s *ru); + /// function pointer to TX front-end processing routine (IDFTs and prefix removal or NULL) + void (*feptx_ofdm)(struct RU_t_s *ru); + /// function pointer to TX front-end processing routine (PRECODING) + void (*feptx_prec)(struct RU_t_s *ru); + /// function pointer to wakeup routine in lte-enb. + int (*wakeup_rxtx)(struct PHY_VARS_eNB_s *eNB, struct RU_t_s *ru); + /// function pointer to wakeup routine in lte-enb. + void (*wakeup_prach_eNB)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); #ifdef Rel14 - /// pthread attributes for prach processing thread BL/CE UEs - pthread_attr_t attr_prach_br; + /// function pointer to wakeup routine in lte-enb. + void (*wakeup_prach_eNB_br)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); #endif - /// pthread attributes for asynchronous RX thread - pthread_attr_t attr_asynch_rxtx; - /// scheduling parameters for parallel turbo-decoder thread - struct sched_param sched_param_td; - /// scheduling parameters for parallel turbo-encoder thread - struct sched_param sched_param_te; - /// scheduling parameters for single eNB thread - struct sched_param sched_param_single; - /// scheduling parameters for prach thread - struct sched_param sched_param_prach; -#ifdef Rel14 - /// scheduling parameters for prach thread - struct sched_param sched_param_prach_br; -#endif - /// scheduling parameters for asynch_rxtx thread - struct sched_param sched_param_asynch_rxtx; - /// pthread structure for parallel turbo-decoder thread - pthread_t pthread_td; - /// pthread structure for parallel turbo-encoder thread - pthread_t pthread_te; - /// pthread structure for PRACH thread - pthread_t pthread_prach; -#ifdef Rel14 - /// pthread structure for PRACH thread BL/CE UEs - pthread_t pthread_prach_br; -#endif - /// condition variable for parallel turbo-decoder thread - pthread_cond_t cond_td; - /// condition variable for parallel turbo-encoder thread - pthread_cond_t cond_te; - /// condition variable for PRACH processing thread; - pthread_cond_t cond_prach; -#ifdef Rel14 - /// condition variable for PRACH processing thread BL/CE UEs; - pthread_cond_t cond_prach_br; -#endif - /// condition variable for asynch RX/TX thread - pthread_cond_t cond_asynch_rxtx; - /// mutex for parallel turbo-decoder thread - pthread_mutex_t mutex_td; - /// mutex for parallel turbo-encoder thread - pthread_mutex_t mutex_te; - /// mutex for PRACH thread - pthread_mutex_t mutex_prach; + /// function pointer to eNB entry routine + void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string, struct RU_t_s *ru); + /// Timing statistics + time_stats_t ofdm_demod_stats; + /// Timing statistics (TX) + time_stats_t ofdm_mod_stats; + /// Timing wait statistics + time_stats_t ofdm_demod_wait_stats; + /// Timing wakeup statistics + time_stats_t ofdm_demod_wakeup_stats; + /// Timing wait statistics (TX) + time_stats_t ofdm_mod_wait_stats; + /// Timing wakeup statistics (TX) + time_stats_t ofdm_mod_wakeup_stats; + /// Timing statistics (RX Fronthaul + Compression) + time_stats_t rx_fhaul; + /// Timing statistics (TX Fronthaul + Compression) + time_stats_t tx_fhaul; + /// Timong statistics (Compression) + time_stats_t compression; + /// Timing statistics (Fronthaul transport) + time_stats_t transport; + /// RX and TX buffers for precoder output + RU_COMMON common; + /// beamforming weight vectors per eNB + int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15]; + + /// received frequency-domain signal for PRACH (IF4p5 RRU) + int16_t **prach_rxsigF; + /// received frequency-domain signal for PRACH BR (IF4p5 RRU) + int16_t **prach_rxsigF_br[4]; + /// sequence number for IF5 + uint8_t seqno; + /// initial timestamp used as an offset make first real timestamp 0 + openair0_timestamp ts_offset; + /// process scheduling variables + RU_proc_t proc; + /// stats thread pthread descriptor + pthread_t ru_stats_thread; + +} RU_t; + + + +#define MAX_RRU_CONFIG_SIZE 1024 +typedef enum { + RAU_tick=0, + RRU_capabilities=1, + RRU_config=2, + RRU_MSG_max_num=3 +} rru_config_msg_type_t; + +typedef struct RRU_CONFIG_msg_s { + rru_config_msg_type_t type; + ssize_t len; + uint8_t msg[MAX_RRU_CONFIG_SIZE]; +} RRU_CONFIG_msg_t; + +typedef enum { + OAI_IF5_only =0, + OAI_IF4p5_only =1, + OAI_IF5_and_IF4p5 =2, + MBP_IF5 =3, + MAX_FH_FMTs =4 +} FH_fmt_options_t; + +#define MAX_BANDS_PER_RRU 4 + +typedef struct RRU_capabilities_s { + /// Fronthaul format + FH_fmt_options_t FH_fmt; + /// number of EUTRA bands (<=4) supported by RRU + uint8_t num_bands; + /// EUTRA band list supported by RRU + uint8_t band_list[MAX_BANDS_PER_RRU]; + /// Number of concurrent bands (component carriers) + uint8_t num_concurrent_bands; + /// Maximum TX EPRE of each band + int8_t max_pdschReferenceSignalPower[MAX_BANDS_PER_RRU]; + /// Maximum RX gain of each band + uint8_t max_rxgain[MAX_BANDS_PER_RRU]; + /// Number of RX ports of each band + uint8_t nb_rx[MAX_BANDS_PER_RRU]; + /// Number of TX ports of each band + uint8_t nb_tx[MAX_BANDS_PER_RRU]; + /// max DL bandwidth (1,6,15,25,50,75,100) + uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; + /// max UL bandwidth (1,6,15,25,50,75,100) + uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; +} RRU_capabilities_t; + +typedef struct RRU_config_s { + + /// Fronthaul format + RU_if_south_t FH_fmt; + /// number of EUTRA bands (<=4) configured in RRU + uint8_t num_bands; + /// EUTRA band list configured in RRU + uint8_t band_list[MAX_BANDS_PER_RRU]; + /// TDD configuration (0-6) + uint8_t tdd_config[MAX_BANDS_PER_RRU]; + /// TDD special subframe configuration (0-10) + uint8_t tdd_config_S[MAX_BANDS_PER_RRU]; + /// TX frequency + uint32_t tx_freq[MAX_BANDS_PER_RRU]; + /// RX frequency + uint32_t rx_freq[MAX_BANDS_PER_RRU]; + /// TX attenation w.r.t. max + uint8_t att_tx[MAX_BANDS_PER_RRU]; + /// RX attenuation w.r.t. max + uint8_t att_rx[MAX_BANDS_PER_RRU]; + /// DL bandwidth + uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; + /// UL bandwidth + uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; + /// 3/4 sampling rate + uint8_t threequarter_fs[MAX_BANDS_PER_RRU]; + /// prach_FreqOffset for IF4p5 + int prach_FreqOffset[MAX_BANDS_PER_RRU]; + /// prach_ConfigIndex for IF4p5 + int prach_ConfigIndex[MAX_BANDS_PER_RRU]; #ifdef Rel14 - /// mutex for PRACH thread for BL/CE UEs - pthread_mutex_t mutex_prach_br; + int emtc_prach_CElevel_enable[MAX_BANDS_PER_RRU][4]; + /// emtc_prach_FreqOffset for IF4p5 per CE Level + int emtc_prach_FreqOffset[MAX_BANDS_PER_RRU][4]; + /// emtc_prach_ConfigIndex for IF4p5 per CE Level + int emtc_prach_ConfigIndex[MAX_BANDS_PER_RRU][4]; #endif - /// mutex for asynch RX/TX thread - pthread_mutex_t mutex_asynch_rxtx; - /// mutex for RU access to eNB processing (PDSCH/PUSCH) - pthread_mutex_t mutex_RU; - /// mutex for RU access to eNB processing (PRACH) - pthread_mutex_t mutex_RU_PRACH; - /// mutex for RU access to eNB processing (PRACH BR) - pthread_mutex_t mutex_RU_PRACH_br; - /// mask for RUs serving eNB (PDSCH/PUSCH) - int RU_mask; - /// mask for RUs serving eNB (PRACH) - int RU_mask_prach; +} RRU_config_t; + + +typedef struct { + /// \brief Pointers (dynamic) to the received data in the time domain. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ + int32_t **rxdata; + /// \brief Pointers (dynamic) to the received data in the frequency domain. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ + int32_t **rxdataF; + /// \brief holds the transmit data in the frequency domain. + /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //? + /// - first index: eNB id [0..2] (hard coded) + /// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports. + /// - third index: sample [0..] + int32_t **txdataF; +} LTE_eNB_COMMON; + +typedef struct { + uint8_t num_dci; + uint8_t num_pdcch_symbols; + DCI_ALLOC_t dci_alloc[32]; +} LTE_eNB_PDCCH; + +typedef struct { + uint8_t hi; + uint8_t first_rb; + uint8_t n_DMRS; +} phich_config_t; + +typedef struct { + uint8_t num_hi; + phich_config_t config[32]; +} LTE_eNB_PHICH; + +typedef struct { + uint8_t num_dci; + eDCI_ALLOC_t edci_alloc[32]; +} LTE_eNB_EPDCCH; + +typedef struct { + /// number of active MPDCCH allocations + uint8_t num_dci; + /// MPDCCH DCI allocations from MAC + mDCI_ALLOC_t mdci_alloc[32]; + // MAX SIZE of an EPDCCH set is 16EREGs * 9REs/EREG * 8 PRB pairs = 2304 bits + uint8_t e[2304]; +} LTE_eNB_MPDCCH; + + +typedef struct { + /// \brief Hold the channel estimates in frequency domain based on SRS. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..ofdm_symbol_size[ + int32_t **srs_ch_estimates; + /// \brief Hold the channel estimates in time domain based on SRS. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..2*ofdm_symbol_size[ + int32_t **srs_ch_estimates_time; + /// \brief Holds the SRS for channel estimation at the RX. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..ofdm_symbol_size[ + int32_t *srs; +} LTE_eNB_SRS; + +typedef struct { + /// \brief Holds the received data in the frequency domain for the allocated RBs in repeated format. + /// - 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[ + int32_t **drs_ch_estimates_time; + /// \brief Hold the channel estimates in frequency domain based on DRS. + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **drs_ch_estimates; + /// \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[ + int32_t **rxdataF_comp; + /// \brief Magnitude of the UL channel estimates. Used for 2nd-bit level thresholds in LLR computation + /// - 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_mag; + /// \brief Magnitude of the UL channel estimates scaled for 3rd bit level thresholds in LLR computation + /// - first index: rx antenna id [0..nb_antennas_rx[ + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **ul_ch_magb; + /// measured RX power based on DRS + int ulsch_power[2]; + /// \brief llr values. + /// - first index: ? [0..1179743] (hard coded) + int16_t *llr; +} LTE_eNB_PUSCH; + +#define PBCH_A 24 +typedef struct { + uint8_t pbch_d[96+(3*(16+PBCH_A))]; + uint8_t pbch_w[3*3*(16+PBCH_A)]; + uint8_t pbch_e[1920]; +} LTE_eNB_PBCH; + +#define MAX_NUM_RX_PRACH_PREAMBLES 4 + +typedef struct { + /// \brief ?. + /// first index: ? [0..1023] (hard coded) + int16_t *prachF; + /// \brief ?. + /// first index: ce_level [0..3] + /// second index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. + /// third index: frequency-domain sample [0..ofdm_symbol_size*12[ + int16_t **rxsigF[4]; + /// \brief local buffer to compute prach_ifft (necessary in case of multiple CCs) + /// first index: ce_level [0..3] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. + /// second index: ? [0..63] (hard coded) + /// third index: ? [0..63] (hard coded) + int32_t **prach_ifft[4]; + + /// repetition number #ifdef Rel14 - /// mask for RUs serving eNB (PRACH) - int RU_mask_prach_br; + /// indicator of first frame in a group of PRACH repetitions + int first_frame[4]; + /// current repetition for each CE level + int repetition_number[4]; #endif - /// parameters for turbo-decoding worker thread - td_params tdp; - /// parameters for turbo-encoding worker thread - te_params tep; - /// set of scheduling variables RXn-TXnp4 threads - eNB_rxtx_proc_t proc_rxtx[2]; -} eNB_proc_t; +} LTE_eNB_PRACH; +#include "PHY/TOOLS/time_meas.h" +#include "PHY/CODING/coding_defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "PHY/LTE_TRANSPORT/transport_eNB.h" /// Context data structure for RX/TX portion of subframe processing typedef struct { - /// index of the current UE RX/TX proc - int proc_id; /// Component Carrier index uint8_t CC_id; /// timestamp transmitted to HW @@ -594,294 +631,179 @@ typedef struct { pthread_mutex_t mutex_rxtx; /// scheduling parameters for RXn-TXnp4 thread struct sched_param sched_param_rxtx; + /// pipeline ready state + int pipe_ready; +} eNB_rxtx_proc_t; - /// internal This variable is protected by ref mutex_fep_slot1. - //int instance_cnt_slot0_dl_processing; - int instance_cnt_slot1_dl_processing; - /// pthread descriptor fep_slot1 thread - //pthread_t pthread_slot0_dl_processing; - pthread_t pthread_slot1_dl_processing; - /// pthread attributes for fep_slot1 processing thread - // pthread_attr_t attr_slot0_dl_processing; - pthread_attr_t attr_slot1_dl_processing; - /// condition variable for UE fep_slot1 thread; - //pthread_cond_t cond_slot0_dl_processing; - pthread_cond_t cond_slot1_dl_processing; - /// mutex for UE synch thread - //pthread_mutex_t mutex_slot0_dl_processing; - pthread_mutex_t mutex_slot1_dl_processing; - // - uint8_t chan_est_pilot0_slot1_available; - uint8_t chan_est_slot1_available; - uint8_t llr_slot1_available; - uint8_t dci_slot0_available; - uint8_t first_symbol_available; - //uint8_t channel_level; - /// scheduling parameters for fep_slot1 thread - struct sched_param sched_param_fep_slot1; - - int sub_frame_start; - int sub_frame_step; - unsigned long long gotIQs; -} UE_rxtx_proc_t; +typedef struct { + struct PHY_VARS_eNB_s *eNB; + int UE_id; + int harq_pid; + int llr8_flag; + int ret; +} td_params; -/// Context data structure for eNB subframe processing typedef struct { + struct PHY_VARS_eNB_s *eNB; + LTE_eNB_DLSCH_t *dlsch; + int G; + int harq_pid; + int total_worker; + int current_worker; + /// \internal This variable is protected by \ref mutex_te. + int instance_cnt_te; + /// pthread attributes for parallel turbo-encoder thread + pthread_attr_t attr_te; + /// scheduling parameters for parallel turbo-encoder thread + struct sched_param sched_param_te; + /// pthread structure for parallel turbo-encoder thread + pthread_t pthread_te; + /// condition variable for parallel turbo-encoder thread + pthread_cond_t cond_te; + /// mutex for parallel turbo-encoder thread + pthread_mutex_t mutex_te; +} te_params; + +/// Context data structure for eNB subframe processing +typedef struct eNB_proc_t_s { /// Component Carrier index uint8_t CC_id; - /// Last RX timestamp + /// thread index + int thread_index; + /// timestamp received from HW openair0_timestamp timestamp_rx; - /// pthread attributes for main UE thread - pthread_attr_t attr_ue; - /// scheduling parameters for main UE thread - struct sched_param sched_param_ue; - /// pthread descriptor main UE thread - pthread_t pthread_ue; - /// \brief Instance count for synch thread. - /// \internal This variable is protected by \ref mutex_synch. + /// timestamp to send to "slave rru" + openair0_timestamp timestamp_tx; + /// subframe to act upon for reception + int subframe_rx; + /// subframe to act upon for PRACH + int subframe_prach; +#ifdef Rel14 + /// subframe to act upon for reception of prach BL/CE UEs + int subframe_prach_br; +#endif + /// frame to act upon for reception + int frame_rx; + /// frame to act upon for transmission + int frame_tx; + /// frame to act upon for PRACH + int frame_prach; +#ifdef Rel14 + /// frame to act upon for PRACH BL/CE UEs + int frame_prach_br; +#endif + /// \internal This variable is protected by \ref mutex_td. + int instance_cnt_td; + /// \internal This variable is protected by \ref mutex_te. + int instance_cnt_te; + /// \internal This variable is protected by \ref mutex_prach. + int instance_cnt_prach; +#ifdef Rel14 + /// \internal This variable is protected by \ref mutex_prach for BL/CE UEs. + int instance_cnt_prach_br; +#endif + // instance count for over-the-air eNB synchronization int instance_cnt_synch; - /// pthread attributes for synch processing thread - pthread_attr_t attr_synch; - /// scheduling parameters for synch thread - struct sched_param sched_param_synch; - /// pthread descriptor synch thread - pthread_t pthread_synch; - /// condition variable for UE synch thread; - pthread_cond_t cond_synch; - /// mutex for UE synch thread - pthread_mutex_t mutex_synch; - /// instance count for eNBs - int instance_cnt_eNBs; - /// set of scheduling variables RXn-TXnp4 threads - UE_rxtx_proc_t proc_rxtx[RX_NB_TH]; -} UE_proc_t; - -typedef enum { - LOCAL_RF =0, - REMOTE_IF5 =1, - REMOTE_MBP_IF5 =2, - REMOTE_IF4p5 =3, - REMOTE_IF1pp =4, - MAX_RU_IF_TYPES =5 -} RU_if_south_t; - -typedef struct RU_t_s{ - /// index of this ru - uint32_t idx; - /// Pointer to configuration file - char *rf_config_file; - /// southbound interface - RU_if_south_t if_south; - /// timing - node_timing_t if_timing; - /// function - node_function_t function; - /// Ethernet parameters for fronthaul interface - eth_params_t eth_params; - /// flag to indicate the RU is in synch with a master reference - int in_synch; - /// timing offset - int rx_offset; - /// flag to indicate the RU is a slave to another source - int is_slave; - /// Total gain of receive chain - uint32_t rx_total_gain_dB; - /// number of bands that this device can support - int num_bands; - /// band list - int band[MAX_BANDS_PER_RRU]; - /// number of RX paths on device - int nb_rx; - /// number of TX paths on device - int nb_tx; - /// maximum PDSCH RS EPRE - int max_pdschReferenceSignalPower; - /// maximum RX gain - int max_rxgain; - /// Attenuation of RX paths on device - int att_rx; - /// Attenuation of TX paths on device - int att_tx; - /// flag to indicate precoding operation in RU - int do_precoding; - /// Frame parameters - LTE_DL_FRAME_PARMS frame_parms; - ///timing offset used in TDD - int N_TA_offset; - /// RF device descriptor - openair0_device rfdevice; - /// HW configuration - openair0_config_t openair0_cfg; - /// Number of eNBs using this RU - int num_eNB; - /// list of eNBs using this RU - struct PHY_VARS_eNB_s *eNB_list[NUMBER_OF_eNB_MAX]; - /// Mapping of antenna ports to RF chain index - openair0_rf_map rf_map; - /// IF device descriptor - openair0_device ifdevice; - /// Pointer for ifdevice buffer struct - if_buffer_t ifbuffer; - /// if prach processing is to be performed in RU - int do_prach; - /// function pointer to synchronous RX fronthaul function (RRU,3GPP_eNB) - void (*fh_south_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to synchronous TX fronthaul function - void (*fh_south_out)(struct RU_t_s *ru); - /// function pointer to synchronous RX fronthaul function (RRU) - void (*fh_north_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to synchronous RX fronthaul function (RRU) - void (*fh_north_out)(struct RU_t_s *ru); - /// function pointer to asynchronous fronthaul interface - void (*fh_north_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to asynchronous fronthaul interface - void (*fh_south_asynch_in)(struct RU_t_s *ru,int *frame, int *subframe); - /// function pointer to initialization function for radio interface - int (*start_rf)(struct RU_t_s *ru); - /// function pointer to release function for radio interface - int (*stop_rf)(struct RU_t_s *ru); - /// function pointer to initialization function for radio interface - int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); - /// function pointer to RX front-end processing routine (DFTs/prefix removal or NULL) - void (*feprx)(struct RU_t_s *ru); - /// function pointer to TX front-end processing routine (IDFTs and prefix removal or NULL) - void (*feptx_ofdm)(struct RU_t_s *ru); - /// function pointer to TX front-end processing routine (PRECODING) - void (*feptx_prec)(struct RU_t_s *ru); - /// function pointer to wakeup routine in lte-enb. - int (*wakeup_rxtx)(struct PHY_VARS_eNB_s *eNB, struct RU_t_s *ru); - /// function pointer to wakeup routine in lte-enb. - void (*wakeup_prach_eNB)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); + /// \internal This variable is protected by \ref mutex_asynch_rxtx. + int instance_cnt_asynch_rxtx; + /// pthread structure for asychronous RX/TX processing thread + pthread_t pthread_asynch_rxtx; + /// flag to indicate first RX acquisition + int first_rx; + /// flag to indicate first TX transmission + int first_tx; + /// pthread attributes for parallel turbo-decoder thread + pthread_attr_t attr_td; + /// pthread attributes for parallel turbo-encoder thread + pthread_attr_t attr_te; + /// pthread attributes for single eNB processing thread + pthread_attr_t attr_single; + /// pthread attributes for prach processing thread + pthread_attr_t attr_prach; +#ifdef Rel14 + /// pthread attributes for prach processing thread BL/CE UEs + pthread_attr_t attr_prach_br; +#endif + /// pthread attributes for asynchronous RX thread + pthread_attr_t attr_asynch_rxtx; + /// scheduling parameters for parallel turbo-decoder thread + struct sched_param sched_param_td; + /// scheduling parameters for parallel turbo-encoder thread + struct sched_param sched_param_te; + /// scheduling parameters for single eNB thread + struct sched_param sched_param_single; + /// scheduling parameters for prach thread + struct sched_param sched_param_prach; +#ifdef Rel14 + /// scheduling parameters for prach thread + struct sched_param sched_param_prach_br; +#endif + /// scheduling parameters for asynch_rxtx thread + struct sched_param sched_param_asynch_rxtx; + /// pthread structure for parallel turbo-decoder thread + pthread_t pthread_td; + /// pthread structure for parallel turbo-encoder thread + pthread_t pthread_te; + /// pthread structure for PRACH thread + pthread_t pthread_prach; #ifdef Rel14 - /// function pointer to wakeup routine in lte-enb. - void (*wakeup_prach_eNB_br)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); + /// pthread structure for PRACH thread BL/CE UEs + pthread_t pthread_prach_br; #endif - /// function pointer to eNB entry routine - void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string); - /// Timing statistics - time_stats_t ofdm_demod_stats; - /// Timing statistics (TX) - time_stats_t ofdm_mod_stats; - /// Timing statistics (RX Fronthaul + Compression) - time_stats_t rx_fhaul; - /// Timing statistics (TX Fronthaul + Compression) - time_stats_t tx_fhaul; - /// Timong statistics (Compression) - time_stats_t compression; - /// Timing statistics (Fronthaul transport) - time_stats_t transport; - /// RX and TX buffers for precoder output - RU_COMMON common; - /// beamforming weight vectors per eNB - int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15]; - - /// received frequency-domain signal for PRACH (IF4p5 RRU) - int16_t **prach_rxsigF; - /// received frequency-domain signal for PRACH BR (IF4p5 RRU) - int16_t **prach_rxsigF_br[4]; - /// sequence number for IF5 - uint8_t seqno; - /// initial timestamp used as an offset make first real timestamp 0 - openair0_timestamp ts_offset; - /// process scheduling variables - RU_proc_t proc; + /// condition variable for parallel turbo-decoder thread + pthread_cond_t cond_td; + /// condition variable for parallel turbo-encoder thread + pthread_cond_t cond_te; + /// condition variable for PRACH processing thread; + pthread_cond_t cond_prach; +#ifdef Rel14 + /// condition variable for PRACH processing thread BL/CE UEs; + pthread_cond_t cond_prach_br; +#endif + /// condition variable for asynch RX/TX thread + pthread_cond_t cond_asynch_rxtx; + /// mutex for parallel turbo-decoder thread + pthread_mutex_t mutex_td; + /// mutex for parallel turbo-encoder thread + pthread_mutex_t mutex_te; + /// mutex for PRACH thread + pthread_mutex_t mutex_prach; +#ifdef Rel14 + /// mutex for PRACH thread for BL/CE UEs + pthread_mutex_t mutex_prach_br; +#endif + /// mutex for asynch RX/TX thread + pthread_mutex_t mutex_asynch_rxtx; + /// mutex for RU access to eNB processing (PDSCH/PUSCH) + pthread_mutex_t mutex_RU; + /// mutex for RU access to eNB processing (PRACH) + pthread_mutex_t mutex_RU_PRACH; + /// mutex for RU access to eNB processing (PRACH BR) + pthread_mutex_t mutex_RU_PRACH_br; + /// mask for RUs serving eNB (PDSCH/PUSCH) + int RU_mask; + /// mask for RUs serving eNB (PRACH) + int RU_mask_prach; +#ifdef Rel14 + /// mask for RUs serving eNB (PRACH) + int RU_mask_prach_br; +#endif + /// parameters for turbo-decoding worker thread + td_params tdp; + /// parameters for turbo-encoding worker thread + te_params tep[3]; + /// set of scheduling variables RXn-TXnp4 threads + eNB_rxtx_proc_t proc_rxtx[2]; /// stats thread pthread descriptor - pthread_t ru_stats_thread; -} RU_t; + pthread_t process_stats_thread; + /// for waking up tx procedure + RU_proc_t *ru_proc; +} eNB_proc_t; -typedef struct { - //unsigned int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (linear) - //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (dB) - //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //! estimated avg received signal power (dB) - // RRC measurements - uint32_t rssi; - int n_adj_cells; - unsigned int adj_cell_id[6]; - uint32_t rsrq[7]; - uint32_t rsrp[7]; - float rsrp_filtered[7]; // after layer 3 filtering - float rsrq_filtered[7]; - // common measurements - //! estimated noise power (linear) - unsigned int n0_power[NB_ANTENNAS_RX]; - //! estimated noise power (dB) - unsigned short n0_power_dB[NB_ANTENNAS_RX]; - //! total estimated noise power (linear) - unsigned int n0_power_tot; - //! total estimated noise power (dB) - unsigned short n0_power_tot_dB; - //! average estimated noise power (linear) - unsigned int n0_power_avg; - //! average estimated noise power (dB) - unsigned short n0_power_avg_dB; - //! total estimated noise power (dBm) - short n0_power_tot_dBm; - // UE measurements - //! estimated received spatial signal power (linear) - int rx_spatial_power[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; - //! estimated received spatial signal power (dB) - unsigned short rx_spatial_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][2][2]; - - /// estimated received signal power (sum over all TX antennas) - //int wideband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - /// estimated received signal power (sum over all TX antennas) - //int wideband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - - /// estimated received signal power (sum over all TX/RX antennas) - int rx_power_tot[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW - /// estimated received signal power (sum over all TX/RX antennas) - unsigned short rx_power_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW - - //! estimated received signal power (sum of all TX/RX antennas, time average) - int rx_power_avg[NUMBER_OF_CONNECTED_eNB_MAX]; - //! estimated received signal power (sum of all TX/RX antennas, time average, in dB) - unsigned short rx_power_avg_dB[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// SINR (sum of all TX/RX antennas, in dB) - int wideband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX]; - /// SINR (sum of all TX/RX antennas, time average, in dB) - int wideband_cqi_avg[NUMBER_OF_CONNECTED_eNB_MAX]; - //! estimated rssi (dBm) - short rx_rssi_dBm[NUMBER_OF_CONNECTED_eNB_MAX]; - //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) - int rx_correlation[NUMBER_OF_CONNECTED_eNB_MAX][2]; - //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) - int rx_correlation_dB[NUMBER_OF_CONNECTED_eNB_MAX][2]; - - /// Wideband CQI (sum of all RX antennas, in dB, for precoded transmission modes (3,4,5,6), up to 4 spatial streams) - int precoded_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX+1][4]; - /// Subband CQI per RX antenna (= SINR) - int subband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; - /// Total Subband CQI (= SINR) - int subband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; - /// Subband CQI in dB (= SINR dB) - int subband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX]; - /// Total Subband CQI - int subband_cqi_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; - /// Wideband PMI for each RX antenna - int wideband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - /// Wideband PMI for each RX antenna - int wideband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; - ///Subband PMI for each RX antenna - int subband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; - ///Subband PMI for each RX antenna - int subband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX]; - /// chosen RX antennas (1=Rx antenna 1, 2=Rx antenna 2, 3=both Rx antennas) - unsigned char selected_rx_antennas[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX]; - /// Wideband Rank indication - unsigned char rank[NUMBER_OF_CONNECTED_eNB_MAX]; - /// Number of RX Antennas - unsigned char nb_antennas_rx; - /// DLSCH error counter - // short dlsch_errors; - -} PHY_MEASUREMENTS; typedef struct { //unsigned int rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX]; //! estimated received signal power (linear) @@ -955,7 +877,7 @@ typedef struct PHY_VARS_eNB_s { eth_params_t eth_params; int rx_total_gain_dB; int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); - int (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *); + int (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *); int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); uint8_t local_flag; LTE_DL_FRAME_PARMS frame_parms; @@ -977,14 +899,14 @@ typedef struct PHY_VARS_eNB_s { nfapi_cqi_indication_raw_pdu_t cqi_raw_pdu_list[NFAPI_CQI_IND_MAX_PDU]; /// NFAPI PRACH information nfapi_preamble_pdu_t preamble_list[MAX_NUM_RX_PRACH_PREAMBLES]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// NFAPI PRACH information BL/CE UEs nfapi_preamble_pdu_t preamble_list_br[MAX_NUM_RX_PRACH_PREAMBLES]; #endif Sched_Rsp_t Sched_INFO; LTE_eNB_PDCCH pdcch_vars[2]; LTE_eNB_PHICH phich_vars[2]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LTE_eNB_EPDCCH epdcch_vars[2]; LTE_eNB_MPDCCH mpdcch_vars[2]; LTE_eNB_PRACH prach_vars_br; @@ -1016,7 +938,7 @@ typedef struct PHY_VARS_eNB_s { uint32_t lte_gold_mbsfn_table[10][3][42]; uint32_t X_u[64][839]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) uint32_t X_u_br[4][64][839]; #endif uint8_t pbch_configured; @@ -1134,7 +1056,14 @@ typedef struct PHY_VARS_eNB_s { time_stats_t dlsch_modulation_stats; time_stats_t dlsch_scrambling_stats; time_stats_t dlsch_rate_matching_stats; + time_stats_t dlsch_turbo_encoding_preperation_stats; + time_stats_t dlsch_turbo_encoding_segmentation_stats; time_stats_t dlsch_turbo_encoding_stats; + time_stats_t dlsch_turbo_encoding_waiting_stats; + time_stats_t dlsch_turbo_encoding_signal_stats; + time_stats_t dlsch_turbo_encoding_main_stats; + time_stats_t dlsch_turbo_encoding_wakeup_stats0; + time_stats_t dlsch_turbo_encoding_wakeup_stats1; time_stats_t dlsch_interleaving_stats; time_stats_t rx_dft_stats; @@ -1155,11 +1084,6 @@ typedef struct PHY_VARS_eNB_s { time_stats_t ulsch_tc_intl1_stats; time_stats_t ulsch_tc_intl2_stats; -#ifdef LOCALIZATION - /// time state for localization - time_stats_t localization_stats; -#endif - int32_t pucch1_stats_cnt[NUMBER_OF_UE_MAX][10]; int32_t pucch1_stats[NUMBER_OF_UE_MAX][10*1024]; int32_t pucch1_stats_thres[NUMBER_OF_UE_MAX][10*1024]; @@ -1172,512 +1096,4 @@ typedef struct PHY_VARS_eNB_s { int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240]; } PHY_VARS_eNB; -#define debug_msg if (((mac_xface->frame%100) == 0) || (mac_xface->frame < 50)) msg - -/// Top-level PHY Data Structure for UE -typedef struct { - /// \brief Module ID indicator for this instance - uint8_t Mod_id; - /// \brief Component carrier ID for this PHY instance - uint8_t CC_id; - /// \brief Mapping of CC_id antennas to cards - openair0_rf_map rf_map; - //uint8_t local_flag; - /// \brief Indicator of current run mode of UE (normal_txrx, rx_calib_ue, no_L2_connect, debug_prach) - runmode_t mode; - /// \brief Indicator that UE should perform band scanning - int UE_scan; - /// \brief Indicator that UE should perform coarse scanning around carrier - int UE_scan_carrier; - /// \brief Indicator that UE is synchronized to an eNB - int is_synchronized; - /// Data structure for UE process scheduling - UE_proc_t proc; - /// Flag to indicate the UE shouldn't do timing correction at all - int no_timing_correction; - /// \brief Total gain of the TX chain (16-bit baseband I/Q to antenna) - uint32_t tx_total_gain_dB; - /// \brief Total gain of the RX chain (antenna to baseband I/Q) This is a function of rx_gain_mode (and the corresponding gain) and the rx_gain of the card. - uint32_t rx_total_gain_dB; - /// \brief Total gains with maximum RF gain stage (ExpressMIMO2/Lime) - uint32_t rx_gain_max[4]; - /// \brief Total gains with medium RF gain stage (ExpressMIMO2/Lime) - uint32_t rx_gain_med[4]; - /// \brief Total gains with bypassed RF gain stage (ExpressMIMO2/Lime) - uint32_t rx_gain_byp[4]; - /// \brief Current transmit power - int16_t tx_power_dBm[10]; - /// \brief Total number of REs in current transmission - int tx_total_RE[10]; - /// \brief Maximum transmit power - int8_t tx_power_max_dBm; - /// \brief Number of eNB seen by UE - uint8_t n_connected_eNB; - /// \brief indicator that Handover procedure has been initiated - uint8_t ho_initiated; - /// \brief indicator that Handover procedure has been triggered - uint8_t ho_triggered; - /// \brief Measurement variables. - PHY_MEASUREMENTS measurements; - LTE_DL_FRAME_PARMS frame_parms; - /// \brief Frame parame before ho used to recover if ho fails. - LTE_DL_FRAME_PARMS frame_parms_before_ho; - LTE_UE_COMMON common_vars; - - // point to the current rxTx thread index - uint8_t current_thread_id[10]; - - LTE_UE_PDSCH *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX+1]; // two RxTx Threads - LTE_UE_PDSCH_FLP *pdsch_vars_flp[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_SI[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_ra[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_p[NUMBER_OF_CONNECTED_eNB_MAX+1]; - LTE_UE_PDSCH *pdsch_vars_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][2]; // two RxTx Threads - LTE_UE_ULSCH_t *ulsch[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_eNB_MAX]; - LTE_UE_DLSCH_t *dlsch_MCH[NUMBER_OF_CONNECTED_eNB_MAX]; - // This is for SIC in the UE, to store the reencoded data - LTE_eNB_DLSCH_t *dlsch_eNB[NUMBER_OF_CONNECTED_eNB_MAX]; - - //Paging parameters - uint32_t IMSImod1024; - uint32_t PF; - uint32_t PO; - - // For abstraction-purposes only - uint8_t sr[10]; - uint8_t pucch_sel[10]; - uint8_t pucch_payload[22]; - - UE_MODE_t UE_mode[NUMBER_OF_CONNECTED_eNB_MAX]; - /// cell-specific reference symbols - uint32_t lte_gold_table[7][20][2][14]; - - /// UE-specific reference symbols (p=5), TM 7 - uint32_t lte_gold_uespec_port5_table[20][38]; - - /// ue-specific reference symbols - uint32_t lte_gold_uespec_table[2][20][2][21]; - - /// mbsfn reference symbols - uint32_t lte_gold_mbsfn_table[10][3][42]; - - uint32_t X_u[64][839]; - - uint32_t high_speed_flag; - uint32_t perfect_ce; - int16_t ch_est_alpha; - int generate_ul_signal[NUMBER_OF_CONNECTED_eNB_MAX]; - - UE_SCAN_INFO_t scan_info[NB_BANDS_MAX]; - - char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX]; - - - - unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_eNB_MAX]; - uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_eNB_MAX]; - unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_eNB_MAX]; - PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_eNB_MAX]; - int turbo_iterations, turbo_cntl_iterations; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t total_TBS[NUMBER_OF_CONNECTED_eNB_MAX]; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t total_TBS_last[NUMBER_OF_CONNECTED_eNB_MAX]; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t bitrate[NUMBER_OF_CONNECTED_eNB_MAX]; - /// \brief ?. - /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded) - uint32_t total_received_bits[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_errors_last[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_received_last[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_fer[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_SI_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_SI_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_ra_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_ra_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_p_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_p_errors[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mch_received_sf[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mch_received[NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mcch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mtch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mcch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mtch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mcch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int dlsch_mtch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX]; - int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX]; - unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX]; - uint8_t generate_prach; - uint8_t prach_cnt; - uint8_t prach_PreambleIndex; - // uint8_t prach_timer; - uint8_t decode_SIB; - uint8_t decode_MIB; - int rx_offset; /// Timing offset - int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP - int time_sync_cell; - int timing_advance; ///timing advance signalled from eNB - int hw_timing_advance; - int N_TA_offset; ///timing offset used in TDD - /// Flag to tell if UE is secondary user (cognitive mode) - unsigned char is_secondary_ue; - /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from. - unsigned char has_valid_precoder; - /// hold the precoder for NULL beam to the primary eNB - int **ul_precoder_S_UE; - /// holds the maximum channel/precoder coefficient - char log2_maxp; - - /// if ==0 enables phy only test mode - int mac_enabled; - - /// Flag to initialize averaging of PHY measurements - int init_averaging; - - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; - - /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_CQI_dB; - - /// sinr_effective used for CQI calulcation - double sinr_eff; - - /// N0 (used for abstraction) - double N0; - - /// PDSCH Varaibles - PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// PUSCH Varaibles - PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// PUSCH contention-based access vars - PUSCH_CA_CONFIG_DEDICATED pusch_ca_config_dedicated[NUMBER_OF_eNB_MAX]; // lola - - /// PUCCH variables - - PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - uint8_t ncs_cell[20][7]; - - /// UL-POWER-Control - UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// TPC - TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_CONNECTED_eNB_MAX]; - TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// CQI reporting - CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// SRS Variables - SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// Scheduling Request Config - SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX]; - - /// Transmission mode per eNB - uint8_t transmission_mode[NUMBER_OF_CONNECTED_eNB_MAX]; - - time_stats_t phy_proc[RX_NB_TH]; - time_stats_t phy_proc_tx; - time_stats_t phy_proc_rx[RX_NB_TH]; - - uint32_t use_ia_receiver; - - time_stats_t ofdm_mod_stats; - time_stats_t ulsch_encoding_stats; - time_stats_t ulsch_modulation_stats; - time_stats_t ulsch_segmentation_stats; - time_stats_t ulsch_rate_matching_stats; - time_stats_t ulsch_turbo_encoding_stats; - time_stats_t ulsch_interleaving_stats; - time_stats_t ulsch_multiplexing_stats; - - time_stats_t generic_stat; - time_stats_t generic_stat_bis[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t ue_front_end_stat[RX_NB_TH]; - time_stats_t ue_front_end_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t pdcch_procedures_stat[RX_NB_TH]; - time_stats_t pdsch_procedures_stat[RX_NB_TH]; - time_stats_t pdsch_procedures_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t dlsch_procedures_stat[RX_NB_TH]; - - time_stats_t ofdm_demod_stats; - time_stats_t dlsch_rx_pdcch_stats; - time_stats_t rx_dft_stats; - time_stats_t dlsch_channel_estimation_stats; - time_stats_t dlsch_freq_offset_estimation_stats; - time_stats_t dlsch_decoding_stats[2]; - time_stats_t dlsch_demodulation_stats; - time_stats_t dlsch_rate_unmatching_stats; - time_stats_t dlsch_turbo_decoding_stats; - time_stats_t dlsch_deinterleaving_stats; - time_stats_t dlsch_llr_stats; - time_stats_t dlsch_llr_stats_parallelization[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; - time_stats_t dlsch_unscrambling_stats; - time_stats_t dlsch_rate_matching_stats; - time_stats_t dlsch_turbo_encoding_stats; - time_stats_t dlsch_interleaving_stats; - time_stats_t dlsch_tc_init_stats; - time_stats_t dlsch_tc_alpha_stats; - time_stats_t dlsch_tc_beta_stats; - time_stats_t dlsch_tc_gamma_stats; - time_stats_t dlsch_tc_ext_stats; - time_stats_t dlsch_tc_intl1_stats; - time_stats_t dlsch_tc_intl2_stats; - time_stats_t tx_prach; - - /// RF and Interface devices per CC - - openair0_device rfdevice; -} PHY_VARS_UE; - -/* this structure is used to pass both UE phy vars and - * proc to the function UE_thread_rxn_txnp4 - */ -struct rx_tx_thread_data { - PHY_VARS_UE *UE; - UE_rxtx_proc_t *proc; -}; - -void exit_fun(const char* s); - -#include "UTIL/LOG/log_extern.h" -extern pthread_cond_t sync_cond; -extern pthread_mutex_t sync_mutex; -extern int sync_var; - - -#define MODE_DECODE_NONE 0 -#define MODE_DECODE_SSE 1 -#define MODE_DECODE_C 2 -#define MODE_DECODE_AVX2 3 - -#define DECODE_INITTD8_SSE_FPTRIDX 0 -#define DECODE_INITTD16_SSE_FPTRIDX 1 -#define DECODE_INITTD_AVX2_FPTRIDX 2 -#define DECODE_TD8_SSE_FPTRIDX 3 -#define DECODE_TD16_SSE_FPTRIDX 4 -#define DECODE_TD_C_FPTRIDX 5 -#define DECODE_TD16_AVX2_FPTRIDX 6 -#define DECODE_FREETD8_FPTRIDX 7 -#define DECODE_FREETD16_FPTRIDX 8 -#define DECODE_FREETD_AVX2_FPTRIDX 9 -#define ENCODE_SSE_FPTRIDX 10 -#define ENCODE_C_FPTRIDX 11 -#define ENCODE_INIT_SSE_FPTRIDX 12 -#define DECODE_NUM_FPTR 13 - - -typedef uint8_t(*decoder_if_t)(int16_t *y, - int16_t *y2, - uint8_t *decoded_bytes, - uint8_t *decoded_bytes2, - uint16_t n, - uint16_t f1, - uint16_t f2, - uint8_t max_iterations, - uint8_t crc_type, - uint8_t F, - time_stats_t *init_stats, - time_stats_t *alpha_stats, - time_stats_t *beta_stats, - time_stats_t *gamma_stats, - time_stats_t *ext_stats, - time_stats_t *intl1_stats, - time_stats_t *intl2_stats); - -typedef uint8_t(*encoder_if_t)(uint8_t *input, - uint16_t input_length_bytes, - uint8_t *output, - uint8_t F, - uint16_t interleaver_f1, - uint16_t interleaver_f2); - -#define MAX_RRU_CONFIG_SIZE 1024 -typedef enum { - RAU_tick=0, - RRU_capabilities=1, - RRU_config=2, - RRU_MSG_max_num=3 -} rru_config_msg_type_t; - -typedef struct RRU_CONFIG_msg_s { - rru_config_msg_type_t type; - ssize_t len; - uint8_t msg[MAX_RRU_CONFIG_SIZE]; -} RRU_CONFIG_msg_t; - -typedef enum { - OAI_IF5_only =0, - OAI_IF4p5_only =1, - OAI_IF5_and_IF4p5 =2, - MBP_IF5 =3, - MAX_FH_FMTs =4 -} FH_fmt_options_t; - -#define MAX_BANDS_PER_RRU 4 - -typedef struct RRU_capabilities_s { - /// Fronthaul format - FH_fmt_options_t FH_fmt; - /// number of EUTRA bands (<=4) supported by RRU - uint8_t num_bands; - /// EUTRA band list supported by RRU - uint8_t band_list[MAX_BANDS_PER_RRU]; - /// Number of concurrent bands (component carriers) - uint8_t num_concurrent_bands; - /// Maximum TX EPRE of each band - int8_t max_pdschReferenceSignalPower[MAX_BANDS_PER_RRU]; - /// Maximum RX gain of each band - uint8_t max_rxgain[MAX_BANDS_PER_RRU]; - /// Number of RX ports of each band - uint8_t nb_rx[MAX_BANDS_PER_RRU]; - /// Number of TX ports of each band - uint8_t nb_tx[MAX_BANDS_PER_RRU]; - /// max DL bandwidth (1,6,15,25,50,75,100) - uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; - /// max UL bandwidth (1,6,15,25,50,75,100) - uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; -} RRU_capabilities_t; - -typedef struct RRU_config_s { - - /// Fronthaul format - RU_if_south_t FH_fmt; - /// number of EUTRA bands (<=4) configured in RRU - uint8_t num_bands; - /// EUTRA band list configured in RRU - uint8_t band_list[MAX_BANDS_PER_RRU]; - /// TDD configuration (0-6) - uint8_t tdd_config[MAX_BANDS_PER_RRU]; - /// TDD special subframe configuration (0-10) - uint8_t tdd_config_S[MAX_BANDS_PER_RRU]; - /// TX frequency - uint32_t tx_freq[MAX_BANDS_PER_RRU]; - /// RX frequency - uint32_t rx_freq[MAX_BANDS_PER_RRU]; - /// TX attenation w.r.t. max - uint8_t att_tx[MAX_BANDS_PER_RRU]; - /// RX attenuation w.r.t. max - uint8_t att_rx[MAX_BANDS_PER_RRU]; - /// DL bandwidth - uint8_t N_RB_DL[MAX_BANDS_PER_RRU]; - /// UL bandwidth - uint8_t N_RB_UL[MAX_BANDS_PER_RRU]; - /// 3/4 sampling rate - uint8_t threequarter_fs[MAX_BANDS_PER_RRU]; - /// prach_FreqOffset for IF4p5 - int prach_FreqOffset[MAX_BANDS_PER_RRU]; - /// prach_ConfigIndex for IF4p5 - int prach_ConfigIndex[MAX_BANDS_PER_RRU]; -#ifdef Rel14 - int emtc_prach_CElevel_enable[MAX_BANDS_PER_RRU][4]; - /// emtc_prach_FreqOffset for IF4p5 per CE Level - int emtc_prach_FreqOffset[MAX_BANDS_PER_RRU][4]; - /// emtc_prach_ConfigIndex for IF4p5 per CE Level - int emtc_prach_ConfigIndex[MAX_BANDS_PER_RRU][4]; -#endif -} RRU_config_t; - - -static inline void wait_sync(char *thread_name) { - - printf( "waiting for sync (%s)\n",thread_name); - pthread_mutex_lock( &sync_mutex ); - - while (sync_var<0) - pthread_cond_wait( &sync_cond, &sync_mutex ); - - pthread_mutex_unlock(&sync_mutex); - - printf( "got sync (%s)\n", thread_name); - -} - -static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { - if (pthread_mutex_lock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - - while (*instance_cnt < 0) { - // most of the time the thread is waiting here - // proc->instance_cnt_rxtx is -1 - pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again - } - - if (pthread_mutex_unlock(mutex) != 0) { - LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - return(0); -} - -static inline int wait_on_busy_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { - - if (pthread_mutex_lock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - - while (*instance_cnt == 0) { - // most of the time the thread will skip this - // waits only if proc->instance_cnt_rxtx is 0 - pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again - } - - if (pthread_mutex_unlock(mutex) != 0) { - LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - return(0); -} - -static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *name) { - - if (pthread_mutex_lock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - - *instance_cnt=*instance_cnt-1; - - if (pthread_mutex_unlock(mutex) != 0) { - LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for %s\n",name); - exit_fun("nothing to add"); - return(-1); - } - return(0); -} - - -#include "PHY/INIT/defs.h" -#include "PHY/LTE_REFSIG/defs.h" -#include "PHY/MODULATION/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/LTE_ESTIMATION/defs.h" - -#include "SIMULATION/ETH_TRANSPORT/defs.h" -#endif // __PHY_DEFS__H__ +#endif /* __PHY_DEFS_ENB__H__ */ diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 066dc7012c317f08da23c8b5433be624f1937f6a..8ffe1fabf40533f151ade91c194e6b906a2301b4 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -34,661 +34,9 @@ #define __PHY_IMPLEMENTATION_DEFS_LTE_H__ -#include "types.h" -#include "nfapi_interface.h" -//#include "defs.h" -#include "openair2/COMMON/platform_types.h" -#define RX_NB_TH_MAX 2 -#define RX_NB_TH 2 -#define LTE_SLOTS_PER_SUBFRAME 2 -#define LTE_NUMBER_OF_SUBFRAMES_PER_FRAME 10 -#define LTE_SLOTS_PER_FRAME 20 -#define LTE_CE_FILTER_LENGTH 5 -#define LTE_CE_OFFSET LTE_CE_FILTER_LENGTH -#define TX_RX_SWITCH_SYMBOL (NUMBER_OF_SYMBOLS_PER_FRAME>>1) -#define PBCH_PDU_SIZE 3 //bytes - -#define PRACH_SYMBOL 3 //position of the UL PSS wrt 2nd slot of special subframe - -#define NUMBER_OF_FREQUENCY_GROUPS (lte_frame_parms->N_RB_DL) - -#define SSS_AMP 1148 - -#define MAX_NUM_PHICH_GROUPS 56 //110 RBs Ng=2, p.60 36-212, Sec. 6.9 - -#define MAX_MBSFN_AREA 8 - -#define NB_RX_ANTENNAS_MAX 64 - -#ifdef OCP_FRAMEWORK -#include "enums.h" -#else -typedef enum {TDD=1,FDD=0} lte_frame_type_t; - -typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t; - -typedef enum {LOCALIZED=0,DISTRIBUTED=1} vrb_t; - -/// Enumeration for parameter PHICH-Duration \ref PHICH_CONFIG_COMMON::phich_duration. -typedef enum { - normal=0, - extended=1 -} PHICH_DURATION_t; - -/// Enumeration for parameter Ng \ref PHICH_CONFIG_COMMON::phich_resource. -typedef enum { - oneSixth=1, - half=3, - one=6, - two=12 -} PHICH_RESOURCE_t; -#endif -/// PHICH-Config from 36.331 RRC spec -typedef struct { - /// Parameter: PHICH-Duration, see TS 36.211 (Table 6.9.3-1). - PHICH_DURATION_t phich_duration; - /// Parameter: Ng, see TS 36.211 (6.9). \details Value oneSixth corresponds to 1/6, half corresponds to 1/2 and so on. - PHICH_RESOURCE_t phich_resource; -} PHICH_CONFIG_COMMON; - -/// PRACH-ConfigInfo from 36.331 RRC spec -typedef struct { - /// Parameter: prach-ConfigurationIndex, see TS 36.211 (5.7.1). \vr{[0..63]} - uint8_t prach_ConfigIndex; - /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. - uint8_t highSpeedFlag; - /// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. - uint8_t zeroCorrelationZoneConfig; - /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. - uint8_t prach_FreqOffset; -} PRACH_CONFIG_INFO; - - - -/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec -typedef struct { - /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} - uint16_t rootSequenceIndex; - /// prach_Config_enabled=1 means enabled. \vr{[0..1]} - uint8_t prach_Config_enabled; - /// PRACH Configuration Information - PRACH_CONFIG_INFO prach_ConfigInfo; -} PRACH_CONFIG_COMMON; - -#ifdef Rel14 - -/// PRACH-eMTC-Config from 36.331 RRC spec -typedef struct { - /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set. - uint8_t highSpeedFlag; -/// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4. - uint8_t zeroCorrelationZoneConfig; - /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex. - - /// PRACH starting subframe periodicity, expressed in number of subframes available for preamble transmission (PRACH opportunities), see TS 36.211. Value 2 corresponds to 2 subframes, 4 corresponds to 4 subframes and so on. EUTRAN configures the PRACH starting subframe periodicity larger than or equal to the Number of PRACH repetitions per attempt for each CE level (numRepetitionPerPreambleAttempt). - uint8_t prach_starting_subframe_periodicity[4]; - /// number of repetitions per preamble attempt per CE level - uint8_t prach_numRepetitionPerPreambleAttempt[4]; - /// prach configuration index for each CE level - uint8_t prach_ConfigIndex[4]; - /// indicator for CE level activation - uint8_t prach_CElevel_enable[4]; - /// prach frequency offset for each CE level - uint8_t prach_FreqOffset[4]; - /// indicator for CE level hopping activation - uint8_t prach_hopping_enable[4]; - /// indicator for CE level hopping activation - uint8_t prach_hopping_offset[4]; -} PRACH_eMTC_CONFIG_INFO; - -/// PRACH-ConfigSIB or PRACH-Config from 36.331 RRC spec -typedef struct { - /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]} - uint16_t rootSequenceIndex; - /// prach_Config_enabled=1 means enabled. \vr{[0..1]} - uint8_t prach_Config_enabled; - /// PRACH Configuration Information -#ifdef Rel14 - PRACH_eMTC_CONFIG_INFO prach_ConfigInfo; -#endif -} PRACH_eMTC_CONFIG_COMMON; - -#endif - -/// Enumeration for parameter \f$N_\text{ANRep}\f$ \ref PUCCH_CONFIG_DEDICATED::repetitionFactor. -typedef enum { - n2=0, - n4, - n6 -} ACKNAKREP_t; - -/// Enumeration for \ref PUCCH_CONFIG_DEDICATED::tdd_AckNackFeedbackMode. -typedef enum { - bundling=0, - multiplexing -} ANFBmode_t; - -/// PUCCH-ConfigDedicated from 36.331 RRC spec -typedef struct { - /// Flag to indicate ACK NAK repetition activation, see TS 36.213 (10.1). \vr{[0..1]} - uint8_t ackNackRepetition; - /// Parameter: \f$N_\text{ANRep}\f$, see TS 36.213 (10.1). - ACKNAKREP_t repetitionFactor; - /// Parameter: \f$n^{(1)}_\text{PUCCH,ANRep}\f$, see TS 36.213 (10.1). \vr{[0..2047]} - uint16_t n1PUCCH_AN_Rep; - /// Feedback mode, see TS 36.213 (7.3). \details Applied to both PUCCH and PUSCH feedback. For TDD, should always be set to bundling. - ANFBmode_t tdd_AckNackFeedbackMode; -} PUCCH_CONFIG_DEDICATED; - -/// PUCCH-ConfigCommon from 36.331 RRC spec -typedef struct { - /// Parameter: \f$\Delta^\text{PUCCH}_\text{shift}\f$, see TS 36.211 (5.4.1). \vr{[1..3]} \note the specification sais it is an enumerated value. - uint8_t deltaPUCCH_Shift; - /// Parameter: \f$N^{(2)}_\text{RB}\f$, see TS 36.211 (5.4). \vr{[0..98]} - uint8_t nRB_CQI; - /// Parameter: \f$N^{(1)}_\text{CS}\f$, see TS 36.211 (5.4). \vr{[0..7]} - uint8_t nCS_AN; - /// Parameter: \f$N^{(1)}_\text{PUCCH}\f$ see TS 36.213 (10.1). \vr{[0..2047]} - uint16_t n1PUCCH_AN; - - /// group hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. - uint8_t grouphop[20]; - /// sequence hopping sequence for DRS \note not part of offical UL-PUCCH_CONFIG_COMMON ASN1 specification. - uint8_t seqhop[20]; -} PUCCH_CONFIG_COMMON; - -/// UL-ReferenceSignalsPUSCH from 36.331 RRC spec -typedef struct { - /// Parameter: Group-hopping-enabled, see TS 36.211 (5.5.1.3). \vr{[0..1]} - uint8_t groupHoppingEnabled; - /// Parameter: \f$\Delta SS\f$, see TS 36.211 (5.5.1.3). \vr{[0..29]} - uint8_t groupAssignmentPUSCH; - /// Parameter: Sequence-hopping-enabled, see TS 36.211 (5.5.1.4). \vr{[0..1]} - uint8_t sequenceHoppingEnabled; - /// Parameter: cyclicShift, see TS 36.211 (Table 5.5.2.1.1-2). \vr{[0..7]} - uint8_t cyclicShift; - /// nPRS for cyclic shift of DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. - uint8_t nPRS[20]; - /// group hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. - uint8_t grouphop[20]; - /// sequence hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification. - uint8_t seqhop[20]; -} UL_REFERENCE_SIGNALS_PUSCH_t; - -/// Enumeration for parameter Hopping-mode \ref PUSCH_CONFIG_COMMON::hoppingMode. -#ifndef OCP_FRAMEWORK -typedef enum { - interSubFrame=0, - intraAndInterSubFrame=1 -} PUSCH_HOPPING_t; -#endif - -/// PUSCH-ConfigCommon from 36.331 RRC spec. -typedef struct { - /// Parameter: \f$N_{sb}\f$, see TS 36.211 (5.3.4). \vr{[1..4]} - uint8_t n_SB; - /// Parameter: Hopping-mode, see TS 36.211 (5.3.4). - PUSCH_HOPPING_t hoppingMode; - /// Parameter: \f$N^{HO}_{RB}\f$, see TS 36.211 (5.3.4). \vr{[0..98]} - uint8_t pusch_HoppingOffset; - /// See TS 36.213 (8.6.1). \vr{[0..1]} 1 indicates 64QAM is allowed, 0 not allowed. - uint8_t enable64QAM; - /// Ref signals configuration - UL_REFERENCE_SIGNALS_PUSCH_t ul_ReferenceSignalsPUSCH; -} PUSCH_CONFIG_COMMON; - -/// UE specific PUSCH configuration. -typedef struct { - /// Parameter: \f$I^\text{HARQ-ACK}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-1). \vr{[0..15]} - uint16_t betaOffset_ACK_Index; - /// Parameter: \f$I^{RI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-2). \vr{[0..15]} - uint16_t betaOffset_RI_Index; - /// Parameter: \f$I^{CQI}_\text{offset}\f$, see TS 36.213 (Table 8.6.3-3). \vr{[0..15]} - uint16_t betaOffset_CQI_Index; -} PUSCH_CONFIG_DEDICATED; - -/// lola CBA information -typedef struct { - /// - uint16_t betaOffset_CA_Index; - /// - uint16_t cShift; -} PUSCH_CA_CONFIG_DEDICATED; - -/// PDSCH-ConfigCommon from 36.331 RRC spec -typedef struct { - /// Parameter: Reference-signal power, see TS 36.213 (5.2). \vr{[-60..50]}\n Provides the downlink reference-signal EPRE. The actual value in dBm. - int8_t referenceSignalPower; - /// Parameter: \f$P_B\f$, see TS 36.213 (Table 5.2-1). \vr{[0..3]} - uint8_t p_b; -} PDSCH_CONFIG_COMMON; - -/// Enumeration for Parameter \f$P_A\f$ \ref PDSCH_CONFIG_DEDICATED::p_a. -typedef enum { - dBm6=0, ///< (dB-6) corresponds to -6 dB - dBm477, ///< (dB-4dot77) corresponds to -4.77 dB - dBm3, ///< (dB-3) corresponds to -3 dB - dBm177, ///< (dB-1dot77) corresponds to -1.77 dB - dB0, ///< corresponds to 0 dB - dB1, ///< corresponds to 1 dB - dB2, ///< corresponds to 2 dB - dB3 ///< corresponds to 3 dB -} PA_t; - -/// PDSCH-ConfigDedicated from 36.331 RRC spec -typedef struct { - /// Parameter: \f$P_A\f$, see TS 36.213 (5.2). - PA_t p_a; -} PDSCH_CONFIG_DEDICATED; - -/// SoundingRS-UL-ConfigCommon Information Element from 36.331 RRC spec -typedef struct { - /// enabled flag=1 means SRS is enabled. \vr{[0..1]} - uint8_t enabled_flag; - /// Parameter: SRS Bandwidth Configuration, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..7]}\n Actual configuration depends on UL bandwidth. \note the specification sais it is an enumerated value. - uint8_t srs_BandwidthConfig; - /// Parameter: SRS SubframeConfiguration, see TS 36.211 (table 5.5.3.3-1 for FDD, table 5.5.3.3-2 for TDD). \vr{[0..15]} \note the specification sais it is an enumerated value. - uint8_t srs_SubframeConfig; - /// Parameter: Simultaneous-AN-and-SRS, see TS 36.213 (8.2). \vr{[0..1]} - uint8_t ackNackSRS_SimultaneousTransmission; - /// Parameter: srsMaxUpPts, see TS 36.211 (5.5.3.2). \details If this field is present, reconfiguration of \f$m^\text{max}_\text{SRS,0}\f$ applies for UpPts, otherwise reconfiguration does not apply. - uint8_t srs_MaxUpPts; -} SOUNDINGRS_UL_CONFIG_COMMON; - -/// \note UNUSED -typedef enum { - ulpc_al0=0, - ulpc_al04=1, - ulpc_al05=2, - ulpc_al06=3, - ulpc_al07=4, - ulpc_al08=5, - ulpc_al09=6, - ulpc_al11=7 -} UL_POWER_CONTROL_COMMON_alpha_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1. -typedef enum { - deltaF_PUCCH_Format1_deltaF_2 = 0, - deltaF_PUCCH_Format1_deltaF0 = 1, - deltaF_PUCCH_Format1_deltaF2 = 2 -} deltaF_PUCCH_Format1_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format1b. -typedef enum { - deltaF_PUCCH_Format1b_deltaF1 = 0, - deltaF_PUCCH_Format1b_deltaF3 = 1, - deltaF_PUCCH_Format1b_deltaF5 = 2 -} deltaF_PUCCH_Format1b_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2. -typedef enum { - deltaF_PUCCH_Format2_deltaF_2 = 0, - deltaF_PUCCH_Format2_deltaF0 = 1, - deltaF_PUCCH_Format2_deltaF1 = 2, - deltaF_PUCCH_Format2_deltaF2 = 3 -} deltaF_PUCCH_Format2_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2a. -typedef enum { - deltaF_PUCCH_Format2a_deltaF_2 = 0, - deltaF_PUCCH_Format2a_deltaF0 = 1, - deltaF_PUCCH_Format2a_deltaF2 = 2 -} deltaF_PUCCH_Format2a_t; - -/// Enumeration for \ref deltaFList_PUCCH_t::deltaF_PUCCH_Format2b. -typedef enum { - deltaF_PUCCH_Format2b_deltaF_2 = 0, - deltaF_PUCCH_Format2b_deltaF0 = 1, - deltaF_PUCCH_Format2b_deltaF2 = 2 -} deltaF_PUCCH_Format2b_t; - -/// DeltaFList-PUCCH from 36.331 RRC spec -typedef struct { - deltaF_PUCCH_Format1_t deltaF_PUCCH_Format1; - deltaF_PUCCH_Format1b_t deltaF_PUCCH_Format1b; - deltaF_PUCCH_Format2_t deltaF_PUCCH_Format2; - deltaF_PUCCH_Format2a_t deltaF_PUCCH_Format2a; - deltaF_PUCCH_Format2b_t deltaF_PUCCH_Format2b; -} deltaFList_PUCCH_t; - -/// SoundingRS-UL-ConfigDedicated Information Element from 36.331 RRC spec -typedef struct { - /// This descriptor is active - uint8_t active; - /// This descriptor's frame - uint16_t frame; - /// This descriptor's subframe - uint8_t subframe; - /// rnti - uint16_t rnti; - /// Parameter: \f$B_\text{SRS}\f$, see TS 36.211 (table 5.5.3.2-1, 5.5.3.2-2, 5.5.3.2-3 and 5.5.3.2-4). \vr{[0..3]} \note the specification sais it is an enumerated value. - uint8_t srs_Bandwidth; - /// Parameter: SRS hopping bandwidth \f$b_\text{hop}\in\{0,1,2,3\}\f$, see TS 36.211 (5.5.3.2) \vr{[0..3]} \note the specification sais it is an enumerated value. - uint8_t srs_HoppingBandwidth; - /// Parameter: \f$n_\text{RRC}\f$, see TS 36.211 (5.5.3.2). \vr{[0..23]} - uint8_t freqDomainPosition; - /// Parameter: Duration, see TS 36.213 (8.2). \vr{[0..1]} 0 corresponds to "single" and 1 to "indefinite". - uint8_t duration; - /// Parameter: \f$k_\text{TC}\in\{0,1\}\f$, see TS 36.211 (5.5.3.2). \vr{[0..1]} - uint8_t transmissionComb; - /// Parameter: \f$I_\text{SRS}\f$, see TS 36.213 (table 8.2-1). \vr{[0..1023]} - uint16_t srs_ConfigIndex; - /// Parameter: \f$n^\text{CS}_\text{SRS}\f$. See TS 36.211 (5.5.3.1). \vr{[0..7]} \note the specification sais it is an enumerated value. - uint8_t cyclicShift; - // Parameter: internal implementation: UE SRS configured - uint8_t srsConfigDedicatedSetup; - // Parameter: cell srs subframe for internal implementation - uint8_t srsCellSubframe; - // Parameter: ue srs subframe for internal implementation - uint8_t srsUeSubframe; -} SOUNDINGRS_UL_CONFIG_DEDICATED; - -/// UplinkPowerControlDedicated Information Element from 36.331 RRC spec -typedef struct { - /// Parameter: \f$P_\text{0\_UE\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dB. \vr{[-8..7]}\n This field is applicable for non-persistent scheduling, only. - int8_t p0_UE_PUSCH; - /// Parameter: Ks, see TS 36.213 (5.1.1.1). \vr{[0..1]}\n en0 corresponds to value 0 corresponding to state “disabledâ€. en1 corresponds to value 1.25 corresponding to “enabledâ€. \note the specification sais it is an enumerated value. \warning the enumeration values do not correspond to the given values in the specification (en1 should be 1.25). - uint8_t deltaMCS_Enabled; - /// Parameter: Accumulation-enabled, see TS 36.213 (5.1.1.1). \vr{[0..1]} 1 corresponds to "enabled" whereas 0 corresponds to "disabled". - uint8_t accumulationEnabled; - /// Parameter: \f$P_\text{0\_UE\_PUCCH}(1)\f$, see TS 36.213 (5.1.2.1), unit dB. \vr{[-8..7]} - int8_t p0_UE_PUCCH; - /// Parameter: \f$P_\text{SRS\_OFFSET}\f$, see TS 36.213 (5.1.3.1). \vr{[0..15]}\n For Ks=1.25 (\ref deltaMCS_Enabled), the actual parameter value is pSRS_Offset value - 3. For Ks=0, the actual parameter value is -10.5 + 1.5*pSRS_Offset value. - int8_t pSRS_Offset; - /// Specifies the filtering coefficient for RSRP measurements used to calculate path loss, as specified in TS 36.213 (5.1.1.1).\details The same filtering mechanism applies as for quantityConfig described in 5.5.3.2. \note the specification sais it is an enumerated value. - uint8_t filterCoefficient; -} UL_POWER_CONTROL_DEDICATED; - -#ifndef OCP_FRAMEWORK -/// Enumeration for parameter \f$\alpha\f$ \ref UL_POWER_CONTROL_CONFIG_COMMON::alpha. -typedef enum { - al0=0, - al04=1, - al05=2, - al06=3, - al07=4, - al08=5, - al09=6, - al1=7 -} PUSCH_alpha_t; -#endif - -/// \note UNUSED -typedef enum { - deltaFm2=0, - deltaF0, - deltaF1, - deltaF2, - deltaF3, - deltaF5 -} deltaF_PUCCH_t; - -/// UplinkPowerControlCommon Information Element from 36.331 RRC spec \note this structure does not currently make use of \ref deltaFList_PUCCH_t. -typedef struct { - /// Parameter: \f$P_\text{0\_NOMINAL\_PUSCH}(1)\f$, see TS 36.213 (5.1.1.1), unit dBm. \vr{[-126..24]}\n This field is applicable for non-persistent scheduling, only. - int8_t p0_NominalPUSCH; - /// Parameter: \f$\alpha\f$, see TS 36.213 (5.1.1.1) \warning the enumeration values do not correspond to the given values in the specification (al04 should be 0.4, ...)! - PUSCH_alpha_t alpha; - /// Parameter: \f$P_\text{0\_NOMINAL\_PUCCH}\f$ See TS 36.213 (5.1.2.1), unit dBm. \vr{[-127..-96]} - int8_t p0_NominalPUCCH; - /// Parameter: \f$\Delta_\text{PREAMBLE\_Msg3}\f$ see TS 36.213 (5.1.1.1). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. - int8_t deltaPreambleMsg3; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format1; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format1a; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 1b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format1b; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2, see TS 36.213 (5.1.2). \vr{[0..3]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format2; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2a, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format2a; - /// Parameter: \f$\Delta_\text{F\_PUCCH}(F)\f$ for the PUCCH format 2b, see TS 36.213 (5.1.2). \vr{[0..2]} \warning check value range, why is this a long? \note the specification sais it is an enumerated value. - long deltaF_PUCCH_Format2b; -} UL_POWER_CONTROL_CONFIG_COMMON; - -/// Union for \ref TPC_PDCCH_CONFIG::tpc_Index. -typedef union { - /// Index of N when DCI format 3 is used. See TS 36.212 (5.3.3.1.6). \vr{[1..15]} - uint8_t indexOfFormat3; - /// Index of M when DCI format 3A is used. See TS 36.212 (5.3.3.1.7). \vr{[1..31]} - uint8_t indexOfFormat3A; -} TPC_INDEX_t; - -/// TPC-PDCCH-Config Information Element from 36.331 RRC spec -typedef struct { - /// RNTI for power control using DCI format 3/3A, see TS 36.212. \vr{[0..65535]} - uint16_t rnti; - /// Index of N or M, see TS 36.212 (5.3.3.1.6 and 5.3.3.1.7), where N or M is dependent on the used DCI format (i.e. format 3 or 3a). - TPC_INDEX_t tpc_Index; -} TPC_PDCCH_CONFIG; - -/// Enumeration for parameter SR transmission \ref SCHEDULING_REQUEST_CONFIG::dsr_TransMax. -typedef enum { - sr_n4=0, - sr_n8=1, - sr_n16=2, - sr_n32=3, - sr_n64=4 -} DSR_TRANSMAX_t; - -/// SchedulingRequestConfig Information Element from 36.331 RRC spec -typedef struct { - /// Parameter: \f$n^{(1)}_\text{PUCCH,SRI}\f$, see TS 36.213 (10.1). \vr{[0..2047]} - uint16_t sr_PUCCH_ResourceIndex; - /// Parameter: \f$I_\text{SR}\f$, see TS 36.213 (10.1). \vr{[0..155]} - uint8_t sr_ConfigIndex; - /// Parameter for SR transmission in TS 36.321 (5.4.4). \details The value n4 corresponds to 4 transmissions, n8 corresponds to 8 transmissions and so on. - DSR_TRANSMAX_t dsr_TransMax; -} SCHEDULING_REQUEST_CONFIG; - -/// CQI-ReportPeriodic -typedef struct { - /// Parameter: \f$n^{(2)}_\text{PUCCH}\f$, see TS 36.213 (7.2). \vr{[0..1185]}, -1 indicates inactivity - int16_t cqi_PUCCH_ResourceIndex; - /// Parameter: CQI/PMI Periodicity and Offset Configuration Index \f$I_\text{CQI/PMI}\f$, see TS 36.213 (tables 7.2.2-1A and 7.2.2-1C). \vr{[0..1023]} - int16_t cqi_PMI_ConfigIndex; - /// Parameter: K, see 36.213 (4.2.2). \vr{[1..4]} - uint8_t K; - /// Parameter: RI Config Index \f$I_\text{RI}\f$, see TS 36.213 (7.2.2-1B). \vr{[0..1023]}, -1 indicates inactivity - int16_t ri_ConfigIndex; - /// Parameter: Simultaneous-AN-and-CQI, see TS 36.213 (10.1). \vr{[0..1]} 1 indicates that simultaneous transmission of ACK/NACK and CQI is allowed. - uint8_t simultaneousAckNackAndCQI; - /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C - uint16_t Npd; - /// parameter computed from Tables 7.2.2-1A and 7.2.2-1C - uint16_t N_OFFSET_CQI; -} CQI_REPORTPERIODIC; - -/// Enumeration for parameter reporting mode \ref CQI_REPORT_CONFIG::cqi_ReportModeAperiodic. -typedef enum { - rm12=0, - rm20=1, - rm22=2, - rm30=3, - rm31=4 -} CQI_REPORTMODEAPERIODIC; - -/// CQI-ReportConfig Information Element from 36.331 RRC spec -typedef struct { - /// Parameter: reporting mode. Value rm12 corresponds to Mode 1-2, rm20 corresponds to Mode 2-0, rm22 corresponds to Mode 2-2 etc. PUSCH reporting modes are described in TS 36.213 [23, 7.2.1]. - CQI_REPORTMODEAPERIODIC cqi_ReportModeAperiodic; - /// Parameter: \f$\Delta_\text{offset}\f$, see TS 36.213 (7.2.3). \vr{[-1..6]}\n Actual value = IE value * 2 [dB]. - int8_t nomPDSCH_RS_EPRE_Offset; - CQI_REPORTPERIODIC CQI_ReportPeriodic; -} CQI_REPORT_CONFIG; - -/// MBSFN-SubframeConfig Information Element from 36.331 RRC spec \note deviates from specification. -typedef struct { - /// MBSFN subframe occurance. \details Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. \note the specification sais it is an enumerated value {n1, n2, n4, n8, n16, n32}. - int radioframeAllocationPeriod; - /// MBSFN subframe occurance. \vr{[0..7]}\n Radio-frames that contain MBSFN subframes occur when equation SFN mod radioFrameAllocationPeriod = radioFrameAllocationOffset is satisfied. When fourFrames is used for subframeAllocation, the equation defines the first radio frame referred to in the description below. Values n1 and n2 are not applicable when fourFrames is used. - int radioframeAllocationOffset; - /// oneFrame or fourFrames. \vr{[0..1]} - int fourFrames_flag; - /// Subframe configuration. \vr{[0..63]} (\ref fourFrames_flag == 0) or \vr{[0..16777215]} (\ref fourFrames_flag == 1) - /// \par fourFrames_flag == 0 - /// "1" denotes that the corresponding subframe is allocated for MBSFN. The following mapping applies:\n FDD: The first/leftmost bit defines the MBSFN allocation for subframe #1, the second bit for #2, third bit for #3 , fourth bit for #6, fifth bit for #7, sixth bit for #8.\n TDD: The first/leftmost bit defines the allocation for subframe #3, the second bit for #4, third bit for #7, fourth bit for #8, fifth bit for #9. Uplink subframes are not allocated. The last bit is not used. - /// \par fourFrames_flag == 1 - /// A bit-map indicating MBSFN subframe allocation in four consecutive radio frames, "1" denotes that the corresponding subframe is allocated for MBSFN. The bitmap is interpreted as follows:\n FDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #1, #2, #3 , #6, #7, and #8 in the sequence of the four radio-frames.\n TDD: Starting from the first radioframe and from the first/leftmost bit in the bitmap, the allocation applies to subframes #3, #4, #7, #8, and #9 in the sequence of the four radio-frames. The last four bits are not used. Uplink subframes are not allocated. - int mbsfn_SubframeConfig; -} MBSFN_config_t; - -typedef struct { - /// Number of resource blocks (RB) in DL - uint8_t N_RB_DL; - /// Number of resource blocks (RB) in UL - uint8_t N_RB_UL; - /// EUTRA Band - uint8_t eutra_band; - /// DL carrier frequency - uint32_t dl_CarrierFreq; - /// UL carrier frequency - uint32_t ul_CarrierFreq; - /// TX attenuation - uint32_t att_tx; - /// RX attenuation - uint32_t att_rx; - /// total Number of Resource Block Groups: this is ceil(N_PRB/P) - uint8_t N_RBG; - /// Total Number of Resource Block Groups SubSets: this is P - uint8_t N_RBGS; - /// Cell ID - uint16_t Nid_cell; - /// MBSFN Area ID - uint16_t Nid_cell_mbsfn; - /// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP) - lte_prefix_type_t Ncp; - /// Cyclic Prefix for UL (0=Normal CP, 1=Extended CP) - lte_prefix_type_t Ncp_UL; - /// shift of pilot position in one RB - uint8_t nushift; - /// Frame type (0 FDD, 1 TDD) - lte_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) - uint8_t tdd_config_S; - /// srs extra symbol flag for TDD - uint8_t srsX; - /// indicates if node is a UE (NODE=2) or eNB (PRIMARY_CH=0). - uint8_t node_id; - /// Indicator that 20 MHz channel uses 3/4 sampling frequency - uint8_t threequarter_fs; - /// Size of FFT - uint16_t ofdm_symbol_size; - /// Number of prefix samples in all but first symbol of slot - uint16_t nb_prefix_samples; - /// Number of prefix samples in first symbol of slot - uint16_t nb_prefix_samples0; - /// Carrier offset in FFT buffer for first RE in PRB0 - uint16_t first_carrier_offset; - /// Number of samples in a subframe - uint32_t samples_per_tti; - /// Number of OFDM/SC-FDMA symbols in one subframe (to be modified to account for potential different in UL/DL) - uint16_t symbols_per_tti; - /// Number of OFDM symbols in DL portion of S-subframe - uint16_t dl_symbols_in_S_subframe; - /// Number of SC-FDMA symbols in UL portion of S-subframe - uint16_t ul_symbols_in_S_subframe; - /// Number of Physical transmit antennas in node - uint8_t nb_antennas_tx; - /// Number of Receive antennas in node - uint8_t nb_antennas_rx; - /// Number of common transmit antenna ports in eNodeB (1 or 2) - uint8_t nb_antenna_ports_eNB; - /// PRACH_CONFIG - PRACH_CONFIG_COMMON prach_config_common; -#ifdef Rel14 - /// PRACH_eMTC_CONFIG - PRACH_eMTC_CONFIG_COMMON prach_emtc_config_common; -#endif - /// PUCCH Config Common (from 36-331 RRC spec) - PUCCH_CONFIG_COMMON pucch_config_common; - /// PDSCH Config Common (from 36-331 RRC spec) - PDSCH_CONFIG_COMMON pdsch_config_common; - /// PUSCH Config Common (from 36-331 RRC spec) - PUSCH_CONFIG_COMMON pusch_config_common; - /// PHICH Config (from 36-331 RRC spec) - PHICH_CONFIG_COMMON phich_config_common; - /// SRS Config (from 36-331 RRC spec) - SOUNDINGRS_UL_CONFIG_COMMON soundingrs_ul_config_common; - /// UL Power Control (from 36-331 RRC spec) - UL_POWER_CONTROL_CONFIG_COMMON ul_power_control_config_common; - /// Number of MBSFN Configurations - int num_MBSFN_config; - /// Array of MBSFN Configurations (max 8 (maxMBSFN-Allocations) elements as per 36.331) - MBSFN_config_t MBSFN_config[8]; - /// Maximum Number of Retransmissions of RRCConnectionRequest (from 36-331 RRC Spec) - uint8_t maxHARQ_Msg3Tx; - /// Size of SI windows used for repetition of one SI message (in frames) - uint8_t SIwindowsize; - /// Period of SI windows used for repetition of one SI message (in frames) - uint16_t SIPeriod; - /// REGs assigned to PCFICH - uint16_t pcfich_reg[4]; - /// Index of first REG assigned to PCFICH - uint8_t pcfich_first_reg_idx; - /// REGs assigned to PHICH - uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; - - struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[MAX_MBSFN_AREA]; - -} LTE_DL_FRAME_PARMS; - -typedef enum { - /// TM1 - SISO=0, - /// TM2 - ALAMOUTI=1, - /// TM3 - LARGE_CDD=2, - /// the next 6 entries are for TM5 - UNIFORM_PRECODING11=3, - UNIFORM_PRECODING1m1=4, - UNIFORM_PRECODING1j=5, - UNIFORM_PRECODING1mj=6, - PUSCH_PRECODING0=7, - PUSCH_PRECODING1=8, - /// the next 3 entries are for TM4 - DUALSTREAM_UNIFORM_PRECODING1=9, - DUALSTREAM_UNIFORM_PRECODINGj=10, - DUALSTREAM_PUSCH_PRECODING=11, - TM7=12, - TM8=13, - TM9_10=14 -} MIMO_mode_t; - - -typedef enum { - /// MRT - MRT=0, - /// ZF - ZF=1, - /// MMSE - MMSE=2 -} PRECODE_TYPE_t; - -typedef struct { - /// \brief Pointers (dynamic) to the received data in the time domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ - int32_t **rxdata; - /// \brief Pointers (dynamic) to the received data in the frequency domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[ - int32_t **rxdataF; - /// \brief holds the transmit data in the frequency domain. - /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //? - /// - first index: eNB id [0..2] (hard coded) - /// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports. - /// - third index: sample [0..] - int32_t **txdataF; -} LTE_eNB_COMMON; typedef struct { /// \brief Holds the transmit data in the frequency domain. @@ -725,567 +73,9 @@ typedef struct { int32_t **tdd_calib_coeffs; } RU_COMMON; -typedef enum {format0, - format1, - format1A, - format1B, - format1C, - format1D, - format1E_2A_M10PRB, - format2, - format2A, - format2B, - format2C, - format2D, - format3, - format3A, - format4, - format5, - format6_0A, - format6_0B, - format6_1A, - format6_1B, - format6_2 - } DCI_format_t; - -typedef struct { - /// Length of DCI in bits - uint8_t dci_length; - /// Aggregation level - uint8_t L; - /// Position of first CCE of the dci - int firstCCE; - /// flag to indicate that this is a RA response - boolean_t ra_flag; - /// rnti - rnti_t rnti; - /// harq_pid - rnti_t harq_pid; - /// Format - DCI_format_t format; - /// DCI pdu - uint8_t dci_pdu[8]; -} DCI_ALLOC_t; - -#define MAX_EPDCCH_PRB 8 - -typedef struct { - /// Length of DCI in bits - uint8_t dci_length; - /// Aggregation level - uint8_t L; - /// Position of first CCE of the dci - int firstCCE; - /// flag to indicate that this is a RA response - boolean_t ra_flag; - /// rnti - rnti_t rnti; - /// Format - DCI_format_t format; - /// epdcch resource assignment (0=localized,1=distributed) - uint8_t epdcch_resource_assignment_flag; - /// epdcch index - uint16_t epdcch_id; - /// epdcch start symbol - uint8_t epdcch_start_symbol; - /// epdcch number of PRBs in set - uint8_t epdcch_num_prb; - /// vector of prb ids for set - uint8_t epdcch_prb_index[MAX_EPDCCH_PRB]; - /// LBT parameter for frame configuration - uint8_t dwpts_symbols; - /// LBT parameter for frame configuration - uint8_t initial_lbt_sf; - /// DCI pdu - uint8_t dci_pdu[8]; -} eDCI_ALLOC_t; - -typedef struct { - /// Length of DCI in bits - uint8_t dci_length; - /// Aggregation level - uint8_t L; - /// Position of first CCE of the dci - int firstCCE; - /// flag to indicate that this is a RA response - boolean_t ra_flag; - /// rnti - rnti_t rnti; - /// Format - DCI_format_t format; - /// harq process index - uint8_t harq_pid; - /// Narrowband index - uint8_t narrowband; - /// number of PRB pairs for MPDCCH - uint8_t number_of_prb_pairs; - /// mpdcch resource assignment (combinatorial index r) - uint8_t resource_block_assignment; - /// transmission type (0=localized,1=distributed) - uint8_t transmission_type; - /// mpdcch start symbol - uint8_t start_symbol; - /// CE mode (1=ModeA,2=ModeB) - uint8_t ce_mode; - /// 0-503 n_EPDCCHid_i - uint16_t dmrs_scrambling_init; - /// Absolute subframe of the initial transmission (0-10239) - uint16_t i0; - /// number of mdpcch repetitions - uint16_t reps; - /// current absolute subframe number - uint16_t absSF; - /// DCI pdu - uint8_t dci_pdu[8]; -} mDCI_ALLOC_t; - - -typedef struct { - uint8_t num_dci; - uint8_t num_pdcch_symbols; - DCI_ALLOC_t dci_alloc[32]; -} LTE_eNB_PDCCH; - -typedef struct { - uint8_t hi; - uint8_t first_rb; - uint8_t n_DMRS; -} phich_config_t; - -typedef struct { - uint8_t num_hi; - phich_config_t config[32]; -} LTE_eNB_PHICH; - -typedef struct { - uint8_t num_dci; - eDCI_ALLOC_t edci_alloc[32]; -} LTE_eNB_EPDCCH; - -typedef struct { - /// number of active MPDCCH allocations - uint8_t num_dci; - /// MPDCCH DCI allocations from MAC - mDCI_ALLOC_t mdci_alloc[32]; - // MAX SIZE of an EPDCCH set is 16EREGs * 9REs/EREG * 8 PRB pairs = 2304 bits - uint8_t e[2304]; -} LTE_eNB_MPDCCH; - - -typedef struct { - /// \brief Hold the channel estimates in frequency domain based on SRS. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..ofdm_symbol_size[ - int32_t **srs_ch_estimates; - /// \brief Hold the channel estimates in time domain based on SRS. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..2*ofdm_symbol_size[ - int32_t **srs_ch_estimates_time; - /// \brief Holds the SRS for channel estimation at the RX. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..ofdm_symbol_size[ - int32_t *srs; -} LTE_eNB_SRS; - -typedef struct { - /// \brief Holds the received data in the frequency domain for the allocated RBs in repeated format. - /// - 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[ - int32_t **drs_ch_estimates_time; - /// \brief Hold the channel estimates in frequency domain based on DRS. - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **drs_ch_estimates; - /// \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[ - int32_t **rxdataF_comp; - /// \brief Magnitude of the UL channel estimates. Used for 2nd-bit level thresholds in LLR computation - /// - 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_mag; - /// \brief Magnitude of the UL channel estimates scaled for 3rd bit level thresholds in LLR computation - /// - first index: rx antenna id [0..nb_antennas_rx[ - /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ - int32_t **ul_ch_magb; - /// measured RX power based on DRS - int ulsch_power[2]; - /// \brief llr values. - /// - first index: ? [0..1179743] (hard coded) - int16_t *llr; -} LTE_eNB_PUSCH; - -typedef struct { - - /// \brief Holds the received data in the frequency domain. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: symbol [0..28*ofdm_symbol_size[ - int32_t **rxdataF; - - /// \brief Hold the channel estimates in frequency domain. - /// - first index: eNB id [0..6] (hard coded) - /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - third index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[ - int32_t **dl_ch_estimates[7]; - - /// \brief Hold the channel estimates in time domain (used for tracking). - /// - first index: eNB id [0..6] (hard coded) - /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - third index: samples? [0..2*ofdm_symbol_size[ - int32_t **dl_ch_estimates_time[7]; -}LTE_UE_COMMON_PER_THREAD; - -typedef struct { - /// \brief Holds the transmit data in time domain. - /// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER. - /// - first index: tx antenna [0..nb_antennas_tx[ - /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES[ - int32_t **txdata; - /// \brief Holds the transmit data in the frequency domain. - /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. - /// - first index: tx antenna [0..nb_antennas_tx[ - /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX[ - int32_t **txdataF; - - /// \brief Holds the received data in time domain. - /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES+2048[ - int32_t **rxdata; - - LTE_UE_COMMON_PER_THREAD common_vars_rx_data_per_thread[RX_NB_TH_MAX]; - - /// holds output of the sync correlator - int32_t *sync_corr; - /// estimated frequency offset (in radians) for all subcarriers - int32_t freq_offset; - /// eNb_id user is synched to - int32_t eNb_id; -} LTE_UE_COMMON; - -typedef struct { - /// \brief Received frequency-domain signal after extraction. - /// - 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 Received frequency-domain ue specific pilots. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..12*N_RB_DL[ - int32_t **rxdataF_uespec_pilots; - /// \brief Received frequency-domain signal after extraction and channel compensation. - /// - 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 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_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)[ - int32_t **dl_bf_ch_estimates; - /// \brief Downlink beamforming channel estimates. - /// - 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; - /// \brief Magnitude of Downlink Channel first layer (16QAM level/First 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..168*N_RB_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 Cross-correlation of two eNB signals. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: symbol [0..] - int32_t **rho; - /// never used... always send dl_ch_rho_ext instead... - int32_t **rho_i; - /// \brief Pointers to llr vectors (2 TBs). - /// - first index: ? [0..1] (hard coded) - /// - second index: ? [0..1179743] (hard coded) - int16_t *llr[2]; - /// \f$\log_2(\max|H_i|^2)\f$ - int16_t log2_maxh; - /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer1 channel compensation - int16_t log2_maxh0; - /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer2 channel commpensation - int16_t log2_maxh1; - /// \brief LLR shifts for subband scaling. - /// - first index: ? [0..168*N_RB_DL[ - uint8_t *llr_shifts; - /// \brief Pointer to LLR shifts. - /// - first index: ? [0..168*N_RB_DL[ - uint8_t *llr_shifts_p; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128_2ndstream; - //uint32_t *rb_alloc; - //uint8_t Qm[2]; - //MIMO_mode_t mimo_mode; - // llr offset per ofdm symbol - uint32_t llr_offset[14]; - // llr length per ofdm symbol - uint32_t llr_length[14]; -} LTE_UE_PDSCH; - -typedef struct { - /// \brief Received frequency-domain signal after extraction. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - int32_t **rxdataF_ext; - /// \brief Received frequency-domain signal after extraction and channel compensation. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - double **rxdataF_comp; - /// \brief Downlink channel estimates extracted in PRBS. - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - int32_t **dl_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..] - double **dl_ch_rho_ext; - /// \brief Downlink PMIs extracted in PRBS and grouped in subbands. - /// - first index: ressource block [0..N_RB_DL[ - uint8_t *pmi_ext; - /// \brief Magnitude of Downlink Channel (16QAM level/First 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - double **dl_ch_mag; - /// \brief Magnitude of Downlink Channel (2nd 64QAM level). - /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx - /// - second index: ? [0..] - double **dl_ch_magb; - /// \brief Cross-correlation of two eNB signals. - /// - first index: rx antenna [0..nb_antennas_rx[ - /// - second index: ? [0..] - double **rho; - /// never used... always send dl_ch_rho_ext instead... - double **rho_i; - /// \brief Pointers to llr vectors (2 TBs). - /// - first index: ? [0..1] (hard coded) - /// - second index: ? [0..1179743] (hard coded) - int16_t *llr[2]; - /// \f$\log_2(\max|H_i|^2)\f$ - uint8_t log2_maxh; - /// \brief Pointers to llr vectors (128-bit alignment). - /// - first index: ? [0..0] (hard coded) - /// - second index: ? [0..] - int16_t **llr128; - //uint32_t *rb_alloc; - //uint8_t Qm[2]; - //MIMO_mode_t mimo_mode; -} LTE_UE_PDSCH_FLP; - -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 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-eNB 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-eNB 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[ - uint16_t *llr; - /// \brief Pointer to llrs, 16-bit resolution. - /// - first index: ? [0..96*N_RB_DL[ - uint16_t *llr16; - /// \brief \f$\overline{w}\f$ from 36-211. - /// - first index: ? [0..48*N_RB_DL[ - uint16_t *wbar; - /// \brief PDCCH/DCI e-sequence (input to rate matching). - /// - first index: ? [0..96*N_RB_DL[ - int8_t *e_rx; - /// number of PDCCH symbols in current subframe - uint8_t num_pdcch_symbols; - /// Allocated CRNTI for UE - uint16_t crnti; - /// 1: the allocated crnti is Temporary C-RNTI / 0: otherwise - uint8_t crnti_is_temporary; - /// Total number of PDU errors (diagnostic mode) - uint32_t dci_errors; - /// 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 PUCCH per subframe - uint8_t nCCE[10]; - //Check for specific DCIFormat and AgregationLevel - uint8_t dciFormat; - uint8_t agregationLevel; -} LTE_UE_PDCCH; - -#define PBCH_A 24 -typedef struct { - uint8_t pbch_d[96+(3*(16+PBCH_A))]; - uint8_t pbch_w[3*3*(16+PBCH_A)]; - uint8_t pbch_e[1920]; -} LTE_eNB_PBCH; - -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 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 Pointer to PBCH llrs. - /// - first index: ? [0..1919] (hard coded) - int8_t *llr; - /// \brief Pointer to PBCH decoded output. - /// - first index: ? [0..63] (hard coded) - uint8_t *decoded_output; - /// \brief Total number of PDU errors. - uint32_t pdu_errors; - /// \brief Total number of PDU errors 128 frames ago. - uint32_t pdu_errors_last; - /// \brief Total number of consecutive PDU errors. - uint32_t pdu_errors_conseq; - /// \brief FER (in percent) . - uint32_t pdu_fer; -} LTE_UE_PBCH; - -typedef struct { - int16_t amp; - int16_t *prachF; - int16_t *prach; -} LTE_UE_PRACH; - -#define MAX_NUM_RX_PRACH_PREAMBLES 4 - -typedef struct { - /// \brief ?. - /// first index: ? [0..1023] (hard coded) - int16_t *prachF; - /// \brief ?. - /// first index: ce_level [0..3] - /// second index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. - /// third index: frequency-domain sample [0..ofdm_symbol_size*12[ - int16_t **rxsigF[4]; - /// \brief local buffer to compute prach_ifft (necessary in case of multiple CCs) - /// first index: ce_level [0..3] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. - /// second index: ? [0..63] (hard coded) - /// third index: ? [0..63] (hard coded) - int32_t **prach_ifft[4]; - - /// repetition number -#ifdef Rel14 - /// indicator of first frame in a group of PRACH repetitions - int first_frame[4]; - /// current repetition for each CE level - int repetition_number[4]; -#endif -} LTE_eNB_PRACH; - -typedef struct { - /// Preamble index for PRACH (0-63) - uint8_t ra_PreambleIndex; - /// RACH MaskIndex - uint8_t ra_RACH_MaskIndex; - /// Target received power at eNB (-120 ... -82 dBm) - int8_t ra_PREAMBLE_RECEIVED_TARGET_POWER; - /// PRACH index for TDD (0 ... 6) depending on TDD configuration and prachConfigIndex - uint8_t ra_TDD_map_index; - /// Corresponding RA-RNTI for UL-grant - uint16_t ra_RNTI; - /// Pointer to Msg3 payload for UL-grant - uint8_t *Msg3; -} PRACH_RESOURCES_t; - - -typedef struct { - /// Downlink Power offset field - uint8_t dl_pow_off; - ///Subband resource allocation field - uint8_t rballoc_sub[50]; - ///Total number of PRBs indicator - uint8_t pre_nb_available_rbs; -} MU_MIMO_mode; - -typedef enum { - NOT_SYNCHED=0, - PRACH=1, - RA_RESPONSE=2, - PUSCH=3, - RESYNCH=4 -} UE_MODE_t; -typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; -typedef enum { - /// do not detect any DCIs in the current subframe - NO_DCI = 0x0, - /// detect only downlink DCIs in the current subframe - UL_DCI = 0x1, - /// detect only uplink DCIs in the current subframe - DL_DCI = 0x2, - /// detect both uplink and downlink DCIs in the current subframe - UL_DL_DCI = 0x3} dci_detect_mode_t; #endif diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 60d3fec5f4da660076ae16cc68fdf8e2c145aff3..8b31b601621d59e7121ad6f9805b1efe402255c7 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -107,7 +107,7 @@ * @} */ -#include "defs.h" +#include "defs_eNB.h" #include "types.h" @@ -203,6 +203,9 @@ // QAM amplitude definitions +/// Amplitude for QPSK (\f$ 2^15 \times 1/\sqrt{2}\f$) +#define QPSK 23170 + /// First Amplitude for QAM16 (\f$ 2^{15} \times 2/\sqrt{10}\f$) #define QAM16_n1 20724 /// Second Amplitude for QAM16 (\f$ 2^{15} \times 1/\sqrt{10}\f$) @@ -269,13 +272,48 @@ typedef struct { /// Measurement Variables -#define NUMBER_OF_SUBBANDS_MAX 13 +//#define NUMBER_OF_SUBBANDS_MAX 13 #define NUMBER_OF_HARQ_PID_MAX 8 #define MAX_FRAME_NUMBER 0x400 #include "openairinterface5g_limits.h" - - +#include "assertions.h" + +#define cmax(a,b) ((a>b) ? (a) : (b)) +#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) +#define cmin(a,b) ((a<b) ? (a) : (b)) +#define max(a,b) cmax(a,b) +#define min(a,b) cmin(a,b) + +#ifndef malloc16 +# ifdef __AVX2__ +# define malloc16(x) memalign(32,x) +# else +# define malloc16(x) memalign(16,x) +# endif +#endif +#define free16(y,x) free(y) +#define bigmalloc malloc +#define bigmalloc16 malloc16 +#define openair_free(y,x) free((y)) +#define PAGE_SIZE 4096 +#define free_and_zero(PtR) do { \ + if (PtR) { \ + free(PtR); \ + PtR = NULL; \ + } \ + } while (0) +static inline void* malloc16_clear( size_t size ) +{ +#ifdef __AVX2__ + void* ptr = memalign(32, size); +#else + void* ptr = memalign(16, size); +#endif + DevAssert(ptr); + memset( ptr, 0, size ); + return ptr; +} #endif //__PHY_IMPLEMENTATION_DEFS_H__ /**@} diff --git a/openair1/PHY/extern.h b/openair1/PHY/phy_extern.h similarity index 93% rename from openair1/PHY/extern.h rename to openair1/PHY/phy_extern.h index 5868c1c0221ce345d81aa10267d76bfe211be1a2..4cb3cc538f91a06f55cd7705fefbb4c35dac9c81 100644 --- a/openair1/PHY/extern.h +++ b/openair1/PHY/phy_extern.h @@ -22,7 +22,7 @@ #ifndef __PHY_EXTERN_H__ #define __PHY_EXTERN_H__ -#include "PHY/defs.h" +#include "PHY/defs_common.h" #include "common/ran_context.h" extern char* namepointer_chMag ; @@ -32,23 +32,21 @@ extern char fmageren_name2[512]; extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX]; extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; -#include "PHY/LTE_TRANSPORT/extern.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" +#include "PHY/LTE_TRANSPORT/transport_extern.h" +//#include "SIMULATION/ETH_TRANSPORT/extern.h" extern unsigned int DAQ_MBOX; extern int number_of_cards; #ifndef OCP_FRAMEWORK -extern PHY_VARS_UE ***PHY_vars_UE_g; //extern PHY_VARS_eNB ***PHY_vars_eNB_g; extern RAN_CONTEXT_t RC; -extern PHY_VARS_RN **PHY_vars_RN_g; extern LTE_DL_FRAME_PARMS *lte_frame_parms_g; #else #define MAX_UE 10 #define MAX_eNB 20 -extern PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]; + extern PHY_VARS_eNB * PHY_vars_eNB_g[MAX_eNB][MAX_NUM_CCs]; #endif @@ -70,7 +68,7 @@ extern int flagMag; extern char mode_string[4][20]; -#include "PHY/LTE_TRANSPORT/extern.h" + extern unsigned char NB_RU; diff --git a/openair1/PHY/phy_extern_ue.h b/openair1/PHY/phy_extern_ue.h new file mode 100644 index 0000000000000000000000000000000000000000..98dbfb886e858da98de2d418d7afb7a84dd6b859 --- /dev/null +++ b/openair1/PHY/phy_extern_ue.h @@ -0,0 +1,124 @@ +/* + * 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 __PHY_EXTERN_UE__H__ +#define __PHY_EXTERN_UE__H__ + +#include "PHY/defs_UE.h" +#include "common/ran_context.h" + +extern char* namepointer_chMag ; +extern char* namepointer_log2; +extern char fmageren_name2[512]; + +extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX]; +extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; + +#include "PHY/LTE_TRANSPORT/transport_extern.h" + +extern int number_of_cards; + + +#ifndef OCP_FRAMEWORK +extern PHY_VARS_UE ***PHY_vars_UE_g; +extern LTE_DL_FRAME_PARMS *lte_frame_parms_g; +#else +#define MAX_UE 10 +#define MAX_eNB 20 + +extern PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]; +#endif + +extern short primary_synch0[144]; +extern short primary_synch1[144]; +extern short primary_synch2[144]; +extern unsigned char primary_synch0_tab[72]; +extern unsigned char primary_synch1_tab[72]; +extern unsigned char primary_synch2_tab[72]; +extern int16_t *primary_synch0_time; //!< index: [0..ofdm_symbol_size*2[ +extern int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[ +extern int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[ +extern int *sync_corr_ue0; //!< index [0..10*samples_per_tti[ +extern int *sync_corr_ue1; //!< index [0..10*samples_per_tti[ +extern int *sync_corr_ue2; //!< index [0..10*samples_per_tti[ + +extern int flagMag; +//extern short **txdataF_rep_tmp; + +extern char mode_string[4][20]; + +extern unsigned char NB_RU; + +#ifndef OPENAIR2 +extern unsigned char NB_eNB_INST; +extern unsigned char NB_UE_INST; +extern unsigned char NB_RN_INST; +#endif + +extern unsigned int ULSCH_max_consecutive_errors; +extern int flag_LA; +extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX]; +extern double sinr_bler_map_up[MCS_COUNT][2][16]; +extern int table_length[MCS_COUNT]; +extern double sinr_to_cqi[4][16]; +extern int cqi_to_mcs[16]; + +//for MU-MIMO abstraction using MIESM +//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively +extern double MI_map_4qam[3][162]; +extern double MI_map_16qam[3][197]; +extern double MI_map_64qam[3][227]; + +extern double beta1_dlsch_MI[6][MCS_COUNT]; +extern double beta2_dlsch_MI[6][MCS_COUNT]; + +extern double q_qpsk[8]; +extern double q_qam16[8]; +extern double q_qam64[8]; + +extern double p_qpsk[8]; +extern double p_qam16[8]; +extern double p_qam64[8]; + +extern double beta1_dlsch[6][MCS_COUNT]; +extern double beta2_dlsch[6][MCS_COUNT]; + +extern char eNB_functions[6][20]; +extern char eNB_timing[2][20]; +extern char ru_if_types[MAX_RU_IF_TYPES][20]; + +extern int16_t unscrambling_lut[65536*16]; +extern uint8_t scrambling_lut[65536*16]; + +extern unsigned short msrsb_6_40[8][4]; +extern unsigned short msrsb_41_60[8][4]; +extern unsigned short msrsb_61_80[8][4]; +extern unsigned short msrsb_81_110[8][4]; +extern unsigned short Nb_6_40[8][4]; +extern unsigned short Nb_41_60[8][4]; +extern unsigned short Nb_61_80[8][4]; +extern unsigned short Nb_81_110[8][4]; + +extern uint16_t hundred_times_log10_NPRB[100]; +extern uint8_t alpha_lut[8]; +extern uint8_t max_turbo_iterations; +#endif /*__PHY_EXTERN_H__ */ + diff --git a/openair1/PHY/vars.h b/openair1/PHY/phy_vars.h similarity index 98% rename from openair1/PHY/vars.h rename to openair1/PHY/phy_vars.h index e8f4e27de13e6c5c0c818b1a721981536f3f7b3b..783a151046871bb85ecd1ee129e43a1eedfb131d 100644 --- a/openair1/PHY/vars.h +++ b/openair1/PHY/phy_vars.h @@ -23,7 +23,8 @@ #define __PHY_VARS_H__ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "common/ran_context.h" char* namepointer_chMag ; @@ -37,7 +38,9 @@ int16_t *primary_synch1_time; int16_t *primary_synch2_time; -#include "PHY/CODING/vars.h" +#include "PHY/CODING/coding_vars.h" +#include "PHY/LTE_TRANSPORT/transport_vars.h" +#include "PHY/MODULATION/modulation_vars.h" //PHY_VARS *PHY_vars; #ifndef OCP_FRAMEWORK @@ -58,7 +61,7 @@ unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048] char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"}; -#include "PHY/LTE_TRANSPORT/vars.h" + diff --git a/openair1/PHY/phy_vars_ue.h b/openair1/PHY/phy_vars_ue.h new file mode 100644 index 0000000000000000000000000000000000000000..c323d1eade612f6a3173ba5848322fefa2f5d117 --- /dev/null +++ b/openair1/PHY/phy_vars_ue.h @@ -0,0 +1,150 @@ +/* + * 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 __PHY_VARS_H__ +#define __PHY_VARS_H__ + +#include "PHY/types.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_vars_ue.h" + +#include "common/ran_context.h" + +char* namepointer_chMag ; +char fmageren_name2[512]; +char* namepointer_log2; + + +#include "PHY/LTE_REFSIG/primary_synch.h" +int16_t *primary_synch0_time; +int16_t *primary_synch1_time; +int16_t *primary_synch2_time; + + +#include "PHY/CODING/coding_vars.h" + +//PHY_VARS *PHY_vars; +#ifndef OCP_FRAMEWORK +PHY_VARS_UE ***PHY_vars_UE_g; +LTE_DL_FRAME_PARMS *lte_frame_parms_g; +#else +PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL}; + +#endif + + +unsigned short rev[2048],rev_times4[8192],rev_half[1024]; +unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192]; + + +char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"}; + + + +#include "SIMULATION/ETH_TRANSPORT/vars.h" + +unsigned char NB_RU=0; + +#ifndef OPENAIR2 +unsigned char NB_eNB_INST=0; +unsigned char NB_UE_INST=0; +unsigned char NB_RN_INST=0; +unsigned char NB_INST=0; +#endif + +unsigned int ULSCH_max_consecutive_errors = 20; + +int number_of_cards; + + +int flag_LA=0; +int flagMag; +//extern channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; +//extern double ABS_SINR_eff_BLER_table[MCS_COUNT][9][9]; +//extern double ABS_beta[MCS_COUNT];odi +double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX]; +int table_length[MCS_COUNT]; +//double sinr_bler_map_up[MCS_COUNT][2][16]; + +//for MU-MIMO abstraction using MIESM +//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively +double MI_map_4qam[3][162]; +double MI_map_16qam[3][197]; +double MI_map_64qam[3][227]; + +// here the first index is for transmission mode 1, 2, 5 and 6 whereas the second index is for the 16 sinr vaues corresponding to 16 CQIs +double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281, 17.2424, 17.2424, 17.2424}, + {-2.2360, -2.2360, -1.3919, -0.0218, 1.5319, 2.9574, 4.3234, 6.3387, 8.9879, 9.5096, 12.6609, 14.0116, 16.4984, 18.1572, 18.1572, 18.1572}, + {-1, -1.0000, -0.4198, -0.0140, 1.0362, 2.3520, 3.5793, 6.1136, 8.4836, 9.0858, 12.4723, 13.9128, 16.2054, 17.7392, 17.7392, 17.7392}, + { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545} +}; + +//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27}; +int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28}; + +//for SNR to MI conversion 7 th order Polynomial coeff +double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639}; +double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425}; +double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898}; + +//for MI to SNR conversion 7 th order Polynomial coeff +double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965}; +double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089}; +double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343}; + +// ideal CE MIESM + +double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}}; +double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}}; + +//real CE MIESM +/* +double beta1_dlsch_MI[6][MCS_COUNT] = { {1.32955, 0.59522, 0.54024, 0.98698, 0.81305, 0.76976, 0.69258, 0.69713, 0.70546, 0.69111, 0.81904, 0.72664, 0.79491, 0.72562, 0.53980, 0.33134, 0.50550, 0.40602,0.40281,0.47012,0.50510,0.23540,0.32045,1}, {0.59632, 1.08475, 1.02431, 1.07020, 0.90170, 0.97719, 0.95464, 0.92764, 0.86721, 0.85986, 0.64558, 0.80631, 0.82673, 0.82888, 0.87122, 0.77245, 0.29771, 0.43477, 0.55321, 0.61027, 0.56111, 0.57292, 0.39737,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.77532, 1.07544, 1.10571, 1.04099, 0.91638, 0.88644, 0.96405, 0.86709, 0.94066, 0.84430, 1.24478, 1.09665, 1.42604, 0.79541, 0.71847, 0.71604, 0.74561, 0.36431, 0.41536, 0.52175, 0.47096, 0.49977, 0.59728,1}}; +double beta2_dlsch_MI[6][MCS_COUNT] = { {1.36875, 0.59304, 0.53870, 0.98239, 0.81637, 0.76847, 0.69842, 0.69885, 0.69967, 0.69826, 0.82660, 0.70559, 0.78404, 0.70670, 0.55393, 0.36893, 0.52225, 0.39752, 0.40494, 0.46239, 0.49247,0.26900,0.34504,1}, {0.43775, 0.78208, 0.72875, 0.77458, 0.64485, 0.69174, 0.66097, 0.63289, 0.59652, 0.61175, 0.44551, 0.56047, 0.57314, 0.57553, 0.58849, 0.52159, 0.21241, 0.30139, 0.37373, 0.32029, 0.37067, 0.36706, 0.27118,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.54448, 0.73731, 0.79165, 0.74407, 0.68042, 0.64906, 0.71349, 0.62109, 0.65815, 0.60940, 0.90549, 0.78708, 1.03176, 0.58431, 0.53379, 0.51224, 0.52767, 0.26848, 0.29642, 0.36879, 0.34148, 0.35279,0.40633,1}}; +*/ +//ideal channel estimation values +//double beta1_dlsch[6][MCS_COUNT] = { {2.3814, 0.4956, 0.5273, 1.1708, 0.8014, 0.7889, 0.8111, 0.8139, 0.8124, 0.8479, 1.9280, 1.9664, 2.3857, 2.5147, 2.4511, 3.0158, 2.8643, 5.3013, 5.8594, 6.5372, 7.8073, 7.8030, 7.5295, 7.1320}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; +//double beta2_dlsch[6][MCS_COUNT] = { {2.3639, 0.4952, 0.5207, 1.1572, 0.8026, 0.7864, 0.7996, 0.8034, 0.8200, 0.8367, 1.8701, 1.9212, 2.2947, 2.4472, 2.4091, 2.9479, 2.8973, 5.0591, 5.5134, 6.1483, 7.2166, 7.5177, 7.5704, 7.2248}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; +double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}}; +double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}}; + +//real channel estimation valus +/* +double beta1_dlsch[6][MCS_COUNT] = { {2.50200, 0.84047, 0.78195, 1.37929, 1.16871, 1.11906, 1.06303, 1.07447, 1.11403, 1.09223, 2.82502, 2.87556, 3.51254, 3.62920, 3.53638, 2.35980, 3.74126, 8.66532, 7.31772, 9.86882, 10.64939, 6.75208, 9.50664, 13.63057}, {0.92257, 1, 1.80445, 1.43175, 1.42093, 1.37381, 1.45392, 1.47255, 1.47451, 1.41235, 3.9079, 3.38557, 4.13059, 4.93355, 4.97277, 6.04951, 5.88896, 8.68076, 10.23746, 12.37069, 5.50538, 17.29612, 17.95050, 13.27095}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79255, 1.88213, 4.44226, 2.25150, 1.93710, 2.18504, 2.57389, 1.94322, 1.78515, 2.09265, 2.37459, 1.74442, 1.74346, 1.19705, 1.56149, 1.59604, 1.6, 1,1,1,1,1,1,1}, {0.93374, 1.40389, 1.36670, 1.38679, 1.35707, 1.26353, 1.32360, 1.40164, 1.51843, 1.34863, 3.45839, 3.13726, 3.94768, 4.21966, 4.60750, 4.97894, 5.40755, 8.12814, 10.59221, 12.96427, 13.37323, 14.27206, 16.61779, 17.19656}}; +double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.16829, 1.11186, 1.06287, 1.07292, 1.09946, 1.10650, 2.79174, 2.75655, 3.36651, 3.49011, 3.60903, 2.73517, 3.84009, 8.20312, 7.41739, 9.64081, 10.40911, 8.11765, 10.41923, 9.34300}, {0.67252, 0.8600, 1.28633, 1.01624, 1.03066, 0.97590, 1.02560, 1.01840, 1.00547, 0.97093, 2.72573, 2.33283, 2.86181, 3.40452, 3.47957, 4.08916, 3.97628, 6.14541, 7.11017, 8.42369, 4.04812, 11.42082, 11.57171, 9.28462}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.85784, 0.90361, 2.09766, 1.08385, 0.96300, 1.04432, 1.22763, 0.99249, 0.95544, 1.12333, 1.37924, 1.12913, 1.30644, 1.19253, 1.75488, 2.13813, 2.10636, 1,1,1,1,1,1,1}, {0.66288, 0.96402, 0.98545, 0.99386, 0.99981, 0.92678, 0.98978, 0.99600, 1.05538, 0.97777, 2.52504, 2.29338, 2.89631, 3.10812, 3.41916, 3.58671, 3.84166, 6.05254, 7.45821, 9.15812, 9.66330, 10.17852, 11.50519, 11.16299}}; + +*/ + +#ifdef OCP_FRAMEWORK +#include <enums.h> +#else +char eNB_functions[6][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",}; +char eNB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; +char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; +#endif + +/// lookup table for unscrambling in RX +int16_t unscrambling_lut[65536*16] __attribute__((aligned(32))); +/// lookup table for scrambling in TX +uint8_t scrambling_lut[65536*16] __attribute__((aligned(32))); + +uint8_t max_turbo_iterations=4; +#endif /*__PHY_VARS_H__ */ diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index df01fad13622307d0c14c65fbd302744d23453e2..5687fd1fc3e7aad6d255f7772daadec6d57b72cc 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -30,11 +30,12 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" + #include "nfapi_interface.h" +#include "nfapi_pnf_interface.h" #include "fapi_l1.h" int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req); @@ -62,7 +63,7 @@ void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, @@ -127,7 +128,7 @@ void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, // adjust transmit amplitude here based on NFAPI info } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) extern uint32_t localRIV2alloc_LUT6[32]; extern uint32_t localRIV2alloc_LUT25[512]; extern uint32_t localRIV2alloc_LUT50_0[1600]; @@ -144,10 +145,10 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr uint8_t *sdu) { nfapi_dl_config_dlsch_pdu_rel8_t *rel8 = &dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8; -#ifndef Rel8 +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) nfapi_dl_config_dlsch_pdu_rel10_t *rel10 = &dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10; #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) nfapi_dl_config_dlsch_pdu_rel13_t *rel13 = &dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13; #endif LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; @@ -162,7 +163,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[subframe] = 0; #endif @@ -216,7 +217,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr rel8->rnti,UE_id,harq_pid); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) dlsch0->sib1_br_flag=0; if ((rel13->pdsch_payload_type <2) && (rel13->ue_type>0)) { // this is a BR/CE UE and SIB1-BR/SI-BR @@ -270,7 +271,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0->i0 = rel13->initial_transmission_sf_io; #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LOG_D(PHY,"dlsch->i0:%04x dlsch0_harq[pdsch_start:%d nb_rb:%d vrb_type:%d rvidx:%d Nl:%d mimo_mode:%d dl_power_off:%d round:%d status:%d TBS:%d Qm:%d codeword:%d rb_alloc:%d] rel8[length:%d]\n", dlsch0->i0, dlsch0_harq->pdsch_start, dlsch0_harq->nb_rb, dlsch0_harq->vrb_type, dlsch0_harq->rvidx, dlsch0_harq->Nl, dlsch0_harq->mimo_mode, dlsch0_harq->dl_power_off, dlsch0_harq->round, dlsch0_harq->status, dlsch0_harq->TBS, dlsch0_harq->Qm, dlsch0_harq->codeword, dlsch0_harq->rb_alloc[0], @@ -774,12 +775,10 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: // handle_nfapi_epdcch_pdu(eNB,dl_config_pdu); break; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: -#ifdef Rel14 handle_nfapi_mpdcch_pdu(eNB,proc,dl_config_pdu); eNB->mpdcch_vars[subframe&1].num_dci++; -#endif break; #endif } @@ -844,3 +843,25 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) } } } + +/*Dummy functions*/ + +int memcpy_dl_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) +{ + return 0; +} + +int memcpy_ul_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) +{ + return 0; +} + +int memcpy_hi_dci0_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) +{ + return 0; +} + +int memcpy_tx_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) +{ + return 0; +} diff --git a/openair1/SCHED/fapi_l1.h b/openair1/SCHED/fapi_l1.h index f04e8581dba863b9ede033cae45810df1ede99ea..efb028f46444b73cbed6df710faf6db75bcc4080 100644 --- a/openair1/SCHED/fapi_l1.h +++ b/openair1/SCHED/fapi_l1.h @@ -30,10 +30,11 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" +#include "SCHED/sched_common.h" #include "nfapi_interface.h" void fill_uci_harq_indication(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); diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index bbb6986ce9c7c3ac375e79eb170e5c4c77b2ab72..81679f199c64b506de424bfb20bcf03ababa2deb 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -29,10 +29,10 @@ * \note * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" void get_Msg3_alloc(LTE_DL_FRAME_PARMS *frame_parms, unsigned char current_subframe, @@ -831,12 +831,7 @@ dci_detect_mode_t dci_detect_mode_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t return ret; } -lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe) -{ - - return(subframe_select(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe)); -} uint8_t phich_subframe_to_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) { @@ -1066,3 +1061,73 @@ void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeri } } + +// uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id, +int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs) +{ + + /// The payload + CRC size in bits, "B" + uint32_t B; + /// Number of code segments + uint32_t C; + /// Number of "small" code segments + uint32_t Cminus; + /// Number of "large" code segments + uint32_t Cplus; + /// Number of bits in "small" code segments (<6144) + uint32_t Kminus; + /// Number of bits in "large" code segments (<6144) + uint32_t Kplus; + /// Total number of bits across all segments + uint32_t sumKr; + /// Number of "Filler" bits + uint32_t F; + // num resource elements + uint32_t num_re=0.0; + // num symbols + uint32_t num_symb=0.0; + /// effective spectral efficiency of the PUSCH + uint32_t MPR_x100=0; + /// beta_offset + uint16_t beta_offset_pusch_x8=8; + /// delta mcs + float delta_mcs=0.0; + /// bandwidth factor + float bw_factor=0.0; + + B= tbs+24; + lte_segmentation(NULL, + NULL, + B, + &C, + &Cplus, + &Cminus, + &Kplus, + &Kminus, + &F); + + + sumKr = Cminus*Kminus + Cplus*Kplus; + num_symb = 12-(ncp<<1)-(use_srs==0?0:1); + num_re = num_symb * nb_rb * 12; + + if (num_re == 0) + return(0); + + MPR_x100 = 100*sumKr/num_re; + + if (control_only == 1 ) + beta_offset_pusch_x8=8; // fixme + + //(beta_offset_pusch_x8=ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; + + // if deltamcs_enabledm + delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0); + bw_factor = (hundred_times_log10_NPRB[nb_rb-1]/100.0); +#ifdef DEBUG_SEGMENTATION + printf("estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n", + (int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor); +#endif + return (int16_t)ceil(delta_mcs + bw_factor); + +} diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 780d3a1a6f830591cab59c0bb975c59f50d41fec..7fbc6a1745bd6f4ec46d10b8f332765f302e3665 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -30,10 +30,11 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" #include "nfapi_interface.h" #include "fapi_l1.h" #include "UTIL/LOG/log.h" @@ -51,16 +52,94 @@ #endif extern uint8_t nfapi_mode; + + + +int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor) +{ + + uint32_t Nre,sumKr,MPR_x100,Kr,r; + uint16_t beta_offset_pusch; + + DevAssert( UE_id < NUMBER_OF_UE_MAX+1 ); + DevAssert( harq_pid < 8 ); + + Nre = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_initial * + eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12; + + sumKr = 0; + + for (r=0; r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->C; r++) { + if (r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->Cminus) + Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kminus; + else + Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus; + + sumKr += Kr; + } + + if (Nre==0) + return(0); + + MPR_x100 = 100*sumKr/Nre; + // Note: MPR=is the effective spectral efficiency of the PUSCH + // FK 20140908 sumKr is only set after the ulsch_encoding + + beta_offset_pusch = 8; + //(eNB->ulsch[UE_id]->harq_processes[harq_pid]->control_only == 1) ? eNB->ulsch[UE_id]->beta_offset_cqi_times8:8; + + DevAssert( UE_id < NUMBER_OF_UE_MAX ); +//#warning "This condition happens sometimes. Need more investigation" // navid + //DevAssert( MPR_x100/6 < 100 ); + + if (1==1) { //eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { + // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) + if (bw_factor == 1) { + uint8_t nb_rb = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; + return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)) + hundred_times_log10_NPRB[nb_rb-1]; + } else + return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); + } else { + return(0); + } +} + + +int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid) +{ + + int8_t UE_id; + + if ((RC.eNB == NULL) || (module_idP > RC.nb_inst) || (CC_id > RC.nb_CC[module_idP])) { + LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",module_idP,CC_id); + return -1; + } + + UE_id = find_ulsch( rnti, RC.eNB[module_idP][CC_id],SEARCH_EXIST); + + if (UE_id == -1) { + // not found + return 0; + } + + return get_hundred_times_delta_IF_eNB( RC.eNB[module_idP][CC_id], UE_id, harq_pid, 0 ); +} + int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); +lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe) +{ + + return(subframe_select(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe)); + +} -void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,PHY_VARS_RN *rn,relaying_type_t r_type) { +void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) MCH_PDU *mch_pduP=NULL; - MCH_PDU mch_pdu; // uint8_t sync_area=255; #endif @@ -75,7 +154,7 @@ void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,PHY_VARS_RN *rn,rel subframe<<1,1); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) // if mcch is active, send regardless of the node type: eNB or RN // when mcch is active, MAC sched does not allow MCCH and MTCH multiplexing /* @@ -84,50 +163,17 @@ void pmch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,PHY_VARS_RN *rn,rel proc->frame_tx, subframe); */ - switch (r_type) { - case no_relay: - if ((mch_pduP->Pdu_size > 0) && (mch_pduP->sync_area == 0)) // TEST: only transmit mcch for sync area 0 - LOG_D(PHY,"[eNB%"PRIu8"] Frame %d subframe %d : Got MCH pdu for MBSFN (MCS %"PRIu8", TBS %d) \n", - eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->mcs, - eNB->dlsch_MCH->harq_processes[0]->TBS>>3); - else { - LOG_D(PHY,"[DeNB %"PRIu8"] Frame %d subframe %d : Do not transmit MCH pdu for MBSFN sync area %"PRIu8" (%s)\n", - eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->sync_area, - (mch_pduP->Pdu_size == 0)? "Empty MCH PDU":"Let RN transmit for the moment"); - mch_pduP = NULL; - } - - break; - - case multicast_relay: - if ((mch_pduP->Pdu_size > 0) && ((mch_pduP->mcch_active == 1) || mch_pduP->msi_active==1)) { - LOG_D(PHY,"[RN %"PRIu8"] Frame %d subframe %d: Got the MCH PDU for MBSFN sync area %"PRIu8" (MCS %"PRIu8", TBS %"PRIu16")\n", - rn->Mod_id,rn->frame, subframe, - mch_pduP->sync_area,mch_pduP->mcs,mch_pduP->Pdu_size); - } else if (rn->mch_avtive[subframe%5] == 1) { // SF2 -> SF7, SF3 -> SF8 - mch_pduP= &mch_pdu; - memcpy(&mch_pduP->payload, // could be a simple copy - rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->b, - rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->TBS>>3); - mch_pduP->Pdu_size = (uint16_t) (rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->TBS>>3); - mch_pduP->mcs = rn->dlsch_rn_MCH[subframe%5]->harq_processes[0]->mcs; - LOG_D(PHY,"[RN %"PRIu8"] Frame %d subframe %d: Forward the MCH PDU for MBSFN received on SF %d sync area %"PRIu8" (MCS %"PRIu8", TBS %"PRIu16")\n", - rn->Mod_id,rn->frame, subframe,subframe%5, - rn->sync_area[subframe%5],mch_pduP->mcs,mch_pduP->Pdu_size); - } else { - mch_pduP=NULL; - } - - rn->mch_avtive[subframe]=0; - break; + if ((mch_pduP->Pdu_size > 0) && (mch_pduP->sync_area == 0)) // TEST: only transmit mcch for sync area 0 + LOG_D(PHY,"[eNB%"PRIu8"] Frame %d subframe %d : Got MCH pdu for MBSFN (MCS %"PRIu8", TBS %d) \n", + eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->mcs, + eNB->dlsch_MCH->harq_processes[0]->TBS>>3); + else { + LOG_D(PHY,"[DeNB %"PRIu8"] Frame %d subframe %d : Do not transmit MCH pdu for MBSFN sync area %"PRIu8" (%s)\n", + eNB->Mod_id,proc->frame_tx,subframe,mch_pduP->sync_area, + (mch_pduP->Pdu_size == 0)? "Empty MCH PDU":"Let RN transmit for the moment"); + mch_pduP = NULL; + } - default: - LOG_W(PHY,"[eNB %"PRIu8"] Frame %d subframe %d: unknown relaying type %d \n", - eNB->Mod_id,proc->frame_tx,subframe,r_type); - mch_pduP=NULL; - break; - }// switch - if (mch_pduP) { fill_eNB_dlsch_MCH(eNB,mch_pduP->mcs,1,0); // Generate PMCH @@ -346,14 +392,24 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, start_meas(&eNB->dlsch_encoding_stats); eNB->te(eNB, - dlsch_harq->pdu, - dlsch_harq->pdsch_start, - dlsch, - frame,subframe, - &eNB->dlsch_rate_matching_stats, - &eNB->dlsch_turbo_encoding_stats, - &eNB->dlsch_interleaving_stats); + dlsch_harq->pdu, + dlsch_harq->pdsch_start, + dlsch, + frame, + subframe, + &eNB->dlsch_rate_matching_stats, + &eNB->dlsch_turbo_encoding_stats, + &eNB->dlsch_turbo_encoding_waiting_stats, + &eNB->dlsch_turbo_encoding_main_stats, + &eNB->dlsch_turbo_encoding_wakeup_stats0, + &eNB->dlsch_turbo_encoding_wakeup_stats1, + &eNB->dlsch_interleaving_stats); stop_meas(&eNB->dlsch_encoding_stats); + //////////////////////////////////////////////////******************************************* + if(eNB->dlsch_encoding_stats.diff_now>500*3000 && opp_enabled == 1) + { + print_meas_now(&eNB->dlsch_encoding_stats,"total coding",stderr); + } // 36-211 start_meas(&eNB->dlsch_scrambling_stats); dlsch_scrambling(fp, @@ -398,11 +454,8 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn, int do_meas) { - UNUSED(rn); int frame=proc->frame_tx; int subframe=proc->subframe_tx; uint32_t i,aa; @@ -433,7 +486,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, if (nfapi_mode == 0 || nfapi_mode == 1) { if (is_pmch_subframe(frame,subframe,fp)) { - pmch_procedures(eNB,proc,rn,r_type); + pmch_procedures(eNB,proc); } else { // this is not a pmch subframe, so generate PSS/SSS/PBCH @@ -546,6 +599,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, else { // generate pdsch + pdsch_procedures(eNB, proc, harq_pid, @@ -1359,37 +1413,63 @@ extern int oai_exit; extern void *td_thread(void*); -void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) { +void init_td_thread(PHY_VARS_eNB *eNB) { eNB_proc_t *proc = &eNB->proc; proc->tdp.eNB = eNB; proc->instance_cnt_td = -1; - + + pthread_attr_init( &proc->attr_td); pthread_mutex_init( &proc->mutex_td, NULL); pthread_cond_init( &proc->cond_td, NULL); + + pthread_create(&proc->pthread_td, &proc->attr_td, td_thread, (void*)&proc->tdp); - pthread_create(&proc->pthread_td, attr_td, td_thread, (void*)&proc->tdp); +} +void kill_td_thread(PHY_VARS_eNB *eNB) { + eNB_proc_t *proc = &eNB->proc; + proc->instance_cnt_td = 0; + pthread_cond_signal(&proc->cond_td); + + pthread_join(proc->pthread_td, NULL); + pthread_mutex_destroy( &proc->mutex_td ); + pthread_cond_destroy( &proc->cond_td ); } extern void *te_thread(void*); -void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te) { +void init_te_thread(PHY_VARS_eNB *eNB) { eNB_proc_t *proc = &eNB->proc; - proc->tep.eNB = eNB; - proc->instance_cnt_te = -1; + for(int i=0; i<3 ;i++){ + proc->tep[i].eNB = eNB; + proc->tep[i].instance_cnt_te = -1; + + pthread_mutex_init( &proc->tep[i].mutex_te, NULL); + pthread_cond_init( &proc->tep[i].cond_te, NULL); + pthread_attr_init( &proc->tep[i].attr_te); - pthread_mutex_init( &proc->mutex_te, NULL); - pthread_cond_init( &proc->cond_te, NULL); + printf("Creating te_thread 0\n"); + pthread_create(&proc->tep[i].pthread_te, &proc->tep[i].attr_te, te_thread, (void*)&proc->tep[i]); + } +} +void kill_te_thread(PHY_VARS_eNB *eNB) { - printf("Creating te_thread\n"); - pthread_create(&proc->pthread_te, attr_te, te_thread, (void*)&proc->tep); + eNB_proc_t *proc = &eNB->proc; + for(int i=0; i<3 ;i++){ + proc->tep[i].instance_cnt_te = 0; + pthread_cond_signal(&proc->tep[i].cond_te); + pthread_join(proc->tep[i].pthread_te, NULL); + pthread_mutex_destroy( &proc->tep[i].mutex_te); + pthread_cond_destroy( &proc->tep[i].cond_te); + } } + void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) { nfapi_rx_indication_pdu_t *pdu; @@ -1624,6 +1704,7 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, // release DLSCH if needed release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + #if T_TRACER /* TODO: get correct harq pid */ if (ulsch_harq->o_ACK[i] != 1) @@ -1722,6 +1803,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, // release DLSCH if needed release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + #if T_TRACER if (harq_ack[0] != 1) T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe), @@ -1879,7 +1961,7 @@ void fill_crc_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe,uint pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type) +void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { //RX processing for ue-specific resources (i LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index 0b3623929737628546163b659a4bb83462bbf6b6..2ef3e20feabc081bf84ecbd393f4859db06aa369 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -30,10 +30,9 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" #include "nfapi_interface.h" #include "fapi_l1.h" #include "nfapi_pnf.h" @@ -56,7 +55,7 @@ extern uint32_t nfapi_mode; extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); void prach_procedures(PHY_VARS_eNB *eNB -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , int br_flag #endif @@ -65,7 +64,7 @@ void prach_procedures(PHY_VARS_eNB *eNB uint16_t i; int frame,subframe; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (br_flag==1) { subframe = eNB->proc.subframe_prach_br; frame = eNB->proc.frame_prach_br; @@ -95,7 +94,7 @@ void prach_procedures(PHY_VARS_eNB *eNB ru=eNB->RU_list[i]; for (ru_aa=0,aa=0;ru_aa<ru->nb_rx;ru_aa++,aa++) { eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[i]->prach_rxsigF[ru_aa]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int ce_level; if (br_flag==1) @@ -111,7 +110,7 @@ void prach_procedures(PHY_VARS_eNB *eNB &max_preamble_delay[0], frame, 0 -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,br_flag #endif ); @@ -123,7 +122,7 @@ void prach_procedures(PHY_VARS_eNB *eNB max_preamble_delay[0], eNB->prach_energy_counter); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (br_flag==1) { int prach_mask; diff --git a/openair1/SCHED/pusch_pc.c b/openair1/SCHED/pusch_pc.c deleted file mode 100644 index caef13162726849dd38948a8079adaca4982bcc9..0000000000000000000000000000000000000000 --- a/openair1/SCHED/pusch_pc.c +++ /dev/null @@ -1,275 +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 pusch_pc.c - * \brief Implementation of UE PUSCH Power Control procedures from 36.213 LTE specifications (Section - * \author R. Knopp - * \date 2011 - * \version 0.1 - * \company Eurecom - * \email: knopp@eurecom.fr - * \note - * \warning - */ - -#include "defs.h" -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/extern.h" - -// 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 -int16_t hundred_times_delta_TF[100] = {-32768,-1268,-956,-768,-631,-523,-431,-352,-282,-219,-161,-107,-57,-9,36,79,120,159,197,234,269,304,337,370,402,434,465,495,525,555,583,612,640,668,696,723,750,777,803,829,856,881,907,933,958,983,1008,1033,1058,1083,1108,1132,1157,1181,1205,1229,1254,1278,1302,1325,1349,1373,1397,1421,1444,1468,1491,1515,1538,1562,1585,1609,1632,1655,1679,1702,1725,1748,1772,1795,1818,1841,1864,1887,1910,1933,1956,1980,2003,2026,2049,2072,2095,2118,2141,2164,2186,2209,2232,2255}; -uint16_t hundred_times_log10_NPRB[100] = {0,301,477,602,698,778,845,903,954,1000,1041,1079,1113,1146,1176,1204,1230,1255,1278,1301,1322,1342,1361,1380,1397,1414,1431,1447,1462,1477,1491,1505,1518,1531,1544,1556,1568,1579,1591,1602,1612,1623,1633,1643,1653,1662,1672,1681,1690,1698,1707,1716,1724,1732,1740,1748,1755,1763,1770,1778,1785,1792,1799,1806,1812,1819,1826,1832,1838,1845,1851,1857,1863,1869,1875,1880,1886,1892,1897,1903,1908,1913,1919,1924,1929,1934,1939,1944,1949,1954,1959,1963,1968,1973,1977,1982,1986,1991,1995,2000}; - -int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor) -{ - - uint32_t Nre,sumKr,MPR_x100,Kr,r; - uint16_t beta_offset_pusch; - - DevAssert( UE_id < NUMBER_OF_UE_MAX+1 ); - DevAssert( harq_pid < 8 ); - - Nre = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_initial * - eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12; - - sumKr = 0; - - for (r=0; r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->C; r++) { - if (r<eNB->ulsch[UE_id]->harq_processes[harq_pid]->Cminus) - Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kminus; - else - Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus; - - sumKr += Kr; - } - - if (Nre==0) - return(0); - - MPR_x100 = 100*sumKr/Nre; - // Note: MPR=is the effective spectral efficiency of the PUSCH - // FK 20140908 sumKr is only set after the ulsch_encoding - - beta_offset_pusch = 8; - //(eNB->ulsch[UE_id]->harq_processes[harq_pid]->control_only == 1) ? eNB->ulsch[UE_id]->beta_offset_cqi_times8:8; - - DevAssert( UE_id < NUMBER_OF_UE_MAX ); -//#warning "This condition happens sometimes. Need more investigation" // navid - //DevAssert( MPR_x100/6 < 100 ); - - if (1==1) { //eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { - // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) - if (bw_factor == 1) { - uint8_t nb_rb = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; - return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)) + hundred_times_log10_NPRB[nb_rb-1]; - } else - return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); - } else { - return(0); - } -} - -int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid) -{ - - int8_t UE_id; - - if ((RC.eNB == NULL) || (module_idP > RC.nb_inst) || (CC_id > RC.nb_CC[module_idP])) { - LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",module_idP,CC_id); - return -1; - } - - UE_id = find_ulsch( rnti, RC.eNB[module_idP][CC_id],SEARCH_EXIST); - - if (UE_id == -1) { - // not found - return 0; - } - - return get_hundred_times_delta_IF_eNB( RC.eNB[module_idP][CC_id], UE_id, harq_pid, 0 ); -} - -int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_pid) -{ - - uint32_t Nre = 2*ue->ulsch[eNB_id]->harq_processes[harq_pid]->Nsymb_initial * - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb*12; - - if (Nre==0) - return(0); - - uint32_t MPR_x100 = 100*ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/Nre; - // Note: MPR=is the effective spectral efficiency of the PUSCH - // FK 20140908 sumKr is only set after the ulsch_encoding - - uint16_t beta_offset_pusch = (ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? - ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; - - if (ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled == 1) { - // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) - return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); - } else { - return(0); - } -} - - - -uint8_t alpha_lut[8] = {0,40,50,60,70,80,90,100}; - -void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag) -{ - - - uint8_t harq_pid = subframe2harq_pid(&ue->frame_parms, - proc->frame_tx, - proc->subframe_tx); - - uint8_t nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb; - int16_t PL; - - - // P_pusch = 10*log10(nb_rb + P_opusch(j)+ alpha(u)*PL + delta_TF(i) + f(i)) - // - // P_opusch(0) = P_oPTR + deltaP_Msg3 if PUSCH is transporting Msg3 - // else - // P_opusch(0) = PO_NOMINAL_PUSCH(j) + P_O_UE_PUSCH(j) - PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id); - - ue->ulsch[eNB_id]->Po_PUSCH = (hundred_times_log10_NPRB[nb_rb-1]+ - get_hundred_times_delta_IF(ue,eNB_id,harq_pid) + - 100*ue->ulsch[eNB_id]->f_pusch)/100; - - if(ue->ulsch_Msg3_active[eNB_id] == 1) { // Msg3 PUSCH - - ue->ulsch[eNB_id]->Po_PUSCH += (get_Po_NOMINAL_PUSCH(ue->Mod_id,0) + PL); - - - LOG_I(PHY,"[UE %d][RAPROC] frame %d, subframe %d: Msg3 Po_PUSCH %d dBm (%d,%d,100*PL=%d,%d,%d)\n", - ue->Mod_id,proc->frame_tx,proc->subframe_tx,ue->ulsch[eNB_id]->Po_PUSCH, - 100*get_Po_NOMINAL_PUSCH(ue->Mod_id,0), - hundred_times_log10_NPRB[nb_rb-1], - 100*PL, - get_hundred_times_delta_IF(ue,eNB_id,harq_pid), - 100*ue->ulsch[eNB_id]->f_pusch); - } else if (j==0) { // SPS PUSCH - } else if (j==1) { // Normal PUSCH - - ue->ulsch[eNB_id]->Po_PUSCH += ((alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL)/100); - ue->ulsch[eNB_id]->Po_PUSCH += ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; - ue->ulsch[eNB_id]->PHR = ue->tx_power_max_dBm-ue->ulsch[eNB_id]->Po_PUSCH; - - if (ue->ulsch[eNB_id]->PHR < -23) - ue->ulsch[eNB_id]->PHR = -23; - else if (ue->ulsch[eNB_id]->PHR > 40) - ue->ulsch[eNB_id]->PHR = 40; - - LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubframe %d.%d: nb_rb: %d, Po_PUSCH %d dBm : tx power %d, Po_NOMINAL_PUSCH %d,log10(NPRB) %f,PHR %d, PL %d, alpha*PL %f,delta_IF %f,f_pusch %d\n", - ue->Mod_id,harq_pid,proc->frame_tx,proc->subframe_tx,nb_rb, - ue->ulsch[eNB_id]->Po_PUSCH, - ue->tx_power_max_dBm, - ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH, - hundred_times_log10_NPRB[nb_rb-1]/100.0, - ue->ulsch[eNB_id]->PHR, - PL, - alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL/100.0, - get_hundred_times_delta_IF(ue,eNB_id,harq_pid)/100.0, - ue->ulsch[eNB_id]->f_pusch); - } - -} - -int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index) -{ - - return PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->PHR; -} - -// uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id, -int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs) -{ - - /// The payload + CRC size in bits, "B" - uint32_t B; - /// Number of code segments - uint32_t C; - /// Number of "small" code segments - uint32_t Cminus; - /// Number of "large" code segments - uint32_t Cplus; - /// Number of bits in "small" code segments (<6144) - uint32_t Kminus; - /// Number of bits in "large" code segments (<6144) - uint32_t Kplus; - /// Total number of bits across all segments - uint32_t sumKr; - /// Number of "Filler" bits - uint32_t F; - // num resource elements - uint32_t num_re=0.0; - // num symbols - uint32_t num_symb=0.0; - /// effective spectral efficiency of the PUSCH - uint32_t MPR_x100=0; - /// beta_offset - uint16_t beta_offset_pusch_x8=8; - /// delta mcs - float delta_mcs=0.0; - /// bandwidth factor - float bw_factor=0.0; - - B= tbs+24; - lte_segmentation(NULL, - NULL, - B, - &C, - &Cplus, - &Cminus, - &Kplus, - &Kminus, - &F); - - - sumKr = Cminus*Kminus + Cplus*Kplus; - num_symb = 12-(ncp<<1)-(use_srs==0?0:1); - num_re = num_symb * nb_rb * 12; - - if (num_re == 0) - return(0); - - MPR_x100 = 100*sumKr/num_re; - - if (control_only == 1 ) - beta_offset_pusch_x8=8; // fixme - - //(beta_offset_pusch_x8=ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; - - // if deltamcs_enabledm - delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0); - bw_factor = (hundred_times_log10_NPRB[nb_rb-1]/100.0); -#ifdef DEBUG_SEGMENTATION - printf("estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n", - (int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor); -#endif - return (int16_t)ceil(delta_mcs + bw_factor); - -} diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 534023632c2cdc9354efcdaa0f617d9f79bf4fab..d5a78c7f98e05be2c8a72687643f9ba1c3e92313 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -30,16 +30,15 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" - +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "SCHED/sched_eNB.h" +#include "PHY/MODULATION/modulation_eNB.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" @@ -138,12 +137,22 @@ static void *feptx_thread(void *param) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + thread_top_init("feptx_thread",1,85000,120000,500000); + pthread_setname_np( pthread_self(),"feptx processing"); + LOG_I(PHY,"thread feptx created id=%ld\n", syscall(__NR_gettid)); + //CPU_SET(6, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //wait_sync("feptx_thread"); - thread_top_init("feptx_thread",0,870000,1000000,1000000); + while (!oai_exit) { if (wait_on_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break; + //stop_meas(&ru->ofdm_mod_wakeup_stats); feptx0(ru,1); if (release_thread(&proc->mutex_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break; @@ -152,6 +161,10 @@ static void *feptx_thread(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return NULL; } + /*if(opp_enabled == 1 && ru->ofdm_mod_wakeup_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_mod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wakeup in frame_tx: %d subframe_rx: %d \n",proc->frame_tx,proc->subframe_tx); + }*/ } @@ -168,7 +181,7 @@ void feptx_ofdm_2thread(RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 1 ); start_meas(&ru->ofdm_mod_stats); if (subframe_select(fp,subframe) == SF_UL) return; @@ -198,17 +211,25 @@ void feptx_ofdm_2thread(RU_t *ru) { exit_fun( "ERROR pthread_cond_signal" ); return; } + //start_meas(&ru->ofdm_mod_wakeup_stats); pthread_mutex_unlock( &proc->mutex_feptx ); } // call first slot in this thread feptx0(ru,0); + start_meas(&ru->ofdm_mod_wait_stats); wait_on_busy_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread"); + stop_meas(&ru->ofdm_mod_wait_stats); + /*if(opp_enabled == 1 && ru->ofdm_mod_wait_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_mod_wait_stats,"fep wakeup",stderr); + printf("delay in feptx wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_tx,proc->subframe_tx); + }*/ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 ); stop_meas(&ru->ofdm_mod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 ); } @@ -426,12 +447,23 @@ static void *fep_thread(void *param) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; - thread_top_init("fep_thread",0,870000,1000000,1000000); + thread_top_init("fep_thread",1,100000,120000,5000000); + pthread_setname_np( pthread_self(),"fep processing"); + LOG_I(PHY,"thread fep created id=%ld\n", syscall(__NR_gettid)); + + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + //CPU_SET(2, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //wait_sync("fep_thread"); while (!oai_exit) { - if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break; + if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break; + //stop_meas(&ru->ofdm_demod_wakeup_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 1 ); fep0(ru,0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 0 ); if (release_thread(&proc->mutex_fep,&proc->instance_cnt_fep,"fep thread")<0) break; if (pthread_cond_signal(&proc->cond_fep) != 0) { @@ -439,6 +471,10 @@ static void *fep_thread(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return NULL; } + /*if(opp_enabled == 1 && ru->ofdm_demod_wakeup_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_demod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wakeup in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + }*/ } @@ -489,6 +525,7 @@ void ru_fep_full_2thread(RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); start_meas(&ru->ofdm_demod_stats); if (pthread_mutex_timedlock(&proc->mutex_fep,&wait) != 0) { @@ -512,15 +549,23 @@ void ru_fep_full_2thread(RU_t *ru) { exit_fun( "ERROR pthread_cond_signal" ); return; } + //start_meas(&ru->ofdm_demod_wakeup_stats); pthread_mutex_unlock( &proc->mutex_fep ); // call second slot in this symbol fep0(ru,1); + start_meas(&ru->ofdm_demod_wait_stats); wait_on_busy_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread"); + stop_meas(&ru->ofdm_demod_wait_stats); + if(opp_enabled == 1 && ru->ofdm_demod_wakeup_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_demod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + } stop_meas(&ru->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); } diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/sched_common.h similarity index 62% rename from openair1/SCHED/defs.h rename to openair1/SCHED/sched_common.h index 3c232a82b755bc001c59f50d4de5a6433f47db3d..30de6dbb4a3c201761b7158bdc863f4407590b81 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/sched_common.h @@ -25,195 +25,11 @@ \email knopp@eurecom.fr */ -#ifndef __openair_SCHED_H__ -#define __openair_SCHED_H__ +#ifndef __openair_SCHED_COMMON_H__ +#define __openair_SCHED_COMMON_H__ -#include "PHY/defs.h" -#include "PHY_INTERFACE/defs.h" - -enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0, - TOP_LEVEL_SCHEDULER_THREAD_INDEX, - DLC_SCHED_THREAD_INDEX, - openair_SCHED_NB_THREADS - }; // do not modify this line - - -#define OPENAIR_THREAD_PRIORITY 255 - - -#define OPENAIR_THREAD_STACK_SIZE PTHREAD_STACK_MIN //4096 //RTL_PTHREAD_STACK_MIN*6 -//#define DLC_THREAD_STACK_SIZE 4096 //DLC stack size -//#define UE_SLOT_PARALLELISATION - -enum openair_SCHED_STATUS { - openair_SCHED_STOPPED=1, - openair_SCHED_STARTING, - openair_SCHED_STARTED, - openair_SCHED_STOPPING -}; - -enum openair_ERROR { - // HARDWARE CAUSES - openair_ERROR_HARDWARE_CLOCK_STOPPED= 1, - - // SCHEDULER CAUSE - openair_ERROR_OPENAIR_RUNNING_LATE, - openair_ERROR_OPENAIR_SCHEDULING_FAILED, - - // OTHERS - openair_ERROR_OPENAIR_TIMING_OFFSET_OUT_OF_BOUNDS, -}; - -enum openair_SYNCH_STATUS { - openair_NOT_SYNCHED=1, - openair_SYNCHED, - openair_SCHED_EXIT -}; - -enum openair_HARQ_TYPE { - openair_harq_DL = 0, - openair_harq_UL, - openair_harq_RA -}; - -#define DAQ_AGC_ON 1 -#define DAQ_AGC_OFF 0 - - -/** @addtogroup _PHY_PROCEDURES_ - * @{ - */ - - - -/*! \brief Top-level entry routine for eNB procedures. Called every slot by process scheduler. In even slots, it performs RX functions from previous subframe (if required). On odd slots, it generate TX waveform for the following subframe. - @param subframe Index of current subframe (0-9) - @param phy_vars_eNB Pointer to eNB variables on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param *phy_vars_rn pointer to RN variables -*/ -void phy_procedures_eNB_lte(uint8_t subframe,PHY_VARS_eNB **phy_vars_eNB,uint8_t abstraction_flag, relaying_type_t r_type, PHY_VARS_RN *phy_vars_rn); - -/*! \brief Top-level entry routine for UE procedures. Called every slot by process scheduler. In even slots, it performs RX functions from previous subframe (if required). On odd slots, it generate TX waveform for the following subframe. - @param phy_vars_ue Pointer to UE variables on which to act - @param eNB_id ID of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param mode calibration/debug mode - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param *phy_vars_rn pointer to RN variables -*/ -void phy_procedures_UE_lte(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); - -#if defined(Rel10) || defined(Rel14) -/*! \brief Top-level entry routine for relay node procedures when acting as eNB. This proc will make us of the existing eNB procs. - @param last_slot Index of last slot (0-19) - @param next_slot Index of next_slot (0-19) - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -int phy_procedures_RN_eNB_TX(unsigned char last_slot, unsigned char next_slot, relaying_type_t r_type); -/*! \brief Top-level entry routine for relay node procedures actinf as UE. This proc will make us of the existing UE procs. - @param last_slot Index of last slot (0-19) - @param next_slot Index of next_slot (0-19) - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -int phy_procedures_RN_UE_RX(unsigned char last_slot, unsigned char next_slot, relaying_type_t r_type); -#endif - -/*! \brief Scheduling for UE TX procedures in normal subframes. - @param phy_vars_ue Pointer to UE variables on which to act - @param proc Pointer to RXn-TXnp4 proc information - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param mode calib/normal mode - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type); -/*! \brief Scheduling for UE RX procedures in normal subframes. - @param last_slot Index of last slot (0-19) - @param phy_vars_ue Pointer to UE variables on which to act - @param proc Pointer to RXn_TXnp4 proc information - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param mode calibration/debug mode - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param phy_vars_rn pointer to RN variables -*/ -int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); -int phy_procedures_slot_parallelization_UE_RX(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, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); -#ifdef UE_SLOT_PARALLELISATION -void *UE_thread_slot1_dl_processing(void *arg); -#endif - -/*! \brief Scheduling for UE TX procedures in TDD S-subframes. - @param phy_vars_ue Pointer to UE variables on which to act - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_UE_S_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type); - -/*! \brief Scheduling for UE RX procedures in TDD S-subframes. - @param phy_vars_ue Pointer to UE variables on which to act - @param eNB_id Local id of eNB on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_UE_S_RX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag, relaying_type_t r_type); - -/*! \brief Scheduling for eNB TX procedures in normal subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param abstraction_flag Indicator of PHY abstraction - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying - @param phy_vars_rn pointer to the RN variables - @param do_meas Do inline timing measurement -*/ -void phy_procedures_eNB_TX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn,int do_meas); - -/*! \brief Scheduling for eNB RX UE-specific procedures in normal subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param proc Pointer to RXn-TXnp4 proc information - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type); - -/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param proc Pointer to RXn-TXnp4 proc information - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ - -/*! \brief Scheduling for eNB RX common procedures in normal subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param abstraction_flag Indicator of PHY abstraction -*/ -void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); - -/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ - -void phy_procedures_eNB_S_TX(PHY_VARS_eNB *phy_vars_eNB,relaying_type_t r_type); - -/*! \brief Scheduling for eNB RX procedures in TDD S-subframes. - @param phy_vars_eNB Pointer to eNB variables on which to act - @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying -*/ -void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,relaying_type_t r_type); - -/*! \brief Scheduling for eNB PRACH RX procedures - @param phy_vars_eNB Pointer to eNB variables on which to act - @param br_flag indicator for eMTC PRACH -*/ -#ifdef Rel14 -void prach_procedures(PHY_VARS_eNB *eNB, - int br_flag); -#else -void prach_procedures(PHY_VARS_eNB *eNB); -#endif +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" /*! \brief Function to compute subframe Number(DL and S) as a function of Frame type and TDD Configuration @param frame_parms Pointer to DL frame parameter descriptor @@ -238,13 +54,8 @@ lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) */ dci_detect_mode_t dci_detect_mode_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); -/*! \brief Function to compute subframe type as a function of Frame type and TDD Configuration (implements Table 4.2.2 from 36.211, p.11 from version 8.6) and subframe index. Same as subframe_select, except that it uses the Mod_id and is provided as a service to the MAC scheduler. - @param Mod_id Index of eNB - @param CC_id Component Carrier Index - @param subframe Subframe index - @returns Subframe type (DL,UL,S) -*/ -lte_subframe_t get_subframe_direction(uint8_t Mod_id, uint8_t CC_id,uint8_t subframe); + + /*! \brief Function to indicate PHICH transmission subframes. Implements Table 9.1.2-1 for TDD. @param frame_parms Pointer to DL frame parameter descriptor diff --git a/openair1/SCHED/extern.h b/openair1/SCHED/sched_common_extern.h similarity index 88% rename from openair1/SCHED/extern.h rename to openair1/SCHED/sched_common_extern.h index b1e8df67ef86a5bb11c9cf9bb2d5dd57374d2eee..b5edc6f38e390dc027a1f3699c2a05c157778092 100644 --- a/openair1/SCHED/extern.h +++ b/openair1/SCHED/sched_common_extern.h @@ -24,16 +24,7 @@ #ifndef __SCHED_EXTERN_H__ #define __SCHED_EXTERN_H__ -#include "defs.h" -//#include "dlc_engine.h" - -extern int openair_sched_status; - -//extern int exit_PHY; -//extern int exit_PHY_ack; - -extern int synch_wait_cnt; - +#include "sched_eNB.h" extern int16_t hundred_times_delta_TF[100]; extern uint16_t hundred_times_log10_NPRB[100]; diff --git a/openair1/SCHED/sched_common_vars.h b/openair1/SCHED/sched_common_vars.h new file mode 100644 index 0000000000000000000000000000000000000000..2cae2aa96f21bc49bc32dc156ac688b8c22f72eb --- /dev/null +++ b/openair1/SCHED/sched_common_vars.h @@ -0,0 +1,28 @@ +/* + * 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 <stdint.h> + + +// 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 +int16_t hundred_times_delta_TF[100] = {-32768,-1268,-956,-768,-631,-523,-431,-352,-282,-219,-161,-107,-57,-9,36,79,120,159,197,234,269,304,337,370,402,434,465,495,525,555,583,612,640,668,696,723,750,777,803,829,856,881,907,933,958,983,1008,1033,1058,1083,1108,1132,1157,1181,1205,1229,1254,1278,1302,1325,1349,1373,1397,1421,1444,1468,1491,1515,1538,1562,1585,1609,1632,1655,1679,1702,1725,1748,1772,1795,1818,1841,1864,1887,1910,1933,1956,1980,2003,2026,2049,2072,2095,2118,2141,2164,2186,2209,2232,2255}; +uint16_t hundred_times_log10_NPRB[100] = {0,301,477,602,698,778,845,903,954,1000,1041,1079,1113,1146,1176,1204,1230,1255,1278,1301,1322,1342,1361,1380,1397,1414,1431,1447,1462,1477,1491,1505,1518,1531,1544,1556,1568,1579,1591,1602,1612,1623,1633,1643,1653,1662,1672,1681,1690,1698,1707,1716,1724,1732,1740,1748,1755,1763,1770,1778,1785,1792,1799,1806,1812,1819,1826,1832,1838,1845,1851,1857,1863,1869,1875,1880,1886,1892,1897,1903,1908,1913,1919,1924,1929,1934,1939,1944,1949,1954,1959,1963,1968,1973,1977,1982,1986,1991,1995,2000}; + diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h new file mode 100644 index 0000000000000000000000000000000000000000..e03b7f6b62be7579cdefd02a17b69db3e2809c95 --- /dev/null +++ b/openair1/SCHED/sched_eNB.h @@ -0,0 +1,227 @@ +/* + * 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 + */ + +/* + \author R. Knopp, F. Kaltenberger + \company EURECOM + \email knopp@eurecom.fr +*/ + +#ifndef __openair_SCHED_ENB_H__ +#define __openair_SCHED_ENB_H__ + +#include "PHY/defs_eNB.h" +#include "PHY_INTERFACE/phy_interface.h" +#include "sched_common.h" + +enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0, + TOP_LEVEL_SCHEDULER_THREAD_INDEX, + DLC_SCHED_THREAD_INDEX, + openair_SCHED_NB_THREADS + }; // do not modify this line + + +#define OPENAIR_THREAD_PRIORITY 255 + + +#define OPENAIR_THREAD_STACK_SIZE PTHREAD_STACK_MIN //4096 //RTL_PTHREAD_STACK_MIN*6 +//#define DLC_THREAD_STACK_SIZE 4096 //DLC stack size +//#define UE_SLOT_PARALLELISATION + +enum openair_SCHED_STATUS { + openair_SCHED_STOPPED=1, + openair_SCHED_STARTING, + openair_SCHED_STARTED, + openair_SCHED_STOPPING +}; + +enum openair_ERROR { + // HARDWARE CAUSES + openair_ERROR_HARDWARE_CLOCK_STOPPED= 1, + + // SCHEDULER CAUSE + openair_ERROR_OPENAIR_RUNNING_LATE, + openair_ERROR_OPENAIR_SCHEDULING_FAILED, + + // OTHERS + openair_ERROR_OPENAIR_TIMING_OFFSET_OUT_OF_BOUNDS, +}; + +enum openair_SYNCH_STATUS { + openair_NOT_SYNCHED=1, + openair_SYNCHED, + openair_SCHED_EXIT +}; + +enum openair_HARQ_TYPE { + openair_harq_DL = 0, + openair_harq_UL, + openair_harq_RA +}; + +#define DAQ_AGC_ON 1 +#define DAQ_AGC_OFF 0 + + +/** @addtogroup _PHY_PROCEDURES_ + * @{ + */ + + + +/*! \brief Scheduling for eNB TX procedures in normal subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param abstraction_flag Indicator of PHY abstraction + @param do_meas Do inline timing measurement +*/ +void phy_procedures_eNB_TX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,int do_meas); + +/*! \brief Scheduling for eNB RX UE-specific procedures in normal subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param proc Pointer to RXn-TXnp4 proc information +*/ +void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); + +/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param proc Pointer to RXn-TXnp4 proc information + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ + +/*! \brief Scheduling for eNB RX common procedures in normal subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act + @param abstraction_flag Indicator of PHY abstraction +*/ +void phy_procedures_eNB_common_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); + +/*! \brief Scheduling for eNB TX procedures in TDD S-subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act +*/ + +void phy_procedures_eNB_S_TX(PHY_VARS_eNB *phy_vars_eNB); + +/*! \brief Scheduling for eNB RX procedures in TDD S-subframes. + @param phy_vars_eNB Pointer to eNB variables on which to act +*/ +void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc); + +/*! \brief Scheduling for eNB PRACH RX procedures + @param phy_vars_eNB Pointer to eNB variables on which to act + @param br_flag indicator for eMTC PRACH +*/ +#ifdef Rel14 +void prach_procedures(PHY_VARS_eNB *eNB, + int br_flag); +#else +void prach_procedures(PHY_VARS_eNB *eNB); +#endif + +/*! \brief Function to compute timing of Msg3 transmission on UL-SCH (first UE transmission in RA procedure). This implements the timing in paragraph a) from Section 6.1.1 in 36.213 (p. 17 in version 8.6). Used by eNB upon transmission of random-access response (RA_RNTI) to program corresponding ULSCH reception procedure. Used by UE upon reception of random-access response (RA_RNTI) to program corresponding ULSCH transmission procedure. This does not support the UL_delay field in RAR (always assumed to be 0). + @param frame_parms Pointer to DL frame parameter descriptor + @param current_subframe Index of subframe where RA_RNTI was received + @param current_frame Index of frame where RA_RNTI was received + @param frame Frame index where Msg3 is to be transmitted (n+6 mod 10 for FDD, different for TDD) + @param subframe subframe index where Msg3 is to be transmitted (n, n+1 or n+2) +*/ +void get_Msg3_alloc(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t current_subframe, + uint32_t current_frame, + uint32_t *frame, + uint8_t *subframe); + +/*! \brief Function to compute timing of Msg3 retransmission on UL-SCH (first UE transmission in RA procedure). + @param frame_parms Pointer to DL frame parameter descriptor + @param current_subframe Index of subframe where RA_RNTI was received + @param current_frame Index of frame where RA_RNTI was received + @param frame Frame index where Msg3 is to be transmitted (n+6 mod 10 for FDD, different for TDD) + @param subframe subframe index where Msg3 is to be transmitted (n, n+1 or n+2) +*/ +void get_Msg3_alloc_ret(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t current_subframe, + uint32_t current_frame, + uint32_t *frame, + uint8_t *subframe); + +/*! \brief Get ULSCH harq_pid for Msg3 from RAR subframe. This returns n+k mod 10 (k>6) and corresponds to the rule in Section 6.1.1 from 36.213 + @param frame_parms Pointer to DL Frame Parameters + @param frame Frame index + @param current_subframe subframe of RAR transmission + @returns harq_pid (0 ... 7) + */ +uint8_t get_Msg3_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t current_subframe); + +/*! \brief Get ULSCH harq_pid from PHICH subframe + @param frame_parms Pointer to DL Frame Parameters + @param subframe subframe of PHICH + @returns harq_pid (0 ... 7) + */ + +/*! \brief Function to indicate failure of contention resolution or RA procedure. It places the UE back in PRACH mode. + @param Mod_id Instance index of UE + @param CC_id Component Carrier Index + @param eNB_index Index of eNB + */ +void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief Indicates the SR TXOp in current subframe for eNB and particular UE index. Implements Table 10.1-5 from 36.213. + @param phy_vars_eNB Pointer to eNB variables + @param UE_id ID of UE which may be issuing the SR + @returns 1 if TXOp is active. +*/ +uint8_t is_SR_subframe(PHY_VARS_eNB *phy_vars_eNB,eNB_rxtx_proc_t *proc,uint8_t UE_id); + +int8_t find_ue_dlsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); +int8_t find_ue_ulsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); + + + + + +void schedule_response(Sched_Rsp_t *Sched_INFO); + +LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti); + +/*! \brief Function to compute subframe type as a function of Frame type and TDD Configuration (implements Table 4.2.2 from 36.211, p.11 from version 8.6) and subframe index. Same as subframe_select, except that it uses the Mod_id and is provided as a service to the MAC scheduler. + @param Mod_id Index of eNB + @param CC_id Component Carrier Index + @param subframe Subframe index + @returns Subframe type (DL,UL,S) +*/ +lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subframe); + + +int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *phy_vars_eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor); + +int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid); + +int16_t get_target_pusch_rx_power(module_id_t module_idP, uint8_t CC_id); +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); + +/*@}*/ + + +#endif + + diff --git a/openair1/SCHED_NBIOT/README b/openair1/SCHED_NBIOT/README new file mode 100644 index 0000000000000000000000000000000000000000..319372ee93aa05bec7537d2b8c771fad0c7cb854 --- /dev/null +++ b/openair1/SCHED_NBIOT/README @@ -0,0 +1 @@ +213 procedures for NB-IoT eNB diff --git a/openair1/SCHED_NR/README b/openair1/SCHED_NR/README new file mode 100644 index 0000000000000000000000000000000000000000..8814a972b0e5a84dbb757a8769d485afb74ec131 --- /dev/null +++ b/openair1/SCHED_NR/README @@ -0,0 +1 @@ +213/214 procedures for NR gNB diff --git a/openair1/SCHED_NR_UE/README b/openair1/SCHED_NR_UE/README new file mode 100644 index 0000000000000000000000000000000000000000..b2bc9d09b8ae274660cf13da0636158b31811e57 --- /dev/null +++ b/openair1/SCHED_NR_UE/README @@ -0,0 +1 @@ +213/214 procedures for NR UE diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c similarity index 98% rename from openair1/SCHED/phy_procedures_lte_ue.c rename to openair1/SCHED_UE/phy_procedures_lte_ue.c index 2635649589643575b027439581079c63b1527ba9..da788d343ca04e33720b2d9add754a1d0f6238f7 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -33,22 +33,23 @@ #define _GNU_SOURCE #include "assertions.h" -#include "defs.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern_ue.h" #include <sched.h> #include "targets/RT/USER/lte-softmodem.h" -#define DEBUG_PHY_PROC +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "SCHED_UE/sched_UE.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + +//#define DEBUG_PHY_PROC #ifndef PUCCH #define PUCCH #endif -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" @@ -58,13 +59,13 @@ # include "intertask_interface.h" #endif -#include "PHY/defs.h" +#include "PHY/defs_UE.h" -#include "PHY/CODING/extern.h" +#include "PHY/CODING/coding_extern.h" #include "T.h" -#include "PHY/TOOLS/defs.h" +#include "PHY/TOOLS/tools_defs.h" #define DLSCH_RB_ALLOC 0x1fbf // skip DC RB (total 23/25 RBs) #define DLSCH_RB_ALLOC_12 0x0aaa // skip DC RB (total 23/25 RBs) @@ -81,7 +82,7 @@ extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; #endif -#define UE_DEBUG_TRACE 1 +//#define UE_DEBUG_TRACE 1 void dump_dlsch(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid) { @@ -506,6 +507,7 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id { int Mod_id = ue->Mod_id; int CC_id = ue->CC_id; + // Panos: Substitute call to ue_get_SR() with the filled ue_SR_config->SR_payload (0, or 1). SR_payload = ue_get_SR(Mod_id, CC_id, frame_tx, @@ -1322,13 +1324,13 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt for (k=ulsch_start,l=0; k<cmin(frame_parms->samples_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]<<4; - ((short*)ue->common_vars.txdata[aa])[2*k+1] = ((short*)dummy_tx_buffer)[2*l+1]<<4; + ((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; k<overflow; k++,l++) { - ((short*)ue->common_vars.txdata[aa])[2*k] = ((short*)dummy_tx_buffer)[2*l]<<4; - ((short*)ue->common_vars.txdata[aa])[2*k+1] = ((short*)dummy_tx_buffer)[2*l+1]<<4; + ((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 defined(EXMIMO) // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on @@ -1389,7 +1391,6 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin frame_tx, eNB_id, subframe_tx); - LOG_D(PHY,"Got prach_resources for eNB %d address %p, RRCCommon %p\n",eNB_id,ue->prach_resources[eNB_id],UE_mac_inst[ue->Mod_id].radioResourceConfigCommon); LOG_D(PHY,"Prach resources %p\n",ue->prach_resources[eNB_id]); } } @@ -1411,7 +1412,7 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->prach_resources[eNB_id]->ra_PreambleIndex = 19; } - LOG_I(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d : Generating PRACH, preamble %d,PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n", + LOG_D(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d : Generating PRACH, preamble %d,PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n", ue->Mod_id, frame_tx, subframe_tx, @@ -1454,8 +1455,6 @@ void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin ue->tx_power_dBm[subframe_tx], dB_fixed(prach_power), ue->prach_vars[eNB_id]->amp); - - if (ue->mac_enabled==1){ Msg1_transmitted(ue->Mod_id, @@ -1754,6 +1753,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) { //if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->calibration_flag == 0) { access_mode=SCHEDULED_ACCESS; + ue_get_sdu(Mod_id, CC_id, frame_tx, @@ -2333,7 +2333,28 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin } -void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type) { +void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) { + + int subframe_tx = proc->subframe_tx; + int frame_tx = proc->frame_tx; + SLSS_t *slss; + SLDCH_t *sldch; + SLSCH_t *slsch; + + LOG_D(PHY,"****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx); + + // check for SLBCH/SLSS + if ((slss = ue_get_slss(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slss(ue,slss,frame_tx,subframe_tx); + + // check for SLDCH + if ((sldch = ue_get_sldch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_sldch(ue,sldch,frame_tx,subframe_tx); + + // check for SLSCH + if ((slsch = ue_get_slsch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slsch(ue,slsch,frame_tx,subframe_tx); + +} + +void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) { LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; @@ -2452,7 +2473,7 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui #endif } -void phy_procedures_UE_S_TX(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type) +void phy_procedures_UE_S_TX(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag) { int aa;//i,aa; LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; @@ -2727,6 +2748,7 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin ue->pbch_vars[eNB_id]->pdu_errors_conseq++; ue->pbch_vars[eNB_id]->pdu_errors++; + // Panos: Substitute call to rrc_out_of_sync_ind() with fill_bch_incication(sync=0). if (ue->mac_enabled == 1) rrc_out_of_sync_ind(ue->Mod_id,frame_rx,eNB_id); else AssertFatal(ue->pbch_vars[eNB_id]->pdu_errors_conseq<100, "More that 100 consecutive PBCH errors! Exiting!\n"); @@ -2747,6 +2769,8 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_OUT); } + + int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t abstraction_flag) { @@ -2770,15 +2794,17 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint subframe_rx, eNB_id, ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI, - ue->high_speed_flag, - ue->is_secondary_ue); + ue->high_speed_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_IN); - //printf("Decode SIB frame param agregation + DCI %d %d \n",agregationLevel,dciFormat); - + /*printf("Decode SIB frame param aggregation + DCI %d %d, num_pdcch_symbols %d\n", + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dciFormat, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); + */ //agregation level == FF means no configuration on if(ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel == 0xFF || ue->decode_SIB) { @@ -3108,7 +3134,7 @@ void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abs int subframe_rx = proc->subframe_rx; int frame_rx = proc->frame_rx; int pmch_mcs=-1; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) int CC_id = ue->CC_id; #endif uint8_t sync_area=255; @@ -3121,7 +3147,7 @@ void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abs LOG_D(PHY,"[UE %d] Frame %d, subframe %d: Querying for PMCH demodulation\n", ue->Mod_id,(subframe_rx==9?-1:0)+frame_rx,subframe_rx); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) pmch_mcs = ue_query_mch(ue->Mod_id, CC_id, @@ -3212,7 +3238,7 @@ void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abs // if (subframe_rx==9) // mac_xface->macphy_exit("Why are we exiting here?"); } else { // decoding successful -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mcch_active == 1) { ue_send_mch_sdu(ue->Mod_id, @@ -3235,7 +3261,7 @@ void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abs } -#endif // Rel10 || Rel14 +#endif // #if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) } // decoding sucessful } // pmch_mcs>=0 } // is_pmch_subframe=true @@ -3397,6 +3423,7 @@ void process_rar(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, runmode_t mo subframe_rx, ue->prach_resources[eNB_id]->ra_PreambleIndex); + // Panos: Substitute call to ue_process_rar() with call to fill_dlsch_rar_indication() timing_advance = ue_process_rar(ue->Mod_id, ue->CC_id, frame_rx, @@ -3727,6 +3754,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, switch (pdsch) { case PDSCH: + // Panos: Substitute call to ue_send_sdu() with call to fill_dlsch_indication() ue_send_sdu(ue->Mod_id, CC_id, frame_rx, @@ -3736,6 +3764,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, eNB_id); break; case SI_PDSCH: + // Panos: Substitute call with call to fill_dlsch_indication() ue_decode_si(ue->Mod_id, CC_id, frame_rx, @@ -3744,7 +3773,8 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, ue->dlsch_SI[eNB_id]->harq_processes[0]->TBS>>3); break; case P_PDSCH: - ue_decode_p(ue->Mod_id, + // Panos: Substitute call with call to fill_dlsch_indication() + ue_decode_p(ue->Mod_id, CC_id, frame_rx, eNB_id, @@ -3752,6 +3782,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, ue->dlsch_SI[eNB_id]->harq_processes[0]->TBS>>3); break; case RA_PDSCH: + // Panos: Substitute with call to fill_dlsch_rar_indication() process_rar(ue,proc,eNB_id,mode,abstraction_flag); break; case PDSCH1: @@ -4138,8 +4169,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { #ifdef UE_SLOT_PARALLELISATION int phy_procedures_slot_parallelization_UE_RX(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, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { int l,l2; int pmch_flag=0; @@ -4189,8 +4219,7 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *pr } #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[%s %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", - (r_type == multicast_relay) ? "RN/UE" : "UE", + LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", ue->Mod_id,frame_rx, subframe_rx); #endif @@ -4654,9 +4683,13 @@ int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *pr #endif +void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) { + + +} + int phy_procedures_UE_RX(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, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { int l,l2; int pilot1; @@ -4705,8 +4738,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[%s %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", - (r_type == multicast_relay) ? "RN/UE" : "UE", + LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", ue->Mod_id,frame_rx, subframe_rx); #endif @@ -5131,38 +5163,9 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, return (0); } -#if defined(Rel10) || defined(Rel14) - -int phy_procedures_RN_UE_RX(uint8_t slot_rx, uint8_t next_slot, relaying_type_t r_type) -{ - - int do_proc =0; // do nothing by default - - switch(r_type) { - case no_relay: - do_proc=no_relay; // perform the normal UE operation - break; - - case multicast_relay: - if (slot_rx > 12) - do_proc = 0; // do nothing - else // SF#1, SF#2, SF3, SF#3, SF#4, SF#5, SF#6(do rx slot 12) - do_proc = multicast_relay ; // do PHY procedures UE RX - break; - default: // should'not be here - LOG_W(PHY,"Not supported relay type %d, do nothing \n", r_type); - do_proc= 0; - break; - } - - return do_proc; -} -#endif - -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, - relaying_type_t r_type, PHY_VARS_RN *phy_vars_rn) +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) { #if defined(ENABLE_ITTI) MessageDef *msg_p; @@ -5224,30 +5227,22 @@ void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,u 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,r_type); + 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)) { -#if defined(Rel10) || defined(Rel14) - - if (phy_procedures_RN_UE_RX(subframe_rx, subframe_tx, r_type) != 0 ) -#endif - phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode,r_type,phy_vars_rn); + (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,r_type); + phy_procedures_UE_S_TX(ue,eNB_id,abstraction_flag); } if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_S) && - (slot==0)) { -#if defined(Rel10) || defined(Rel14) - - if (phy_procedures_RN_UE_RX(subframe_rx, subframe_tx, r_type) != 0 ) -#endif - phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode,r_type,phy_vars_rn); + (slot==0)) { + phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); } if (ue->mac_enabled==1) { diff --git a/openair1/SCHED/pucch_pc.c b/openair1/SCHED_UE/pucch_pc.c similarity index 95% rename from openair1/SCHED/pucch_pc.c rename to openair1/SCHED_UE/pucch_pc.c index f01d0d96dd7df5ddbc65cc8270d0ea4d760e5b43..f03cd93d34995b4313c1104aebd30f439b6afc8f 100644 --- a/openair1/SCHED/pucch_pc.c +++ b/openair1/SCHED_UE/pucch_pc.c @@ -30,10 +30,11 @@ * \warning */ -#include "PHY/defs.h" -#include "SCHED/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "SCHED_UE/sched_UE.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" int16_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,uint8_t eNB_id,PUCCH_FMT_t pucch_fmt) { diff --git a/openair1/SCHED_UE/pusch_pc.c b/openair1/SCHED_UE/pusch_pc.c new file mode 100644 index 0000000000000000000000000000000000000000..90c17099a04634f2193c3a73913affa40b2b0c51 --- /dev/null +++ b/openair1/SCHED_UE/pusch_pc.c @@ -0,0 +1,138 @@ +/* + * 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 pusch_pc.c + * \brief Implementation of UE PUSCH Power Control procedures from 36.213 LTE specifications (Section + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + +#include "sched_UE.h" +#include "SCHED/sched_common_extern.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" + +extern uint8_t nfapi_mode; + +int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_pid) +{ + + uint32_t Nre = 2*ue->ulsch[eNB_id]->harq_processes[harq_pid]->Nsymb_initial * + ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb*12; + + if (Nre==0) + return(0); + + uint32_t MPR_x100 = 100*ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/Nre; + // Note: MPR=is the effective spectral efficiency of the PUSCH + // FK 20140908 sumKr is only set after the ulsch_encoding + + uint16_t beta_offset_pusch = (ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? + ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; + + if (ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled == 1) { + // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) + return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch)>>3)); + } else { + return(0); + } +} + + + +uint8_t alpha_lut[8] = {0,40,50,60,70,80,90,100}; + +void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag) +{ + + + uint8_t harq_pid = subframe2harq_pid(&ue->frame_parms, + proc->frame_tx, + proc->subframe_tx); + + uint8_t nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb; + int16_t PL; + + + // P_pusch = 10*log10(nb_rb + P_opusch(j)+ alpha(u)*PL + delta_TF(i) + f(i)) + // + // P_opusch(0) = P_oPTR + deltaP_Msg3 if PUSCH is transporting Msg3 + // else + // P_opusch(0) = PO_NOMINAL_PUSCH(j) + P_O_UE_PUSCH(j) + PL = get_PL(ue->Mod_id,ue->CC_id,eNB_id); + + ue->ulsch[eNB_id]->Po_PUSCH = (hundred_times_log10_NPRB[nb_rb-1]+ + get_hundred_times_delta_IF(ue,eNB_id,harq_pid) + + 100*ue->ulsch[eNB_id]->f_pusch)/100; + + if(ue->ulsch_Msg3_active[eNB_id] == 1) { // Msg3 PUSCH + + ue->ulsch[eNB_id]->Po_PUSCH += (get_Po_NOMINAL_PUSCH(ue->Mod_id,0) + PL); + + + LOG_I(PHY,"[UE %d][RAPROC] frame %d, subframe %d: Msg3 Po_PUSCH %d dBm (%d,%d,100*PL=%d,%d,%d)\n", + ue->Mod_id,proc->frame_tx,proc->subframe_tx,ue->ulsch[eNB_id]->Po_PUSCH, + 100*get_Po_NOMINAL_PUSCH(ue->Mod_id,0), + hundred_times_log10_NPRB[nb_rb-1], + 100*PL, + get_hundred_times_delta_IF(ue,eNB_id,harq_pid), + 100*ue->ulsch[eNB_id]->f_pusch); + } else if (j==0) { // SPS PUSCH + } else if (j==1) { // Normal PUSCH + + ue->ulsch[eNB_id]->Po_PUSCH += ((alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL)/100); + ue->ulsch[eNB_id]->Po_PUSCH += ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH; + ue->ulsch[eNB_id]->PHR = ue->tx_power_max_dBm-ue->ulsch[eNB_id]->Po_PUSCH; + + if (ue->ulsch[eNB_id]->PHR < -23) + ue->ulsch[eNB_id]->PHR = -23; + else if (ue->ulsch[eNB_id]->PHR > 40) + ue->ulsch[eNB_id]->PHR = 40; + + LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubframe %d.%d: nb_rb: %d, Po_PUSCH %d dBm : tx power %d, Po_NOMINAL_PUSCH %d,log10(NPRB) %f,PHR %d, PL %d, alpha*PL %f,delta_IF %f,f_pusch %d\n", + ue->Mod_id,harq_pid,proc->frame_tx,proc->subframe_tx,nb_rb, + ue->ulsch[eNB_id]->Po_PUSCH, + ue->tx_power_max_dBm, + ue->frame_parms.ul_power_control_config_common.p0_NominalPUSCH, + hundred_times_log10_NPRB[nb_rb-1]/100.0, + ue->ulsch[eNB_id]->PHR, + PL, + alpha_lut[ue->frame_parms.ul_power_control_config_common.alpha]*PL/100.0, + get_hundred_times_delta_IF(ue,eNB_id,harq_pid)/100.0, + ue->ulsch[eNB_id]->f_pusch); + } + +} + +int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index) +{ + if(nfapi_mode!=3) + return PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->PHR; + else + return 40; // For nfapi_mode=3 consider ideal conditions +} diff --git a/openair1/SCHED_UE/sched_UE.h b/openair1/SCHED_UE/sched_UE.h new file mode 100644 index 0000000000000000000000000000000000000000..32702b114893329bf0db88291e2df50be8661a34 --- /dev/null +++ b/openair1/SCHED_UE/sched_UE.h @@ -0,0 +1,288 @@ +/* + * 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 + */ + +/* + \author R. Knopp, F. Kaltenberger + \company EURECOM + \email knopp@eurecom.fr +*/ + +#ifndef __openair_SCHED_UE_H__ +#define __openair_SCHED_UE_H__ + +#include "PHY/defs_UE.h" +#include "../SCHED/sched_common.h" + +/*! \brief Scheduling for UE TX procedures in normal subframes. + @param phy_vars_ue Pointer to UE variables on which to act + @param proc Pointer to RXn-TXnp4 proc information + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param mode calib/normal mode + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ +void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode); +/*! \brief Scheduling for UE RX procedures in normal subframes. + @param last_slot Index of last slot (0-19) + @param phy_vars_ue Pointer to UE variables on which to act + @param proc Pointer to RXn_TXnp4 proc information + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param mode calibration/debug mode + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying + @param phy_vars_rn pointer to RN variables +*/ +int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode); + +/*! \brief Scheduling for UE Sidelink RX procedures in normal subframes. + @param ue Pointer to UE variables on which to act + @param proc Pointer to RXn_TXnp4 proc information +*/ +void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc); + +/*! \brief Scheduling for UE Sidelink TX procedures in normal subframes. + @param ue Pointer to UE variables on which to act + @param proc Pointer to RXn_TXnp4 proc information +*/ +void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc); + +int phy_procedures_slot_parallelization_UE_RX(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); +#ifdef UE_SLOT_PARALLELISATION +void *UE_thread_slot1_dl_processing(void *arg); +#endif + +/*! \brief Scheduling for UE TX procedures in TDD S-subframes. + @param phy_vars_ue Pointer to UE variables on which to act + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ +void phy_procedures_UE_S_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag); + +/*! \brief Scheduling for UE RX procedures in TDD S-subframes. + @param phy_vars_ue Pointer to UE variables on which to act + @param eNB_id Local id of eNB on which to act + @param abstraction_flag Indicator of PHY abstraction + @param r_type indicates the relaying operation: 0: no_relaying, 1: unicast relaying type 1, 2: unicast relaying type 2, 3: multicast relaying +*/ +void phy_procedures_UE_S_RX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstraction_flag); + +/*! \brief Get ULSCH harq_pid for Msg3 from RAR subframe. This returns n+k mod 10 (k>6) and corresponds to the rule in Section 6.1.1 from 36.213 + @param frame_parms Pointer to DL Frame Parameters + @param frame Frame index + @param current_subframe subframe of RAR transmission + @returns harq_pid (0 ... 7) + */ +uint8_t get_Msg3_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t current_subframe); + +/*! \brief Get ULSCH harq_pid from PHICH subframe + @param frame_parms Pointer to DL Frame Parameters + @param subframe subframe of PHICH + @returns harq_pid (0 ... 7) + */ + +/*! \brief Function to indicate failure of contention resolution or RA procedure. It places the UE back in PRACH mode. + @param Mod_id Instance index of UE + @param CC_id Component Carrier Index + @param eNB_index Index of eNB + */ +void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief Function to indicate success of contention resolution or RA procedure. + @param Mod_id Instance index of UE + @param CC_id Component Carrier Index + @param eNB_index Index of eNB + */ +void ra_succeeded(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +uint8_t phich_subframe_to_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe); + +/*! \brief Get PDSCH subframe (n+k) from PDCCH subframe n using relationship from Table 8-2 from 36.213 + @param frame_parms Pointer to DL Frame Parameters + @param n subframe of PDCCH + @returns PDSCH subframe (0 ... 7) (note: this is n+k from Table 8-2) + */ +uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); + + +/*! \brief Compute ACK/NACK information for PUSCH/PUCCH for UE transmission in subframe n. This function implements table 10.1-1 of 36.213, p. 69. + @param frame_parms Pointer to DL frame parameter descriptor + @param harq_ack Pointer to dlsch_ue harq_ack status descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @param o_ACK Pointer to ACK/NAK payload for PUCCH/PUSCH + @returns status indicator for PUCCH/PUSCH transmission +*/ +uint8_t get_ack(LTE_DL_FRAME_PARMS *frame_parms,harq_status_t *harq_ack,uint8_t subframe_tx,uint8_t subframe_rx,uint8_t *o_ACK, uint8_t cw_idx); + +/*! \brief Reset ACK/NACK information + @param frame_parms Pointer to DL frame parameter descriptor + @param harq_ack Pointer to dlsch_ue harq_ack status descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @param o_ACK Pointer to ACK/NAK payload for PUCCH/PUSCH + @returns status indicator for PUCCH/PUSCH transmission +*/ +uint8_t reset_ack(LTE_DL_FRAME_PARMS *frame_parms, + harq_status_t *harq_ack, + unsigned char subframe_tx, + unsigned char subframe_rx, + unsigned char *o_ACK, + uint8_t *pN_bundled, + uint8_t cw_idx); + +/*! \brief Compute UL ACK subframe from DL subframe. This is used to retrieve corresponding DLSCH HARQ pid at eNB upon reception of ACK/NAK information on PUCCH/PUSCH. Derived from Table 10.1-1 in 36.213 (p. 69 in version 8.6) + @param frame_parms Pointer to DL frame parameter descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @param ACK_index TTI bundling index (0,1) + @returns Subframe index for corresponding DL transmission +*/ +uint8_t ul_ACK_subframe2_dl_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe,uint8_t ACK_index); + +/*! \brief Computes number of DL subframes represented by a particular ACK received on UL (M from Table 10.1-1 in 36.213, p. 69 in version 8.6) + @param frame_parms Pointer to DL frame parameter descriptor + @param subframe Subframe for UE transmission (n in 36.213) + @returns Number of DL subframes (M) +*/ +uint8_t ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe); + +/*! \brief Indicates the SR TXOp in current subframe. Implements Table 10.1-5 from 36.213. + @param phy_vars_ue Pointer to UE variables + @param proc Pointer to RXn_TXnp4 thread context + @param eNB_id ID of eNB which is to receive the SR + @returns 1 if TXOp is active. +*/ +uint8_t is_SR_TXOp(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id); + +uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); + +/*! \brief Gives the UL frame corresponding to a PDDCH order in subframe n + @param frame_parms Pointer to DL frame parameters + @param frame Frame of received PDCCH + @param n subframe of PDCCH + @returns UL frame corresponding to pdcch order +*/ +uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n); + + +uint16_t get_Np(uint8_t N_RB_DL,uint8_t nCCE,uint8_t plus1); + + + +void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance); +void process_timing_advance_rar(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint16_t timing_advance); + +unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb); + +void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief This function retrives the resource (n1_pucch) corresponding to a PDSCH transmission in +subframe n-4 which is acknowledged in subframe n (for FDD) according to n1_pucch = Ncce + N1_pucch. For +TDD, this routine computes the complex procedure described in Section 10.1 of 36.213 (through tables 10.1-1,10.1-2) +@param phy_vars_ue Pointer to UE variables +@param proc Pointer to RXn-TXnp4 proc information +@param harq_ack Pointer to dlsch_ue harq_ack status descriptor +@param eNB_id Index of eNB +@param b Pointer to PUCCH payload (b[0],b[1]) +@param SR 1 means there's a positive SR in parallel to ACK/NAK +@returns n1_pucch +*/ +uint16_t get_n1_pucch(PHY_VARS_UE *phy_vars_ue, + UE_rxtx_proc_t *proc, + harq_status_t *harq_ack, + uint8_t eNB_id, + uint8_t *b, + uint8_t SR); + + + + +/*! \brief This function retrieves the PHY UE mode. It is used as a helper function for the UE MAC. + @param Mod_id Local UE index on which to act + @param CC_id Component Carrier Index + @param eNB_index ID of eNB + @returns UE mode +*/ +UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + +/*! \brief This function implements the power control mechanism for PUCCH from 36.213. + @param phy_vars_ue PHY variables + @param proc Pointer to proc descriptor + @param eNB_id Index of eNB + @param pucch_fmt Format of PUCCH that is being transmitted + @returns Transmit power + */ +int16_t pucch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t subframe,uint8_t eNB_id,PUCCH_FMT_t pucch_fmt); + +/*! \brief This function implements the power control mechanism for PUCCH from 36.213. + @param phy_vars_ue PHY variables + @param proc Pointer to proc descriptor + @param eNB_id Index of eNB + @param j index of type of PUSCH (SPS, Normal, Msg3) + @returns Transmit power + */ +void pusch_power_cntl(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t j, uint8_t abstraction_flag); + +/*! \brief This function implements the power control mechanism for SRS from 36.213. + @param phy_vars_ue PHY variables + @param proc Pointer to proc descriptor + @param eNB_id Index of eNB + @param j index of type of PUSCH (SPS, Normal, Msg3) + @returns Transmit power + */ +void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag); + +void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id); + +int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id, uint8_t eNB_index); + + + +LTE_DL_FRAME_PARMS *get_lte_frame_parms(module_id_t Mod_id, uint8_t CC_id); + +MU_MIMO_mode* get_mu_mimo_mode (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); + +int16_t get_hundred_times_delta_IF(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t harq_pid); + + +int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid); + +int16_t get_target_pusch_rx_power(module_id_t module_idP, uint8_t CC_id); +int16_t get_target_pucch_rx_power(module_id_t module_idP, uint8_t CC_id); + +int get_ue_active_harq_pid(uint8_t Mod_id,uint8_t CC_id,uint16_t rnti,int frame, uint8_t subframe,uint8_t *harq_pid,uint8_t *round,uint8_t ul_flag); + +void dump_dlsch(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid); +void dump_dlsch_SI(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe); +void dump_dlsch_ra(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe); + +void dump_dlsch2(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe, unsigned int *coded_bits_per_codeword,int round, unsigned char harq_pid); + + +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); + +/*@}*/ + + +#endif + + diff --git a/openair1/SCHED/srs_pc.c b/openair1/SCHED_UE/srs_pc.c similarity index 96% rename from openair1/SCHED/srs_pc.c rename to openair1/SCHED_UE/srs_pc.c index 04dacecc25a5aa59e6feb2ea35811dbe913082fc..9463db2cd62b594db9fad1adeb7514fbcd34516e 100644 --- a/openair1/SCHED/srs_pc.c +++ b/openair1/SCHED_UE/srs_pc.c @@ -30,9 +30,10 @@ * \warning */ -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/extern.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/phy_extern_ue.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" void srs_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t *pnb_rb_srs, uint8_t abstraction_flag) { diff --git a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c b/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c index 1ba724976fabdd87b82c623ee50ea9b43cb8cbfb..8cf9e13212244ec7e1ab7350c1228deff9b1d5e0 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/multicast_link.c @@ -113,7 +113,7 @@ multicast_link_init(void) if (multicast_if != NULL) { if (setsockopt(group_list[group].socket, SOL_SOCKET,SO_BINDTODEVICE, - multicast_if, 4) < 0) { + multicast_if, strlen(multicast_if)) < 0) { LOG_E(EMU, "[MULTICAST] ERROR : setsockopt:SO_BINDTODEVICE on interface %s, exiting ...\n", multicast_if); diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index b578721a1a0ffed4b79f7956551d8ae3fe49c00c..230eeac726fb3039ca23bdc88ba3839be4e2c0c4 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -39,6 +39,13 @@ #include <fcntl.h> #include <errno.h> #include "platform_constants.h" +#ifdef UE_NAS_USE_TUN +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <linux/if.h> +#include <linux/if_tun.h> +#include "openairinterface5g_limits.h" +#endif char nl_rx_buf[NL_MAX_PAYLOAD]; @@ -47,12 +54,119 @@ struct nlmsghdr *nas_nlh_tx = NULL; struct nlmsghdr *nas_nlh_rx = NULL; struct iovec nas_iov_tx; struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; +#ifdef UE_NAS_USE_TUN +int nas_sock_fd[NUMBER_OF_UE_MAX]; +#else int nas_sock_fd; +#endif struct msghdr nas_msg_tx; struct msghdr nas_msg_rx; #define GRAAL_NETLINK_ID 31 +#ifdef UE_NAS_USE_TUN + +static int tun_alloc(char *dev) +{ + struct ifreq ifr; + int fd, err; + + if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) { + printf("[TUN] failed to open /dev/net/tun\n"); + return -1; + } + + memset(&ifr, 0, sizeof(ifr)); + + /* Flags: IFF_TUN - TUN device (no Ethernet headers) + * IFF_TAP - TAP device + * + * IFF_NO_PI - Do not provide packet information + */ + ifr.ifr_flags = IFF_TUN | IFF_NO_PI; + if( *dev ) + strncpy(ifr.ifr_name, dev, IFNAMSIZ); + + if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){ + close(fd); + return err; + } + strcpy(dev, ifr.ifr_name); + return fd; +} + +int netlink_init(void) +{ + int i; + int ret; + + char ifname[64]; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + sprintf(ifname, "oip%d", i+1); + nas_sock_fd[i] = tun_alloc(ifname); + + if (nas_sock_fd[i] == -1) { + printf("[NETLINK] Error opening socket %d (%d:%s)\n",nas_sock_fd[i],errno, strerror(errno)); + exit(1); + } + + printf("[NETLINK]Opened socket with fd %d\n",nas_sock_fd[i]); + +#if !defined(PDCP_USE_NETLINK_QUEUES) + ret = fcntl(nas_sock_fd[i],F_SETFL,O_NONBLOCK); + + if (ret == -1) { + printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); +#if defined(LINK_ENB_PDCP_TO_IP_DRIVER) + exit(1); +#endif + } + +#endif + + memset(&nas_src_addr, 0, sizeof(nas_src_addr)); + nas_src_addr.nl_family = AF_NETLINK; + nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ + nas_src_addr.nl_groups = 0; /* not in mcast groups */ + ret = bind(nas_sock_fd[i], (struct sockaddr*)&nas_src_addr, sizeof(nas_src_addr)); + + + + memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); + nas_dest_addr.nl_family = AF_NETLINK; + nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ + nas_dest_addr.nl_groups = 0; /* unicast */ + + // TX PART + nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); + memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); + /* Fill the netlink message header */ + nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); + nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */ + nas_nlh_tx->nlmsg_flags = 0; + + nas_iov_tx.iov_base = (void *)nas_nlh_tx; + nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len; + memset(&nas_msg_tx,0,sizeof(nas_msg_tx)); + nas_msg_tx.msg_name = (void *)&nas_dest_addr; + nas_msg_tx.msg_namelen = sizeof(nas_dest_addr); + nas_msg_tx.msg_iov = &nas_iov_tx; + nas_msg_tx.msg_iovlen = 1; + + + // RX PART + memset(&nas_msg_rx,0,sizeof(nas_msg_rx)); + nas_msg_rx.msg_name = (void *)&nas_src_addr; + nas_msg_rx.msg_namelen = sizeof(nas_src_addr); + nas_msg_rx.msg_iov = &nas_iov_rx; + nas_msg_rx.msg_iovlen = 1; + } + + return 1; +} + +#else /* UE_NAS_USE_TUN */ + int netlink_init(void) { int ret; @@ -119,3 +233,5 @@ int netlink_init(void) return(nas_sock_fd); } + +#endif /* UE_NAS_USE_TUN */ diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 885d29cc4e1c8caee548a5f376c8f7b4daa8632e..77b8c0e674d3b09cad69be0fcb6048abc7f54f46 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -36,14 +36,15 @@ #include <execinfo.h> #include <signal.h> -#include "SIMULATION/TOOLS/defs.h" +#include "SIMULATION/TOOLS/sim.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/vars.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_vars.h" -#include "SCHED/defs.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" +#include "SCHED/sched_eNB.h" +#include "SCHED/sched_common_vars.h" +#include "LAYER2/MAC/mac_vars.h" #include "OCG_vars.h" #include "UTIL/LOG/log.h" @@ -56,7 +57,18 @@ #include "dummy_functions.c" +#include "PHY/MODULATION/modulation_common.h" +#include "PHY/MODULATION/modulation_eNB.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "SCHED/sched_eNB.h" +#include "SCHED_UE/sched_UE.h" +#include "common/config/config_load_configmodule.h" +#include "PHY/INIT/phy_init.h" +void feptx_ofdm(RU_t *ru); +void feptx_prec(RU_t *ru); double cpuf; @@ -69,6 +81,8 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ +int codingw = 0; + void handler(int sig) { void *array[10]; @@ -538,7 +552,6 @@ int main(int argc, char **argv) DCI_ALLOC_t da; DCI_ALLOC_t *dci_alloc = &da; - unsigned int ret; unsigned int coded_bits_per_codeword=0,nsymb; //,tbs=0; unsigned int tx_lev=0,tx_lev_dB=0,trials; @@ -561,16 +574,6 @@ int main(int argc, char **argv) unsigned char input_trch_file=0; FILE *input_fd=NULL; unsigned char input_file=0; - // char input_val_str[50],input_val_str2[50]; - - char input_trch_val[16]; - - // unsigned char pbch_pdu[6]; - - - - - // FILE *rx_frame_file; int n_frames; int n_ch_rlz = 1; @@ -593,7 +596,7 @@ int main(int argc, char **argv) // void *data; // int ii; // int bler; - double blerr[4],uncoded_ber=0; //,avg_ber; + double blerr[4]; short *uncoded_ber_bit=NULL; uint8_t N_RB_DL=25,osf=1; frame_t frame_type = FDD; @@ -1592,13 +1595,13 @@ int main(int argc, char **argv) eNB->abstraction_flag=0; schedule_response(&sched_resp); - phy_procedures_eNB_TX(eNB,proc_eNB,no_relay,NULL,1); + phy_procedures_eNB_TX(eNB,proc_eNB,1); if (uncoded_ber_bit == NULL) { // this is for user 0 only printf("nb_rb %d, rb_alloc %x, mcs %d\n", eNB->dlsch[0][0]->harq_processes[0]->nb_rb, - eNB->dlsch[0][0]->harq_processes[0]->rb_alloc, + eNB->dlsch[0][0]->harq_processes[0]->rb_alloc[0], eNB->dlsch[0][0]->harq_processes[0]->mcs); coded_bits_per_codeword = get_G(&eNB->frame_parms, @@ -1634,7 +1637,7 @@ int main(int argc, char **argv) proc_eNB->subframe_tx = subframe+1; sched_resp.subframe=subframe+1; schedule_response(&sched_resp); - phy_procedures_eNB_TX(eNB,proc_eNB,no_relay,NULL,0); + phy_procedures_eNB_TX(eNB,proc_eNB,0); ru->proc.subframe_tx=(subframe+1)%10; @@ -1723,7 +1726,7 @@ int main(int argc, char **argv) dci_received = UE->pdcch_vars[UE->current_thread_id[proc->subframe_rx]][eNB_id]->dci_received; - phy_procedures_UE_RX(UE,proc,0,0,dci_flag,normal_txrx,no_relay,NULL); + phy_procedures_UE_RX(UE,proc,0,0,dci_flag,normal_txrx); dci_received = dci_received - UE->pdcch_vars[UE->current_thread_id[proc->subframe_rx]][eNB_id]->dci_received; diff --git a/openair1/SIMULATION/LTE_PHY/dummy_functions.c b/openair1/SIMULATION/LTE_PHY/dummy_functions.c index dc86e76113aa7c5dd32c79b0146f1f2596cd8aa3..ac96d53b0f5d2f6baa8bc91c849813c15b621eb9 100644 --- a/openair1/SIMULATION/LTE_PHY/dummy_functions.c +++ b/openair1/SIMULATION/LTE_PHY/dummy_functions.c @@ -38,6 +38,14 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frame, sub_frame_t subframe, uint8_t * sdu, uint16_t sdu_len, uint8_t CH_index){} +SLSS_t *ue_get_slss(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe) {return(NULL);} + +SLDCH_t *ue_get_sldch(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe) {return(NULL);} + +SLSCH_t *ue_get_slsch(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe) {return(NULL);} + +void multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP) {} + uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index fc782be07a05db17d3a78dbe2464bd6a10a3e0b5..22cac3719374c4dcd86a2e71eefc17151dc97d2f 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -33,22 +33,30 @@ #include <string.h> #include <math.h> #include <unistd.h> -#include "SIMULATION/TOOLS/defs.h" +#include "SIMULATION/TOOLS/sim.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/vars.h" +#include "PHY/defs_common.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_vars.h" -#include "SCHED/defs.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" + +#include "SCHED/sched_common_vars.h" +#include "SCHED/sched_eNB.h" +#include "SCHED_UE/sched_UE.h" +#include "LAYER2/MAC/mac_vars.h" #include "OCG_vars.h" -#include "intertask_interface_init.h" + +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/INIT/phy_init.h" #include "unitary_defs.h" #include "PHY/TOOLS/lte_phy_scope.h" #include "dummy_functions.c" +#include "common/config/config_load_configmodule.h" double cpuf; @@ -89,6 +97,8 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU]; nfapi_tx_request_t TX_req; Sched_Rsp_t sched_resp; +int codingw = 0; + void fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu, uint8_t cqi_req, @@ -873,6 +883,7 @@ int main(int argc, char **argv) // NN: N_RB_UL has to be defined in ulsim for (int k=0;k<NUMBER_OF_UE_MAX;k++) eNB->ulsch[k] = new_eNB_ulsch(max_turbo_iterations,N_RB_DL,0); UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0); + printf("ULSCH %p\n",UE->ulsch[0]); if (parallel_flag == 1) { extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); @@ -946,34 +957,6 @@ int main(int argc, char **argv) UE->ulsch_Msg3_active[eNB_id] = 0; UE->ul_power_control_dedicated[eNB_id].accumulationEnabled=1; - /* - generate_ue_ulsch_params_from_dci((void *)&UL_alloc_pdu, - 14, - proc_rxtx->subframe_tx, - format0, - UE, - proc_rxtx_ue, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - 0, - srs_flag); - - // printf("RIV %d\n",UL_alloc_pdu.rballoc); - - generate_eNB_ulsch_params_from_dci(eNB,proc_rxtx, - (void *)&UL_alloc_pdu, - 14, - format0, - 0, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - srs_flag); - */ - coded_bits_per_codeword = nb_rb * (12 * get_Qm_ul(mcs)) * nsymb; if (cqi_flag == 1) coded_bits_per_codeword-=UE->ulsch[0]->O; @@ -1211,7 +1194,7 @@ int main(int argc, char **argv) proc_rxtx_ue->subframe_tx = proc_rxtx->subframe_rx; proc_rxtx_ue->subframe_rx = proc_rxtx->subframe_tx; - phy_procedures_UE_TX(UE,proc_rxtx_ue,0,0,normal_txrx,no_relay); + phy_procedures_UE_TX(UE,proc_rxtx_ue,0,0,normal_txrx); tx_lev = signal_energy(&UE->common_vars.txdata[0][eNB->frame_parms.samples_per_tti*subframe], @@ -1339,7 +1322,7 @@ int main(int argc, char **argv) ru->feprx(ru); - phy_procedures_eNB_uespec_RX(eNB,proc_rxtx,no_relay); + phy_procedures_eNB_uespec_RX(eNB,proc_rxtx); if (cqi_flag > 0) { diff --git a/openair1/SIMULATION/RF/dac.c b/openair1/SIMULATION/RF/dac.c index 8cf6b496231d630df17437b3712fd0f617eb218a..b09bd20374bf7bec5df4143443a841472c3a2876 100644 --- a/openair1/SIMULATION/RF/dac.c +++ b/openair1/SIMULATION/RF/dac.c @@ -22,8 +22,8 @@ //#define DEBUG_DAC 1 #include <math.h> #include <stdio.h> -#include "PHY/TOOLS/defs.h" - +#include "PHY/TOOLS/tools_defs.h" +#include "rf.h" void dac(double *s_re[2], double *s_im[2], uint32_t **input, @@ -91,10 +91,8 @@ double dac_fixed_gain(double *s_re[2], int i; int aa; - double amp,amp1_local,*amp1p; - - amp = //sqrt(NB_RE)*pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna - pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna + double amp1_local,*amp1p; + double amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna if (amp1==NULL) amp1p = &1_local; else amp1p = amp1; @@ -123,7 +121,7 @@ double dac_fixed_gain(double *s_re[2], //printf("DL: amp1 %f dB (%d,%d), tx_power %f\n",20*log10(amp1),input_offset,input_offset_meas,txpwr_dBm); */ - + // printf("DAC: amp/amp1p %f amp1 %f dB (%d,%d), tx_power %f\n",amp/(*amp1p),20*log10(*amp1p),input_offset,input_offset_meas,txpwr_dBm); for (i=0; i<length; i++) { for (aa=0; aa<nb_tx_antennas; aa++) { s_re[aa][i] = amp*((double)(((short *)input[aa]))[((i+input_offset)<<1)])/(*amp1p); @@ -131,7 +129,7 @@ double dac_fixed_gain(double *s_re[2], } } - // printf("ener %e\n",signal_energy_fp(s_re,s_im,nb_tx_antennas,length,0)); + // printf("ener %e\n",signal_energy_fp(s_re,s_im,nb_tx_antennas,length<length_meas?length:length_meas,0)); return(signal_energy_fp(s_re,s_im,nb_tx_antennas,length<length_meas?length:length_meas,0)/NB_RE); } diff --git a/openair1/SIMULATION/RF/rf.c b/openair1/SIMULATION/RF/rf.c index 3cf770ac7cf8c1a0f3038626807dedf18fccdef2..51b7e7524d4bb2bc953fc908a4b2fd1a5a0aa5ee 100644 --- a/openair1/SIMULATION/RF/rf.c +++ b/openair1/SIMULATION/RF/rf.c @@ -19,14 +19,13 @@ * contact@openairinterface.org */ -//#include "defs.h" #include <stdio.h> #include <stdlib.h> #include <math.h> //#include "PHY/defs.h" -#include "SIMULATION/TOOLS/defs.h" - +#include "SIMULATION/TOOLS/sim.h" +#include "rf.h" /* extern void randominit(void); extern double gaussdouble(double,double); diff --git a/openair1/SIMULATION/RF/defs.h b/openair1/SIMULATION/RF/rf.h similarity index 98% rename from openair1/SIMULATION/RF/defs.h rename to openair1/SIMULATION/RF/rf.h index 05e74647a06c0f6c4ac17d61369eb76fdb56c841..65055bc71a4257495cec26f333952103b630cd16 100644 --- a/openair1/SIMULATION/RF/defs.h +++ b/openair1/SIMULATION/RF/rf.h @@ -76,7 +76,7 @@ void adc(double *r_re[2], void dac(double *s_re[2], double *s_im[2], - int **input, + unsigned int **input, unsigned int input_offset, unsigned int nb_tx_antennas, unsigned int length, @@ -87,7 +87,7 @@ void dac(double *s_re[2], double dac_fixed_gain(double *s_re[2], double *s_im[2], - int **input, + unsigned int **input, unsigned int input_offset, unsigned int nb_tx_antennas, unsigned int length, diff --git a/openair1/SIMULATION/TOOLS/abstraction.c b/openair1/SIMULATION/TOOLS/abstraction.c index 7e99371c3736dae18f92ac18c2b6536347506087..6b846bb2d5db9e584d54cfd027792506d6363ae8 100644 --- a/openair1/SIMULATION/TOOLS/abstraction.c +++ b/openair1/SIMULATION/TOOLS/abstraction.c @@ -26,8 +26,9 @@ #include <string.h> #include <errno.h> -#include "PHY/TOOLS/defs.h" -#include "defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "PHY/TOOLS/tools_defs.h" +#include "assertions.h" // NEW code with lookup table for sin/cos based on delay profile (TO BE TESTED) diff --git a/openair1/SIMULATION/TOOLS/multipath_channel.c b/openair1/SIMULATION/TOOLS/multipath_channel.c index 757d5023de214d5ae8a823b3a3dd03e6ca045b9e..02f4abbc7e25285ca3cfa291ffdd52cd275e6126 100644 --- a/openair1/SIMULATION/TOOLS/multipath_channel.c +++ b/openair1/SIMULATION/TOOLS/multipath_channel.c @@ -23,8 +23,9 @@ #include <stdlib.h> #include <math.h> #include <string.h> -#include "defs.h" -#include "SIMULATION/RF/defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "SIMULATION/RF/rf.h" +#include "sim.h" //#define DEBUG_CH uint8_t multipath_channel_nosigconv(channel_desc_t *desc) diff --git a/openair1/SIMULATION/TOOLS/multipath_tv_channel.c b/openair1/SIMULATION/TOOLS/multipath_tv_channel.c index c2078b91d478763895c25771f24fe109260e4eb6..daa3462b1c85c1f4cf6ec22fcb29cea1e740c6e3 100644 --- a/openair1/SIMULATION/TOOLS/multipath_tv_channel.c +++ b/openair1/SIMULATION/TOOLS/multipath_tv_channel.c @@ -23,8 +23,8 @@ #include <stdlib.h> #include <math.h> #include <string.h> -#include "defs.h" -#include "SIMULATION/RF/defs.h" +#include "sim.h" +#include "SIMULATION/RF/rf.h" #include <complex.h> void tv_channel(channel_desc_t *desc,double complex ***H,uint16_t length); diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 222a196e20b9c0e171ecd3ac5c5177a88138e889..dc8df153159c58cd75506054941237c4701439fe 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -26,12 +26,14 @@ #include <string.h> -#include "PHY/TOOLS/defs.h" -#include "defs.h" +#include "PHY/TOOLS/tools_defs.h" +#include "sim.h" #include "scm_corrmat.h" #include "UTIL/LOG/log.h" //#define DEBUG_CH +#include "assertions.h" + extern void print_shorts(char *s,__m128i *x); void fill_channel_desc(channel_desc_t *chan_desc, @@ -1210,10 +1212,8 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { struct complex anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX]; struct complex phase, alpha, beta; - if ((desc->nb_tx>NB_ANTENNAS_TX) || (desc->nb_rx > NB_ANTENNAS_RX)) { - LOG_E(PHY,"random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); - return(-1); - } + AssertFatal(desc->nb_tx<=NB_ANTENNAS_TX && desc->nb_rx <= NB_ANTENNAS_RX, + "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); start_meas(&desc->random_channel); for (i=0;i<(int)desc->nb_taps;i++) { @@ -1372,8 +1372,7 @@ double N_RB2sampling_rate(uint16_t N_RB) break; default: - LOG_E(PHY,"Unknown N_PRB\n"); - return(-1); + AssertFatal(1==0,"Unknown N_PRB %d",N_RB); } return(sampling_rate); diff --git a/openair1/SIMULATION/TOOLS/rangen_double.c b/openair1/SIMULATION/TOOLS/rangen_double.c index 0fc01a8d3132233ff34502b71466e4a3886adb3a..6dcdd9418e2bf703a1d21d2780c184dc5cd2deeb 100644 --- a/openair1/SIMULATION/TOOLS/rangen_double.c +++ b/openair1/SIMULATION/TOOLS/rangen_double.c @@ -24,7 +24,7 @@ #include <math.h> #include <time.h> -#include "defs.h" +#include "sim.h" static unsigned int seed, iy, ir[98]; /* diff --git a/openair1/SIMULATION/TOOLS/defs.h b/openair1/SIMULATION/TOOLS/sim.h similarity index 99% rename from openair1/SIMULATION/TOOLS/defs.h rename to openair1/SIMULATION/TOOLS/sim.h index a958c6b4ebcfb2737c58f30fff63d6475d8446d3..420e5d0072f193a42057902ceae63d2b54cf1a51 100644 --- a/openair1/SIMULATION/TOOLS/defs.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -21,7 +21,7 @@ #ifndef __SIMULATION_TOOLS_DEFS_H__ #define __SIMULATION_TOOLS_DEFS_H__ -#include "PHY/defs.h" +#include "PHY/defs_common.h" /** @defgroup _numerical_ Useful Numerical Functions *@{ diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h index 3a73000e505aa5452bd53543669bf3bec0e0ec8e..fb229bf951b58d757ab0c9f2253a110dc1974baf 100644 --- a/openair2/COMMON/mac_rrc_primitives.h +++ b/openair2/COMMON/mac_rrc_primitives.h @@ -34,7 +34,7 @@ #include "RadioResourceConfigDedicated.h" #include "MeasGapConfig.h" #include "TDD-Config.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "MBSFN-AreaInfoList-r9.h" #include "MBSFN-SubframeConfigList.h" #endif @@ -356,7 +356,7 @@ typedef struct { TDD_Config_t *tdd_Config, uint8_t *SIwindowsize, uint16_t *SIperiod -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , MBMS_flag_t MBMS_Flag, struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList, @@ -364,10 +364,20 @@ typedef struct { struct PMCH_InfoList_r9 *pmch_InfoList #endif ); - unsigned int (*mac_rlc_data_req)(module_id_t, unsigned int, const unsigned int,char*); + unsigned int (*mac_rlc_data_req)(module_id_t, unsigned int, const unsigned int,char* +#ifdef Rel14 + ,uint32_t + ,uint32_t +#endif + ); void (*mac_rlc_data_ind)(module_id_t, logical_chan_id_t, char*, tb_size_t, num_tb_t, crc_t* ); mac_rlc_status_resp_t (*mac_rlc_status_ind) (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, sub_frame_t subframeP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, - logical_chan_id_t channel_idP, tb_size_t tb_sizeP); + logical_chan_id_t channel_idP, tb_size_t tb_sizeP +#ifdef Rel14 + ,uint32_t sourceL2Id + ,uint32_t destinationL2Id +#endif + ); signed int (*rrc_rlc_data_req)(module_id_t, rb_id_t, mui_t, confirm_t, sdu_size_t, char *); void (*rrc_rlc_register_rrc) (void (*rrc_data_indP)(module_id_t , rb_id_t , sdu_size_t , char* ), void (*rrc_data_confP) (module_id_t , rb_id_t , mui_t ) ) ; diff --git a/openair2/COMMON/phy_messages_types.h b/openair2/COMMON/phy_messages_types.h index c425efa89cb38b88fe08c804ecbcc11bf0e29ecb..1f040a0a773e00163df53a660af70c799629f5d2 100644 --- a/openair2/COMMON/phy_messages_types.h +++ b/openair2/COMMON/phy_messages_types.h @@ -29,10 +29,8 @@ #ifndef PHY_MESSAGES_TYPES_H_ #define PHY_MESSAGES_TYPES_H_ -#include "PHY/impl_defs_lte.h" -#if ENABLE_RAL -#include "ral_messages_types.h" //LG: MIH moved from repository/trunk to repository/extras -#endif +#include "PHY/defs_common.h" + //-------------------------------------------------------------------------------------------// // Defines to access message fields. #define PHY_CONFIGURATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.phy_configuration_req diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index 4debccc7b05075ce37e830420336551a29c6c323..917c149833f9d21df65dc988c70fa0ec14007078 100644 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -69,10 +69,12 @@ #ifdef LARGE_SCALE # define MAX_MOBILES_PER_ENB 128 -//# define MAX_RG 2 +# define MAX_MOBILES_PER_ENB_NB_IoT 128 +# define MAX_eNB 2 #else # define MAX_MOBILES_PER_ENB 16 -//# define MAX_RG 2 +# define MAX_MOBILES_PER_ENB_NB_IoT 16 +# define MAX_eNB 2 #endif #define MAX_MANAGED_ENB_PER_MOBILE 2 @@ -84,7 +86,7 @@ #define DEFAULT_RAB_ID 1 #define NB_RB_MAX (maxDRB + 3) /* was 11, now 14, maxDRB comes from asn1_constants.h, + 3 because of 3 SRB, one invisible id 0, then id 1 and 2 */ -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #define NB_RB_MBMS_MAX (maxSessionPerPMCH*maxServiceCount) #else // Do not allocate unused memory diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 0ab8d9670145ceab059356b9d6675e94b786b2b7..bb8fa7bb1c2ed9f5a3224f3906e3544fcd4dd760 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -88,6 +88,10 @@ typedef boolean_t srb_flag_t; #define SRB_FLAG_NO FALSE #define SRB_FLAG_YES TRUE +typedef boolean_t sl_discovery_flag_t; +#define SL_DISCOVERY_FLAG_NO FALSE +#define SL_DISCOVERY_FLAG_YES TRUE + typedef enum link_direction_e { UNKNOWN_DIR = 0, DIR_UPLINK = 1, @@ -164,7 +168,9 @@ typedef enum ip_traffic_type_e { TRAFFIC_IPV4_TYPE_UNICAST = 5, TRAFFIC_IPV4_TYPE_MULTICAST = 6, TRAFFIC_IPV4_TYPE_BROADCAST = 7, - TRAFFIC_IPV4_TYPE_UNKNOWN = 8 + TRAFFIC_IPV4_TYPE_UNKNOWN = 8, + TRAFFIC_PC5S_SIGNALLING = 9, + TRAFFIC_PC5S_SESSION_INIT = 10 } ip_traffic_type_t; //----------------------------------------------------------------------------- diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 9bd25d3b3aa52075eaf3acf5f5c51b0f9f7581b5..5625c9fab501ddf03384b7bc84460e1611ebe73d 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -37,6 +37,12 @@ #else #include "RRC/LITE/MESSAGES/SystemInformationBlockType2.h" #endif +#include "SL-OffsetIndicator-r12.h" +#include "SubframeBitmapSL-r12.h" +#include "SL-CP-Len-r12.h" +#include "SL-PeriodComm-r12.h" +#include "SL-DiscResourcePool-r12.h" + //-------------------------------------------------------------------------------------------// // Messages for RRC logging @@ -117,7 +123,7 @@ typedef struct RrcConfigurationReq_s { long pucch_delta_shift[MAX_NUM_CCs]; long pucch_nRB_CQI[MAX_NUM_CCs]; long pucch_nCS_AN[MAX_NUM_CCs]; -#if !defined(Rel10) && !defined(Rel14) +#if (RRC_VERSION < MAKE_VERSION(10, 0, 0)) long pucch_n1_AN[MAX_NUM_CCs]; #endif long pdsch_referenceSignalPower[MAX_NUM_CCs]; @@ -168,6 +174,56 @@ typedef struct RrcConfigurationReq_s { long ue_TimersAndConstants_n310[MAX_NUM_CCs]; long ue_TimersAndConstants_n311[MAX_NUM_CCs]; long ue_TransmissionMode[MAX_NUM_CCs]; + + //TTN - for D2D + //SIB18 + e_SL_CP_Len_r12 rxPool_sc_CP_Len[MAX_NUM_CCs]; + e_SL_PeriodComm_r12 rxPool_sc_Period[MAX_NUM_CCs]; + e_SL_CP_Len_r12 rxPool_data_CP_Len[MAX_NUM_CCs]; + long rxPool_ResourceConfig_prb_Num[MAX_NUM_CCs]; + long rxPool_ResourceConfig_prb_Start[MAX_NUM_CCs]; + long rxPool_ResourceConfig_prb_End[MAX_NUM_CCs]; + SL_OffsetIndicator_r12_PR rxPool_ResourceConfig_offsetIndicator_present[MAX_NUM_CCs]; + long rxPool_ResourceConfig_offsetIndicator_choice[MAX_NUM_CCs]; + SubframeBitmapSL_r12_PR rxPool_ResourceConfig_subframeBitmap_present[MAX_NUM_CCs]; + char* rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; + long rxPool_ResourceConfig_subframeBitmap_choice_bs_size[MAX_NUM_CCs]; + long rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[MAX_NUM_CCs]; + + //SIB19 + //for discRxPool + SL_CP_Len_r12_t discRxPool_cp_Len[MAX_NUM_CCs]; + e_SL_DiscResourcePool_r12__discPeriod_r12 discRxPool_discPeriod[MAX_NUM_CCs]; + long discRxPool_numRetx[MAX_NUM_CCs]; + long discRxPool_numRepetition[MAX_NUM_CCs]; + long discRxPool_ResourceConfig_prb_Num[MAX_NUM_CCs]; + long discRxPool_ResourceConfig_prb_Start[MAX_NUM_CCs]; + long discRxPool_ResourceConfig_prb_End[MAX_NUM_CCs]; + SL_OffsetIndicator_r12_PR discRxPool_ResourceConfig_offsetIndicator_present[MAX_NUM_CCs]; + long discRxPool_ResourceConfig_offsetIndicator_choice[MAX_NUM_CCs]; + SubframeBitmapSL_r12_PR discRxPool_ResourceConfig_subframeBitmap_present[MAX_NUM_CCs]; + char* discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; + long discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[MAX_NUM_CCs]; + long discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[MAX_NUM_CCs]; + //for discRxPoolPS + SL_CP_Len_r12_t discRxPoolPS_cp_Len[MAX_NUM_CCs]; + e_SL_DiscResourcePool_r12__discPeriod_r12 discRxPoolPS_discPeriod[MAX_NUM_CCs]; + long discRxPoolPS_numRetx[MAX_NUM_CCs]; + long discRxPoolPS_numRepetition[MAX_NUM_CCs]; + long discRxPoolPS_ResourceConfig_prb_Num[MAX_NUM_CCs]; + long discRxPoolPS_ResourceConfig_prb_Start[MAX_NUM_CCs]; + long discRxPoolPS_ResourceConfig_prb_End[MAX_NUM_CCs]; + SL_OffsetIndicator_r12_PR discRxPoolPS_ResourceConfig_offsetIndicator_present[MAX_NUM_CCs]; + long discRxPoolPS_ResourceConfig_offsetIndicator_choice[MAX_NUM_CCs]; + SubframeBitmapSL_r12_PR discRxPoolPS_ResourceConfig_subframeBitmap_present[MAX_NUM_CCs]; + char* discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; + long discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[MAX_NUM_CCs]; + long discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[MAX_NUM_CCs]; + + + + + } RrcConfigurationReq; #define MAX_NUM_NBIOT_CELEVELS 3 typedef struct NbIoTRrcConfigurationReq_s { diff --git a/openair2/COMMON/s1ap_messages_def.h b/openair2/COMMON/s1ap_messages_def.h index a39953d8f77e777ca79b1e4644be41690ae3f799..d81bd87ed5f97b990caf7abfbc0dae4d2180182e 100644 --- a/openair2/COMMON/s1ap_messages_def.h +++ b/openair2/COMMON/s1ap_messages_def.h @@ -38,6 +38,7 @@ MESSAGE_DEF(S1AP_E_RAB_MODIFY_RESPONSE_LOG , MESSAGE_PRIORITY_MED, IttiMsgTex MESSAGE_DEF(S1AP_PAGING_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_paging_log) MESSAGE_DEF(S1AP_E_RAB_RELEASE_REQUEST_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_release_request_log) MESSAGE_DEF(S1AP_E_RAB_RELEASE_RESPONSE_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_e_rab_release_response_log) +MESSAGE_DEF(S1AP_E_RAB_ERROR_INDICATION_LOG , MESSAGE_PRIORITY_MED, IttiMsgText , s1ap_error_indication_log) /* eNB application layer -> S1AP messages */ MESSAGE_DEF(S1AP_REGISTER_ENB_REQ , MESSAGE_PRIORITY_MED, s1ap_register_enb_req_t , s1ap_register_enb_req) diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 6cb79efb11ce90b8410bb2d14e7659711b5d0b2f..0545eeb3be11e59522aebcafb3161b4aaa61e60a 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -34,7 +34,7 @@ #include "flexran_agent_timer.h" #include "flexran_agent_ran_api.h" -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "liblfds700.h" @@ -836,7 +836,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle Protocol__FlexHeader *header = NULL; int i, j, UE_id; - int available_harq[NUMBER_OF_UE_MAX]; + int available_harq[MAX_MOBILES_PER_ENB]; const int xid = *((int *)params); @@ -854,7 +854,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle frame_t frame; sub_frame_t subframe; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { available_harq[i] = -1; } @@ -878,7 +878,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle sf_trigger_msg->n_dl_info = 0; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { for (j = 0; j < 8; j++) { if (RC.mac && RC.mac[mod_id] && RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid == 1) { available_harq[i] = j; @@ -904,7 +904,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle goto error; i = -1; //Fill the status of the current HARQ process for each UE - for(UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for(UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (available_harq[UE_id] < 0) { continue; } else { @@ -1262,7 +1262,7 @@ void flexran_agent_init_mac_agent(mid_t mod_id) { //Allow RINGBUFFER_SIZE messages to be stored in the ringbuffer at any time dl_mac_config_array[mod_id] = malloc( sizeof(struct lfds700_ringbuffer_element) * num_elements); lfds700_ringbuffer_init_valid_on_current_logical_core( &ringbuffer_state[mod_id], dl_mac_config_array[mod_id], num_elements, &ps[mod_id], NULL ); - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { for (j = 0; j < 8; j++) { if (RC.mac && RC.mac[mod_id]) RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid = 0; diff --git a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c index 43455fa32a4043edeac6eda7c869b0fe2c783348..b2723f718126973f96d972a3284b995c5e99c3e2 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c +++ b/openair2/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c @@ -37,7 +37,7 @@ unsigned int pdcp_agent_registered[NUM_MAX_ENB]; /*Array containing the Agent-PDCP interfaces*/ AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB]; -// NUMBER_OF_UE_MAX +// MAX_MOBILES_PER_ENB void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id, const mid_t ue_id, diff --git a/openair2/ENB_APP/NB_IoT_interface.c b/openair2/ENB_APP/NB_IoT_interface.c index 30ffbb3bb550f6fdcb1cc19075e120df2dac5d9b..c4884453c2e9cc03d62f5c4e454bd3a3dd3f57fb 100644 --- a/openair2/ENB_APP/NB_IoT_interface.c +++ b/openair2/ENB_APP/NB_IoT_interface.c @@ -30,7 +30,7 @@ #include <sys/types.h> -#include "openair1/PHY/extern.h" +#include "openair1/PHY/phy_extern.h" #include "common/utils/load_module_shlib.h" #define NBIOT_INTERFACE_SOURCE #include "NB_IoT_interface.h" diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index b5e21343ff4de556421362bb0b0e40798d42b544..2cf83d72d2007c213377c68dadacc8c11f4cbcda 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -50,6 +50,7 @@ # include "flexran_agent.h" #endif +#include "openair1/PHY/INIT/phy_init.h" extern unsigned char NB_eNB_INST; #endif diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index c67a0fa47502c9816247c7b6e4e4c367bda3b330..a64f32004241621a3e17ff5431785ba1d5da0980 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -45,9 +45,10 @@ #endif #include "sctp_default_values.h" #include "SystemInformationBlockType2.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" -#include "PHY/extern.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "PHY/phy_extern.h" +#include "PHY/INIT/phy_init.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" #include "nfapi_vnf.h" #include "nfapi_pnf.h" @@ -101,6 +102,52 @@ void RCconfig_flexran() ue_TimersAndConstants_n310, ue_TimersAndConstants_n311, ue_TransmissionMode; + + e_SL_CP_Len_r12 rxPool_sc_CP_Len; + e_SL_PeriodComm_r12 rxPool_sc_Period; + e_SL_CP_Len_r12 rxPool_data_CP_Len; + long rxPool_ResourceConfig_prb_Num; + long rxPool_ResourceConfig_prb_Start; + long rxPool_ResourceConfig_prb_End; + SL_OffsetIndicator_r12_PR rxPool_ResourceConfig_offsetIndicator_present; + long rxPool_ResourceConfig_offsetIndicator_choice; + SubframeBitmapSL_r12_PR rxPool_ResourceConfig_subframeBitmap_present; + char* rxPool_ResourceConfig_subframeBitmap_choice_bs_buf; + long rxPool_ResourceConfig_subframeBitmap_choice_bs_size; + long rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused; + + //SIB19 + //for discRxPool + SL_CP_Len_r12_t discRxPool_cp_Len; + e_SL_DiscResourcePool_r12__discPeriod_r12 discRxPool_discPeriod; + long discRxPool_numRetx; + long discRxPool_numRepetition; + long discRxPool_ResourceConfig_prb_Num; + long discRxPool_ResourceConfig_prb_Start; + long discRxPool_ResourceConfig_prb_End; + SL_OffsetIndicator_r12_PR discRxPool_ResourceConfig_offsetIndicator_present; + long discRxPool_ResourceConfig_offsetIndicator_choice; + SubframeBitmapSL_r12_PR discRxPool_ResourceConfig_subframeBitmap_present; + char* discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf; + long discRxPool_ResourceConfig_subframeBitmap_choice_bs_size; + long discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused; + //for discRxPoolPS + SL_CP_Len_r12_t discRxPoolPS_cp_Len; + e_SL_DiscResourcePool_r12__discPeriod_r12 discRxPoolPS_discPeriod; + long discRxPoolPS_numRetx; + long discRxPoolPS_numRepetition; + long discRxPoolPS_ResourceConfig_prb_Num; + long discRxPoolPS_ResourceConfig_prb_Start; + long discRxPoolPS_ResourceConfig_prb_End; + SL_OffsetIndicator_r12_PR discRxPoolPS_ResourceConfig_offsetIndicator_present; + long discRxPoolPS_ResourceConfig_offsetIndicator_choice; + SubframeBitmapSL_r12_PR discRxPoolPS_ResourceConfig_subframeBitmap_present; + char* discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf; + long discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size; + long discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused; + + + /* get number of eNBs */ paramdef_t ENBSParams[] = ENBSPARAMS_DESC; config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL); @@ -181,6 +228,48 @@ void RCconfig_flexran() } } + +/*void UE_config_stub_pnf(void) { + int j; + paramdef_t L1_Params[] = L1PARAMS_DESC; + paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0}; + + config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL); + if (L1_ParamList.numelt > 0) { + for (j=0; j<L1_ParamList.numelt; j++){ + //nb_L1_CC = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr); // Number of component carriers is of no use for the + // phy_stub mode UE pnf. Maybe we can completely skip it. + + if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { + sf_ahead = 4; // Need 4 subframe gap between RX and TX + } + // Panos: Right now that we have only one UE (thread) it is ok to put the eth_params in the UE_mac_inst. + // Later I think we have to change that to attribute eth_params to a global element for all the UEs. + else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { + stub_eth_params.local_if_name = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr)); + stub_eth_params.my_addr = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr)); + stub_eth_params.remote_addr = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr)); + stub_eth_params.my_portc = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr); + stub_eth_params.remote_portc = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr); + stub_eth_params.my_portd = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr); + stub_eth_params.remote_portd = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); + stub_eth_params.transp_preference = ETH_UDP_MODE; + + + sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2 + //configure_nfapi_pnf(UE_mac_inst[0].eth_params_n.remote_addr, UE_mac_inst[0].eth_params_n.remote_portc, UE_mac_inst[0].eth_params_n.my_addr, UE_mac_inst[0].eth_params_n.my_portd, UE_mac_inst[0].eth_params_n.remote_portd); + configure_nfapi_pnf(stub_eth_params.remote_addr, stub_eth_params.remote_portc, stub_eth_params.my_addr, stub_eth_params.my_portd, stub_eth_params.remote_portd); + } + else { // other midhaul + } + } + } + else { + + } +}*/ + + void RCconfig_L1(void) { int i,j; paramdef_t L1_Params[] = L1PARAMS_DESC; @@ -196,7 +285,6 @@ void RCconfig_L1(void) { config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL); if (L1_ParamList.numelt > 0) { - for (j = 0; j < RC.nb_L1_inst; j++) { RC.nb_L1_CC[j] = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr); @@ -249,6 +337,7 @@ void RCconfig_L1(void) { configure_nfapi_pnf(RC.eNB[j][0]->eth_params_n.remote_addr, RC.eNB[j][0]->eth_params_n.remote_portc, RC.eNB[j][0]->eth_params_n.my_addr, RC.eNB[j][0]->eth_params_n.my_portd, RC.eNB[j][0]->eth_params_n .remote_portd); } else { // other midhaul + //printf("Panos-D: RCconfig_L1 12 \n"); } }// j=0..num_inst printf("Initializing northbound interface for L1\n"); @@ -295,7 +384,12 @@ void RCconfig_macrlc() { RC.nb_macrlc_inst=MacRLC_ParamList.numelt; mac_top_init_eNB(); + RC.nb_mac_CC = (int*)malloc(RC.nb_macrlc_inst*sizeof(int)); + for (j=0;j<RC.nb_macrlc_inst;j++) { + RC.nb_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr); + //RC.mac[j]->phy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr); + //printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j); if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { // check number of instances is same as RRC/PDCP @@ -501,7 +595,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { int32_t pucch_delta_shift = 0; int32_t pucch_nRB_CQI = 0; int32_t pucch_nCS_AN = 0; -//#if !defined(Rel10) && !defined(Rel14) +//#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) int32_t pucch_n1_AN = 0; //#endif int32_t pdsch_referenceSignalPower = 0; @@ -554,6 +648,52 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { int32_t ue_TimersAndConstants_n311 = 0; int32_t ue_TransmissionMode = 0; + //TTN - for D2D + //SIB18 + const char* rxPool_sc_CP_Len = NULL; + const char* rxPool_sc_Period = NULL; + const char* rxPool_data_CP_Len = NULL; + libconfig_int rxPool_ResourceConfig_prb_Num = 0; + libconfig_int rxPool_ResourceConfig_prb_Start = 0; + libconfig_int rxPool_ResourceConfig_prb_End = 0; + const char* rxPool_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int rxPool_ResourceConfig_offsetIndicator_choice = 0; + const char* rxPool_ResourceConfig_subframeBitmap_present = NULL; + char* rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + //SIB19 + //For discRxPool + const char* discRxPool_cp_Len = NULL; + const char* discRxPool_discPeriod = NULL; + libconfig_int discRxPool_numRetx = 0; + libconfig_int discRxPool_numRepetition = 0; + + libconfig_int discRxPool_ResourceConfig_prb_Num = 0; + libconfig_int discRxPool_ResourceConfig_prb_Start = 0; + libconfig_int discRxPool_ResourceConfig_prb_End = 0; + const char* discRxPool_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int discRxPool_ResourceConfig_offsetIndicator_choice = 0; + const char* discRxPool_ResourceConfig_subframeBitmap_present = NULL; + char* discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + //For discRxPoolPS + const char* discRxPoolPS_cp_Len = NULL; + const char* discRxPoolPS_discPeriod = NULL; + libconfig_int discRxPoolPS_numRetx = 0; + libconfig_int discRxPoolPS_numRepetition = 0; + + libconfig_int discRxPoolPS_ResourceConfig_prb_Num = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_Start = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_End = 0; + const char* discRxPoolPS_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int discRxPoolPS_ResourceConfig_offsetIndicator_choice = 0; + const char* discRxPoolPS_ResourceConfig_subframeBitmap_present = NULL; + char* discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + int32_t srb1_timer_poll_retransmit = 0; int32_t srb1_timer_reordering = 0; @@ -733,6 +873,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { for (j = 0; j < CCsParamList.numelt ;j++) { sprintf(ccspath,"%s.%s.[%i]",enbpath,ENB_CONFIG_STRING_COMPONENT_CARRIERS,j); + LOG_I(RRC, "enb_config::RCconfig_RRC() parameter number: %d, total number of parameters: %zd, ccspath: %s \n \n", j, sizeof(CCsParams)/sizeof(paramdef_t), ccspath); config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath); @@ -767,7 +908,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n", RC.config_file_name, i, prefix_type); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (!pbch_repetition) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d define %s: TRUE,FALSE!\n", @@ -932,7 +1073,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n", RC.config_file_name, i, pucch_nCS_AN); -#if !defined(Rel10) && !defined(Rel14) +#if (RRC_VERSION < MAKE_VERSION(10, 0, 0)) RRC_CONFIGURATION_REQ (msg_p).pucch_n1_AN[j] = pucch_n1_AN; if ((pucch_n1_AN <0) || (pucch_n1_AN > 2047)) @@ -1112,7 +1253,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n", RC.config_file_name, i, pusch_p0_Nominal); -#ifndef Rel14 +#if (RRC_VERSION <= MAKE_VERSION(12, 0, 0)) if (strcmp(pusch_alpha,"AL0")==0) { RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al0; } else if (strcmp(pusch_alpha,"AL04")==0) { @@ -1130,7 +1271,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { } else if (strcmp(pusch_alpha,"AL1")==0) { RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = UplinkPowerControlCommon__alpha_al1; } -#else +#endif + +#if (RRC_VERSION >= MAKE_VERSION(12, 0, 0)) if (strcmp(pusch_alpha,"AL0")==0) { RRC_CONFIGURATION_REQ (msg_p).pusch_alpha[j] = Alpha_r12_al0; } else if (strcmp(pusch_alpha,"AL04")==0) { @@ -1333,7 +1476,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { switch (rach_preambleTransMax) { -#ifndef Rel14 +#if (RRC_VERSION < MAKE_VERSION(14, 0, 0)) case 3: RRC_CONFIGURATION_REQ (msg_p).rach_preambleTransMax[j] = RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3; break; @@ -1563,6 +1706,267 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RC.config_file_name, i, ue_TransmissionMode); break; } + + //TTN - for D2D + //SIB18 + if (strcmp(rxPool_sc_CP_Len,"normal")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_CP_Len[j] = SL_CP_Len_r12_normal; + } else if (strcmp(rxPool_sc_CP_Len,"extended")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_CP_Len[j] = SL_CP_Len_r12_extended; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_sc_CP_Len choice: normal,extended!\n", + RC.config_file_name, i, rxPool_sc_CP_Len); + + if (strcmp(rxPool_sc_Period,"sf40")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf40; + } else if (strcmp(rxPool_sc_Period,"sf60")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf60; + } else if (strcmp(rxPool_sc_Period,"sf70")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf70; + } else if (strcmp(rxPool_sc_Period,"sf80")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf80; + } else if (strcmp(rxPool_sc_Period,"sf120")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf120; + } else if (strcmp(rxPool_sc_Period,"sf140")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf140; + } else if (strcmp(rxPool_sc_Period,"sf160")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf160; + } else if (strcmp(rxPool_sc_Period,"sf240")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf240; + } else if (strcmp(rxPool_sc_Period,"sf280")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf280; + } else if (strcmp(rxPool_sc_Period,"sf320")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_sf320; + } else if (strcmp(rxPool_sc_Period,"spare6")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_spare6; + } else if (strcmp(rxPool_sc_Period,"spare5")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_spare5; + } else if (strcmp(rxPool_sc_Period,"spare4")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_spare4; + } else if (strcmp(rxPool_sc_Period,"spare3")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_spare3; + } else if (strcmp(rxPool_sc_Period,"spare2")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_spare2; + } else if (strcmp(rxPool_sc_Period,"spare")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_sc_Period[j] = SL_PeriodComm_r12_spare; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_sc_Period choice: sf40,sf60,sf70,sf80,sf120,sf140,sf160,sf240,sf280,sf320,spare6,spare5,spare4,spare3,spare2,spare!\n", + RC.config_file_name, i, rxPool_sc_Period); + + if (strcmp(rxPool_data_CP_Len,"normal")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_data_CP_Len[j] = SL_CP_Len_r12_normal; + } else if (strcmp(rxPool_data_CP_Len,"extended")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_data_CP_Len[j] = SL_CP_Len_r12_extended; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_data_CP_Len choice: normal,extended!\n", + RC.config_file_name, i, rxPool_data_CP_Len); + + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_Num[j] = rxPool_ResourceConfig_prb_Num; + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_Start[j] = rxPool_ResourceConfig_prb_Start; + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_prb_End[j] = rxPool_ResourceConfig_prb_End; + + if (strcmp(rxPool_ResourceConfig_offsetIndicator_present,"prNothing")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_NOTHING; + } else if (strcmp(rxPool_ResourceConfig_offsetIndicator_present,"prSmall")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_small_r12; + } else if (strcmp(rxPool_ResourceConfig_offsetIndicator_present,"prLarge")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_large_r12; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n", + RC.config_file_name, i, rxPool_ResourceConfig_offsetIndicator_present); + + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_offsetIndicator_choice[j] = rxPool_ResourceConfig_offsetIndicator_choice; + + if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prNothing")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_NOTHING; + } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs4")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs4_r12; + } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs8")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs8_r12; + } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs12")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs12_r12; + } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs16")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs16_r12; + } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs30")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs30_r12; + } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs40")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs40_r12; + } else if (strcmp(rxPool_ResourceConfig_subframeBitmap_present,"prBs42")==0) { + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs42_r12; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rxPool_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n", + RC.config_file_name, i, rxPool_ResourceConfig_subframeBitmap_present); + + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[j] = rxPool_ResourceConfig_subframeBitmap_choice_bs_buf; + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_size[j] = rxPool_ResourceConfig_subframeBitmap_choice_bs_size; + RRC_CONFIGURATION_REQ (msg_p).rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[j] = rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused; + + //SIB19 - for discRxPool + if (strcmp(discRxPool_cp_Len,"normal")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_cp_Len[j] = SL_CP_Len_r12_normal; + } else if (strcmp(discRxPool_cp_Len,"extended")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_cp_Len[j] = SL_CP_Len_r12_extended; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_cp_Len choice: normal,extended!\n", + RC.config_file_name, i, discRxPool_cp_Len); + + + if (strcmp(discRxPool_discPeriod,"rf32")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf32; + } else if (strcmp(discRxPool_discPeriod,"rf64")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf64; + } else if (strcmp(discRxPool_discPeriod,"rf128")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf128; + } else if (strcmp(discRxPool_discPeriod,"rf256")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf256; + } else if (strcmp(discRxPool_discPeriod,"rf512")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf512; + } else if (strcmp(discRxPool_discPeriod,"rf1024")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf1024; + } else if (strcmp(discRxPool_discPeriod,"rf16")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf16_v1310; + } else if (strcmp(discRxPool_discPeriod,"spare")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_spare; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_discPeriod choice: rf32,rf64,rf128,rf512,rf1024,rf16,spare!\n", + RC.config_file_name, i, discRxPool_discPeriod); + + + + RRC_CONFIGURATION_REQ (msg_p).discRxPool_numRetx[j] = discRxPool_numRetx; + RRC_CONFIGURATION_REQ (msg_p).discRxPool_numRepetition[j] = discRxPool_numRepetition; + + + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_Num[j] = discRxPool_ResourceConfig_prb_Num; + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_Start[j] = discRxPool_ResourceConfig_prb_Start; + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_prb_End[j] = discRxPool_ResourceConfig_prb_End; + + if (strcmp(discRxPool_ResourceConfig_offsetIndicator_present,"prNothing")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_NOTHING; + } else if (strcmp(discRxPool_ResourceConfig_offsetIndicator_present,"prSmall")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_small_r12; + } else if (strcmp(discRxPool_ResourceConfig_offsetIndicator_present,"prLarge")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_large_r12; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n", + RC.config_file_name, i, discRxPool_ResourceConfig_offsetIndicator_present); + + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_offsetIndicator_choice[j] = discRxPool_ResourceConfig_offsetIndicator_choice; + + if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prNothing")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_NOTHING; + } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs4")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs4_r12; + } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs8")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs8_r12; + } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs12")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs12_r12; + } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs16")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs16_r12; + } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs30")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs30_r12; + } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs40")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs40_r12; + } else if (strcmp(discRxPool_ResourceConfig_subframeBitmap_present,"prBs42")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs42_r12; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPool_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n", + RC.config_file_name, i, discRxPool_ResourceConfig_subframeBitmap_present); + + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[j] = discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf; + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[j] = discRxPool_ResourceConfig_subframeBitmap_choice_bs_size; + RRC_CONFIGURATION_REQ (msg_p).discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[j] = discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused; + + //SIB19 - For discRxPoolPS + if (strcmp(discRxPoolPS_cp_Len,"normal")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_cp_Len[j] = SL_CP_Len_r12_normal; + } else if (strcmp(discRxPoolPS_cp_Len,"extended")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_cp_Len[j] = SL_CP_Len_r12_extended; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_cp_Len choice: normal,extended!\n", + RC.config_file_name, i, discRxPoolPS_cp_Len); + + + if (strcmp(discRxPoolPS_discPeriod,"rf32")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf32; + } else if (strcmp(discRxPoolPS_discPeriod,"rf64")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf64; + } else if (strcmp(discRxPoolPS_discPeriod,"rf128")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf128; + } else if (strcmp(discRxPoolPS_discPeriod,"rf256")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf256; + } else if (strcmp(discRxPoolPS_discPeriod,"rf512")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf512; + } else if (strcmp(discRxPoolPS_discPeriod,"rf1024")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf1024; + } else if (strcmp(discRxPoolPS_discPeriod,"rf16")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_rf16_v1310; + } else if (strcmp(discRxPoolPS_discPeriod,"spare")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_discPeriod[j] = SL_DiscResourcePool_r12__discPeriod_r12_spare; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_discPeriod choice: rf32,rf64,rf128,rf512,rf1024,rf16,spare!\n", + RC.config_file_name, i, discRxPoolPS_discPeriod); + + + + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_numRetx[j] = discRxPoolPS_numRetx; + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_numRepetition[j] = discRxPoolPS_numRepetition; + + + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_Num[j] = discRxPoolPS_ResourceConfig_prb_Num; + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_Start[j] = discRxPoolPS_ResourceConfig_prb_Start; + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_prb_End[j] = discRxPoolPS_ResourceConfig_prb_End; + + if (strcmp(discRxPoolPS_ResourceConfig_offsetIndicator_present,"prNothing")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_NOTHING; + } else if (strcmp(discRxPoolPS_ResourceConfig_offsetIndicator_present,"prSmall")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_small_r12; + } else if (strcmp(discRxPoolPS_ResourceConfig_offsetIndicator_present,"prLarge")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_present[j] = SL_OffsetIndicator_r12_PR_large_r12; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_ResourceConfig_offsetIndicator_present choice: prNothing,prSmal,prLarge!\n", + RC.config_file_name, i, discRxPoolPS_ResourceConfig_offsetIndicator_present); + + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_offsetIndicator_choice[j] = discRxPoolPS_ResourceConfig_offsetIndicator_choice; + + if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prNothing")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_NOTHING; + } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs4")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs4_r12; + } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs8")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs8_r12; + } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs12")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs12_r12; + } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs16")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs16_r12; + } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs30")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs30_r12; + } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs40")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs40_r12; + } else if (strcmp(discRxPoolPS_ResourceConfig_subframeBitmap_present,"prBs42")==0) { + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_present[j] = SubframeBitmapSL_r12_PR_bs42_r12; + } else + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for discRxPoolPS_ResourceConfig_subframeBitmap_present choice: prNothing,prBs4,prBs8,prBs12,prBs16,prBs30,prBs40,prBs42!\n", + RC.config_file_name, i, discRxPoolPS_ResourceConfig_subframeBitmap_present); + + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[j] = discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf; + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[j] = discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size; + RRC_CONFIGURATION_REQ (msg_p).discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[j] = discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused; + + } } char srb1path[MAX_OPTNAME_SIZE*2 + 8]; diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h index 57ae102848059a1ec62bc8e083615db9b7e78ec2..3e645b458c78fdfeb4f857badbcce860582659f2 100644 --- a/openair2/ENB_APP/enb_config.h +++ b/openair2/ENB_APP/enb_config.h @@ -33,21 +33,21 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <libconfig.h> -#include "RRC/LITE/defs.h" #include "commonDef.h" #include "platform_types.h" #include "platform_constants.h" #include "PHY/impl_defs_lte.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "s1ap_messages_types.h" #ifdef CMAKER #include "SystemInformationBlockType2.h" #include "rrc_messages_types.h" #else -#include "RRC/LITE/MESSAGES/SystemInformationBlockType2.h" +#include "RRC/LTE/MESSAGES/SystemInformationBlockType2.h" #endif #include "intertask_interface_types.h" +#include "RRC/LTE/rrc_defs.h" #define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\ struct in_addr inp;\ @@ -135,6 +135,7 @@ extern void RCconfig_RU(void); extern void RCconfig_flexran(void); extern void RCconfig_L1(void); extern void RCconfig_macrlc(void); +extern void UE_config_stub_pnf(void); extern int RCconfig_gtpu(void ); extern void RCConfig(void); diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 81b06273005bcae8dd98e886cd3c36d547b6bc19..82d79271cbe71a5004209ead8c6c1aa91548b5bd 100755 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -35,11 +35,6 @@ - - - - - #define ENB_CONFIG_STRING_CC_NODE_FUNCTION "node_function" #define ENB_CONFIG_STRING_CC_NODE_TIMING "node_timing" #define ENB_CONFIG_STRING_CC_NODE_SYNCH_REF "node_synch_ref" @@ -259,7 +254,7 @@ typedef enum { #define ENB_CONFIG_STRING_PUCCH_DELTA_SHIFT "pucch_delta_shift" #define ENB_CONFIG_STRING_PUCCH_NRB_CQI "pucch_nRB_CQI" #define ENB_CONFIG_STRING_PUCCH_NCS_AN "pucch_nCS_AN" -//#if !defined(Rel10) && !defined(Rel14) +//#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) #define ENB_CONFIG_STRING_PUCCH_N1_AN "pucch_n1_AN" //#endif #define ENB_CONFIG_STRING_PDSCH_RS_EPRE "pdsch_referenceSignalPower" @@ -310,6 +305,54 @@ typedef enum { #define ENB_CONFIG_STRING_UETIMERS_N311 "ue_TimersAndConstants_n311" #define ENB_CONFIG_STRING_UE_TRANSMISSION_MODE "ue_TransmissionMode" +//TTN - for D2D +//SIB18 +#define ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN "rxPool_sc_CP_Len" +#define ENB_CONFIG_STRING_RXPOOL_SC_PRIOD "rxPool_sc_Period" +#define ENB_CONFIG_STRING_RXPOOL_DATA_CP_LEN "rxPool_data_CP_Len" +#define ENB_CONFIG_STRING_RXPOOL_RC_PRB_NUM "rxPool_ResourceConfig_prb_Num" +#define ENB_CONFIG_STRING_RXPOOL_RC_PRB_START "rxPool_ResourceConfig_prb_Start" +#define ENB_CONFIG_STRING_RXPOOL_RC_PRB_END "rxPool_ResourceConfig_prb_End" +#define ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_PRESENT "rxPool_ResourceConfig_offsetIndicator_present" +#define ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_CHOICE "rxPool_ResourceConfig_offsetIndicator_choice" +#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_PRESENT "rxPool_ResourceConfig_subframeBitmap_present" +#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_BUF "rxPool_ResourceConfig_subframeBitmap_choice_bs_buf" +#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE "rxPool_ResourceConfig_subframeBitmap_choice_bs_size" +#define ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED "rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused" +//SIB19 for DiscRxPool +#define ENB_CONFIG_STRING_DISCRXPOOL_CP_LEN "discRxPool_cp_Len" +#define ENB_CONFIG_STRING_DISCRXPOOL_DISCPERIOD "discRxPool_discPeriod" +#define ENB_CONFIG_STRING_DISCRXPOOL_NUMRETX "discRxPool_numRetx" +#define ENB_CONFIG_STRING_DISCRXPOOL_NUMREPETITION "discRxPool_numRepetition" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_NUM "discRxPool_ResourceConfig_prb_Num" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_START "discRxPool_ResourceConfig_prb_Start" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_END "discRxPool_ResourceConfig_prb_End" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_PRESENT "discRxPool_ResourceConfig_offsetIndicator_present" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_CHOICE "discRxPool_ResourceConfig_offsetIndicator_choice" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_PRESENT "discRxPool_ResourceConfig_subframeBitmap_present" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_BUF "discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE "discRxPool_ResourceConfig_subframeBitmap_choice_bs_size" +#define ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED "discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused" + +//SIB19 for DiscRxPoolPS +#define ENB_CONFIG_STRING_DISCRXPOOLPS_CP_LEN "DISCRXPOOLPS_cp_Len" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_DISCPERIOD "DISCRXPOOLPS_discPeriod" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_NUMRETX "DISCRXPOOLPS_numRetx" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_NUMREPETITION "DISCRXPOOLPS_numRepetition" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_NUM "DISCRXPOOLPS_ResourceConfig_prb_Num" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_START "DISCRXPOOLPS_ResourceConfig_prb_Start" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_END "DISCRXPOOLPS_ResourceConfig_prb_End" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_PRESENT "DISCRXPOOLPS_ResourceConfig_offsetIndicator_present" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_CHOICE "DISCRXPOOLPS_ResourceConfig_offsetIndicator_choice" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_PRESENT "DISCRXPOOLPS_ResourceConfig_subframeBitmap_present" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_BUF "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_buf" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_size" +#define ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED "DISCRXPOOLPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused" + +/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* component carriers configuration parameters */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* init for checkedparam_t structure */ #define CCPARAMS_CHECK { \ @@ -381,11 +424,51 @@ typedef enum { { .s1a= { config_check_modify_integer, UETIMER_N310_OKVALUES, UETIMER_N310_MODVALUES,8}} , \ { .s1a= { config_check_modify_integer, UETIMER_N311_OKVALUES, UETIMER_N311_MODVALUES,8}} , \ { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ + { .s5= {NULL }} , \ } /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* component carriers configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt checked_param */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ + #define CCPARAMS_DESC { \ {ENB_CONFIG_STRING_FRAME_TYPE, NULL, 0, strptr:&frame_type, defstrval:"FDD", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_TDD_CONFIG, NULL, 0, iptr:&tdd_config, defintval:3, TYPE_UINT, 0}, \ @@ -454,7 +537,45 @@ typedef enum { {ENB_CONFIG_STRING_UETIMERS_T311, NULL, 0, iptr:&ue_TimersAndConstants_t311, defintval:10000, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_UETIMERS_N310, NULL, 0, iptr:&ue_TimersAndConstants_n310, defintval:20, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_UETIMERS_N311, NULL, 0, iptr:&ue_TimersAndConstants_n311, defintval:1, TYPE_UINT, 0}, \ -{ENB_CONFIG_STRING_UE_TRANSMISSION_MODE, NULL, 0, iptr:&ue_TransmissionMode, defintval:1, TYPE_UINT, 0} \ +{ENB_CONFIG_STRING_UE_TRANSMISSION_MODE, NULL, 0, iptr:&ue_TransmissionMode, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_SC_CP_LEN, NULL, 0, strptr:(char **)&rxPool_sc_CP_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_SC_PRIOD, NULL, 0, strptr:(char **)&rxPool_sc_Period, defstrval:"sf40", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_DATA_CP_LEN, NULL, 0, strptr:(char **)&rxPool_data_CP_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_PRB_NUM, NULL, 0, iptr:(int32_t *)&rxPool_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_PRB_START, NULL, 0, iptr:(int32_t *)&rxPool_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_PRB_END, NULL, 0, iptr:(int32_t *)&rxPool_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_PRESENT, NULL, 0, strptr:(char **)&rxPool_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_OFFSETIND_CHOICE, NULL, 0, iptr:(int32_t *)&rxPool_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_PRESENT, NULL, 0, strptr:(char **)&rxPool_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:(char **)&rxPool_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:(int32_t *)&rxPool_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_RXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED, NULL, 0, iptr:(int32_t *)&rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_CP_LEN, NULL, 0, strptr:(char **)&discRxPool_cp_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_DISCPERIOD, NULL, 0, strptr:(char **)&discRxPool_discPeriod, defstrval:"rf32", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_NUMRETX, NULL, 0, iptr:(int32_t *)&discRxPool_numRetx, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_NUMREPETITION, NULL, 0, iptr:(int32_t *)&discRxPool_numRepetition, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_NUM, NULL, 0, iptr:(int32_t *)&discRxPool_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_START, NULL, 0, iptr:(int32_t *)&discRxPool_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_PRB_END, NULL, 0, iptr:(int32_t *)&discRxPool_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_PRESENT, NULL, 0, strptr:(char **)&discRxPool_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_OFFSETIND_CHOICE, NULL, 0, iptr:(int32_t *)&discRxPool_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_PRESENT, NULL, 0, strptr:(char **)&discRxPool_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:(char **)&discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:(int32_t *)&discRxPool_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOL_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL, 0, iptr:(int32_t *)&discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_CP_LEN, NULL, 0, strptr:(char **)&discRxPoolPS_cp_Len, defstrval:"normal", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_DISCPERIOD, NULL, 0, strptr:(char **)&discRxPoolPS_discPeriod, defstrval:"rf32", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMRETX, NULL, 0, iptr:(int32_t *)&discRxPoolPS_numRetx, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_NUMREPETITION, NULL, 0, iptr:(int32_t *)&discRxPoolPS_numRepetition, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_NUM, NULL, 0, iptr:(int32_t *)&discRxPoolPS_ResourceConfig_prb_Num, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_START, NULL, 0, iptr:(int32_t *)&discRxPoolPS_ResourceConfig_prb_Start, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_PRB_END, NULL, 0, iptr:(int32_t *)&discRxPoolPS_ResourceConfig_prb_End, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_PRESENT, NULL, 0, strptr:(char **)&discRxPoolPS_ResourceConfig_offsetIndicator_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_OFFSETIND_CHOICE, NULL, 0, iptr:(int32_t *)&discRxPoolPS_ResourceConfig_offsetIndicator_choice, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_PRESENT, NULL, 0, strptr:(char **)&discRxPoolPS_ResourceConfig_subframeBitmap_present, defstrval:"prNothing", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_BUF, NULL, 0, strptr:(char **)&discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf, defstrval:"001001", TYPE_STRING, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_SIZE, NULL, 0, iptr:(int32_t *)&discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size, defintval:1, TYPE_UINT, 0}, \ +{ENB_CONFIG_STRING_DISCRXPOOLPS_RC_SFBITMAP_CHOICE_BS_ASN_BITS_UNUSED,NULL, 0, iptr:(int32_t *)&discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused, defintval:1, TYPE_UINT, 0} \ } #define ENB_CONFIG_FRAME_TYPE_IDX 0 @@ -739,4 +860,43 @@ typedef enum { #define CONFIG_STRING_MACRLC_CONFIG "macrlc_config" - +/* MACRLC configuration parameters names */ +#define CONFIG_STRING_MACRLC_CC "num_cc" +#define CONFIG_STRING_MACRLC_TRANSPORT_N_PREFERENCE "tr_n_preference" +#define CONFIG_STRING_MACRLC_LOCAL_N_IF_NAME "local_n_if_name" +#define CONFIG_STRING_MACRLC_LOCAL_N_ADDRESS "local_n_address" +#define CONFIG_STRING_MACRLC_REMOTE_N_ADDRESS "remote_n_address" +#define CONFIG_STRING_MACRLC_LOCAL_N_PORTC "local_n_portc" +#define CONFIG_STRING_MACRLC_REMOTE_N_PORTC "remote_n_portc" +#define CONFIG_STRING_MACRLC_LOCAL_N_PORTD "local_n_portd" +#define CONFIG_STRING_MACRLC_REMOTE_N_PORTD "remote_n_portd" +#define CONFIG_STRING_MACRLC_TRANSPORT_S_PREFERENCE "tr_s_preference" +#define CONFIG_STRING_MACRLC_LOCAL_S_IF_NAME "local_s_if_name" +#define CONFIG_STRING_MACRLC_LOCAL_S_ADDRESS "local_s_address" +#define CONFIG_STRING_MACRLC_REMOTE_S_ADDRESS "remote_s_address" +#define CONFIG_STRING_MACRLC_LOCAL_S_PORTC "local_s_portc" +#define CONFIG_STRING_MACRLC_REMOTE_S_PORTC "remote_s_portc" +#define CONFIG_STRING_MACRLC_LOCAL_S_PORTD "local_s_portd" +#define CONFIG_STRING_MACRLC_REMOTE_S_PORTD "remote_s_portd" +#define CONFIG_STRING_MACRLC_PHY_TEST_MODE "phy_test_mode" + + +#define MACRLC_CC_IDX 0 +#define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 +#define MACRLC_LOCAL_N_IF_NAME_IDX 2 +#define MACRLC_LOCAL_N_ADDRESS_IDX 3 +#define MACRLC_REMOTE_N_ADDRESS_IDX 4 +#define MACRLC_LOCAL_N_PORTC_IDX 5 +#define MACRLC_REMOTE_N_PORTC_IDX 6 +#define MACRLC_LOCAL_N_PORTD_IDX 7 +#define MACRLC_REMOTE_N_PORTD_IDX 8 +#define MACRLC_TRANSPORT_S_PREFERENCE_IDX 9 +#define MACRLC_LOCAL_S_IF_NAME_IDX 10 +#define MACRLC_LOCAL_S_ADDRESS_IDX 11 +#define MACRLC_REMOTE_S_ADDRESS_IDX 12 +#define MACRLC_LOCAL_S_PORTC_IDX 13 +#define MACRLC_REMOTE_S_PORTC_IDX 14 +#define MACRLC_LOCAL_S_PORTD_IDX 15 +#define MACRLC_REMOTE_S_PORTD_IDX 16 +#define MACRLC_PHY_TEST_IDX 17 +/*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 4b0a22300fc5064e21e68dd4664e48a0ce977207..3bbea167d37dfacf1e8e2ca6cc0c576a2918f18d 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -35,11 +35,11 @@ #include "flexran_agent_extern.h" #include "flexran_agent_net_comm.h" #include "flexran_agent_ran_api.h" -#include "PHY/extern.h" +//#include "PHY/extern.h" #include "log.h" -#include "SCHED/defs.h" -#include "RRC/LITE/extern.h" +//#include "SCHED/defs.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rrc_eNB_UE_context.h" diff --git a/openair2/ENB_APP/flexran_agent_common.h b/openair2/ENB_APP/flexran_agent_common.h index 242cb55ca86364db4254f250a6a97657ad73e71d..057c5b9489a7332a9cdb8923f3abeb58a44f7d46 100644 --- a/openair2/ENB_APP/flexran_agent_common.h +++ b/openair2/ENB_APP/flexran_agent_common.h @@ -42,7 +42,6 @@ #include "flexran_agent_defs.h" #include "enb_config.h" -#include "LAYER2/MAC/extern.h" #include "LAYER2/RLC/rlc.h" # include "tree.h" diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index 3200f55f16fa1100e75140b87c98b6f257786701..2e5bccd93514671481c537884190448238a19a13 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -140,7 +140,11 @@ rlc_buffer_occupancy_t flexran_get_tx_queue_size(mid_t mod_id, mid_t ue_id, logi rnti_t rnti = flexran_get_ue_crnti(mod_id, ue_id); frame_t frame = flexran_get_current_frame(mod_id); sub_frame_t subframe = flexran_get_current_subframe(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0 +#ifdef Rel14 + ,0, 0 +#endif + ); return rlc_status.bytes_in_buffer; } @@ -149,7 +153,11 @@ rlc_buffer_occupancy_t flexran_get_num_pdus_buffer(mid_t mod_id, mid_t ue_id, lo rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); frame_t frame = flexran_get_current_frame(mod_id); sub_frame_t subframe = flexran_get_current_subframe(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id,rnti, mod_id, frame, subframe, ENB_FLAG_YES,MBMS_FLAG_NO, channel_id, 0 +#ifdef Rel14 + ,0, 0 +#endif + ); return rlc_status.pdus_in_buffer; } @@ -158,7 +166,11 @@ frame_t flexran_get_hol_delay(mid_t mod_id, mid_t ue_id, logical_chan_id_t chann rnti_t rnti = flexran_get_ue_crnti(mod_id,ue_id); frame_t frame = flexran_get_current_frame(mod_id); sub_frame_t subframe = flexran_get_current_subframe(mod_id); - mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, subframe, ENB_FLAG_YES, MBMS_FLAG_NO, channel_id, 0); + mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mod_id, rnti, mod_id, frame, subframe, ENB_FLAG_YES, MBMS_FLAG_NO, channel_id, 0 +#ifdef Rel14 + ,0, 0 +#endif + ); return rlc_status.head_sdu_creation_time; } @@ -1207,7 +1219,7 @@ void flexran_set_pdcp_rx_stat_window(const mid_t mod_id, const mid_t ue_id, uint /*PDCP num tx pdu status flexRAN*/ uint32_t flexran_get_pdcp_tx(const mid_t mod_id, const mid_t ue_id, const lcid_t lcid){ - if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> NUMBER_OF_UE_MAX || lcid<0 || lcid>NB_RB_MAX) + if (mod_id <0 || mod_id> MAX_NUM_CCs || ue_id<0 || ue_id> MAX_MOBILES_PER_ENB || lcid<0 || lcid>NB_RB_MAX) return -1; return Pdcp_stats_tx[mod_id][ue_id][lcid]; } diff --git a/openair2/ENB_APP/flexran_agent_ran_api.h b/openair2/ENB_APP/flexran_agent_ran_api.h index 4e5f214af00f133cc2d2485589b17650f7af0712..3354d8ace875da91ed0dc6fc9b53f5fca5225877 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.h +++ b/openair2/ENB_APP/flexran_agent_ran_api.h @@ -36,14 +36,13 @@ #include "enb_config.h" -#include "LAYER2/MAC/extern.h" #include "LAYER2/RLC/rlc.h" -#include "SCHED/defs.h" +#include "SCHED/sched_eNB.h" #include "pdcp.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "RRC/LITE/rrc_eNB_UE_context.h" -#include "PHY/extern.h" +#include "RRC/LTE/rrc_eNB_UE_context.h" +#include "PHY/phy_extern.h" #include "log.h" /**************************** diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 42ed105f23b3c507416b0508e292fd6efcb9c8c5..78e4ca04ab240f9e65b6671b337f082deb1fb5fd 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -32,25 +32,24 @@ #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" -#include "SCHED/defs.h" #include "SystemInformationBlockType2.h" //#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) #include "PRACH-ConfigSIB-v1310.h" #endif #include "MeasGapConfig.h" #include "MeasObjectToAddModList.h" #include "TDD-Config.h" #include "MAC-MainConfig.h" -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "common/ran_context.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "MBSFN-AreaInfoList-r9.h" #include "MBSFN-AreaInfo-r9.h" #include "MBSFN-SubframeConfigList.h" @@ -194,7 +193,7 @@ void config_mib(int Mod_idP, int p_eNBP, uint32_t dl_CarrierFreqP, uint32_t ul_CarrierFreqP -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , uint32_t pbch_repetitionP #endif @@ -266,14 +265,14 @@ void config_mib(int Mod_idP, cfg->sch_config.physical_cell_id.tl.tag = NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG; cfg->num_tlv++; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) cfg->emtc_config.pbch_repetitions_enable_r13.value = pbch_repetitionP; cfg->emtc_config.pbch_repetitions_enable_r13.tl.tag = NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG; cfg->num_tlv++; #endif LOG_I(MAC, "%s() NFAPI_CONFIG_REQUEST(num_tlv:%u) DL_BW:%u UL_BW:%u Ncp %d,p_eNB %d,earfcn %d,band %d,phich_resource %u phich_duration %u phich_power_offset %u PSS %d SSS %d PCI %d" -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) " PBCH repetition %d" #endif @@ -291,7 +290,7 @@ void config_mib(int Mod_idP, ,cfg->sch_config.primary_synchronization_signal_epre_eprers.value ,cfg->sch_config.secondary_synchronization_signal_epre_eprers.value ,cfg->sch_config.physical_cell_id.value -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,cfg->emtc_config.pbch_repetitions_enable_r13.value #endif ); @@ -330,7 +329,7 @@ void config_sib2(int Mod_idP, int CC_idP, RadioResourceConfigCommonSIB_t * radioResourceConfigCommonP, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RadioResourceConfigCommonSIB_t * radioResourceConfigCommon_BRP, #endif ARFCN_ValueEUTRA_t *ul_CArrierFreqP, @@ -446,7 +445,7 @@ config_sib2(int Mod_idP, cfg->num_tlv++; } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0) { AssertFatal(radioResourceConfigCommon_BRP != NULL, "radioResource rou is missing\n"); AssertFatal(radioResourceConfigCommon_BRP->ext4 != NULL, "ext4 is missing\n"); @@ -677,20 +676,20 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, int physCellId, int p_eNB, int Ncp, int eutra_band, uint32_t dl_CarrierFreq, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int pbch_repetition, #endif rnti_t rntiP, BCCH_BCH_Message_t * mib, RadioResourceConfigCommonSIB_t * radioResourceConfigCommon, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RadioResourceConfigCommonSIB_t * radioResourceConfigCommon_BR, #endif struct PhysicalConfigDedicated *physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) SCellToAddMod_r10_t * sCellToAddMod_r10, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -708,12 +707,12 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, additionalSpectrumEmission, struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , uint8_t MBMS_Flag, MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, PMCH_InfoList_r9_t * pmch_InfoList #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , SystemInformationBlockType1_v1310_IEs_t * sib1_v13ext @@ -764,7 +763,7 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, p_eNB, dl_CarrierFreq, ul_CarrierFreq -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , pbch_repetition #endif ); @@ -776,7 +775,7 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, RC.mac[Mod_idP]->common_channels[CC_idP].schedulingInfoList = schedulingInfoList; config_sib1(Mod_idP,CC_idP,tdd_Config); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) if (sib1_v13ext != NULL) { RC.mac[Mod_idP]->common_channels[CC_idP].sib1_v13ext = sib1_v13ext; } @@ -835,7 +834,7 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, dl_Bandwidth; config_sib2(Mod_idP, CC_idP, radioResourceConfigCommon, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) radioResourceConfigCommon_BR, #endif NULL, ul_Bandwidth, additionalSpectrumEmission, @@ -877,7 +876,7 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (sCellToAddMod_r10 != NULL) { UE_id = find_UE_id(Mod_idP, rntiP); @@ -910,11 +909,11 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, subframeAllocation.choice.oneFrame.buf[0]); } -#ifdef Rel10 +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) RC.mac[Mod_idP]->common_channels[0].MBMS_flag = MBMS_Flag; #endif } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mbsfn_AreaInfoList != NULL) { // One eNB could be part of multiple mbsfn syc area, this could change over time so reset each time diff --git a/openair2/LAYER2/MAC/config_ue.c b/openair2/LAYER2/MAC/config_ue.c index 5ef18f5bdad0c2b4917d943824c9cae3f1c90430..0b27955dad61a096ffebeaf9b87e0b8fd556ba93 100644 --- a/openair2/LAYER2/MAC/config_ue.c +++ b/openair2/LAYER2/MAC/config_ue.c @@ -32,25 +32,26 @@ #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" -#include "SCHED/defs.h" +#include "SCHED_UE/sched_UE.h" #include "SystemInformationBlockType2.h" //#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) #include "PRACH-ConfigSIB-v1310.h" #endif #include "MeasGapConfig.h" #include "MeasObjectToAddModList.h" #include "TDD-Config.h" #include "MAC-MainConfig.h" -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" +#include "PHY/INIT/phy_init.h" #include "common/ran_context.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "MBSFN-AreaInfoList-r9.h" #include "MBSFN-AreaInfo-r9.h" #include "MBSFN-SubframeConfigList.h" @@ -60,6 +61,8 @@ extern void mac_init_cell_params(int Mod_idP,int CC_idP); extern void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); +extern uint8_t nfapi_mode; + /* sec 5.9, 36.321: MAC Reset Procedure */ void ue_mac_reset(module_id_t module_idP, uint8_t eNB_index) @@ -108,7 +111,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, radioResourceConfigCommon, struct PhysicalConfigDedicated *physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) SCellToAddMod_r10_t * sCellToAddMod_r10, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -127,13 +130,18 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, additionalSpectrumEmission, struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , uint8_t MBMS_Flag, MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, PMCH_InfoList_r9_t * pmch_InfoList #endif #ifdef CBA , uint8_t num_active_cba_groups, uint16_t cba_rnti +#endif +#if defined(Rel14) + ,config_action_t config_action + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id #endif ) { @@ -211,7 +219,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, mac_MainConfig->ul_SCH_Config->periodicBSR_Timer; } else { UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = -#ifndef Rel14 +#if (RRC_VERSION < MAKE_VERSION(12, 0, 0)) (uint16_t) MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity #else @@ -228,16 +236,17 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, (uint16_t) MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; } - phy_config_harq_ue(Mod_idP, 0, eNB_index, - UE_mac_inst[Mod_idP]. - scheduling_info.maxHARQ_Tx); + if(nfapi_mode!=3) + phy_config_harq_ue(Mod_idP, 0, eNB_index, + UE_mac_inst[Mod_idP]. + scheduling_info.maxHARQ_Tx); if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) { UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = (uint16_t) mac_MainConfig->ul_SCH_Config-> retxBSR_Timer; } else { -#ifndef Rel14 +#if (RRC_VERSION < MAKE_VERSION(12, 0, 0)) UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = (uint16_t) MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; @@ -247,7 +256,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, #endif } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { @@ -348,11 +357,12 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, if (physicalConfigDedicated != NULL) { - phy_config_dedicated_ue(Mod_idP, 0, eNB_index, - physicalConfigDedicated); + if(nfapi_mode!=3) + phy_config_dedicated_ue(Mod_idP, 0, eNB_index, + physicalConfigDedicated); UE_mac_inst[Mod_idP].physicalConfigDedicated = physicalConfigDedicated; // for SR proc } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (sCellToAddMod_r10 != NULL) { @@ -522,7 +532,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, // UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mbsfn_AreaInfoList != NULL) { LOG_I(MAC, "[UE %d][CONFIG] Received %d MBSFN Area Info\n", @@ -579,6 +589,34 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, #endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); + //for D2D + #if defined(Rel10) || defined(Rel14) + switch (config_action) { + case CONFIG_ACTION_ADD: + if (sourceL2Id){ + UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id; + LOG_I(MAC,"[UE %d] Configure source L2Id 0x%08x \n", Mod_idP, *sourceL2Id ); + } + if (destinationL2Id) { + LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id ); + int j = 0; + int i = 0; + for (i=0; i< MAX_NUM_DEST; i++) { + if ((UE_mac_inst[Mod_idP].destinationList[i] == 0) && (j == 0)) j = i+1; + if (UE_mac_inst[Mod_idP].destinationList[i] == *destinationL2Id) break; //destination already exists! + } + if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[Mod_idP].destinationList[j-1] = *destinationL2Id; + UE_mac_inst[Mod_idP].numCommFlows++; + } + break; + case CONFIG_ACTION_REMOVE: + //TODO + break; + default: + break; + } + + #endif return (0); } diff --git a/openair2/LAYER2/MAC/defs_NB_IoT.h b/openair2/LAYER2/MAC/defs_NB_IoT.h index 77c0828b283076bd4edce975379dfe99f4bbd321..02f9c47ea5cdc7d0443cd13c64492460014d4adb 100644 --- a/openair2/LAYER2/MAC/defs_NB_IoT.h +++ b/openair2/LAYER2/MAC/defs_NB_IoT.h @@ -98,7 +98,7 @@ typedef enum{ DL }message_direction_t; -#define MAX_NUMBER_OF_UE_MAX_NB_IoT 20 +#define MAX_MAX_MOBILES_PER_ENB_NB_IoT 20 #define SCH_PAYLOAD_SIZE_MAX_NB_IoT 320 #define MAX_NUMBER_OF_SIBs_NB_IoT 16 @@ -233,17 +233,17 @@ typedef struct{ typedef struct { /// DCI template and MAC connection parameters for UEs - UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; /// NPDCCH Period and searching space info NPDCCH_config_dedicated_NB_IoT_t NPDCCH_config_dedicated; - //int next[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + //int next[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; // -1:No UE in list int head; // -1:No UE in list int tail; int num_UEs; - //boolean_t active[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + //boolean_t active[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; } UE_list_NB_IoT_t; @@ -261,7 +261,7 @@ typedef struct{ // flag to indicate scheduling type1 NPDCCH CSS with different CE level uint8_t flag_type1_css[3]; // flag to indicate scheduling NPDCCH USS with UE list - uint8_t flag_uss[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + uint8_t flag_uss[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; // flag to indicate scheduling sib1/MIB uint8_t flag_fix_scheduling; // number of the type2 css to schedule in this period @@ -494,7 +494,7 @@ typedef struct eNB_MAC_INST_NB_IoT_s { RA_template_list_t RA_msg3_list; RA_template_list_t RA_msg4_list; - RA_TEMPLATE_NB_IoT RA_template[MAX_NUMBER_OF_UE_MAX_NB_IoT]; + RA_TEMPLATE_NB_IoT RA_template[MAX_MAX_MOBILES_PER_ENB_NB_IoT]; //int32_t last_tx_subframe; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 8dab2a9b71857a027ded133e2f932df1a1be1d60..fd086c4adba680f002b274ef8f7eba983247accf 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -30,23 +30,18 @@ */ #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" - -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -60,10 +55,13 @@ #include "intertask_interface.h" #endif +#include "assertions.h" + #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 extern RAN_CONTEXT_t RC; +extern int phy_test; uint16_t pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; @@ -107,9 +105,8 @@ schedule_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) if ((1 << tmp) & deltaTSFC) { // This is an SRS subframe, loop over UEs - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE) - continue; + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { + if (!RC.mac[module_idP]->UE_list.active[UE_id]) continue; ul_req = &RC.mac[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; @@ -169,9 +166,8 @@ schedule_CSI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { cc = &eNB->common_channels[CC_id]; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] != TRUE) - continue; + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { + if (!UE_list->active[UE_id]) continue; ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; @@ -210,7 +206,7 @@ schedule_CSI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) ul_req->number_of_pdus++; ul_req->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) // PUT rel10-13 UCI options here #endif } else @@ -255,8 +251,8 @@ schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { RC.mac[module_idP]->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE) continue; + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { + if (!RC.mac[module_idP]->UE_list.active[UE_id]) continue; ul_req = &RC.mac[module_idP]->UL_req[CC_id]; ul_req_body = &ul_req->ul_config_request_body; @@ -313,7 +309,7 @@ schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) LOG_D(MAC,"Frame %d, Subframe %d : Scheduling SR for UE %d/%x is_harq:%d\n",frameP,subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].rnti, is_harq); // check Rel10 or Rel8 SR -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if ((UE_list-> UE_template[CC_id][UE_id].physicalConfigDedicated->ext2) && (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020) && (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020)) { @@ -526,7 +522,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, memset(cc[CC_id].vrb_map_UL, 0, 100); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) cc[CC_id].mcch_active = 0; #endif @@ -534,91 +530,93 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, } // refresh UE list based on UEs dropped by PHY in previous subframe - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) - continue; - - rnti = UE_RNTI(module_idP, i); - CC_id = UE_PCCID(module_idP, i); - - if ((frameP == 0) && (subframeP == 0)) { - LOG_I(MAC, - "UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", - rnti, - UE_list->UE_sched_ctrl[i].ul_out_of_sync == - 0 ? "in synch" : "out of sync", - UE_list->UE_template[CC_id][i].phr_info, - UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], - (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2, - (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2); - } + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + if (UE_list->active[i]) { - RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) + - subframeP] = -63; - if (i == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME - (VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, - RC.eNB[module_idP][CC_id]-> - pusch_stats_bsr[i][(frameP * 10) + subframeP]); - // increment this, it is cleared when we receive an sdu - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; - - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++; - LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", i, rnti, - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i]. - ul_inactivity_timer, - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer); - check_ul_failure(module_idP, CC_id, i, frameP, subframeP); - - if (RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer > 0) { - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer++; - if(RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer >= - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres) { - RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer = 0; - for (int ue_id_l = 0; ue_id_l < NUMBER_OF_UE_MAX; ue_id_l++) { - if (reestablish_rnti_map[ue_id_l][0] == rnti) { - // clear currentC-RNTI from map - reestablish_rnti_map[ue_id_l][0] = 0; - reestablish_rnti_map[ue_id_l][1] = 0; - break; + rnti = UE_RNTI(module_idP, i); + CC_id = UE_PCCID(module_idP, i); + + if (((frameP&127) == 0) && (subframeP == 0)) { + LOG_I(MAC, + "UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", + rnti, + UE_list->UE_sched_ctrl[i].ul_out_of_sync == + 0 ? "in synch" : "out of sync", + UE_list->UE_template[CC_id][i].phr_info, + UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], + (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2, + (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2); + } + + RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) + + subframeP] = -63; + if (i == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME + (VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, + RC.eNB[module_idP][CC_id]-> + pusch_stats_bsr[i][(frameP * 10) + subframeP]); + // increment this, it is cleared when we receive an sdu + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; + + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++; + LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", i, rnti, + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i]. + ul_inactivity_timer, + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer); + check_ul_failure(module_idP, CC_id, i, frameP, subframeP); + + if (RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer > 0) { + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer++; + if(RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer >= + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres) { + RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer = 0; + for (int ue_id_l = 0; ue_id_l < MAX_MOBILES_PER_ENB; ue_id_l++) { + if (reestablish_rnti_map[ue_id_l][0] == rnti) { + // clear currentC-RNTI from map + reestablish_rnti_map[ue_id_l][0] = 0; + reestablish_rnti_map[ue_id_l][1] = 0; + break; + } } - } - for (int ii=0; ii<NUMBER_OF_UE_MAX; ii++) { - LTE_eNB_ULSCH_t *ulsch = RC.eNB[module_idP][CC_id]->ulsch[ii]; - if((ulsch != NULL) && (ulsch->rnti == rnti)){ - LOG_I(MAC, "clean_eNb_ulsch UE %x \n", rnti); - clean_eNb_ulsch(ulsch); + // Note: This should not be done in the MAC! + for (int ii=0; ii<MAX_MOBILES_PER_ENB; ii++) { + LTE_eNB_ULSCH_t *ulsch = RC.eNB[module_idP][CC_id]->ulsch[ii]; + if((ulsch != NULL) && (ulsch->rnti == rnti)){ + void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); + LOG_I(MAC, "clean_eNb_ulsch UE %x \n", rnti); + clean_eNb_ulsch(ulsch); + } } - } - for (int ii=0; ii<NUMBER_OF_UE_MAX; ii++) { - LTE_eNB_DLSCH_t *dlsch = RC.eNB[module_idP][CC_id]->dlsch[ii][0]; - if((dlsch != NULL) && (dlsch->rnti == rnti)){ - LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); - clean_eNb_dlsch(dlsch); + for (int ii=0; ii<MAX_MOBILES_PER_ENB; ii++) { + LTE_eNB_DLSCH_t *dlsch = RC.eNB[module_idP][CC_id]->dlsch[ii][0]; + if((dlsch != NULL) && (dlsch->rnti == rnti)){ + void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); + LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); + clean_eNb_dlsch(dlsch); + } } - } - - for(int j = 0; j < 10; j++){ - nfapi_ul_config_request_body_t *ul_req_tmp = NULL; - ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body; - if(ul_req_tmp){ - int pdu_number = ul_req_tmp->number_of_pdus; - for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ - if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ - LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); - if(pdu_index < pdu_number -1){ - memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + + for(int j = 0; j < 10; j++){ + nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body; + if(ul_req_tmp){ + int pdu_number = ul_req_tmp->number_of_pdus; + for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ + if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ + LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); + if(pdu_index < pdu_number -1){ + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + } + ul_req_tmp->number_of_pdus--; } - ul_req_tmp->number_of_pdus--; } } } - } rrc_mac_remove_ue(module_idP,rnti); + } } } } - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, subframeP, module_idP); @@ -627,7 +625,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, rrc_rx_tx(&ctxt, CC_id); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { if (cc[CC_id].MBMS_flag > 0) { @@ -640,26 +638,33 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, #endif // This schedules MIB + if ((subframeP == 0) && (frameP & 3) == 0) schedule_mib(module_idP, frameP, subframeP); - // This schedules SI for legacy LTE and eMTC starting in subframeP - schedule_SI(module_idP, frameP, subframeP); - // This schedules Paging in subframeP - schedule_PCH(module_idP,frameP,subframeP); - // This schedules Random-Access for legacy LTE and eMTC starting in subframeP - schedule_RA(module_idP, frameP, subframeP); - // copy previously scheduled UL resources (ULSCH + HARQ) - copy_ulreq(module_idP, frameP, subframeP); - // This schedules SRS in subframeP - schedule_SRS(module_idP, frameP, subframeP); - // This schedules ULSCH in subframeP (dci0) - schedule_ulsch(module_idP, frameP, subframeP); - // This schedules UCI_SR in subframeP - schedule_SR(module_idP, frameP, subframeP); - // This schedules UCI_CSI in subframeP - schedule_CSI(module_idP, frameP, subframeP); - // This schedules DLSCH in subframeP - schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status); + if (phy_test == 0){ + // This schedules SI for legacy LTE and eMTC starting in subframeP + schedule_SI(module_idP, frameP, subframeP); + // This schedules Paging in subframeP + schedule_PCH(module_idP,frameP,subframeP); + // This schedules Random-Access for legacy LTE and eMTC starting in subframeP + schedule_RA(module_idP, frameP, subframeP); + // copy previously scheduled UL resources (ULSCH + HARQ) + copy_ulreq(module_idP, frameP, subframeP); + // This schedules SRS in subframeP + schedule_SRS(module_idP, frameP, subframeP); + // This schedules ULSCH in subframeP (dci0) + schedule_ulsch(module_idP, frameP, subframeP); + // This schedules UCI_SR in subframeP + schedule_SR(module_idP, frameP, subframeP); + // This schedules UCI_CSI in subframeP + schedule_CSI(module_idP, frameP, subframeP); + // This schedules DLSCH in subframeP + schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status); + } + else{ + schedule_ulsch_phy_test(module_idP,frameP,subframeP); + schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status); + } if (RC.flexran[module_idP]->enabled) flexran_agent_send_update_stats(module_idP); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 3005ecf464233f379d856c22441608f6ea1ca182..6a528a9930af00239341bb305093c53f8415760f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -34,24 +34,20 @@ #include "assertions.h" #include "platform_types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" #include "msc.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" - -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -61,10 +57,14 @@ #include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #include "T.h" +#include "common/ran_context.h" + +extern RAN_CONTEXT_t RC; + extern uint8_t nfapi_mode; extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); @@ -118,7 +118,7 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n", ra->rnti); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (ra->rach_resource_type > 0) { LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d CE level %d is active, Msg3 in (%d,%d)\n", @@ -174,9 +174,9 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, ra->Msg3_subframe); LOG_D(MAC, - "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d)\n", + "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, - ra->msg3_nb_rb, ra->msg3_first_rb, ra->msg3_round); + ra->msg3_nb_rb, ra->msg3_first_rb, ra->msg3_round, ra->rnti); ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; @@ -267,7 +267,7 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP, dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int rmax = 0; int rep = 0; int reps = 0; @@ -620,7 +620,7 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, uint8_t offset; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int rmax = 0; int rep = 0; int reps = 0; @@ -698,7 +698,7 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, else ra->harq_pid = ((frameP * 10) + subframeP) & 7; - // Get RRCConnectionSetup for Piggyback + /* // Get RRCConnectionSetup for Piggyback rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case @@ -708,10 +708,10 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", - module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);*/ -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (ra->rach_resource_type > 0) { // Generate DCI + repetitions first @@ -817,6 +817,20 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, // Program PDSCH + // Get RRCConnectionSetup for Piggyback + /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/ + + rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); + + AssertFatal(rrc_sdu_length > 0, + "[MAC][eNB Scheduler] CCCH not allocated\n"); + LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 BR with RRC Piggyback (ce_level %d RNTI %x)\n", module_idP, CC_idP, frameP, subframeP, @@ -978,8 +992,27 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, } // rach_resource_type > 0 else #endif - { // This is normal LTE case - if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) { + { + // This is normal LTE case + LOG_D(MAC, "Panos-D: generate_Msg4 1 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP); + if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) { + + // Get RRCConnectionSetup for Piggyback + /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/ + + rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); + + AssertFatal(rrc_sdu_length > 0, + "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length); + + + LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", module_idP, CC_idP, frameP, subframeP, ra->rnti); @@ -1185,7 +1218,7 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, int round; /* - #ifdef Rel14 + #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) COMMON_channels_t *cc = mac->common_channels; int rmax = 0; @@ -1233,12 +1266,12 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d)\n", - module_idP, CC_idP, frameP, subframeP, ra->harq_pid, round); + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d), UE_id: %d \n", + module_idP, CC_idP, frameP, subframeP, ra->harq_pid, round, UE_id); if (round != 8) { -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (ra->rach_resource_type > 0) { AssertFatal(1 == 0, "Msg4 Retransmissions not handled yet for BL/CE UEs\n"); @@ -1283,6 +1316,7 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, ra->rnti, round, frameP, subframeP); // DLSCH Config //DJP - fix this pdu_index = -1 + LOG_D(MAC, "Panos:D: check_Msg4_retransmission() before fill_nfapi_dlsch_config() with pdu_index = -1 \n"); fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, -1 /* retransmission, no pdu_index */ @@ -1393,7 +1427,7 @@ initiate_ra_proc(module_id_t module_idP, sub_frame_t subframeP, uint16_t preamble_index, int16_t timing_offset, uint16_t ra_rnti -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , uint8_t rach_resource_type #endif ) @@ -1404,7 +1438,7 @@ initiate_ra_proc(module_id_t module_idP, COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; RA_t *ra = &cc->ra[0]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) struct PRACH_ConfigSIB_v1310 *ext4_prach = NULL; PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; @@ -1415,12 +1449,12 @@ initiate_ra_proc(module_id_t module_idP, prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; } -#endif /* Rel14 */ +#endif /* #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */ LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n", module_idP, CC_id, frameP, subframeP, preamble_index); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n", module_idP, CC_id, frameP, subframeP, rach_resource_type); @@ -1430,7 +1464,7 @@ initiate_ra_proc(module_id_t module_idP, uint16_t msg2_subframe = subframeP; int offset; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) if (prach_ParametersListCE_r13 && prach_ParametersListCE_r13->list.count < rach_resource_type) { @@ -1441,7 +1475,7 @@ initiate_ra_proc(module_id_t module_idP, return; } -#endif /* Rel14 */ +#endif /* #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); @@ -1454,7 +1488,7 @@ initiate_ra_proc(module_id_t module_idP, ra[i].state = MSG2; ra[i].timing_offset = timing_offset; ra[i].preamble_subframe = subframeP; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ra[i].rach_resource_type = rach_resource_type; ra[i].msg2_mpdcch_repetition_cnt = 0; ra[i].msg4_mpdcch_repetition_cnt = 0; @@ -1477,18 +1511,18 @@ initiate_ra_proc(module_id_t module_idP, /* TODO: find better procedure to allocate RNTI */ do { #if defined(USRP_REC_PLAY) // deterministic rnti in usrp record/playback mode - static int drnti[NUMBER_OF_UE_MAX] = { 0xbda7, 0x71da, 0x9c40, 0xc350, 0x2710, 0x4e20, 0x7530, 0x1388, 0x3a98, 0x61a8, 0x88b8, 0xafc8, 0xd6d8, 0x1b58, 0x4268, 0x6978 }; + static int drnti[MAX_MOBILES_PER_ENB] = { 0xbda7, 0x71da, 0x9c40, 0xc350, 0x2710, 0x4e20, 0x7530, 0x1388, 0x3a98, 0x61a8, 0x88b8, 0xafc8, 0xd6d8, 0x1b58, 0x4268, 0x6978 }; int j = 0; int nb_ue = 0; - for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { if (UE_RNTI(module_idP, j) > 0) { nb_ue++; } else { break; } } - if (nb_ue >= NUMBER_OF_UE_MAX) { - printf("No more free RNTI available, increase NUMBER_OF_UE_MAX\n"); + if (nb_ue >= MAX_MOBILES_PER_ENB) { + printf("No more free RNTI available, increase MAX_MOBILES_PER_ENB\n"); abort(); } ra[i].rnti = drnti[nb_ue]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index de4641fac6dc499dd54cf9b77ca8fc121e76a451..7aabc30b8194fe7776f7dcae7db8ac44eca51bf9 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -30,22 +30,16 @@ */ #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -58,11 +52,14 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +#include "common/ran_context.h" + +extern RAN_CONTEXT_t RC; // NEED TO ADD schedule_SI_BR for SIB1_BR and SIB23_BR // CCE_allocation_infeasible to be done for EPDCCH/MPDCCH -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) #define size_Sj25 2 int Sj25[size_Sj25] = { 0, 3 }; @@ -84,7 +81,6 @@ schedule_SIB1_BR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) //------------------------------------------------------------------------------ { - int8_t bcch_sdu_length; int CC_id; eNB_MAC_INST *eNB = RC.mac[module_idP]; @@ -509,7 +505,6 @@ schedule_SI_BR(module_id_t module_idP, frame_t frameP, void schedule_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc; nfapi_dl_config_request_pdu_t *dl_config_pdu; @@ -538,7 +533,7 @@ schedule_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) LOG_D(MAC, "Frame %d, subframe %d: Adding BCH PDU in position %d (length %d)\n", frameP, subframeP, dl_req->number_pdu, mib_sdu_length); if ((frameP & 1023) < 40) -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LOG_D(MAC, "[eNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes (cc->mib->message.schedulingInfoSIB1_BR_r13 %d)\n", module_idP, frameP, CC_id, mib_sdu_length, @@ -787,13 +782,14 @@ schedule_SI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) eNB->eNB_stats[CC_id].bcch_buffer = bcch_sdu_length; eNB->eNB_stats[CC_id].total_bcch_buffer += bcch_sdu_length; eNB->eNB_stats[CC_id].bcch_mcs = mcs; +//printf("SI %d.%d\n", frameP, subframeP);/////////////////////////////////////////****************************** } else { //LOG_D(MAC,"[eNB %d] Frame %d : BCCH not active \n",Mod_id,frame); } } } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) schedule_SIB1_BR(module_idP, frameP, subframeP); schedule_SI_BR(module_idP, frameP, subframeP); #endif diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 0729073eba3cc5e6ca1351603329d83c095497bc..0c44946d732f43b0224bc569cb3e693ef12d0af7 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -29,29 +29,26 @@ */ -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus + +#include "assertions.h" #if defined(ENABLE_ITTI) #include "intertask_interface.h" @@ -1007,7 +1004,11 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, // RLC data on DCCH if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, - TBS - ta_len - header_length_total - sdu_length_total - 3); + TBS - ta_len - header_length_total - sdu_length_total - 3 +#ifdef Rel14 + ,0, 0 +#endif + ); sdu_lengths[0] = 0; @@ -1018,7 +1019,11 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used - (char *)&dlsch_buffer[0]); + (char *)&dlsch_buffer[0] +#ifdef Rel14 + ,0, 0 +#endif + ); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), @@ -1057,7 +1062,11 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, // RLC data on DCCH1 if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, - TBS - ta_len - header_length_total - sdu_length_total - 3); + TBS - ta_len - header_length_total - sdu_length_total - 3 +#ifdef Rel14 + ,0, 0 +#endif + ); // DCCH SDU sdu_lengths[num_sdus] = 0; @@ -1069,7 +1078,11 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS, //not used - (char *)&dlsch_buffer[sdu_length_total]); + (char *)&dlsch_buffer[sdu_length_total] +#ifdef Rel14 + ,0, 0 +#endif + ); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), @@ -1099,6 +1112,7 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, LOG_T(MAC, "\n"); #endif + } } @@ -1119,7 +1133,11 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, - TBS - ta_len - header_length_total - sdu_length_total - 3); + TBS - ta_len - header_length_total - sdu_length_total - 3 +#ifdef Rel14 + ,0, 0 +#endif + ); @@ -1133,7 +1151,11 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, TBS, //not used - (char *)&dlsch_buffer[sdu_length_total]); + (char *)&dlsch_buffer[sdu_length_total] +#ifdef Rel14 + ,0, 0 +#endif + ); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), @@ -1505,7 +1527,6 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, } // CC_id loop - fill_DLSCH_dci(module_idP, frameP, subframeP, mbsfn_flag); stop_meas(&eNB->schedule_dlsch); @@ -1777,7 +1798,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) vrb_map = (void*)&cc->vrb_map; n_rb_dl = to_prb(cc->mib->message.dl_Bandwidth); dl_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (uint16_t i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (uint16_t i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_PF_PO[CC_id][i].enable_flag != TRUE) { continue; } @@ -1992,11 +2013,15 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; // Rel10 fields +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; +#endif // Rel13 fields +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 0; // regular UE dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not BR dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; +#endif if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, P_RNTI)) { LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for P_RNTI\n", frameP,subframeP); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index 37b13d2de71936b52dec051274b91e4c73bdd3fe..bcaa30e3c1f5e30919f3717263dda5ba97006eb6 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -29,40 +29,37 @@ */ -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" +#include "assertions.h" #if defined(ENABLE_ITTI) #include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +#include "common/ran_context.h" extern RAN_CONTEXT_t RC; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) int8_t get_mbsfn_sf_alloction(module_id_t module_idP, uint8_t CC_id, uint8_t mbsfn_sync_area) @@ -588,7 +585,7 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, TBS = get_TBS_DL(cc->MCH_pdu.mcs, to_prb(cc->mib->message.dl_Bandwidth)); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) // do not let mcch and mtch multiplexing when relaying is active // for sync area 1, so not transmit data //if ((i == 0) && ((RC.mac[module_idP]->MBMS_flag != multicast_relay) || (RC.mac[module_idP]->mcch_active==0))) { @@ -635,7 +632,12 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, module_idP, ENB_FLAG_YES, MBMS_FLAG_YES, MTCH, TBS - header_len_mcch - header_len_msi - - sdu_length_total - header_len_mtch); + sdu_length_total - header_len_mtch +#ifdef Rel14 + ,0, 0 +#endif + ); + LOG_D(MAC, "e-MBMS log channel %u frameP %d, subframeP %d, rlc_status.bytes_in_buffer is %d\n", MTCH, frameP, subframeP, rlc_status.bytes_in_buffer); @@ -649,9 +651,15 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, 0, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_YES, MTCH, 0, //not used (char *) - &mch_buffer - [sdu_length_total]); - //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, MBMS_FLAG_NO, MTCH+(MAX_NUM_RB*(NUMBER_OF_UE_MAX+1)), (char*)&mch_buffer[sdu_length_total]); + &mch_buffer[sdu_length_total] +#ifdef Rel14 + ,0, + 0 +#endif + ); + + + //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, MBMS_FLAG_NO, MTCH+(MAX_NUM_RB*(MAX_MOBILES_PER_ENB+1)), (char*)&mch_buffer[sdu_length_total]); LOG_I(MAC, "[eNB %d][MBMS USER-PLANE] CC_id %d Got %d bytes for MTCH %d\n", module_idP, CC_id, sdu_lengths[num_sdus], MTCH); @@ -668,7 +676,7 @@ schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, header_len_mtch = 0; } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) // } #endif diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c new file mode 100644 index 0000000000000000000000000000000000000000..b1bb4a41308c98522a9c1d499d3f9ea1c81a9d98 --- /dev/null +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -0,0 +1,353 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file eNB_scheduler_dlsch.c + * \brief procedures related to eNB for the DLSCH transport channel + * \author Navid Nikaein and Raymond Knopp + * \date 2010 - 2014 + * \email: navid.nikaein@eurecom.fr + * \version 1.0 + * @ingroup _mac + + */ + +#include "assertions.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" + +#include "SCHED/sched_eNB.h" + +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "UTIL/OPT/opt.h" +#include "OCG.h" +#include "OCG_extern.h" + +#include "SIMULATION/TOOLS/sim.h" // for taus + +#include "T.h" + +extern RAN_CONTEXT_t RC; + +//------------------------------------------------------------------------------ +void +schedule_ue_spec_phy_test( + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int* mbsfn_flag +) +//------------------------------------------------------------------------------ +{ + uint8_t CC_id; + int UE_id=0; + uint16_t N_RB_DL; + uint16_t TBS; + uint16_t nb_rb; + + unsigned char harq_pid = subframeP%5; + uint16_t rnti = 0x1235; + uint32_t rb_alloc = 0x1FFFFFFF; + int32_t tpc = 1; + int32_t mcs = 28; + int32_t cqi = 15; + int32_t ndi = subframeP/5; + int32_t dai = 0; + + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + nfapi_dl_config_request_body_t *dl_req; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n",CC_id); + + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + + if (mbsfn_flag[CC_id]>0) + continue; + + nb_rb = conv_nprb(0,rb_alloc,N_RB_DL); + //printf("////////////////////////////////////*************************nb_rb = %d\n",nb_rb); + TBS = get_TBS_DL(mcs,nb_rb); + + LOG_D(PHY,"schedule_ue_spec_phy_test: subframe %d/%d: nb_rb=%d, TBS=%d, mcs=%d (rb_alloc=%x, N_RB_DL=%d)\n",frameP,subframeP,nb_rb,TBS,mcs,rb_alloc,N_RB_DL); + + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_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.dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),cqi,format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = rb_alloc; + + 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 + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = ndi; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; + //deactivate second codeword + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; + + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = dai; + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", + module_idP,CC_id,harq_pid,dai,mcs); + } else { + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", + module_idP,CC_id,harq_pid,mcs); + + } + LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { + + + //ue_sched_ctl->round[CC_id][harq_pid] = 0; + dl_req->number_dci++; + dl_req->number_pdu++; + + // Toggle NDI for next time + /* + LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frameP,subframeP,UE_id, + rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); + + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + */ + + + + fill_nfapi_dlsch_config(eNB, + dl_req, + TBS, + eNB->pdu_index[CC_id], + rnti, + 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag + rb_alloc, // resource_block_coding + getQm(mcs), + 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + PDSCH_ConfigDedicated__p_a_dB0, + 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + + eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, + (frameP*10)+subframeP, + TBS, + eNB->pdu_index[CC_id], + eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); + } + else { + LOG_W(MAC,"[eNB_scheduler_phytest] DCI allocation infeasible!\n"); + } + } +} + +void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) +{ + uint16_t first_rb[MAX_NUM_CCs]; + int UE_id = 0; + uint8_t aggregation = 2; + rnti_t rnti = 0x1235; + uint8_t mcs = 0; + uint8_t harq_pid = 0; + uint32_t cqi_req = 0,cshift,ndi,tpc = 1; + int32_t normalized_rx_power; + int32_t target_rx_power= 178; + int CC_id = 0; + int nb_rb = 96; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + UE_list_t *UE_list=&eNB->UE_list; + UE_TEMPLATE *UE_template; + UE_sched_ctrl *UE_sched_ctrl; + int sched_frame=frameP; + int sched_subframe = (subframeP+4)%10; + + if (sched_subframe<subframeP) sched_frame++; + + nfapi_hi_dci0_request_body_t *hi_dci0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; + + //nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req->ul_config_pdu_list[0];; + nfapi_ul_config_request_body_t *ul_req = &eNB->UL_req[CC_id].ul_config_request_body; + + + eNB->UL_req[CC_id].sfn_sf = (sched_frame<<4) + sched_subframe; + eNB->HI_DCI0_req[CC_id].sfn_sf = (frameP<<4)+subframeP; + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + //rnti = UE_RNTI(module_idP,UE_id); + //leave out first RB for PUCCH + first_rb[CC_id] = 1; + // loop over all active UEs + + // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel + + UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + harq_pid = subframe2harqpid(&cc[CC_id],sched_frame,sched_subframe); + + LOG_D(MAC,"Scheduling for frame %d, subframe %d => harq_pid %d\n",sched_frame,sched_subframe,harq_pid); + + RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->TBS_UL[harq_pid]; + + + + //power control + //compute the expected ULSCH RX power (for the stats) + + // this is the normalized RX power and this should be constant (regardless of mcs + normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; + + // new transmission + + ndi = 1-UE_template->oldNDI_UL[harq_pid]; + UE_template->oldNDI_UL[harq_pid]=ndi; + UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1 = mcs; + UE_template->mcs_UL[harq_pid] = mcs;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = mcs; + // buffer_occupancy = UE_template->ul_total_buffer; + + + + UE_template->TBS_UL[harq_pid] = get_TBS_UL(mcs,nb_rb); + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = get_TBS_UL(mcs,nb_rb); + // buffer_occupancy -= TBS; + + + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = nb_rb; + UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; + + UE_sched_ctrl->ul_scheduled |= (1<<harq_pid); + + // adjust total UL buffer status by TBS, wait for UL sdus to do final update + //UE_template->ul_total_buffer = UE_template->TBS_UL[harq_pid]; + // Cyclic shift for DM RS + cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + // save it for a potential retransmission + UE_template->cshift[harq_pid] = cshift; + + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci+eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi]; + memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = nb_rb; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframe]; + + + eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; + + + // Add UL_config PDUs + fill_nfapi_ulsch_config_request_rel8(&ul_req->ul_config_pdu_list[ul_req->number_of_pdus], + cqi_req, + cc, + 0,//UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + first_rb[CC_id], // resource_block_start + nb_rb, // number_of_resource_blocks + mcs, + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL(mcs,nb_rb) + ); +#ifdef Rel14 + if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req->ul_config_pdu_list[ul_req->number_of_pdus], + UE_template->rach_resource_type>2 ? 2 : 1, + 1, //total_number_of_repetitions + 1, //repetition_number + (frameP*10)+subframeP); + } +#endif + ul_req->number_of_pdus = 1; + eNB->ul_handle++; + + + + add_ue_ulsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_UL_SCHEDULED); + + // increment first rb for next UE allocation + first_rb[CC_id]+= nb_rb; + + + } // loop of CC_id +} diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 110afc1a5ad287af94d87ac4aa071f7d97aee01f..fbb125cf726d7643fd719fc0fac3207a902d341a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -30,23 +30,18 @@ */ #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" - -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" //#include "LAYER2/MAC/pre_processor.c" @@ -61,6 +56,10 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +#include "common/ran_context.h" + +extern RAN_CONTEXT_t RC; + extern int n_active_slices; int choose(int n, int k) @@ -891,7 +890,7 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t * cc, uint8_t tmode, else if (ri >= 2 && cc->p_eNB == 4) return (4 + (N << 1) + 4 + (N << 1) + 4); break; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(12, 5, 0)) case CQI_ReportModeAperiodic_rm32_v1250: AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 || tmode == 10, @@ -925,7 +924,7 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t * cc, uint8_t tmode, return (4 + 4 + 4); break; -#endif /* Rel14 */ +#endif /* #if (RRC_VERSION >= MAKE_VERSION(12, 5, 0)) */ } AssertFatal(1 == 0, "Shouldn't get here\n"); return (0); @@ -984,6 +983,8 @@ get_rel8_dl_cqi_pmi_size(UE_sched_ctrl * sched_ctl, int CC_idP, cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present); } + + void fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t aggregation_level, @@ -1031,7 +1032,7 @@ program_dlsch_acknak(module_id_t module_idP, int CC_idP, int UE_idP, nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = NULL; nfapi_ul_config_harq_information *harq_information = NULL; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 2, 0)) if ((UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2) && (UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2->pucch_ConfigDedicated_v1020) @@ -1201,12 +1202,15 @@ fill_nfapi_ulsch_harq_information(module_id_t module_ UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->pusch_ConfigDedicated) != NULL, "physicalConfigDedicated->puschConfigDedicated for rnti %x is null\n", rntiP); -#if defined(Rel14) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 2, 0)) /* if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2) puschConfigDedicated_v1020 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2->pusch_ConfigDedicated_v1020; #endif - #ifdef Rel14 + #if (RRC_VERSION >= MAKE_VERSION(11, 3, 0)) if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext4) puschConfigDedicated_v1130 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext4->pusch_ConfigDedicated_v1130; + #endif + #if (RRC_VERSION >= MAKE_VERSION(12, 5, 0)) if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext5) puschConfigDedicated_v1250 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext5->pusch_ConfigDedicated_v1250; + #endif */ #endif harq_information->harq_information_rel10.delta_offset_harq = puschConfigDedicated->betaOffset_ACK_Index; @@ -1522,7 +1526,7 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pd } } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) void fill_nfapi_ulsch_config_request_emtc(nfapi_ul_config_request_pdu_t * ul_config_pdu, uint8_t ue_type, @@ -1666,7 +1670,7 @@ void init_ue_sched_info(void) for (i = 0; i < NUMBER_OF_eNB_MAX; i++) { for (k = 0; k < MAX_NUM_CCs; k++) { - for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { // init DL eNB_dlsch_info[i][k][j].weight = 0; eNB_dlsch_info[i][k][j].subframe = 0; @@ -1697,7 +1701,7 @@ int find_UE_id(module_id_t mod_idP, rnti_t rntiP) int UE_id; UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; if (UE_list->UE_template[UE_PCCID(mod_idP, UE_id)][UE_id].rnti == @@ -1823,7 +1827,7 @@ void dump_ue_list(UE_list_t * listP, int ul_flag) } int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP, int harq_pidP -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , uint8_t rach_resource_type #endif ) @@ -1838,7 +1842,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP, int harq_pidP mod_idP, cc_idP, rntiP, UE_list->avail, UE_list->num_UEs); dump_ue_list(UE_list, 0); - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] == TRUE) continue; UE_id = i; @@ -1857,7 +1861,7 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP, int harq_pidP UE_list->UE_template[cc_idP][UE_id].pre_assigned_mcs_ul = 0; #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) UE_list->UE_template[cc_idP][UE_id].rach_resource_type = rach_resource_type; #endif @@ -2324,9 +2328,7 @@ int get_bw_index(module_id_t module_id, uint8_t CC_id) { int bw_index = 0; - int N_RB_DL = - to_prb(RC.mac[module_id]->common_channels[CC_id].mib-> - message.dl_Bandwidth); + int N_RB_DL = to_prb(RC.mac[module_id]->common_channels[CC_id].mib->message.dl_Bandwidth); switch (N_RB_DL) { case 6: // 1.4 MHz @@ -2359,9 +2361,7 @@ int get_bw_index(module_id_t module_id, uint8_t CC_id) int get_min_rb_unit(module_id_t module_id, uint8_t CC_id) { int min_rb_unit = 0; - int N_RB_DL = - to_prb(RC.mac[module_id]->common_channels[CC_id].mib-> - message.dl_Bandwidth); + int N_RB_DL = to_prb(RC.mac[module_id]->common_channels[CC_id].mib->message.dl_Bandwidth); switch (N_RB_DL) { case 6: // 1.4 MHz @@ -3201,7 +3201,7 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, int i, j; uint8_t *pdu; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) if (UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated != NULL && UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->pucch_ConfigDedicated != NULL && (UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated->ext7) @@ -3945,7 +3945,7 @@ extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, } break; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(12, 5, 0)) case CQI_ReportModeAperiodic_rm32_v1250: AssertFatal(tmode == 4 || tmode == 5 || tmode == 6 || tmode == 8 || tmode == 9 @@ -3954,6 +3954,8 @@ extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, tmode); AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm32 to be done\n"); break; +#endif +#if (RRC_VERSION >= MAKE_VERSION(13, 1, 0)) case CQI_ReportModeAperiodic_rm10_v1310: AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 || tmode == 7, @@ -3969,7 +3971,7 @@ extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, tmode); AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm11 to be done\n"); break; -#endif /* Rel14 */ +#endif /* #if (RRC_VERSION >= MAKE_VERSION(13, 1, 0)) */ } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 9ccb0e66ab149bb333d46da09ac923515321d2d9..3884615b89783114a07210742cd11ad6b71cab80 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -31,25 +31,22 @@ /* indented with: indent -kr eNB_scheduler_RA.c */ -#include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SCHED/defs.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "assertions.h" //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" @@ -144,7 +141,7 @@ rx_sdu(const module_id_t enb_mod_idP, start_meas(&mac->rx_ulsch_sdu); - if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1)) + if ((UE_id > MAX_MOBILES_PER_ENB) || (UE_id == -1)) for (ii = 0; ii < NB_RB_MAX; ii++) { rx_lengths[ii] = 0; } @@ -547,7 +544,7 @@ rx_sdu(const module_id_t enb_mod_idP, if ((UE_id = add_new_ue(enb_mod_idP, CC_idP, mac->common_channels[CC_idP]. ra[ii].rnti, harq_pid -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , mac->common_channels[CC_idP]. ra[ii].rach_resource_type @@ -1438,7 +1435,7 @@ schedule_ulsch_rnti(module_id_t module_idP, mcs_UL[harq_pid], rb_table [rb_table_index])); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions 1, //repetition_number @@ -1521,7 +1518,7 @@ schedule_ulsch_rnti(module_id_t module_idP, 0, // n_srs UE_template-> TBS_UL[harq_pid]); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions 1, //repetition_number diff --git a/openair2/LAYER2/MAC/l1_helpers.c b/openair2/LAYER2/MAC/l1_helpers.c index 6e71f66ec5f56d32a52863db3fde89d6594b9b20..0cb5c17f0f6984f22c1ac3cbb77c74b1770aa394 100644 --- a/openair2/LAYER2/MAC/l1_helpers.c +++ b/openair2/LAYER2/MAC/l1_helpers.c @@ -29,10 +29,10 @@ */ -#include "defs.h" -#include "extern.h" +#include "mac.h" +#include "mac_extern.h" #include "UTIL/LOG/log.h" -#include "proto.h" +#include "mac_proto.h" int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id) { @@ -54,6 +54,52 @@ int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id) 1) + get_DELTA_PREAMBLE(module_idP, CC_id)); } +int8_t get_DELTA_PREAMBLE(module_id_t module_idP, int CC_id) +{ + + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + uint8_t prachConfigIndex = + UE_mac_inst[module_idP].radioResourceConfigCommon-> + prach_Config.prach_ConfigInfo.prach_ConfigIndex; + uint8_t preambleformat; + + if (UE_mac_inst[module_idP].tdd_Config) { // TDD + if (prachConfigIndex < 20) { + preambleformat = 0; + } else if (prachConfigIndex < 30) { + preambleformat = 1; + } else if (prachConfigIndex < 40) { + preambleformat = 2; + } else if (prachConfigIndex < 48) { + preambleformat = 3; + } else { + preambleformat = 4; + } + } else { // FDD + preambleformat = prachConfigIndex >> 2; + } + + switch (preambleformat) { + case 0: + case 1: + return (0); + + case 2: + case 3: + return (-3); + + case 4: + return (8); + + default: + AssertFatal(1 == 0, + "[UE %d] ue_procedures.c: FATAL, Illegal preambleformat %d, prachConfigIndex %d\n", + module_idP, preambleformat, prachConfigIndex); + } + +} + int8_t get_deltaP_rampup(module_id_t module_idP, uint8_t CC_id) { diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/mac.h similarity index 76% rename from openair2/LAYER2/MAC/defs.h rename to openair2/LAYER2/MAC/mac.h index e3f5d954f1aacd5d6b958a30c52e55f46092fe29..fac596f406710f5928d9ad36311bbe13da0ae503 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/mac.h @@ -43,11 +43,10 @@ #include <stdlib.h> #include <string.h> -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/defs.h" #include "COMMON/platform_constants.h" #include "BCCH-BCH-Message.h" #include "RadioResourceConfigCommon.h" +#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" #include "MeasGapConfig.h" #include "SchedulingInfoList.h" @@ -55,19 +54,29 @@ #include "RACH-ConfigCommon.h" #include "MeasObjectToAddModList.h" #include "MobilityControlInfo.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "MBSFN-AreaInfoList-r9.h" #include "MBSFN-SubframeConfigList.h" #include "PMCH-InfoList-r9.h" +#endif +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #include "SCellToAddMod-r10.h" #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) #include "SystemInformationBlockType1-v1310-IEs.h" +#include "SystemInformationBlockType18-r12.h" #endif - +#include "RadioResourceConfigCommonSIB.h" #include "nfapi_interface.h" #include "PHY_INTERFACE/IF_Module.h" +#include "PHY/TOOLS/time_meas.h" + +#include "PHY/defs_common.h" // for PRACH_RESOURCES_t +#include "PHY/LTE_TRANSPORT/transport_common.h" + +#include "targets/ARCH/COMMON/common_lib.h" + /** @defgroup _mac MAC * @ingroup _oai2 * @{ @@ -79,9 +88,10 @@ #define RAR_PAYLOAD_SIZE_MAX 128 #define SCH_PAYLOAD_SIZE_MAX 4096 +#define DCH_PAYLOAD_SIZE_MAX 4096 /// Logical channel ids from 36-311 (Note BCCH is not specified in 36-311, uses the same as first DRB) -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) // Mask for identifying subframe for MBMS #define MBSFN_TDD_SF3 0x80 // for TDD @@ -155,6 +165,7 @@ /*!\brief maximum number of slices / groups */ #define MAX_NUM_SLICES 4 + #define U_PLANE_INACTIVITY_VALUE 6000 /* @@ -233,6 +244,75 @@ typedef struct { uint8_t R:2; } __attribute__ ((__packed__)) SCH_SUBHEADER_FIXED; + + +/*!\brief MAC subheader long with 24bit DST field */ +typedef struct { + uint8_t R0:4; + uint8_t V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3. + uint8_t SRC07; //Prose UE source ID. Size 24 bits. + uint8_t SRC815; //Prose UE source ID. Size 24 bits. + uint8_t SRC1623; //Prose UE source ID. Size 24 bits. + uint8_t DST07; //Prose UE destination ID. Size 24 bits. + uint8_t DST815; //Prose UE destination ID. Size 24 bits. + uint8_t DST1623; //Prose UE destination ID. Size 24 bits. + uint8_t LCID:5; + uint8_t E:1; + uint8_t R1:2; + uint8_t L:7; // Length field indicating the size of the corresponding SDU in bytes. + uint8_t F:1; +}__attribute__((__packed__))SLSCH_SUBHEADER_24_Bit_DST_SHORT; + +/*!\brief MAC subheader long with 24bit DST field */ +typedef struct { + uint8_t R0:4; + uint8_t V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3. + uint8_t SRC07; //Prose UE source ID. Size 24 bits. + uint8_t SRC815; //Prose UE source ID. Size 24 bits. + uint8_t SRC1623; //Prose UE source ID. Size 24 bits. + uint8_t DST07; //Prose UE destination ID. Size 24 bits. + uint8_t DST815; //Prose UE destination ID. Size 24 bits. + uint8_t DST1623; //Prose UE destination ID. Size 24 bits. + uint8_t LCID:5; + uint8_t E:1; + uint8_t R1:2; + uint8_t L_MSB:7; // Length field indicating the size of the corresponding SDU in bytes. + uint8_t F:1; + uint8_t L_LSB:8; +}__attribute__((__packed__))SLSCH_SUBHEADER_24_Bit_DST_LONG; + +/*!\brief MAC subheader long with 24bit DST field */ +typedef struct { + uint8_t R0:4; + uint8_t V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3. + uint8_t SRC07; //Prose UE source ID. Size 24 bits. + uint8_t SRC815; //Prose UE source ID. Size 24 bits. + uint8_t DST07; //Prose UE destination ID. Size 16 bits. + uint8_t DST815; //Prose UE destination ID. Size 16 bits. + uint8_t LCID:5; + uint8_t E:1; + uint8_t R1:2; + uint8_t L:7; // Length field indicating the size of the corresponding SDU in bytes. + uint8_t F:1; +}__attribute__((__packed__))SLSCH_SUBHEADER_16_Bit_DST_SHORT; + +/*!\brief MAC subheader long with 24bit DST field */ +typedef struct { + uint8_t R0:4; + uint8_t V:4;//Version number: Possible values "0001", "0010", "0011" based on TS36.321 section 6.2.3. + uint8_t SRC07; //Prose UE source ID. Size 24 bits. + uint8_t SRC815; //Prose UE source ID. Size 24 bits. + uint8_t SRC1623; //Prose UE source ID. Size 24 bits. + uint8_t DST07; //Prose UE destination ID. Size 16 bits. + uint8_t DST815; //Prose UE destination ID. Size 16 bits. + uint8_t LCID:5; + uint8_t E:1; + uint8_t R1:2; + uint8_t L_MSB:7; // Length field indicating the size of the corresponding SDU in bytes. + uint8_t F:1; + uint8_t L_LSB:8; +}__attribute__((__packed__))SLSCH_SUBHEADER_16_Bit_DST_LONG; + /*!\brief mac control element: short buffer status report for a specific logical channel group ID*/ typedef struct { uint8_t Buffer_size:6; // octet 1 LSB @@ -248,6 +328,30 @@ typedef struct { uint8_t Buffer_size0:6; } __attribute__ ((__packed__)) BSR_LONG; +// Panos: +/*!\brief mac control element: sidelink buffer status report */ +typedef struct { + uint8_t DST_1:4; + uint8_t LCGID_1: 2; + uint8_t Buffer_size_1:6; + uint8_t DST_2:4; + uint8_t LCGID_2: 2; + uint8_t Buffer_size_2:6; +}__attribute__((__packed__))SL_BSR; + +/*!\brief mac control element: truncated sidelink buffer status report */ +typedef struct { + uint8_t DST:4; + uint8_t LCGID: 2; + uint8_t Buffer_size:6; + uint8_t R1:1; + uint8_t R2:1; + uint8_t R3:1; + uint8_t R4:1; +}__attribute__((__packed__))SL_BSR_Truncated; + + + #define BSR_LONG_SIZE (sizeof(BSR_LONG)) /*!\brief mac control element: timing advance */ typedef struct { @@ -281,7 +385,7 @@ typedef struct { uint8_t payload[PCCH_PAYLOAD_SIZE_MAX]; } __attribute__ ((__packed__)) PCCH_PDU; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) /*! \brief MCCH payload */ typedef struct { uint8_t payload[MCCH_PAYLOAD_SIZE_MAX]; @@ -338,7 +442,7 @@ typedef struct { /*!\brief LCID of padding LCID for DLSCH */ #define SHORT_PADDING 31 -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) // MCH LCHAN IDs (table6.2.1-4 TS36.321) /*!\brief LCID of MCCH for DL */ #define MCCH_LCHANID 0 @@ -346,6 +450,9 @@ typedef struct { #define MCH_SCHDL_INFO 3 /*!\brief LCID of Carrier component activation/deactivation */ #define CC_ACT_DEACT 27 +//TTN (for D2D) +#define SL_DISCOVERY 8 //LCID (fake) +#define MAX_NUM_DEST 10 #endif // ULSCH LCHAN IDs @@ -392,7 +499,11 @@ typedef struct { uint16_t Pdu_size; } __attribute__ ((__packed__)) ULSCH_PDU; -#include "PHY/impl_defs_top.h" +/*! \brief Uplink SCH PDU Structure */ +typedef struct { + int8_t payload[DCH_PAYLOAD_SIZE_MAX]; /*!< \brief SACH payload */ + uint16_t Pdu_size; +} __attribute__ ((__packed__)) ULDCH_PDU; /*!\brief RA process state*/ typedef enum { @@ -522,7 +633,6 @@ typedef struct { } eNB_STATS; /*! \brief eNB statistics for the connected UEs*/ typedef struct { - /// CRNTI of UE rnti_t crnti; ///user id (rnti) of connected UEs // rrc status @@ -784,7 +894,7 @@ typedef struct { eNB_UE_estimated_distances distance; #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) uint8_t rach_resource_type; uint16_t mpdcch_repetition_cnt; frame_t Msg2_frame; @@ -816,8 +926,8 @@ typedef struct { ///Contention resolution timer used during random access uint8_t mac_ContentionResolutionTimer; - uint16_t max_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES]; - uint16_t max_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES]; + uint16_t max_rbs_allowed_slice[NFAPI_CC_MAX][MAX_NUM_SLICES]; + uint16_t max_rbs_allowed_slice_uplink[NFAPI_CC_MAX][MAX_NUM_SLICES]; uint8_t max_mcs[MAX_NUM_LCID]; @@ -826,14 +936,14 @@ typedef struct { // resource scheduling information /// Current DL harq round per harq_pid on each CC - uint8_t round[MAX_NUM_CCs][10]; + uint8_t round[NFAPI_CC_MAX][10]; /// Current Active TBs per harq_pid on each CC - uint8_t tbcnt[MAX_NUM_CCs][10]; + uint8_t tbcnt[NFAPI_CC_MAX][10]; /// Current UL harq round per harq_pid on each CC - uint8_t round_UL[MAX_NUM_CCs][8]; - uint8_t dl_pow_off[MAX_NUM_CCs]; - uint16_t pre_nb_available_rbs[MAX_NUM_CCs]; - unsigned char rballoc_sub_UE[MAX_NUM_CCs][N_RBG_MAX]; + uint8_t round_UL[NFAPI_CC_MAX][8]; + uint8_t dl_pow_off[NFAPI_CC_MAX]; + uint16_t pre_nb_available_rbs[NFAPI_CC_MAX]; + unsigned char rballoc_sub_UE[NFAPI_CC_MAX][N_RBG_MAX]; uint16_t ta_timer; int16_t ta_update; uint16_t ul_consecutive_errors; @@ -926,7 +1036,7 @@ typedef struct { int msg4_TBsize; /// MCS used for Msg4 int msg4_mcs; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) uint8_t rach_resource_type; uint8_t msg2_mpdcch_repetition_cnt; uint8_t msg4_mpdcch_repetition_cnt; @@ -938,7 +1048,7 @@ typedef struct { /*! \brief subband bitmap confguration (for ALU icic algo purpose), in test phase */ typedef struct { - uint8_t sbmap[NUMBER_OF_SUBBANDS_MAX]; //13 = number of SB MAX for 100 PRB + uint8_t sbmap[13]; //13 = number of SB MAX for 100 PRB uint8_t periodicity; uint8_t first_subframe; uint8_t sb_size; @@ -948,34 +1058,34 @@ typedef struct { typedef struct { /// Dedicated information for UEs struct PhysicalConfigDedicated - *physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + *physicalConfigDedicated[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// DLSCH pdu - DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX]; + DLSCH_PDU DLSCH_pdu[NFAPI_CC_MAX][2][MAX_MOBILES_PER_ENB]; /// DCI template and MAC connection parameters for UEs - UE_TEMPLATE UE_template[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + UE_TEMPLATE UE_template[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// DCI template and MAC connection for RA processes - int pCC_id[NUMBER_OF_UE_MAX]; + int pCC_id[MAX_MOBILES_PER_ENB]; /// sorted downlink component carrier for the scheduler - int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + int ordered_CCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// number of downlink active component carrier - int numactiveCCs[NUMBER_OF_UE_MAX]; + int numactiveCCs[MAX_MOBILES_PER_ENB]; /// sorted uplink component carrier for the scheduler - int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + int ordered_ULCCids[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// number of uplink active component carrier - int numactiveULCCs[NUMBER_OF_UE_MAX]; + int numactiveULCCs[MAX_MOBILES_PER_ENB]; /// number of downlink active component carrier - uint8_t dl_CC_bitmap[NUMBER_OF_UE_MAX]; + uint8_t dl_CC_bitmap[MAX_MOBILES_PER_ENB]; /// eNB to UE statistics - eNB_UE_STATS eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + eNB_UE_STATS eNB_UE_stats[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// scheduling control info - UE_sched_ctrl UE_sched_ctrl[NUMBER_OF_UE_MAX]; - int next[NUMBER_OF_UE_MAX]; + UE_sched_ctrl UE_sched_ctrl[MAX_MOBILES_PER_ENB]; + int next[MAX_MOBILES_PER_ENB]; int head; - int next_ul[NUMBER_OF_UE_MAX]; + int next_ul[MAX_MOBILES_PER_ENB]; int head_ul; int avail; int num_UEs; - boolean_t active[NUMBER_OF_UE_MAX]; + boolean_t active[MAX_MOBILES_PER_ENB]; /// Sorting criteria for the UE list in the MAC preprocessor uint16_t sorting_criteria[MAX_NUM_SLICES][CR_NUM]; @@ -991,7 +1101,7 @@ typedef struct { uint32_t dl_CarrierFreq; BCCH_BCH_Message_t *mib; RadioResourceConfigCommonSIB_t *radioResourceConfigCommon; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR; #endif TDD_Config_t *tdd_Config; @@ -1022,7 +1132,7 @@ typedef struct { struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; /// number of subframe allocation pattern available for MBSFN sync area uint8_t num_sf_allocation_pattern; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) /// MBMS Flag uint8_t MBMS_flag; /// Outgoing MCCH pdu for PHY @@ -1044,7 +1154,7 @@ typedef struct { /// Outgoing MCH pdu for PHY MCH_PDU MCH_pdu; #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) /// Rel13 parameters from SIB1 SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext; /// Counter for SIB1-BR scheduling @@ -1056,82 +1166,82 @@ typedef struct { /*! \brief top level eNB MAC structure */ typedef struct eNB_MAC_INST_s { /// Ethernet parameters for northbound midhaul interface - eth_params_t eth_params_n; - /// Ethernet parameters for fronthaul interface - eth_params_t eth_params_s; - /// - module_id_t Mod_id; - /// frame counter - frame_t frame; - /// subframe counter - sub_frame_t subframe; - /// Pointer to IF module instance for PHY - IF_Module_t *if_inst; - /// Common cell resources - COMMON_channels_t common_channels[MAX_NUM_CCs]; - /// current PDU index (BCH,MCH,DLSCH) - uint16_t pdu_index[MAX_NUM_CCs]; - - /// NFAPI Config Request Structure - nfapi_config_request_t config[MAX_NUM_CCs]; - /// Preallocated DL pdu list - nfapi_dl_config_request_pdu_t - dl_config_pdu_list[MAX_NUM_CCs][MAX_NUM_DL_PDU]; - /// NFAPI DL Config Request Structure - nfapi_dl_config_request_t DL_req[MAX_NUM_CCs]; - /// Preallocated UL pdu list - nfapi_ul_config_request_pdu_t - ul_config_pdu_list[MAX_NUM_CCs][MAX_NUM_UL_PDU]; - /// Preallocated UL pdu list for ULSCH (n+k delay) - nfapi_ul_config_request_pdu_t - ul_config_pdu_list_tmp[MAX_NUM_CCs][10][MAX_NUM_UL_PDU]; - /// NFAPI UL Config Request Structure, send to L1 4 subframes before processing takes place - nfapi_ul_config_request_t UL_req[MAX_NUM_CCs]; - /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests - nfapi_ul_config_request_t UL_req_tmp[MAX_NUM_CCs][10]; - /// Preallocated HI_DCI0 pdu list - nfapi_hi_dci0_request_pdu_t - hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU]; - /// NFAPI HI/DCI0 Config Request Structure - nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs]; - /// Prealocated TX pdu list - nfapi_tx_request_pdu_t - tx_request_pdu[MAX_NUM_CCs][MAX_NUM_TX_REQUEST_PDU]; - /// NFAPI DL PDU structure - nfapi_tx_request_t TX_req[MAX_NUM_CCs]; - /// UL handle - uint32_t ul_handle; - UE_list_t UE_list; - - ///subband bitmap configuration - SBMAP_CONF sbmap_conf; - /// CCE table used to build DCI scheduling information - int CCE_table[MAX_NUM_CCs][800]; - /// active flag for Other lcid - uint8_t lcid_active[NB_RB_MAX]; - /// eNB stats - eNB_STATS eNB_stats[MAX_NUM_CCs]; - // MAC function execution peformance profiler - /// processing time of eNB scheduler - time_stats_t eNB_scheduler; - /// processing time of eNB scheduler for SI - time_stats_t schedule_si; - /// processing time of eNB scheduler for Random access - time_stats_t schedule_ra; - /// processing time of eNB ULSCH scheduler - time_stats_t schedule_ulsch; - /// processing time of eNB DCI generation - time_stats_t fill_DLSCH_dci; - /// processing time of eNB MAC preprocessor - time_stats_t schedule_dlsch_preprocessor; - /// processing time of eNB DLSCH scheduler - time_stats_t schedule_dlsch; // include rlc_data_req + MAC header + preprocessor - /// processing time of eNB MCH scheduler - time_stats_t schedule_mch; - /// processing time of eNB ULSCH reception - time_stats_t rx_ulsch_sdu; // include rlc_data_ind - /// processing time of eNB PCH scheduler - time_stats_t schedule_pch; + eth_params_t eth_params_n; + /// Ethernet parameters for fronthaul interface + eth_params_t eth_params_s; + /// + module_id_t Mod_id; + /// frame counter + frame_t frame; + /// subframe counter + sub_frame_t subframe; + /// Pointer to IF module instance for PHY + IF_Module_t *if_inst; + /// Common cell resources + COMMON_channels_t common_channels[NFAPI_CC_MAX]; + /// current PDU index (BCH,MCH,DLSCH) + uint16_t pdu_index[NFAPI_CC_MAX]; + + /// NFAPI Config Request Structure + nfapi_config_request_t config[NFAPI_CC_MAX]; + /// Preallocated DL pdu list + nfapi_dl_config_request_pdu_t + dl_config_pdu_list[NFAPI_CC_MAX][MAX_NUM_DL_PDU]; + /// NFAPI DL Config Request Structure + nfapi_dl_config_request_t DL_req[NFAPI_CC_MAX]; + /// Preallocated UL pdu list + nfapi_ul_config_request_pdu_t + ul_config_pdu_list[NFAPI_CC_MAX][MAX_NUM_UL_PDU]; + /// Preallocated UL pdu list for ULSCH (n+k delay) + nfapi_ul_config_request_pdu_t + ul_config_pdu_list_tmp[NFAPI_CC_MAX][10][MAX_NUM_UL_PDU]; + /// NFAPI UL Config Request Structure, send to L1 4 subframes before processing takes place + nfapi_ul_config_request_t UL_req[NFAPI_CC_MAX]; + /// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests + nfapi_ul_config_request_t UL_req_tmp[NFAPI_CC_MAX][10]; + /// Preallocated HI_DCI0 pdu list + nfapi_hi_dci0_request_pdu_t + hi_dci0_pdu_list[NFAPI_CC_MAX][MAX_NUM_HI_DCI0_PDU]; + /// NFAPI HI/DCI0 Config Request Structure + nfapi_hi_dci0_request_t HI_DCI0_req[NFAPI_CC_MAX]; + /// Prealocated TX pdu list + nfapi_tx_request_pdu_t + tx_request_pdu[NFAPI_CC_MAX][MAX_NUM_TX_REQUEST_PDU]; + /// NFAPI DL PDU structure + nfapi_tx_request_t TX_req[NFAPI_CC_MAX]; + /// UL handle + uint32_t ul_handle; + UE_list_t UE_list; + + ///subband bitmap configuration + SBMAP_CONF sbmap_conf; + /// CCE table used to build DCI scheduling information + int CCE_table[NFAPI_CC_MAX][800]; + /// active flag for Other lcid + uint8_t lcid_active[NB_RB_MAX]; + /// eNB stats + eNB_STATS eNB_stats[NFAPI_CC_MAX]; + // MAC function execution peformance profiler + /// processing time of eNB scheduler + time_stats_t eNB_scheduler; + /// processing time of eNB scheduler for SI + time_stats_t schedule_si; + /// processing time of eNB scheduler for Random access + time_stats_t schedule_ra; + /// processing time of eNB ULSCH scheduler + time_stats_t schedule_ulsch; + /// processing time of eNB DCI generation + time_stats_t fill_DLSCH_dci; + /// processing time of eNB MAC preprocessor + time_stats_t schedule_dlsch_preprocessor; + /// processing time of eNB DLSCH scheduler + time_stats_t schedule_dlsch; // include rlc_data_req + MAC header + preprocessor + /// processing time of eNB MCH scheduler + time_stats_t schedule_mch; + /// processing time of eNB ULSCH reception + time_stats_t rx_ulsch_sdu; // include rlc_data_ind + /// processing time of eNB PCH scheduler + time_stats_t schedule_pch; } eNB_MAC_INST; /* @@ -1239,10 +1349,36 @@ typedef struct { struct RACH_ConfigDedicated *rach_ConfigDedicated; /// pointer to RRC PHY configuration struct PhysicalConfigDedicated *physicalConfigDedicated; -#if defined(Rel10) || defined(Rel14) - /// pointer to RRC PHY configuration SCEll - struct PhysicalConfigDedicatedSCell_r10 - *physicalConfigDedicatedSCell_r10; +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + /// pointer to RRC PHY configuration SCEll + struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10; + /// Preconfiguration for Sidelink + struct SL_Preconfiguration_r12 *SL_Preconfiguration; + /// RX Pool for Sidelink from SIB18 + SL_CommRxPoolList_r12_t commRxPool_r12; + /// TX Pool Normal for Sidelink from SIB18 + struct SL_CommTxPoolList_r12 *commTxPoolNormalCommon_r12; + /// TX Pool Exceptional for Sidelink from SIB18 + struct SL_CommTxPoolList_r12 *commTxPoolExceptional_r12; + /// Common Sync Config for Sidelink from SIB18 + struct SL_SyncConfigList_r12 *commSyncConfig_r12; + /// Dedicated Sync TX control for Sidelink + struct SL_SyncTxControl_r12 *sl_SyncTxControl_r12; + /// Dedicated Discovery TX control for Sidelink + struct SL_DiscConfig_r12 *sl_DiscConfig_r12; + /// Dedicated TX config for Sidelink + struct SL_CommConfig_r12 *sl_CommConfig_r12; + //SL sourceL2ID + uint32_t sourceL2Id; + //SL groupL2Id + uint32_t groupL2Id; + //SL destinationL2Id + uint32_t destinationL2Id; + //List of destinations + uint32_t destinationList[MAX_NUM_DEST]; + uint8_t numCommFlows; + uint32_t SL_LCID[MAX_NUM_LCID]; + #endif /// pointer to TDD Configuration (NULL for FDD) TDD_Config_t *tdd_Config; @@ -1263,7 +1399,14 @@ typedef struct { /// Outgoing RAR pdu for PHY RAR_PDU RAR_pdu; /// Incoming DLSCH pdu for PHY - DLSCH_PDU DLSCH_pdu[NUMBER_OF_UE_MAX][2]; + DLSCH_PDU DLSCH_pdu[MAX_MOBILES_PER_ENB][2]; +#ifdef Rel14 + int sltx_active; + SLSCH_t slsch; + SLDCH_t sldch; + ULSCH_PDU slsch_pdu; + int slsch_lcid; +#endif /// number of attempt for rach uint8_t RA_attempt_number; /// Random-access procedure flag @@ -1304,7 +1447,7 @@ typedef struct { /// power backoff due to power management (as allowed by P-MPRc) for this cell uint8_t PHR_reporting_active; /// power backoff due to power management (as allowed by P-MPRc) for this cell - uint8_t power_backoff_db[NUMBER_OF_eNB_MAX]; + uint8_t power_backoff_db[MAX_eNB]; /// BSR report falg management uint8_t BSR_reporting_active; /// retxBSR-Timer expires flag @@ -1316,7 +1459,7 @@ typedef struct { struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? /// number of subframe allocation pattern available for MBSFN sync area uint8_t num_sf_allocation_pattern; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) /// number of active MBSFN area uint8_t num_active_mbsfn_area; /// MBSFN Area Info @@ -1328,26 +1471,41 @@ typedef struct { /// MSI status uint8_t msi_status; // could be an array if there are >1 MCH in one MBSFN area #endif - //#ifdef CBA - /// CBA RNTI for each group - uint16_t cba_rnti[NUM_MAX_CBA_GROUP]; - /// last SFN for CBA channel access - uint8_t cba_last_access[NUM_MAX_CBA_GROUP]; - //#endif - /// total UE scheduler processing time - time_stats_t ue_scheduler; // total - /// UE ULSCH tx processing time inlcuding RLC interface (rlc_data_req) and mac header generation - time_stats_t tx_ulsch_sdu; - /// UE DLSCH rx processing time inlcuding RLC interface (mac_rrc_data_ind or mac_rlc_status_ind+mac_rlc_data_ind) and mac header parser - time_stats_t rx_dlsch_sdu; - /// UE query for MCH subframe processing time - time_stats_t ue_query_mch; - /// UE MCH rx processing time - time_stats_t rx_mch_sdu; - /// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind) - time_stats_t rx_si; - /// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind) - time_stats_t rx_p; + //#ifdef CBA + /// CBA RNTI for each group + uint16_t cba_rnti[NUM_MAX_CBA_GROUP]; + /// last SFN for CBA channel access + uint8_t cba_last_access[NUM_MAX_CBA_GROUP]; + //#endif + /// total UE scheduler processing time + time_stats_t ue_scheduler; // total + /// UE ULSCH tx processing time inlcuding RLC interface (rlc_data_req) and mac header generation + time_stats_t tx_ulsch_sdu; + /// UE DLSCH rx processing time inlcuding RLC interface (mac_rrc_data_ind or mac_rlc_status_ind+mac_rlc_data_ind) and mac header parser + time_stats_t rx_dlsch_sdu ; + /// UE query for MCH subframe processing time + time_stats_t ue_query_mch; + /// UE MCH rx processing time + time_stats_t rx_mch_sdu; + /// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind) + time_stats_t rx_si; + /// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind) + time_stats_t rx_p; + /// Panos: Mutex for nfapi UL_INFO + pthread_mutex_t UL_INFO_mutex; + /// Panos: UE_Mode variable should be used in the case of Phy_stub operation since we won't have access to PHY_VARS_UE + /// where the UE_mode originally is for the full stack operation mode. The transitions between the states of the UE_Mode + /// will be triggered within phy_stub_ue.c in this case + UE_MODE_t UE_mode[NUMBER_OF_CONNECTED_eNB_MAX]; + /// Panos: Phy_stub mode: Boolean variable to distinguish whether a Msg3 or a regular ULSCH data pdu should be generated + /// after the reception of NFAPI_UL_CONFIG_ULSCH_PDU_TYPE. + uint8_t first_ULSCH_Tx; + uint8_t SI_Decoded; + int ra_frame; // This variable keeps the frame in which the RA started for the specific UE. It is used in order + // to make sure that different UEs RA starts within a number of frames difference. + + eth_params_t eth_params_n; + } UE_MAC_INST; /*! \brief ID of the neighboring cells used for HO*/ typedef struct { @@ -1355,6 +1513,6 @@ typedef struct { uint8_t n_adj_cells; } neigh_cell_id_t; -#include "proto.h" +#include "mac_proto.h" /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/mac_extern.h similarity index 73% rename from openair2/LAYER2/MAC/extern.h rename to openair2/LAYER2/MAC/mac_extern.h index e7489ca8e6fffcabb25c34cbb188b1dc7f25dd7c..4ac7cf4d58e79ca0363cd9d813232135b551b9f1 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/mac_extern.h @@ -32,10 +32,10 @@ #ifndef __MAC_EXTERN_H__ #define __MAC_EXTERN_H__ -#include "PHY/defs.h" -#include "defs.h" +//#include "PHY/defs_common.h" +#include "mac.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; //extern uint32_t EBSR_Level[63]; @@ -52,8 +52,8 @@ extern UE_RRC_INST *UE_rrc_inst; extern UE_MAC_INST *UE_mac_inst; -extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 -extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 +extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 +extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 @@ -75,26 +75,5 @@ extern uint32_t RRC_CONNECTION_FLAG; extern uint8_t rb_table[34]; -extern DCI0_5MHz_TDD_1_6_t UL_alloc_pdu; - -extern DCI1A_5MHz_TDD_1_6_t RA_alloc_pdu; -extern DCI1A_5MHz_TDD_1_6_t DLSCH_alloc_pdu1A; -extern DCI1A_5MHz_TDD_1_6_t BCCH_alloc_pdu; - -extern DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; -extern DCI1_5MHz_TDD_t DLSCH_alloc_pdu; - -extern DCI0_5MHz_FDD_t UL_alloc_pdu_fdd; - -extern DCI1A_5MHz_FDD_t DLSCH_alloc_pdu1A_fdd; -extern DCI1A_5MHz_FDD_t RA_alloc_pdu_fdd; -extern DCI1A_5MHz_FDD_t BCCH_alloc_pdu_fdd; - -extern DCI1A_5MHz_FDD_t CCCH_alloc_pdu_fdd; -extern DCI1_5MHz_FDD_t DLSCH_alloc_pdu_fdd; - -extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu1; -extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2; -extern DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu1E; #endif //DEF_H diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/mac_proto.h similarity index 94% rename from openair2/LAYER2/MAC/proto.h rename to openair2/LAYER2/MAC/mac_proto.h index 2586c94f432887276f6359e5039b55770dae3bd9..d648f9def75b2e80756e921cdefaea90d84d7fd8 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/mac_proto.h @@ -29,7 +29,8 @@ #ifndef __LAYER2_MAC_PROTO_H__ #define __LAYER2_MAC_PROTO_H__ -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" +#include "PHY/defs_common.h" // for PRACH_RESOURCES_t and lte_subframe_t /** \addtogroup _mac * @{ @@ -150,6 +151,9 @@ void schedule_dlsch(module_id_t module_idP, frame_t frameP, void schedule_ue_spec(module_id_t module_idP, slice_id_t slice_idP, frame_t frameP,sub_frame_t subframe, int *mbsfn_flag); +void schedule_ue_spec_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag); +void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP); + /** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure. @param Mod_id Module id of UE @@ -207,13 +211,13 @@ void dlsch_scheduler_pre_processor_reset(int module_idP, int UE_id, int subframeP, int N_RBG, uint16_t - nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], + nb_rbs_required[NFAPI_CC_MAX] + [MAX_MOBILES_PER_ENB], unsigned char - rballoc_sub[MAX_NUM_CCs] + rballoc_sub[NFAPI_CC_MAX] [N_RBG_MAX], unsigned char - MIMO_mode_indicator[MAX_NUM_CCs] + MIMO_mode_indicator[NFAPI_CC_MAX] [N_RBG_MAX]); // eNB functions @@ -229,7 +233,7 @@ void dlsch_scheduler_pre_processor(module_id_t module_idP, slice_id_t slice_idP, frame_t frameP, sub_frame_t subframe, - int N_RBG[MAX_NUM_CCs], + int N_RBG[NFAPI_CC_MAX], int *mbsfn_flag); @@ -240,19 +244,10 @@ void dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, int transmission_mode, int min_rb_unit, uint8_t N_RB_DL, - uint16_t - nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_required_remaining - [MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - unsigned char - rballoc_sub[MAX_NUM_CCs] - [N_RBG_MAX], - unsigned char - MIMO_mode_indicator - [MAX_NUM_CCs][N_RBG_MAX]); + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + uint16_t nb_rbs_required_remaining[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + unsigned char rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX], + unsigned char MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX]); /* \brief Function to trigger the eNB scheduling procedure. It is called by PHY at the beginning of each subframe, \f$n$\f and generates all DLSCH allocations for subframe \f$n\f$ and ULSCH allocations for subframe \f$n+k$\f. @@ -272,7 +267,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame void initiate_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t subframeP, uint16_t preamble_index, int16_t timing_offset, uint16_t rnti -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , uint8_t rach_resource_type #endif ); @@ -291,7 +286,7 @@ unsigned short fill_rar(const module_id_t module_idP, const uint16_t N_RB_UL, const uint8_t input_buffer_length); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) unsigned short fill_rar_br(eNB_MAC_INST * eNB, int CC_id, RA_t * ra, @@ -517,8 +512,17 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frame, sub_frame_t subframe, uint8_t * sdu, uint16_t sdu_len, uint8_t CH_index); - -#if defined(Rel10) || defined(Rel14) +void ue_send_sl_sdu(module_id_t module_idP, + uint8_t CC_id, + frame_t frameP, + sub_frame_t subframeP, + uint8_t* sdu, + uint16_t sdu_len, + uint8_t eNB_index, + sl_discovery_flag_t sl_discovery_flag + ); + +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) /* \brief Called by PHY to transfer MCH transport block to ue MAC. @param Mod_id Index of module instance @param frame Frame index @@ -550,13 +554,36 @@ int ue_query_mch(uint8_t Mod_id, uint8_t CC_id, uint32_t frame, @param eNB_id Index of eNB that UE is attached to @param rnti C_RNTI of UE @param subframe subframe number -@returns 0 for no SR, 1 for SR */ void ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t subframe, uint8_t eNB_index, uint8_t * ulsch_buffer, uint16_t buflen, uint8_t * access_mode); +/* \brief Called by PHY to get sdu for PSBCH/SSS/PSS transmission. +@param Mod_id Instance id of UE in machine +@param frame_tx TX frame index +@param subframe_tx TX subframe index +@returns pointer to SLSS_t descriptor +*/ +SLSS_t *ue_get_slss(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe); + +/* \brief Called by PHY to get sdu for PSDCH transmission. +@param Mod_id Instance id of UE in machine +@param frame_tx TX frame index +@param subframe_tx TX subframe index +@returns pointer to SLDCH_t descriptor +*/ +SLDCH_t *ue_get_sldch(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe); + +/* \brief Called by PHY to get sdu for PSSCH transmission. +@param Mod_id Instance id of UE in machine +@param frame_tx TX frame index +@param subframe_tx TX subframe index +@returns pointer to SLSCH_t descriptor +*/ +SLSCH_t *ue_get_slsch(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframe); + /* \brief Function called by PHY to retrieve information to be transmitted using the RA procedure. If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for random-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321) @param Mod_id Index of UE instance @param Mod_id Component Carrier Index @@ -638,11 +665,9 @@ uint8_t *parse_ulsch_header(uint8_t * mac_header, int to_prb(int); int to_rbg(int); -int l2_init(LTE_DL_FRAME_PARMS * frame_parms, int eMBMS_active, - char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); int mac_init(void); int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti, int harq_pid -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , uint8_t rach_resource_type #endif ); @@ -893,20 +918,20 @@ int rrc_mac_config_req_eNB(module_id_t module_idP, int p_eNB, int Ncp, int eutra_band, uint32_t dl_CarrierFreq, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int pbch_repetition, #endif rnti_t rntiP, BCCH_BCH_Message_t * mib, RadioResourceConfigCommonSIB_t * radioResourceConfigCommon, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RadioResourceConfigCommonSIB_t * radioResourceConfigCommon_BR, #endif struct PhysicalConfigDedicated *physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) SCellToAddMod_r10_t * sCellToAddMod_r10, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -924,13 +949,13 @@ int rrc_mac_config_req_eNB(module_id_t module_idP, additionalSpectrumEmission, struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , uint8_t MBMS_Flag, MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, PMCH_InfoList_r9_t * pmch_InfoList #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , SystemInformationBlockType1_v1310_IEs_t * sib1_ext_r13 @@ -964,7 +989,7 @@ int rrc_mac_config_req_ue(module_id_t module_idP, radioResourceConfigCommon, struct PhysicalConfigDedicated *physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) SCellToAddMod_r10_t * sCellToAddMod_r10, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -983,7 +1008,7 @@ int rrc_mac_config_req_ue(module_id_t module_idP, additionalSpectrumEmission, struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , uint8_t MBMS_Flag, MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, @@ -993,7 +1018,13 @@ int rrc_mac_config_req_ue(module_id_t module_idP, , uint8_t num_active_cba_groups, uint16_t cba_rnti #endif - ); +#if defined(Rel14) + ,config_action_t config_action + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id +#endif + ); + uint16_t getRIV(uint16_t N_RB_DL, uint16_t RBstart, uint16_t Lcrbs); @@ -1084,7 +1115,7 @@ void fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t * uint8_t current_tx_nb, uint8_t n_srs, uint16_t size); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void fill_nfapi_ulsch_config_request_emtc(nfapi_ul_config_request_pdu_t * ul_config_pdu, uint8_t ue_type, uint16_t @@ -1160,7 +1191,7 @@ uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP); uint8_t get_ul_req_index(module_id_t module_idP, int CC_idP, sub_frame_t subframeP); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int get_numnarrowbandbits(long dl_Bandwidth); int mpdcch_sf_condition(eNB_MAC_INST * eNB, int CC_id, frame_t frameP, diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/mac_vars.h similarity index 94% rename from openair2/LAYER2/MAC/vars.h rename to openair2/LAYER2/MAC/mac_vars.h index d153c82aeeef2e2ed132cd7c790ffd10150d18d5..5b00387de6e6144bd51891b39cf432b650a03925 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/mac_vars.h @@ -32,8 +32,8 @@ #ifndef __MAC_VARS_H__ #define __MAC_VARS_H__ -#include "PHY/defs.h" -#include "defs.h" +#include "PHY/defs_common.h" +#include "mac.h" #include "COMMON/mac_rrc_primitives.h" const uint32_t BSR_TABLE[BSR_TABLE_SIZE] = @@ -103,8 +103,8 @@ int pCC_id[NUMBER_OF_eNB_MAX]; -eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 -eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 +eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 +eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; // eNBxUE = 8x8 #ifdef OPENAIR2 @@ -124,7 +124,7 @@ DCI1A_5MHz_TDD_1_6_t BCCH_alloc_pdu; DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu; DCI1_5MHz_TDD_t DLSCH_alloc_pdu; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) DCI1C_5MHz_t MCCH_alloc_pdu; #endif diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index afee1632031a2da102c39c739aa18bc3dd260640..062ead2a206d1e6db672afc02d60785e3b628abd 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -29,21 +29,18 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "assertions.h" -#include "PHY_INTERFACE/extern.h" -#include "PHY/defs.h" -#include "SCHED/defs.h" +//#include "PHY_INTERFACE/phy_extern.h" +//#include "PHY/defs_eNB.h" +//#include "SCHED/sched_eNB.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "UTIL/LOG/log.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "SCHED/defs.h" - - #include "common/ran_context.h" extern RAN_CONTEXT_t RC; @@ -123,7 +120,7 @@ void mac_top_init_eNB(void) UE_list->head_ul = -1; UE_list->avail = 0; - for (list_el = 0; list_el < NUMBER_OF_UE_MAX - 1; list_el++) { + for (list_el = 0; list_el < MAX_MOBILES_PER_ENB - 1; list_el++) { UE_list->next[list_el] = list_el + 1; UE_list->next_ul[list_el] = list_el + 1; } @@ -147,7 +144,7 @@ void mac_init_cell_params(int Mod_idP, int CC_idP) UE_template = (UE_TEMPLATE *) & RC.mac[Mod_idP]->UE_list.UE_template[CC_idP][0]; - for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { UE_template[j].rnti = 0; // initiallize the eNB to UE statistics memset(&RC.mac[Mod_idP]->UE_list.eNB_UE_stats[CC_idP][j], 0, diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c index 64326dec614dc9ea452c7ce7bebf73692050167b..272ca5cddd7c953ed87bc458f9018451c161d0f1 100644 --- a/openair2/LAYER2/MAC/main_ue.c +++ b/openair2/LAYER2/MAC/main_ue.c @@ -29,20 +29,18 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" #include "assertions.h" -#include "PHY_INTERFACE/extern.h" -#include "PHY/defs.h" -#include "SCHED/defs.h" +#include "PHY_INTERFACE/phy_interface_extern.h" +#include "PHY/defs_UE.h" +#include "SCHED_UE/sched_UE.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "UTIL/LOG/log.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "SCHED/defs.h" - #include "common/ran_context.h" diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 2cdcfc7de857a8c4df4089881040907b731d21c4..e9b3befc1c10b827b98ecfcb6ac8dcb6a60efdec 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -33,24 +33,22 @@ #include <stdlib.h> #include "assertions.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rlc.h" +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" + +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; #define DEBUG_eNB_SCHEDULER 1 #define DEBUG_HEADER_PARSING 1 @@ -107,7 +105,7 @@ store_dlsch_buffer(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; UE_TEMPLATE *UE_template; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; @@ -128,13 +126,19 @@ store_dlsch_buffer(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = 0; } + rnti = UE_RNTI(Mod_id, UE_id); for (i = 0; i < MAX_NUM_LCID; i++) { // loop over all the logical channels rlc_status = mac_rlc_status_ind(Mod_id, rnti, Mod_id, frameP, subframeP, - ENB_FLAG_YES, MBMS_FLAG_NO, i, 0); + ENB_FLAG_YES, MBMS_FLAG_NO, i, 0 +#ifdef Rel14 + ,0, 0 +#endif + ); + UE_template->dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel UE_template->dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; UE_template->dl_buffer_head_sdu_creation_time[i] = @@ -190,8 +194,8 @@ assign_rbs_required(module_id_t Mod_id, frame_t frameP, sub_frame_t subframe, uint16_t - nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - int min_rb_unit[MAX_NUM_CCs]) + nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + int min_rb_unit[NFAPI_CC_MAX]) { uint16_t TBS = 0; @@ -202,7 +206,7 @@ assign_rbs_required(module_id_t Mod_id, int N_RB_DL; // clear rb allocations across all CC_id - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { if (UE_list->active[UE_id] != TRUE) continue; if (!ue_slice_membership(UE_id, slice_id)) @@ -211,7 +215,6 @@ assign_rbs_required(module_id_t Mod_id, //update CQI information across component carriers for (n = 0; n < UE_list->numactiveCCs[UE_id]; n++) { - CC_id = UE_list->ordered_CCids[n][UE_id]; eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; @@ -226,7 +229,7 @@ assign_rbs_required(module_id_t Mod_id, &UE_list->eNB_UE_stats[UE_list-> ordered_CCids[i][UE_id]][UE_id]; for (j = i + 1; j < UE_list->numactiveCCs[UE_id]; j++) { - DevAssert(j < MAX_NUM_CCs); + DevAssert(j < NFAPI_CC_MAX); eNB_UE_stats_j = &UE_list-> eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]][UE_id]; @@ -310,7 +313,7 @@ maxround(module_id_t Mod_id, uint16_t rnti, int frame, UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; COMMON_channels_t *cc; - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) { cc = &RC.mac[Mod_id]->common_channels[CC_id]; @@ -485,14 +488,14 @@ void decode_sorting_policy(module_id_t Mod_idP, slice_id_t slice_id) { void sort_UEs(module_id_t Mod_idP, slice_id_t slice_id, int frameP, sub_frame_t subframeP) { int i; - int list[NUMBER_OF_UE_MAX]; + int list[MAX_MOBILES_PER_ENB]; int list_size = 0; int rnti; struct sort_ue_dl_params params = { Mod_idP, frameP, subframeP, slice_id }; UE_list_t *UE_list = &RC.mac[Mod_idP]->UE_list; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] == FALSE) continue; @@ -597,11 +600,11 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int min_rb_unit[MAX_NUM_CCs], - uint8_t rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], - uint8_t MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX], - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]) { + int N_RBG[NFAPI_CC_MAX], + int min_rb_unit[NFAPI_CC_MAX], + uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX], + uint8_t MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX], + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]) { int UE_id, CC_id; @@ -609,22 +612,22 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id, rnti_t rnti; uint8_t harq_pid, round, transmission_mode; - uint8_t total_rbs_used[MAX_NUM_CCs]; - uint8_t total_ue_count[MAX_NUM_CCs]; - uint16_t average_rbs_per_user[MAX_NUM_CCs]; - uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; - uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint8_t total_rbs_used[NFAPI_CC_MAX]; + uint8_t total_ue_count[NFAPI_CC_MAX]; + uint16_t average_rbs_per_user[NFAPI_CC_MAX]; + uint16_t nb_rbs_required_remaining[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; + uint16_t nb_rbs_required_remaining_1[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; int N_RB_DL; UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; UE_sched_ctrl *ue_sched_ctl; COMMON_channels_t *cc; - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) { total_ue_count[CC_id] = 0; total_rbs_used[CC_id] = 0; average_rbs_per_user[CC_id] = 0; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; ++UE_id) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; ++UE_id) { nb_rbs_required_remaining[CC_id][UE_id] = 0; } } @@ -815,9 +818,7 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id, transmission_mode, min_rb_unit [CC_id], - to_prb(RC.mac - [Mod_id]->common_channels - [CC_id].mib->message.dl_Bandwidth), + to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth), nb_rbs_required, nb_rbs_required_remaining, rballoc_sub, @@ -997,18 +998,18 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, slice_id_t slice_id, frame_t frameP, sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], + int N_RBG[NFAPI_CC_MAX], int *mbsfn_flag) { int UE_id; uint8_t CC_id; uint16_t i, j; - uint8_t rballoc_sub[MAX_NUM_CCs][N_RBG_MAX]; - uint8_t MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; // If TM5 is revisited, we can move this inside accounting + uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX]; + uint8_t MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX]; // If TM5 is revisited, we can move this inside accounting - int min_rb_unit[MAX_NUM_CCs]; - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + int min_rb_unit[NFAPI_CC_MAX]; + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; UE_sched_ctrl *ue_sched_ctl; @@ -1025,14 +1026,14 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2; #endif - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) { if (mbsfn_flag[CC_id] > 0) // If this CC is allocated for MBSFN skip it here continue; min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; ++UE_id) { + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; ++UE_id) { if (UE_list->active[UE_id] != TRUE) continue; @@ -1076,7 +1077,7 @@ dlsch_scheduler_pre_processor(module_id_t Mod_id, #ifdef TM5 // This has to be revisited!!!! - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; CC_id++) { i1 = 0; i2 = 0; i3 = 0; @@ -1150,13 +1151,13 @@ dlsch_scheduler_pre_processor_reset(int module_idP, int frameP, int subframeP, int N_RBG, - uint16_t nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], + uint16_t nb_rbs_required[NFAPI_CC_MAX] + [MAX_MOBILES_PER_ENB], unsigned char - rballoc_sub[MAX_NUM_CCs] + rballoc_sub[NFAPI_CC_MAX] [N_RBG_MAX], unsigned char - MIMO_mode_indicator[MAX_NUM_CCs] + MIMO_mode_indicator[NFAPI_CC_MAX] [N_RBG_MAX]) { int i, j; @@ -1192,7 +1193,6 @@ dlsch_scheduler_pre_processor_reset(int module_idP, &ue_sched_ctl->round[CC_id], openair_harq_DL); - if (ue_sched_ctl->ta_timer == 0) { // WE SHOULD PROTECT the eNB_UE_stats with a mutex here ... @@ -1338,17 +1338,10 @@ dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, int transmission_mode, int min_rb_unit, uint8_t N_RB_DL, - uint16_t - nb_rbs_required[MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], - uint16_t - nb_rbs_required_remaining - [MAX_NUM_CCs] - [NUMBER_OF_UE_MAX], unsigned char - rballoc_sub[MAX_NUM_CCs] - [N_RBG_MAX], unsigned char - MIMO_mode_indicator - [MAX_NUM_CCs][N_RBG_MAX]) + uint16_t nb_rbs_required[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + uint16_t nb_rbs_required_remaining[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + unsigned char rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX], + unsigned char MIMO_mode_indicator[NFAPI_CC_MAX][N_RBG_MAX]) { int i; @@ -1418,11 +1411,11 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, int16_t i; uint16_t UE_id, n, r; uint8_t CC_id, harq_pid; - uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - total_allocated_rbs[MAX_NUM_CCs], - average_rbs_per_user[MAX_NUM_CCs]; - int16_t total_remaining_rbs[MAX_NUM_CCs]; - uint16_t total_ue_count[MAX_NUM_CCs]; + uint16_t nb_allocated_rbs[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB], + total_allocated_rbs[NFAPI_CC_MAX], + average_rbs_per_user[NFAPI_CC_MAX]; + int16_t total_remaining_rbs[NFAPI_CC_MAX]; + uint16_t total_ue_count[NFAPI_CC_MAX]; rnti_t rnti = -1; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; UE_TEMPLATE *UE_template = 0; @@ -1440,7 +1433,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, // we need to distribute RBs among UEs // step1: reset the vars - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { total_allocated_rbs[CC_id] = 0; total_remaining_rbs[CC_id] = 0; average_rbs_per_user[CC_id] = 0; @@ -1613,7 +1606,7 @@ ulsch_scheduler_pre_processor(module_id_t module_idP, /* this logging is wrong, ue_sched_ctl may not be valid here * TODO: fix */ - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { if (total_allocated_rbs[CC_id] > 0) { LOG_D(MAC, "[eNB %d] total RB allocated for all UEs = %d/%d\n", @@ -1644,7 +1637,7 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, int Ncp; int N_RB_UL; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] != TRUE) continue; @@ -1672,14 +1665,11 @@ assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP, // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; - if (CC_id >= MAX_NUM_CCs) { - LOG_E(MAC, "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", - CC_id, MAX_NUM_CCs, n, UE_id, UE_list->numactiveULCCs[UE_id]); - } - AssertFatal(CC_id < MAX_NUM_CCs, + + AssertFatal(CC_id < RC.nb_mac_CC[module_idP], "CC_id %u should be < %u, loop n=%u < numactiveULCCs[%u]=%u", - CC_id, MAX_NUM_CCs, n, UE_id, + CC_id, NFAPI_CC_MAX, n, UE_id, UE_list->numactiveULCCs[UE_id]); UE_template = &UE_list->UE_template[CC_id][UE_id]; @@ -1841,14 +1831,14 @@ static int ue_ul_compare(const void *_a, const void *_b, void *_params) void sort_ue_ul(module_id_t module_idP, int frameP, sub_frame_t subframeP) { int i; - int list[NUMBER_OF_UE_MAX]; + int list[MAX_MOBILES_PER_ENB]; int list_size = 0; int rnti; struct sort_ue_ul_params params = { module_idP, frameP, subframeP }; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_list->active[i] == FALSE) continue; if ((rnti = UE_RNTI(module_idP, i)) == NOT_A_RNTI) diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 8868d2d548ad30ba445b924c7e294d7df1fc8294..5a66645e3d81e9d5b2ae324372d111193af5eab3 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -30,71 +30,25 @@ * \warning */ -#include "extern.h" -#include "defs.h" -#include "proto.h" +#include "mac_extern.h" +#include "mac.h" +#include "mac_proto.h" #include "UTIL/LOG/vcd_signal_dumper.h" -#include "PHY_INTERFACE/extern.h" -#include "SCHED/defs.h" +#include "PHY_INTERFACE/phy_interface_extern.h" +#include "SCHED_UE/sched_UE.h" #include "COMMON/mac_rrc_primitives.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "UTIL/LOG/log.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#ifdef PHY_EMUL -#include "SIMULATION/simulation_defs.h" -#endif - -#include "SIMULATION/TOOLS/defs.h" // for taus - -int8_t get_DELTA_PREAMBLE(module_id_t module_idP, int CC_id) -{ - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - uint8_t prachConfigIndex = - UE_mac_inst[module_idP].radioResourceConfigCommon-> - prach_Config.prach_ConfigInfo.prach_ConfigIndex; - uint8_t preambleformat; - - if (UE_mac_inst[module_idP].tdd_Config) { // TDD - if (prachConfigIndex < 20) { - preambleformat = 0; - } else if (prachConfigIndex < 30) { - preambleformat = 1; - } else if (prachConfigIndex < 40) { - preambleformat = 2; - } else if (prachConfigIndex < 48) { - preambleformat = 3; - } else { - preambleformat = 4; - } - } else { // FDD - preambleformat = prachConfigIndex >> 2; - } - - switch (preambleformat) { - case 0: - case 1: - return (0); - - case 2: - case 3: - return (-3); - - case 4: - return (8); - - default: - AssertFatal(1 == 0, - "[UE %d] ue_procedures.c: FATAL, Illegal preambleformat %d, prachConfigIndex %d\n", - module_idP, preambleformat, prachConfigIndex); - } - -} +#include "SIMULATION/TOOLS/sim.h" // for taus +#include "PHY/LTE_TRANSPORT/transport_common_proto.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +extern uint8_t nfapi_mode; +extern UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); /// This routine implements Section 5.1.2 (UE Random Access Resource Selection) from 36.321 void @@ -105,7 +59,6 @@ get_prach_resources(module_id_t module_idP, uint8_t first_Msg3, RACH_ConfigDedicated_t * rach_ConfigDedicated) { - uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size; PRACH_RESOURCES_t *prach_resources = &UE_mac_inst[module_idP].RA_prach_resources; @@ -344,9 +297,18 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, sub_frame_t subframeP) { - uint8_t Size = 0; - UE_MODE_t UE_mode = get_ue_mode(module_idP, 0, eNB_indexP); + UE_MODE_t UE_mode; + // Panos: Modification for phy_stub_ue operation + if(nfapi_mode == 3) { // Panos: phy_stub_ue mode + UE_mode = UE_mac_inst[module_idP].UE_mode[0]; + LOG_D(MAC, "ue_get_rach , UE_mode: %d", UE_mode); + } + else { // Full stack mode + UE_mode = get_ue_mode(module_idP,0,eNB_indexP); + } + + uint8_t lcid = CCCH; uint16_t Size16; struct RACH_ConfigCommon *rach_ConfigCommon = @@ -361,6 +323,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, "Transmission on secondary CCs is not supported yet\n"); if (UE_mode == PRACH) { + LOG_D(MAC, "ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active); if (UE_mac_inst[module_idP].radioResourceConfigCommon) { rach_ConfigCommon = &UE_mac_inst[module_idP]. @@ -392,7 +355,6 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, module_idP, frameP, Size); if (Size > 0) { - UE_mac_inst[module_idP].RA_active = 1; UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; @@ -447,7 +409,12 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, subframeP, - ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6); + ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6 +#ifdef Rel14 + ,0, 0 +#endif + ); + if (UE_mac_inst[module_idP].crnti_before_ho) LOG_D(MAC, @@ -463,7 +430,13 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, dcch_header_len); sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6, //not used - (char *) &ulsch_buff[0]); + (char *) &ulsch_buff[0] +#ifdef Rel14 + ,0, + 0 +#endif + ); + LOG_D(MAC, "[UE %d] TX Got %d bytes for DCCH\n", module_idP, sdu_lengths[0]); diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index 6261eaf35690f672225209e7972aa333d6bd9087..d97ab6580e4ff8163307d94faec8cdcfee546f04 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -28,10 +28,10 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" +#include "SIMULATION/TOOLS/sim.h" #include "UTIL/LOG/log.h" #include "OCG.h" #include "OCG_extern.h" @@ -98,7 +98,7 @@ fill_rar(const module_id_t module_idP, return (ra->rnti); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) //------------------------------------------------------------------------------ unsigned short fill_rar_br(eNB_MAC_INST * eNB, diff --git a/openair2/LAYER2/MAC/rar_tools_ue.c b/openair2/LAYER2/MAC/rar_tools_ue.c index ab193c7a66b2422473dd208af125fc815c4a7259..7d24e4c0af31c5fd2a87ea13ec06427f08902d6f 100644 --- a/openair2/LAYER2/MAC/rar_tools_ue.c +++ b/openair2/LAYER2/MAC/rar_tools_ue.c @@ -28,10 +28,10 @@ */ -#include "defs.h" -#include "proto.h" -#include "extern.h" -#include "SIMULATION/TOOLS/defs.h" +#include "mac.h" +#include "mac_proto.h" +#include "mac_extern.h" +#include "SIMULATION/TOOLS/sim.h" #include "UTIL/LOG/log.h" #include "OCG.h" #include "OCG_extern.h" diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 5ca6d10bb530f4ac19246777c488a24d6c8f3b4e..948f6c08d0032c6a105a2d6850aa01431e390db2 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -33,29 +33,25 @@ #include <pthread.h> #endif -#include "extern.h" -#include "defs.h" -#include "proto.h" -#ifdef PHY_EMUL -#include "SIMULATION/PHY_EMULATION/impl_defs.h" -#else -#include "SCHED/defs.h" +#include "mac_extern.h" +#include "mac.h" +#include "mac_proto.h" +#include "SCHED_UE/sched_UE.h" #include "PHY/impl_defs_top.h" -#endif -#include "PHY_INTERFACE/extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" #include "COMMON/mac_rrc_primitives.h" +#include "PHY/INIT/phy_init.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" +#include "openair2/PHY_INTERFACE/phy_stub_UE.h" -#ifdef PHY_EMUL -#include "SIMULATION/simulation_defs.h" -#endif #include "pdcp.h" #if defined(ENABLE_ITTI) @@ -64,13 +60,24 @@ #include "assertions.h" -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #define DEBUG_HEADER_PARSING 1 #define ENABLE_MAC_PAYLOAD_DEBUG 1 extern uint8_t usim_test; +extern UL_IND_t *UL_INFO; + +extern uint8_t nfapi_mode; + +/* + * +#ifndef USER_MODE +#define msg debug_msg +#endif + */ + mapping BSR_names[] = { {"NONE", 0}, {"SHORT BSR", 1}, @@ -83,6 +90,7 @@ mapping BSR_names[] = { void ue_init_mac(module_id_t module_idP) { + int i; // default values as deined in 36.331 sec 9.2.2 LOG_I(MAC, "[UE%d] Applying default macMainConfig\n", module_idP); @@ -145,6 +153,19 @@ void ue_init_mac(module_id_t module_idP) UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0; } + if(nfapi_mode == 3) { + pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL); + UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH; + UE_mac_inst[module_idP].first_ULSCH_Tx =0; + UE_mac_inst[module_idP].SI_Decoded = 0; + next_ra_frame = 0; + next_Mod_id = 0; + tx_request_pdu_list = NULL; + tx_req_num_elems = 0; + + + } + #ifdef CBA for (i = 0; i < NUM_MAX_CBA_GROUP; i++) { @@ -395,7 +416,8 @@ ue_send_sdu(module_id_t module_idP, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN); - LOG_T(MAC, "sdu: %x.%x.%x\n", sdu[0], sdu[1], sdu[2]); + + //LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]); if (opt_enabled) { trace_pdu(1, sdu, sdu_len, module_idP, 3, @@ -453,7 +475,16 @@ ue_send_sdu(module_id_t module_idP, LOG_E(MAC, "[UE %d][RAPROC] Contention detected, RA failed\n", module_idP); - ra_failed(module_idP, CC_id, eNB_index); + if(nfapi_mode == 3) { // Panos: phy_stub mode + // Panos: Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to + // PRACH state. + LOG_I(MAC, "nfapi_mode3: Setting UE_mode BACK to PRACH 1\n"); + UE_mac_inst[module_idP].UE_mode[eNB_index] = PRACH; + //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + } + else{ + ra_failed(module_idP, CC_id, eNB_index); + } UE_mac_inst [module_idP]. RA_contention_resolution_timer_active = 0; @@ -469,7 +500,14 @@ ue_send_sdu(module_id_t module_idP, UE_mac_inst [module_idP]. RA_contention_resolution_timer_active = 0; - ra_succeeded(module_idP, CC_id, eNB_index); + if(nfapi_mode == 3) // phy_stub mode + { + //Panos: Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH + UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH; + } + else { // Full stack mode + ra_succeeded(module_idP,CC_id,eNB_index); + } } payload_ptr += 6; @@ -480,9 +518,14 @@ ue_send_sdu(module_id_t module_idP, LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, payload_ptr[0]); #endif - process_timing_advance(module_idP, CC_id, payload_ptr[0]); - payload_ptr++; - break; + + // Panos: Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct? + if (nfapi_mode!=3) + { + process_timing_advance(module_idP,CC_id,payload_ptr[0]); + } + payload_ptr++; + break; case DRX_CMD: #ifdef DEBUG_HEADER_PARSING @@ -498,7 +541,6 @@ ue_send_sdu(module_id_t module_idP, LOG_D(MAC, "[UE] SDU %d : LCID %d, length %d\n", i, rx_lcids[i], rx_lengths[i]); #endif - if (rx_lcids[i] == CCCH) { LOG_D(MAC, @@ -515,6 +557,7 @@ ue_send_sdu(module_id_t module_idP, LOG_T(MAC, "\n"); #endif + mac_rrc_data_ind_ue(module_idP, CC_id, frameP, subframeP, @@ -646,7 +689,7 @@ ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP, } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) unsigned char *parse_mch_header(unsigned char *mac_header, unsigned char *num_sdu, unsigned char *rx_lcids, @@ -778,9 +821,93 @@ ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, #endif } -int8_t -ue_get_mbsfn_sf_alloction(module_id_t module_idP, - uint8_t mbsfn_sync_area, unsigned char eNB_index) +void ue_send_sl_sdu(module_id_t module_idP, + uint8_t CC_id, + frame_t frameP, + sub_frame_t subframeP, + uint8_t* sdu, + uint16_t sdu_len, + uint8_t eNB_index, + sl_discovery_flag_t sl_discovery_flag + ) { + + int rlc_sdu_len; + char *rlc_sdu; + uint32_t destinationL2Id =0x00000000; + + if (sl_discovery_flag == SL_DISCOVERY_FLAG_NO) { + + // Notes: 1. no control elements are supported yet + // 2. we exit with error if LCID != 3 + // 3. we exit with error if E=1 (more than one SDU/CE) + // extract header + SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu; + AssertFatal(longh->E==0,"E is non-zero\n"); + AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID); + //filter incoming packet based on destination address + destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623); + LOG_I( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id ); + //in case of 1-n communication, verify that UE belongs to that group + int i=0; + for (i=0; i< MAX_NUM_DEST; i++) + if (UE_mac_inst[module_idP].destinationList[i] == destinationL2Id) break; + //match the destinationL2Id with UE L2Id or groupL2ID + if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (i < MAX_NUM_DEST))){ + LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n"); + return; + } + + + if (longh->F==1) { + rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF); + rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG); + } + else { + rlc_sdu_len = ((SLSCH_SUBHEADER_24_Bit_DST_SHORT *)sdu)->L; + rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_SHORT); + } + mac_rlc_data_ind( + module_idP, + 0x1234, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + longh->LCID, //3/10 + rlc_sdu, + rlc_sdu_len, + 1, + NULL); + } else { //SL_DISCOVERY + uint16_t len = sdu_len; + LOG_I( MAC, "SL DISCOVERY \n"); + // Panos: Ask TTN if we should be calling mac_rrc_data_ind_ue() instead of mac_rrc_data_ind() now! + /*mac_rrc_data_ind(module_idP, + CC_id, + frameP,subframeP, + UE_mac_inst[module_idP].crnti, + SL_DISCOVERY, + sdu, //(uint8_t*)&UE_mac_inst[Mod_id].SL_Discovery[0].Rx_buffer.Payload[0], + len, + ENB_FLAG_NO, + eNB_index, + 0);*/ + mac_rrc_data_ind_ue(module_idP, + CC_id, + frameP,subframeP, + UE_mac_inst[module_idP].crnti, + SL_DISCOVERY, + sdu, //(uint8_t*)&UE_mac_inst[Mod_id].SL_Discovery[0].Rx_buffer.Payload[0], + len, + eNB_index, + 0); + + } +} + + +int8_t ue_get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t mbsfn_sync_area, unsigned char eNB_index) + { // currently there is one-to-one mapping between sf allocation pattern and sync area if (mbsfn_sync_area >= MAX_MBSFN_AREA) { @@ -1496,6 +1623,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t * ulsch_buffer, uint16_t buflen, uint8_t * access_mode) { + //LOG_I(MAC, "Panos-D: UE[%d] In ue_get_sdu() 1 \n", module_idP); uint8_t total_rlc_pdu_header_len = 0, rlc_pdu_header_len_last = 0; uint16_t buflen_remain = 0; uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0; @@ -1724,9 +1852,13 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, MBMS_FLAG_NO, lcid, buflen_remain, - (char *) - &ulsch_buff - [sdu_length_total]); + (char *)&ulsch_buff[sdu_length_total] +#ifdef Rel14 + ,0, + 0 +#endif + ); + AssertFatal(buflen_remain >= sdu_lengths[num_sdus], @@ -1864,7 +1996,15 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, } // build PHR and update the timers if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) { - phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index); + if(nfapi_mode ==3){ + //Panos: Substitute with a static value for the MAC layer abstraction (phy_stub mode) + phr_p->PH = 40; + } + else{ + phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index); + } + + phr_p->R = 0; LOG_D(MAC, "[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", @@ -1878,7 +2018,6 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, LOG_T(MAC, "[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", module_idP, frameP, bsr_s, bsr_l, phr_p); - // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 /* For Padding BSR: @@ -2073,6 +2212,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, buflen - sdu_length_total - payload_offset); // cycle through SDUs and place in ulsch_buffer if (sdu_length_total) { + //LOG_I(MAC, "Panos-D: [UE %d] ue_get_sdu() 2 before copying to ulsch_buffer, SFN/SF: %d/%d \n \n \n", module_idP, frameP, subframe); memcpy(&ulsch_buffer[payload_offset], ulsch_buff, sdu_length_total); } @@ -2139,6 +2279,8 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, } } + + //------------------------------------------------------------------------------ // called at each subframe // Performs : @@ -2300,6 +2442,7 @@ ue_scheduler(const module_id_t module_idP, #if UE_TIMING_TRACE stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif + //return(RRC_OK); } @@ -2323,7 +2466,17 @@ ue_scheduler(const module_id_t module_idP, LOG_E(MAC, "Module id %u Contention resolution timer expired, RA failed\n", module_idP); - ra_failed(module_idP, 0, eNB_indexP); + if(nfapi_mode == 3) { // Panos: phy_stub mode + // Panos: Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to + // PRACH state. + LOG_I(MAC, "nfapi_mode3: Setting UE_mode to PRACH 2 \n"); + UE_mac_inst[module_idP].UE_mode[eNB_indexP] = PRACH; + //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + } + else{ + ra_failed(module_idP, CC_id, eNB_indexP); + } + //ra_failed(module_idP, 0, eNB_indexP); } } // Get RLC status info and update Bj for all lcids that are active @@ -2641,92 +2794,92 @@ update_bsr(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, eNB_index_t eNB_index) { - mac_rlc_status_resp_t rlc_status; - boolean_t bsr_regular_triggered = FALSE; - uint8_t lcid; - uint8_t lcgid; - uint8_t num_lcid_with_data = 0; // for LCID with data only if LCGID is defined - uint16_t lcgid_buffer_remain[MAX_NUM_LCGID] = { 0, 0, 0, 0 }; - int32_t lcid_bytes_in_buffer[MAX_NUM_LCID]; - /* Array for ordering LCID with data per decreasing priority order */ - uint8_t lcid_reordered_array[MAX_NUM_LCID] = - { MAX_NUM_LCID, MAX_NUM_LCID, MAX_NUM_LCID, MAX_NUM_LCID, - MAX_NUM_LCID, MAX_NUM_LCID, MAX_NUM_LCID, MAX_NUM_LCID, - MAX_NUM_LCID, - MAX_NUM_LCID, MAX_NUM_LCID - }; - uint8_t pos_next = 0; - uint8_t highest_priority = 16; - uint8_t array_index = 0; - - // Reset All BSR Infos - lcid_bytes_in_buffer[0] = 0; - for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { - // Reset transmission status - lcid_bytes_in_buffer[lcid] = 0; - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = - LCID_EMPTY; - } - - for (lcgid = 0; lcgid < MAX_NUM_LCGID; lcgid++) { - // Reset Buffer Info - UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0; - } - - //Get Buffer Occupancy and fill lcid_reordered_array - for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { - if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) { - lcgid = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]; - - // Store already available data to transmit per Group - if (lcgid < MAX_NUM_LCGID) { - lcgid_buffer_remain[lcgid] += - UE_mac_inst[module_idP]. - scheduling_info.LCID_buffer_remain[lcid]; - } - - rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti, eNB_index, frameP, subframeP, ENB_FLAG_NO, MBMS_FLAG_NO, lcid, 0xFFFF); //TBS is not used in RLC at this step, set a special value for debug - - lcid_bytes_in_buffer[lcid] = rlc_status.bytes_in_buffer; - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, - "[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d subframe %d\n", - module_idP, lcid, lcgid, rlc_status.bytes_in_buffer, - frameP, subframeP); - - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = - LCID_NOT_EMPTY; - //Update BSR_bytes and position in lcid_reordered_array only if Group is defined - if (lcgid < MAX_NUM_LCGID) { - num_lcid_with_data++; - // sum lcid buffer which has same lcgid - UE_mac_inst[module_idP].scheduling_info. - BSR_bytes[lcgid] += rlc_status.bytes_in_buffer; - - //Fill in the array - array_index = 0; - do { - if (UE_mac_inst[module_idP].logicalChannelConfig - [lcid]->ul_SpecificParameters->priority <= - highest_priority) { - //Insert if priority is higher or equal (lower or equal in value) - for (pos_next = num_lcid_with_data - 1; - pos_next > array_index; pos_next--) { - lcid_reordered_array[pos_next] = - lcid_reordered_array[pos_next - 1]; - - } - lcid_reordered_array[array_index] = lcid; - break; - - } - array_index++; - } - while ((array_index < num_lcid_with_data) - && (array_index < MAX_NUM_LCID)); - } + mac_rlc_status_resp_t rlc_status; + boolean_t bsr_regular_triggered = FALSE; + uint8_t lcid; + uint8_t lcgid; + uint8_t num_lcid_with_data = 0; // for LCID with data only if LCGID is defined + uint16_t lcgid_buffer_remain[MAX_NUM_LCGID] = {0,0,0,0}; + int32_t lcid_bytes_in_buffer[MAX_NUM_LCID]; + /* Array for ordering LCID with data per decreasing priority order */ + uint8_t lcid_reordered_array[MAX_NUM_LCID]= + {MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID,MAX_NUM_LCID}; + uint8_t pos_next = 0; + uint8_t highest_priority = 16; + uint8_t array_index = 0; + + // Reset All BSR Infos + lcid_bytes_in_buffer[0] = 0; + for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) + { + // Reset transmission status + lcid_bytes_in_buffer[lcid] = 0; + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; + } + + for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++) + { + // Reset Buffer Info + UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]=0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid]=0; + } + + //Get Buffer Occupancy and fill lcid_reordered_array + for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) + { + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) + { + lcgid = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]; + + // Store already available data to transmit per Group + if (lcgid < MAX_NUM_LCGID) + { + lcgid_buffer_remain[lcgid] += UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]; + } + + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,eNB_index,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, + lcid, + 0xFFFF //TBS is not used in RLC at this step, set a special value for debug +#ifdef Rel14 + ,0, 0 +#endif + ); + + lcid_bytes_in_buffer[lcid] = rlc_status.bytes_in_buffer; + + if (rlc_status.bytes_in_buffer > 0) + { + LOG_D(MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d subframe %d\n", + module_idP, lcid,lcgid,rlc_status.bytes_in_buffer,frameP,subframeP); + + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; + //Update BSR_bytes and position in lcid_reordered_array only if Group is defined + if (lcgid < MAX_NUM_LCGID) + { + num_lcid_with_data ++; + // sum lcid buffer which has same lcgid + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] += rlc_status.bytes_in_buffer; + + //Fill in the array + array_index = 0; + do + { + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->priority <= highest_priority) + { + //Insert if priority is higher or equal (lower or equal in value) + for (pos_next=num_lcid_with_data-1; pos_next > array_index; pos_next--) + { + lcid_reordered_array[pos_next] = lcid_reordered_array[pos_next - 1]; + + } + lcid_reordered_array[array_index] = lcid; + break; + + } + array_index ++; + } + while ((array_index < num_lcid_with_data) && (array_index < MAX_NUM_LCID)); + } } } @@ -3037,3 +3190,164 @@ int get_db_dl_PathlossChange(uint8_t dl_PathlossChange) break; } } + + +SLSS_t *ue_get_slss(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) { + + return((SLSS_t*)NULL); +} + +SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) { + + //UE_MAC_INST *ue = &UE_mac_inst[Mod_id]; + SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch; + // Panos: Ask TTN if we should be calling mac_rrc_data_req_ue() instead of mac_rrc_data_req() now! + /*sldch->payload_length = mac_rrc_data_req(Mod_id, + CC_id, + frame_tx, + SL_DISCOVERY, + 1, + (char*)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0], + 0, + 0, //eNB_indexP + 0);*/ + + sldch->payload_length = mac_rrc_data_req_ue(Mod_id, + CC_id, + frame_tx, + SL_DISCOVERY, + 1, + (uint8_t*)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0], + 0, //eNB_indexP + 0); + + + + if (sldch->payload_length >0 ) { + LOG_I(MAC,"Got %d bytes from RRC for SLDCH @ %p\n",sldch->payload_length,sldch); + return (sldch); + } + else + + return((SLDCH_t*)NULL); +} + + +SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframeP) { + + mac_rlc_status_resp_t rlc_status; //, rlc_status_data; + uint32_t absSF = (frameP*10)+subframeP; + UE_MAC_INST *ue = &UE_mac_inst[module_idP]; + int rvtab[4] = {0,2,3,1}; + int sdu_length; + //uint8_t sl_lcids[2] = {3, 10}; //list of lcids for SL - hardcoded + int i = 0; + + // Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH) + SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch; + + LOG_D(MAC,"Checking SLSCH for absSF %d\n",absSF); + if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period + ue->sltx_active = 0; + + for (i = 0; i < MAX_NUM_LCID; i++){ + if (ue->SL_LCID[i] > 0) { + for (int j = 0; j < ue->numCommFlows; j++){ + if ((ue->sourceL2Id > 0) && (ue->destinationList[j] >0) ){ + rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, + ue->SL_LCID[i], 0xFFFF, ue->sourceL2Id, ue->destinationList[j]); + if (rlc_status.bytes_in_buffer > 2){ + LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer); + // Fill in group id for off-network communications + ue->sltx_active = 1; + //store LCID, destinationL2Id + ue->slsch_lcid = ue->SL_LCID[i]; + ue->destinationL2Id = ue->destinationList[j]; + break; + } + } + } + } + if ( ue->sltx_active == 1) break; + } + } // we're not in the SCCH period + else if (((absSF & 3) == 0 ) && + (ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC + // 10 PRBs, mcs 19 + int TBS = 4584/8; + int req; + + + if (TBS <= rlc_status.bytes_in_buffer) req = TBS; + else req = rlc_status.bytes_in_buffer; + + if (req>0) { + sdu_length = mac_rlc_data_req(module_idP, + 0x1234, + 0, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + ue->slsch_lcid, + req, + (char*)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG)) +#ifdef Rel14 + ,ue->sourceL2Id, + ue->destinationL2Id +#endif + ); + + // Notes: 1. hard-coded to 24-bit destination format for now + if (sdu_length > 0) { + + LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req); + LOG_I(MAC,"sourceL2Id: 0x%08x \n",ue->sourceL2Id); + LOG_I(MAC,"groupL2Id/destinationL2Id: 0x%08x \n",ue->destinationL2Id); + + slsch->payload = (unsigned char*)ue->slsch_pdu.payload; + if (sdu_length < 128) { + slsch->payload++; + SLSCH_SUBHEADER_24_Bit_DST_SHORT *shorth= (SLSCH_SUBHEADER_24_Bit_DST_SHORT *)slsch->payload; + shorth->F = 0; + shorth->L = sdu_length; + shorth->E = 0; + shorth->LCID = ue->slsch_lcid; + shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff; + shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; + shorth->SRC1623 = ue->sourceL2Id & 0x000000ff; + shorth->DST07 = (ue->destinationL2Id >>16) & 0x000000ff; + shorth->DST815 = (ue->destinationL2Id >>8) & 0x000000ff; + shorth->DST1623 = ue->destinationL2Id & 0x000000ff; + shorth->V = 0x1; + } + else { + SLSCH_SUBHEADER_24_Bit_DST_LONG *longh= (SLSCH_SUBHEADER_24_Bit_DST_LONG *)slsch->payload; + longh->F = 1; + longh->L_LSB = sdu_length&0xff; + longh->L_MSB = (sdu_length>>8)&0x7f; + longh->E = 0; + longh->LCID = ue->slsch_lcid; + longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff; + longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; + longh->SRC1623 = ue->sourceL2Id & 0x000000ff; + longh->DST07 = (ue->destinationL2Id >>16) & 0x000000ff; + longh->DST815 = (ue->destinationL2Id>>8) & 0x000000ff; + longh->DST1623 = ue->destinationL2Id & 0x000000ff; + longh->V = 0x1; + } + slsch->rvidx = 0; + slsch->payload_length = TBS; + // fill in SLSCH configuration + return(&ue->slsch); + } + else ue->sltx_active = 0; + } + + } else if ((absSF%40)>3 && ue->sltx_active == 1) { // handle retransmission of SDU + LOG_I(MAC,"SFN.SF %d.%d : retransmission\n",frameP,subframeP); + slsch->rvidx = rvtab[absSF&3]; + return(&ue->slsch); + } + + return(NULL); +} diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 4b85b75ca116bc3b2ca50f151d97c823b327c0ba..942f78cb77649bf77892b9fccb9417d98b676b37 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -36,8 +36,8 @@ #include "pdcp_util.h" #include "pdcp_sequence_manager.h" #include "LAYER2/RLC/rlc.h" -#include "LAYER2/MAC/extern.h" -#include "RRC/LITE/proto.h" +#include "LAYER2/MAC/mac_extern.h" +#include "RRC/LTE/rrc_proto.h" #include "pdcp_primitives.h" #include "OCG.h" #include "OCG_extern.h" @@ -89,6 +89,10 @@ boolean_t pdcp_data_req( const sdu_size_t sdu_buffer_sizeP, unsigned char *const sdu_buffer_pP, const pdcp_transmission_mode_t modeP +#ifdef Rel14 + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id +#endif ) //----------------------------------------------------------------------------- { @@ -172,7 +176,11 @@ boolean_t pdcp_data_req( (unsigned char*)&pdcp_pdu_p->data[0], sdu_buffer_sizeP); #endif - rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP, confirmP, sdu_buffer_sizeP, pdcp_pdu_p); + rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP, confirmP, sdu_buffer_sizeP, pdcp_pdu_p +#ifdef Rel14 + ,NULL, NULL +#endif + ); } else { rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES; LOG_W(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", @@ -384,6 +392,12 @@ boolean_t pdcp_data_req( { proto_agent_send_rlc_data_req(0,cudu->cu[j].du_type, ctxt_pP, srb_flagP, MBMS_FLAG_NO,rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p); } + rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p +#ifdef Rel14 + ,sourceL2Id + ,destinationL2Id +#endif + ); } else if (cudu->cu_balancing == CU_BALANCING_ROUND_ROBIN) @@ -403,7 +417,19 @@ boolean_t pdcp_data_req( else { //It should never get here - rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p); + rlc_status = rlc_data_req(ctxt_pP + , srb_flagP + , MBMS_FLAG_NO + , rb_idP + , muiP + , confirmP + , pdcp_pdu_size + , pdcp_pdu_p + #ifdef Rel14 + ,NULL + ,NULL + #endif + ); } } @@ -446,7 +472,7 @@ boolean_t pdcp_data_req( * so we return TRUE afterwards */ - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ) break; } @@ -833,6 +859,8 @@ pdcp_data_ind( } else { ((pdcp_data_ind_header_t*) new_sdu_p->data)->rb_id = rb_id + (ctxt_pP->module_id * maxDRB); } + ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = ctxt_pP->module_id; + #ifdef DEBUG_PDCP_FIFO_FLUSH_SDU static uint32_t pdcp_inst = 0; ((pdcp_data_ind_header_t*) new_sdu_p->data)->inst = pdcp_inst++; @@ -861,7 +889,7 @@ pdcp_data_ind( * XXX Following two actions are identical, is there a merge error? */ - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ){ break; } @@ -909,10 +937,11 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ // these stats are measured for both eNB and UE on per seond basis for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ - for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ + for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); // tx stats - if (pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ + if (Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && + pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ // unit: bit/s Pdcp_stats_tx_throughput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_tx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; @@ -928,7 +957,8 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; } - if (pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ + if (Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && + pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ // rx stats Pdcp_stats_rx_goodput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_rx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; @@ -965,6 +995,7 @@ pdcp_run ( protocol_ctxt_t ctxt; #endif + if (ctxt_pP->enb_flag) { start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run); @@ -1016,7 +1047,11 @@ pdcp_run ( RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).sdu_size, RRC_DCCH_DATA_REQ (msg_p).sdu_p, - RRC_DCCH_DATA_REQ (msg_p).mode); + RRC_DCCH_DATA_REQ (msg_p).mode +#ifdef Rel14 + , NULL, NULL +#endif + ); if (result != TRUE) LOG_E(PDCP, "PDCP data request failed!\n"); @@ -1111,14 +1146,14 @@ pdcp_run ( void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){ int i, ue_flag=1; //, ret=-1; to be decied later - for (i=0; i < NUMBER_OF_UE_MAX; i++){ + for (i=0; i < MAX_MOBILES_PER_ENB; i++){ if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti) { ue_flag=-1; break; } } if (ue_flag == 1 ){ - for (i=0; i < NUMBER_OF_UE_MAX ; i++){ + for (i=0; i < MAX_MOBILES_PER_ENB ; i++){ if (pdcp_enb[ctxt_pP->module_id].rnti[i] == 0 ){ pdcp_enb[ctxt_pP->module_id].rnti[i]=ctxt_pP->rnti; pdcp_enb[ctxt_pP->module_id].uid[i]=i; @@ -1146,7 +1181,7 @@ pdcp_remove_UE( int i; // check and remove SRBs first - for(int i = 0;i<NUMBER_OF_UE_MAX;i++){ + for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){ if(pdcp_eNB_UE_instance_to_rnti[i] == ctxt_pP->rnti){ pdcp_eNB_UE_instance_to_rnti[i] = NOT_A_RNTI; break; @@ -1167,7 +1202,7 @@ pdcp_remove_UE( (void)h_rc; /* remove gcc warning "set but not used" */ // remove ue for pdcp enb inst - for (i=0; i < NUMBER_OF_UE_MAX; i++) { + for (i=0; i < MAX_MOBILES_PER_ENB; i++) { if (pdcp_enb[ctxt_pP->module_id].rnti[i] == ctxt_pP->rnti ) { LOG_I(PDCP, "remove uid is %d/%d %x\n", i, pdcp_enb[ctxt_pP->module_id].uid[i], @@ -1194,7 +1229,7 @@ rrc_pdcp_config_asn1_req ( uint8_t *const kRRCenc_pP, uint8_t *const kRRCint_pP, uint8_t *const kUPenc_pP -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,PMCH_InfoList_r9_t* const pmch_InfoList_r9_pP #endif ,rb_id_t *const defaultDRB @@ -1221,7 +1256,7 @@ rrc_pdcp_config_asn1_req ( hashtable_rc_t h_rc; hash_key_t key_defaultDRB = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_defaultDRB_rc; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) int i,j; MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL; @@ -1519,7 +1554,7 @@ rrc_pdcp_config_asn1_req ( } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) if (pmch_InfoList_r9_pP != NULL) { for (i=0; i<pmch_InfoList_r9_pP->list.count; i++) { @@ -1604,16 +1639,16 @@ pdcp_config_req_asn1 ( //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; // pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; if( srb_flagP == SRB_FLAG_NO ) { - for(int i = 0;i<NUMBER_OF_UE_MAX;i++){ + for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){ if(pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] == NOT_A_RNTI){ break; } - pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; + pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB; } pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; - pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; + pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB; } - //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % NUMBER_OF_UE_MAX; + //pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB; } else { pdcp_pP->is_ue = TRUE; pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti; @@ -1729,7 +1764,7 @@ pdcp_config_req_asn1 ( memset(pdcp_pP, 0, sizeof(pdcp_t)); break; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) case CONFIG_ACTION_MBMS_ADD: case CONFIG_ACTION_MBMS_MODIFY: @@ -1845,6 +1880,7 @@ rrc_pdcp_config_req ( if (ctxt_pP->enb_flag == ENB_FLAG_NO) { pdcp_p->is_ue = TRUE; + pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti; } else { pdcp_p->is_ue = FALSE; } @@ -1863,9 +1899,9 @@ rrc_pdcp_config_req ( } pdcp_p->first_missing_pdu = -1; - LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n", - PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), - rb_idP); + LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), + rb_idP); break; case CONFIG_ACTION_MODIFY: @@ -1922,10 +1958,10 @@ rrc_pdcp_config_req ( if (ctxt_pP->enb_flag == ENB_FLAG_NO) { pdcp_p->is_ue = TRUE; - + pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id] = ctxt_pP->rnti; } else { pdcp_p->is_ue = FALSE; -} + } pdcp_p->next_pdcp_tx_sn = 0; pdcp_p->next_pdcp_rx_sn = 0; @@ -2049,7 +2085,7 @@ void pdcp_layer_init(void) module_id_t instance; int i,j; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) mbms_session_id_t session_id; mbms_service_id_t service_id; #endif @@ -2060,8 +2096,8 @@ void pdcp_layer_init(void) pdcp_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, pdcp_free); AssertFatal(pdcp_coll_p != NULL, "UNRECOVERABLE error, PDCP hashtable_create failed"); - for (instance = 0; instance < NUMBER_OF_UE_MAX; instance++) { -#if defined(Rel10) || defined(Rel14) + for (instance = 0; instance < MAX_MOBILES_PER_ENB; instance++) { +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) for (service_id = 0; service_id < maxServiceCount; service_id++) { for (session_id = 0; session_id < maxSessionPerPMCH; session_id++) { @@ -2075,7 +2111,7 @@ void pdcp_layer_init(void) for (instance = 0; instance < NUMBER_OF_eNB_MAX; instance++) { -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) for (service_id = 0; service_id < maxServiceCount; service_id++) { for (session_id = 0; session_id < maxSessionPerPMCH; session_id++) { @@ -2098,7 +2134,7 @@ void pdcp_layer_init(void) memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms)); memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms)); for (i =0; i< MAX_NUM_CCs ; i ++){ - for (j=0; j< NUMBER_OF_UE_MAX;j++){ + for (j=0; j< MAX_MOBILES_PER_ENB;j++){ Pdcp_stats_tx_window_ms[i][j]=100; Pdcp_stats_rx_window_ms[i][j]=100; } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 7c8f2dd033571f3faac8d484ea99be494b020a81..6fd0621644423cd7d054f133339bfd1398bb1175 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -67,14 +67,14 @@ #include "UTIL/LISTS/list.h" #endif //NON_ACCESS_STRATUM //----------------------------------------------------------------------------- -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "COMMON/platform_constants.h" #include "COMMON/platform_types.h" #include "DRB-ToAddMod.h" #include "DRB-ToAddModList.h" #include "SRB-ToAddMod.h" #include "SRB-ToAddModList.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "MBMS-SessionInfoList-r9.h" #include "PMCH-InfoList-r9.h" #endif @@ -94,34 +94,34 @@ extern int pdcp_instance_cnt; int init_pdcp_thread(void); void cleanup_pdcp_thread(void); -public_pdcp(uint32_t Pdcp_stats_tx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_throughput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); - -public_pdcp(uint32_t Pdcp_stats_rx_window_ms[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_bytes_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_bytes_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_goodput_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); -public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][NUMBER_OF_UE_MAX][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_window_ms[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_bytes_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_sn[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_throughput_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_aiat_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_tx_iat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); + +public_pdcp(uint32_t Pdcp_stats_rx_window_ms[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]); +public_pdcp(uint32_t Pdcp_stats_rx[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_bytes_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_sn[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_goodput_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_aiat_tmp_w[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_iat[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); +public_pdcp(uint32_t Pdcp_stats_rx_outoforder[MAX_NUM_CCs][MAX_MOBILES_PER_ENB][NB_RB_MAX]); public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const ctxt_pP)); @@ -131,8 +131,8 @@ public_pdcp(void pdcp_update_perioidical_stats(const protocol_ctxt_t* const ctx //public_pdcp(uint64_t *pdcp_size_packet); typedef struct pdcp_enb_s { // used for eNB stats generation - uint16_t uid[NUMBER_OF_UE_MAX]; - rnti_t rnti[NUMBER_OF_UE_MAX]; + uint16_t uid[MAX_MOBILES_PER_ENB]; + rnti_t rnti[MAX_MOBILES_PER_ENB]; uint16_t num_ues; uint64_t sfn; @@ -223,7 +223,7 @@ typedef struct pdcp_s { } pdcp_t; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) typedef struct pdcp_mbms_s { boolean_t instanciated_instance; rb_id_t rb_id; @@ -259,7 +259,12 @@ public_pdcp(boolean_t pdcp_data_req( const confirm_t confirmP, \ const sdu_size_t sdu_buffer_size, unsigned char* const sdu_buffer, - const pdcp_transmission_mode_t mode)); + const pdcp_transmission_mode_t mode +#ifdef Rel14 + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id +#endif + )); /*! \fn boolean_t pdcp_data_ind(const protocol_ctxt_t* const, srb_flag_t, MBMS_flag_t, rb_id_t, sdu_size_t, mem_block_t*, boolean_t) * \brief This functions handles data transfer indications coming from RLC @@ -323,7 +328,7 @@ public_pdcp( uint8_t *const kRRCenc, uint8_t *const kRRCint, uint8_t *const kUPenc -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,PMCH_InfoList_r9_t *pmch_InfoList_r9 #endif ,rb_id_t *const defaultDRB @@ -432,6 +437,10 @@ typedef struct pdcp_data_req_header_s { sdu_size_t data_size; signed int inst; ip_traffic_type_t traffic_type; +#ifdef Rel14 + uint32_t sourceL2Id; + uint32_t destinationL2Id; +#endif } pdcp_data_req_header_t; typedef struct pdcp_data_ind_header_s { @@ -439,6 +448,10 @@ typedef struct pdcp_data_ind_header_s { sdu_size_t data_size; signed int inst; ip_traffic_type_t dummy_traffic_type; +#ifdef Rel14 + uint32_t sourceL2Id; + uint32_t destinationL2Id; +#endif } pdcp_data_ind_header_t; struct pdcp_netlink_element_s { @@ -448,6 +461,43 @@ struct pdcp_netlink_element_s { uint8_t *data; }; +//TTN for D2D (PC5S) +#ifdef Rel14 +#define PDCP_SOCKET_PORT_NO 9999 //temporary value +#define PC5_SIGNALLING_PAYLOAD_SIZE 100 //should be updated with a correct value +int pdcp_pc5_sockfd; +struct sockaddr_in prose_ctrl_addr; +struct sockaddr_in prose_pdcp_addr; +struct sockaddr_in pdcp_sin; +void pdcp_pc5_socket_init(void); + +typedef struct { + rb_id_t rb_id; + sdu_size_t data_size; + signed int inst; + ip_traffic_type_t traffic_type; + uint32_t sourceL2Id; + uint32_t destinationL2Id; +} __attribute__((__packed__)) pc5s_header_t; + +//new PC5S-message +typedef struct { + unsigned char bytes[PC5_SIGNALLING_PAYLOAD_SIZE]; +} __attribute__((__packed__)) PC5SignallingMessage ; + +//example of PC5-S messages +typedef struct { + pc5s_header_t pc5s_header; + union { + uint8_t status; + PC5SignallingMessage pc5_signalling_message; + } pc5sPrimitive; +} __attribute__((__packed__)) sidelink_pc5s_element; + + +#endif + + #if 0 /* * Missing PDU information struct, a copy of this will be enqueued @@ -482,19 +532,19 @@ typedef struct pdcp_missing_pdu_info_t { protected_pdcp(signed int pdcp_2_nas_irq;) -public_pdcp(pdcp_stats_t UE_pdcp_stats[NUMBER_OF_UE_MAX];) +public_pdcp(pdcp_stats_t UE_pdcp_stats[MAX_MOBILES_PER_ENB];) public_pdcp(pdcp_stats_t eNB_pdcp_stats[NUMBER_OF_eNB_MAX];) -//protected_pdcp(pdcp_t pdcp_array_srb_ue[NUMBER_OF_UE_MAX][2];) -//protected_pdcp(pdcp_t pdcp_array_drb_ue[NUMBER_OF_UE_MAX][maxDRB];) -//public_pdcp(pdcp_t pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][2];) -//protected_pdcp(pdcp_t pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][maxDRB];) +//protected_pdcp(pdcp_t pdcp_array_srb_ue[MAX_MOBILES_PER_ENB][2];) +//protected_pdcp(pdcp_t pdcp_array_drb_ue[MAX_MOBILES_PER_ENB][maxDRB];) +//public_pdcp(pdcp_t pdcp_array_srb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][2];) +//protected_pdcp(pdcp_t pdcp_array_drb_eNB[NUMBER_OF_eNB_MAX][MAX_MOBILES_PER_ENB][maxDRB];) // for UE code conly -protected_pdcp(rnti_t pdcp_UE_UE_module_id_to_rnti[NUMBER_OF_UE_MAX];) -protected_pdcp(rnti_t pdcp_eNB_UE_instance_to_rnti[NUMBER_OF_UE_MAX];) // for noS1 mode +protected_pdcp(rnti_t pdcp_UE_UE_module_id_to_rnti[MAX_MOBILES_PER_ENB];) +protected_pdcp(rnti_t pdcp_eNB_UE_instance_to_rnti[MAX_MOBILES_PER_ENB];) // for noS1 mode protected_pdcp(unsigned int pdcp_eNB_UE_instance_to_rnti_index;) -#if defined(Rel10) || defined(Rel14) -public_pdcp(pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) +public_pdcp(pdcp_mbms_t pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h public_pdcp(pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h #endif protected_pdcp(sdu_size_t pdcp_output_sdu_bytes_to_write;) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index a8e7e235afac6d772eb5562555049389f7273af1..321bcdbaa231333306075eb35d60cec76cf6fcd0 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -46,10 +46,10 @@ extern int otg_enabled; #define rtf_put write #define rtf_get read -#include "../MAC/extern.h" +#include "../MAC/mac_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "NETWORK_DRIVER/LITE/constant.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" +//#include "SIMULATION/ETH_TRANSPORT/extern.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OCG/OCG_extern.h" #include "UTIL/LOG/log.h" @@ -58,6 +58,7 @@ extern int otg_enabled; #include "UTIL/LOG/vcd_signal_dumper.h" #include "platform_constants.h" #include "msc.h" +#include "pdcp.h" #include "assertions.h" @@ -72,7 +73,11 @@ extern struct nlmsghdr *nas_nlh_tx; extern struct nlmsghdr *nas_nlh_rx; extern struct iovec nas_iov_tx; extern struct iovec nas_iov_rx; +#ifdef UE_NAS_USE_TUN +extern int nas_sock_fd[MAX_MOBILES_PER_ENB]; +#else extern int nas_sock_fd; +#endif extern struct msghdr nas_msg_tx; extern struct msghdr nas_msg_rx; @@ -108,129 +113,163 @@ pdcp_data_req_header_t pdcp_read_header_g; //----------------------------------------------------------------------------- int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) { - //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- -//#if defined(PDCP_USE_NETLINK) && defined(LINUX) - int ret = 0; -//#endif + //#if defined(PDCP_USE_NETLINK) && defined(LINUX) + int ret = 0; + //#endif #ifdef DEBUG_PDCP_FIFO_FLUSH_SDU #define THREAD_NAME_LEN 16 - static char threadname[THREAD_NAME_LEN]; - ret = pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN); - if (ret != 0) - { - perror("pthread_getname_np : "); - exit_fun("Error getting thread name"); - } + static char threadname[THREAD_NAME_LEN]; + ret = pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN); + if (ret != 0) + { + perror("pthread_getname_np : "); + exit_fun("Error getting thread name"); + } #undef THREAD_NAME_LEN #endif #ifdef PDCP_SDU_FLUSH_LOCK - ret = pthread_mutex_trylock(&mtex); - if (ret == EBUSY) { + ret = pthread_mutex_trylock(&mtex); + if (ret == EBUSY) { #ifdef DEBUG_PDCP_FIFO_FLUSH_SDU - LOG_W(PDCP, "[%s] at SFN/SF=%d/%d wait for PDCP FIFO to be unlocked\n", - threadname, ctxt_pP->frame, ctxt_pP->subframe); + LOG_W(PDCP, "[%s] at SFN/SF=%d/%d wait for PDCP FIFO to be unlocked\n", + threadname, ctxt_pP->frame, ctxt_pP->subframe); #endif - if (pthread_mutex_lock(&mtex)) { - exit_fun("PDCP_SDU_FLUSH_LOCK lock error!"); - } + if (pthread_mutex_lock(&mtex)) { + exit_fun("PDCP_SDU_FLUSH_LOCK lock error!"); + } #ifdef DEBUG_PDCP_FIFO_FLUSH_SDU - LOG_I(PDCP, "[%s] at SFN/SF=%d/%d PDCP FIFO is unlocked\n", - threadname, ctxt_pP->frame, ctxt_pP->subframe); + LOG_I(PDCP, "[%s] at SFN/SF=%d/%d PDCP FIFO is unlocked\n", + threadname, ctxt_pP->frame, ctxt_pP->subframe); #endif - } else if (ret != 0) { - exit_fun("PDCP_SDU_FLUSH_LOCK trylock error!"); - } + } else if (ret != 0) { + exit_fun("PDCP_SDU_FLUSH_LOCK trylock error!"); + } #endif - mem_block_t *sdu_p = list_get_head (&pdcp_sdu_list); - int bytes_wrote = 0; - int pdcp_nb_sdu_sent = 0; - uint8_t cont = 1; + mem_block_t *sdu_p = list_get_head (&pdcp_sdu_list); + int bytes_wrote = 0; + int pdcp_nb_sdu_sent = 0; + uint8_t cont = 1; #if defined(LINK_ENB_PDCP_TO_GTPV1U) - //MessageDef *message_p = NULL; + //MessageDef *message_p = NULL; #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 1 ); - while (sdu_p && cont) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 1 ); + while (sdu_p && cont) { #ifdef DEBUG_PDCP_FIFO_FLUSH_SDU - LOG_D(PDCP, "[%s] SFN/SF=%d/%d inst=%d size=%d\n", - threadname, ctxt_pP->frame, ctxt_pP->subframe, - ((pdcp_data_ind_header_t*) sdu_p->data)->inst, - ((pdcp_data_ind_header_t *) sdu_p->data)->data_size); + LOG_D(PDCP, "[%s] SFN/SF=%d/%d inst=%d size=%d\n", + threadname, ctxt_pP->frame, ctxt_pP->subframe, + ((pdcp_data_ind_header_t*) sdu_p->data)->inst, + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size); +#else + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; #endif #if defined(LINK_ENB_PDCP_TO_GTPV1U) - if (ctxt_pP->enb_flag) { - AssertFatal(0, "Now execution should not go here"); - LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size); - gtpv1u_new_data_req( - ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p, - ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4, - &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]), - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, - 0); - - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu_p = list_get_head (&pdcp_sdu_list); - LOG_D(OTG,"After GTPV1U\n"); - continue; // loop again - } + if (ctxt_pP->enb_flag) { + AssertFatal(0, "Now execution should not go here"); + LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size); + gtpv1u_new_data_req( + ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p, + ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID + ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4, + &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]), + ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, + 0); + + list_remove_head (&pdcp_sdu_list); + free_mem_block (sdu_p, __func__); + cont = 1; + pdcp_nb_sdu_sent += 1; + sdu_p = list_get_head (&pdcp_sdu_list); + LOG_D(OTG,"After GTPV1U\n"); + continue; // loop again + } #endif /* defined(ENABLE_USE_MME) */ #ifdef PDCP_DEBUG - LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n", - ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); + LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n", + ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, + ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); #endif //PDCP_DEBUG - cont = 0; + cont = 0; - if (!pdcp_output_sdu_bytes_to_write) { - if (!pdcp_output_header_bytes_to_write) { - pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t); +//TTN - for D2D (PC5S) +#ifdef Rel14 + sidelink_pc5s_element *sl_pc5s_msg_recv = NULL; + char send_buf[BUFSIZE]; + int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; + + if (rb_id == 10) { //hardcoded for PC5-Signaling + //if ((rb_id == 28) | (rb_id == 29) | (rb_id == 30)) + +#ifdef PDCP_DEBUG + sl_pc5s_msg_recv = calloc(1, sizeof(sidelink_pc5s_element)); + memcpy((void*)sl_pc5s_msg_recv, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element)); + LOG_D(PDCP,"Received PC5S message, header traffic_type: %d)\n", sl_pc5s_msg_recv->pc5s_header.traffic_type); + LOG_D(PDCP,"Received PC5S message, header rb_id: %d)\n", sl_pc5s_msg_recv->pc5s_header.rb_id); + LOG_D(PDCP,"Received PC5S message, header data_size: %d)\n", sl_pc5s_msg_recv->pc5s_header.data_size); + LOG_D(PDCP,"Received PC5S message, header inst: %d)\n", sl_pc5s_msg_recv->pc5s_header.inst); + LOG_D(PDCP,"Received PC5-S message, sourceL2Id: 0x%08x\n)\n", sl_pc5s_msg_recv->pc5s_header.sourceL2Id); + LOG_D(PDCP,"Received PC5-S message, destinationL1Id: 0x%08x\n)\n", sl_pc5s_msg_recv->pc5s_header.destinationL2Id); + free(sl_pc5s_msg_recv); +#endif + memset(send_buf, 0, BUFSIZE); + memcpy((void *)send_buf, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element)); + + int prose_addr_len = sizeof(prose_pdcp_addr); + int n = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); + if (n < 0) { + LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } } +#endif + + if (!pdcp_output_sdu_bytes_to_write) { + if (!pdcp_output_header_bytes_to_write) { + pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t); + } #ifdef PDCP_USE_RT_FIFO - bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, - &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), - pdcp_output_header_bytes_to_write); + bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, + &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), + pdcp_output_header_bytes_to_write); #else #ifdef PDCP_USE_NETLINK #ifdef LINUX - memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), - pdcp_output_header_bytes_to_write); - nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write; + memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), + pdcp_output_header_bytes_to_write); + nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write; #endif //LINUX #endif //PDCP_USE_NETLINK - bytes_wrote = pdcp_output_header_bytes_to_write; + bytes_wrote = pdcp_output_header_bytes_to_write; #endif //PDCP_USE_RT_FIFO #ifdef PDCP_DEBUG - LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n", - ctxt_pP->frame, - bytes_wrote); + LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n", + ctxt_pP->frame, + bytes_wrote); #endif //PDCP_DEBUG - if (bytes_wrote > 0) { - pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote; + if (bytes_wrote > 0) { + pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote; - if (!pdcp_output_header_bytes_to_write) { // continue with sdu - pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; - AssertFatal(pdcp_output_sdu_bytes_to_write >= 0, "invalid data_size!"); + if (!pdcp_output_header_bytes_to_write) { // continue with sdu + pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; + AssertFatal(pdcp_output_sdu_bytes_to_write >= 0, "invalid data_size!"); #ifdef PDCP_USE_RT_FIFO - bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); + bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); #else #ifdef PDCP_USE_NETLINK @@ -239,7 +278,11 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_SIZE, pdcp_output_sdu_bytes_to_write); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 1 ); +#ifdef UE_NAS_USE_TUN + ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); +#else ret = sendmsg(nas_sock_fd,&nas_msg_tx,0); +#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 0 ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_ERR, ret ); @@ -270,288 +313,616 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) #endif // LINUX #endif //PDCP_USE_NETLINK - bytes_wrote= pdcp_output_sdu_bytes_to_write; + bytes_wrote= pdcp_output_sdu_bytes_to_write; #endif // PDCP_USE_RT_FIFO #ifdef PDCP_DEBUG - LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n", - ctxt_pP->frame, - ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, - bytes_wrote, - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); + LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n", + ctxt_pP->frame, + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, + bytes_wrote, + ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); #endif //PDCP_DEBUG - if (bytes_wrote > 0) { - pdcp_output_sdu_bytes_to_write -= bytes_wrote; - - if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU - // LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP); - LOG_D(PDCP, - "[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n", - ctxt_pP->frame, - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id, - ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, - ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, - ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); - - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu_p = list_get_head (&pdcp_sdu_list); + if (bytes_wrote > 0) { + pdcp_output_sdu_bytes_to_write -= bytes_wrote; + + if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU + // LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP); + LOG_D(PDCP, + "[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n", + ctxt_pP->frame, + ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id, + ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, + ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); + + list_remove_head (&pdcp_sdu_list); + free_mem_block (sdu_p, __func__); + cont = 1; + pdcp_nb_sdu_sent += 1; + sdu_p = list_get_head (&pdcp_sdu_list); + } else { + LOG_D(PDCP, "1 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write); + AssertFatal(pdcp_output_sdu_bytes_to_write > 0, "pdcp_output_sdu_bytes_to_write cannot be negative!"); + } + } else { + LOG_W(PDCP, "2: RADIO->IP SEND SDU CONGESTION!\n"); + } } else { - LOG_D(PDCP, "1 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write); - AssertFatal(pdcp_output_sdu_bytes_to_write > 0, "pdcp_output_sdu_bytes_to_write cannot be negative!"); + LOG_W(PDCP, "3: RADIO->IP SEND SDU CONGESTION!\n"); } - } else { - LOG_W(PDCP, "2: RADIO->IP SEND SDU CONGESTION!\n"); - } - } else { - LOG_W(PDCP, "3: RADIO->IP SEND SDU CONGESTION!\n"); - } + } else { + LOG_D(PDCP, "4 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote); + } } else { - LOG_D(PDCP, "4 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote); - } - } else { - // continue writing sdu + // continue writing sdu #ifdef PDCP_USE_RT_FIFO - bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, - (uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])), - pdcp_output_sdu_bytes_to_write); + bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, + (uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])), + pdcp_output_sdu_bytes_to_write); #else // PDCP_USE_RT_FIFO - bytes_wrote = pdcp_output_sdu_bytes_to_write; + bytes_wrote = pdcp_output_sdu_bytes_to_write; #endif // PDCP_USE_RT_FIFO + LOG_D(PDCP, "THINH 2 bytes_wrote = %d\n", bytes_wrote); - if (bytes_wrote > 0) { - pdcp_output_sdu_bytes_to_write -= bytes_wrote; - - if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU - //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n"); - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu_p = list_get_head (&pdcp_sdu_list); - // LOG_D(PDCP, "rb sent a sdu from rab\n"); - } else { - LOG_D(PDCP, "5 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write); - } - } else { - LOG_D(PDCP, "6 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote); + if (bytes_wrote > 0) { + pdcp_output_sdu_bytes_to_write -= bytes_wrote; + + if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU + //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n"); + list_remove_head (&pdcp_sdu_list); + free_mem_block (sdu_p, __func__); + cont = 1; + pdcp_nb_sdu_sent += 1; + sdu_p = list_get_head (&pdcp_sdu_list); + // LOG_D(PDCP, "rb sent a sdu from rab\n"); + } else { + LOG_D(PDCP, "5 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write); + } + } else { + LOG_D(PDCP, "6 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote); + } } - } - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 0 ); + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 0 ); #ifdef PDCP_USE_RT_FIFO - if ((pdcp_nb_sdu_sent)) { - if ((pdcp_2_nas_irq > 0)) { + if ((pdcp_nb_sdu_sent)) { + if ((pdcp_2_nas_irq > 0)) { #ifdef PDCP_DEBUG - LOG_D(PDCP, "Frame %d : Trigger NAS RX interrupt\n", - ctxt_pP->frame); + LOG_D(PDCP, "Frame %d : Trigger NAS RX interrupt\n", + ctxt_pP->frame); #endif //PDCP_DEBUG - rt_pend_linux_srq (pdcp_2_nas_irq); + rt_pend_linux_srq (pdcp_2_nas_irq); - } else { - LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n", - ctxt_pP->frame, - pdcp_2_nas_irq); - } - } + } else { + LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n", + ctxt_pP->frame, + pdcp_2_nas_irq); + } + } #endif //PDCP_USE_RT_FIFO #ifdef PDCP_SDU_FLUSH_LOCK - if (pthread_mutex_unlock(&mtex)) exit_fun("PDCP_SDU_FLUSH_LOCK unlock error!"); + if (pthread_mutex_unlock(&mtex)) exit_fun("PDCP_SDU_FLUSH_LOCK unlock error!"); #endif - return pdcp_nb_sdu_sent; + return pdcp_nb_sdu_sent; } //----------------------------------------------------------------------------- int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) { -#ifdef PDCP_USE_NETLINK - protocol_ctxt_t ctxt_cpy = *ctxt_pP; - protocol_ctxt_t ctxt; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - struct pdcp_netlink_element_s* data_p = NULL; - /* avoid gcc warnings */ - (void)data_p; - module_id_t ue_id = 0; - pdcp_t* pdcp_p = NULL; -# if defined(PDCP_USE_NETLINK_QUEUES) - rb_id_t rab_id = 0; +#ifdef UE_NAS_USE_TUN + protocol_ctxt_t ctxt = *ctxt_pP; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + pdcp_t* pdcp_p = NULL; + int len; + rb_id_t rab_id = DEFAULT_RAB_ID; + + do { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); + len = read(nas_sock_fd[ctxt_pP->module_id], &nl_rx_buf, NL_MAX_PAYLOAD); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); - pdcp_transmission_mode_t pdcp_mode = PDCP_TRANSMISSION_MODE_UNKNOWN; + if (len<=0) continue; + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + if (h_rc == HASH_TABLE_OK) { + LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", + ctxt.frame, ctxt.instance, len, rab_id); + + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, + ctxt.rnti, rab_id); + MSC_LOG_RX_MESSAGE((ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt.instance, rab_id, rab_id, len); + + pdcp_data_req(&ctxt, SRB_FLAG_NO, rab_id, RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, len, (unsigned char *)nl_rx_buf, + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + , NULL, NULL +#endif + ); + } else { + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt.instance, rab_id, rab_id, len); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, + ctxt.rnti, rab_id, key); + } + } while (len > 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); + return len; +#else /* UE_NAS_USE_TUN */ - while (pdcp_netlink_dequeue_element(ctxt_pP, &data_p) != 0) { - DevAssert(data_p != NULL); - rab_id = data_p->pdcp_read_header.rb_id % maxDRB; - // ctxt_pP->rnti is NOT_A_RNTI - ctxt_cpy.rnti = pdcp_module_id_to_rnti[ctxt_cpy.module_id][data_p->pdcp_read_header.inst]; - key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_cpy.rnti, ctxt_pP->enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); +#ifdef PDCP_USE_NETLINK + protocol_ctxt_t ctxt_cpy = *ctxt_pP; + protocol_ctxt_t ctxt; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + struct pdcp_netlink_element_s* data_p = NULL; + /* avoid gcc warnings */ + (void)data_p; + module_id_t ue_id = 0; + pdcp_t* pdcp_p = NULL; + +//TTN for D2D (PC5S) +#ifdef Rel14 + int prose_addr_len; + char send_buf[BUFSIZE], receive_buf[BUFSIZE]; + // Panos: Remove the following definitions due to warnings of unused variables. + //int optval; + int bytes_received; + sidelink_pc5s_element *sl_pc5s_msg_recv = NULL; + sidelink_pc5s_element *sl_pc5s_msg_send = NULL; + //uint32_t sourceL2Id; + //uint32_t groupL2Id; + //module_id_t module_id = 0; + pc5s_header_t *pc5s_header; +#endif - if (h_rc != HASH_TABLE_OK) { - LOG_W(PDCP, PROTOCOL_CTXT_FMT" Dropped IP PACKET cause no PDCP instanciated\n", - PROTOCOL_CTXT_ARGS(ctxt_pP)); - free(data_p->data); - free(data_p); - data_p = NULL; - continue; - } +# if defined(PDCP_USE_NETLINK_QUEUES) + rb_id_t rab_id = 0; + + pdcp_transmission_mode_t pdcp_mode = PDCP_TRANSMISSION_MODE_UNKNOWN; + + + while (pdcp_netlink_dequeue_element(ctxt_pP, &data_p) != 0) { + DevAssert(data_p != NULL); + rab_id = data_p->pdcp_read_header.rb_id % maxDRB; + // ctxt_pP->rnti is NOT_A_RNTI + ctxt_cpy.rnti = pdcp_module_id_to_rnti[ctxt_cpy.module_id][data_p->pdcp_read_header.inst]; + key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_cpy.rnti, ctxt_pP->enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + + if (h_rc != HASH_TABLE_OK) { + LOG_W(PDCP, PROTOCOL_CTXT_FMT" Dropped IP PACKET cause no PDCP instanciated\n", + PROTOCOL_CTXT_ARGS(ctxt_pP)); + free(data_p->data); + free(data_p); + data_p = NULL; + continue; + } - CHECK_CTXT_ARGS(&ctxt_cpy); + CHECK_CTXT_ARGS(&ctxt_cpy); - AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); + AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); - if (rab_id != 0) { - LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " - "/ %d Bytes --->][PDCP][MOD %u][RB %u]\n", - ctxt_cpy.frame, - (ctxt_cpy.enb_flag) ? "eNB" : "UE", - data_p->pdcp_read_header.inst, - data_p->pdcp_read_header.rb_id, - data_p->pdcp_read_header.data_size, - ctxt_cpy.module_id, - rab_id); + if (rab_id != 0) { + LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " + "/ %d Bytes --->][PDCP][MOD %u][RB %u]\n", + ctxt_cpy.frame, + (ctxt_cpy.enb_flag) ? "eNB" : "UE", + data_p->pdcp_read_header.inst, + data_p->pdcp_read_header.rb_id, + data_p->pdcp_read_header.data_size, + ctxt_cpy.module_id, + rab_id); #ifdef OAI_NW_DRIVER_TYPE_ETHERNET - if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_MULTICAST) /*TRAFFIC_IPV6_TYPE_MULTICAST */ || - (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_MULTICAST) /*TRAFFIC_IPV4_TYPE_MULTICAST */ || - (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_BROADCAST) /*TRAFFIC_IPV4_TYPE_BROADCAST */ ) { -#if defined(Rel10) || defined(Rel14) - PDCP_TRANSMISSION_MODE_TRANSPARENT; + if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_MULTICAST) /*TRAFFIC_IPV6_TYPE_MULTICAST */ || + (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_MULTICAST) /*TRAFFIC_IPV4_TYPE_MULTICAST */ || + (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_BROADCAST) /*TRAFFIC_IPV4_TYPE_BROADCAST */ ) { +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + PDCP_TRANSMISSION_MODE_TRANSPARENT; #else - pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; + pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; #endif - } else if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_UNICAST) /* TRAFFIC_IPV6_TYPE_UNICAST */ || - (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_UNICAST) /*TRAFFIC_IPV4_TYPE_UNICAST*/ ) { - pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; - } else { - pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; - LOG_W(PDCP,"unknown IP traffic type \n"); - } + } else if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_UNICAST) /* TRAFFIC_IPV6_TYPE_UNICAST */ || + (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_UNICAST) /*TRAFFIC_IPV4_TYPE_UNICAST*/ ) { + pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; + } else { + pdcp_mode= PDCP_TRANSMISSION_MODE_DATA; + LOG_W(PDCP,"unknown IP traffic type \n"); + } #else // OAI_NW_DRIVER_TYPE_ETHERNET NASMESH driver does not curreenlty support multicast traffic - pdcp_mode = PDCP_TRANSMISSION_MODE_DATA; -#endif - pdcp_data_req(&ctxt_cpy, - SRB_FLAG_NO, - rab_id % maxDRB, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data_p->pdcp_read_header.data_size, - data_p->data, - pdcp_mode); - } else if (ctxt_cpy.enb_flag) { - /* rb_id = 0, thus interpreated as broadcast and transported as - * multiple unicast is a broadcast packet, we have to send this - * packet on all default RABS of all connected UEs - */ - LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID first_ue_local %u nb_ue_local %u\n", oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local); - - for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { - if (pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { - LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID UE %d\n", ue_id); - ctxt.module_id = ctxt_cpy.module_id; - ctxt.rnti = ctxt_cpy.pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ctxt_cpy.enb_flag; - - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data_p->pdcp_read_header.data_size, - data_p->data, - PDCP_TRANSMISSION_MODE_DATA); - } + pdcp_mode = PDCP_TRANSMISSION_MODE_DATA; +#endif + pdcp_data_req(&ctxt_cpy, + SRB_FLAG_NO, + rab_id % maxDRB, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + data_p->pdcp_read_header.data_size, + data_p->data, + pdcp_mode +#ifdef Rel14 + ,NULL, NULL +#endif + ); + } else if (ctxt_cpy.enb_flag) { + /* rb_id = 0, thus interpreated as broadcast and transported as + * multiple unicast is a broadcast packet, we have to send this + * packet on all default RABS of all connected UEs + */ + LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID first_ue_local %u nb_ue_local %u\n", oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local); + + for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { + if (pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { + LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID UE %d\n", ue_id); + ctxt.module_id = ctxt_cpy.module_id; + ctxt.rnti = ctxt_cpy.pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; + + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + data_p->pdcp_read_header.data_size, + data_p->data, + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,NULL, NULL +#endif + ); + } + } + } else { + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + pdcp_data_req( + &ctxt_cpy, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + data_p->pdcp_read_header.data_size, + data_p->data, + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,NULL, NULL +#endif + ); } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - pdcp_data_req( - &ctxt_cpy, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data_p->pdcp_read_header.data_size, - data_p->data, - PDCP_TRANSMISSION_MODE_DATA); - } - free(data_p->data); - free(data_p); - data_p = NULL; - } + free(data_p->data); + free(data_p); + data_p = NULL; + } - return 0; + return 0; # else /* PDCP_USE_NETLINK_QUEUES*/ - int len = 1; - int msg_len; - rb_id_t rab_id = 0; - int rlc_data_req_flag = 3; - - while ((len > 0) && (rlc_data_req_flag !=0)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); - len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); + int len = 1; + int msg_len; + rb_id_t rab_id = 0; + int rlc_data_req_flag = 3; + + +//TTN for D2D (PC5S) +#ifdef Rel14 + prose_addr_len = sizeof(prose_pdcp_addr); + // receive a message from ProSe App + memset(receive_buf, 0, BUFSIZE); + bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0, + (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len); + // if (bytes_received < 0){ + // LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n"); + // exit(EXIT_FAILURE); + // } + if (bytes_received > 0) { + pc5s_header = calloc(1, sizeof(pc5s_header_t)); + memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t)); + + if (pc5s_header->traffic_type == TRAFFIC_PC5S_SESSION_INIT){ + //send reply to ProSe app + LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n"); + memset(send_buf, 0, BUFSIZE); + sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element)); + sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT; + sl_pc5s_msg_send->pc5sPrimitive.status = 1; + + memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element)); + int prose_addr_len = sizeof(prose_pdcp_addr); + int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); + if (bytes_sent < 0) { + LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } + } else if (pc5s_header->traffic_type == TRAFFIC_PC5S_SIGNALLING) { //if containing PC5-S message -> send to other UE + LOG_D(PDCP,"Received PC5-S message ... send to the other UE\n"); +#ifdef PDCP_DEBUG + LOG_D(PDCP,"Received PC5-S message, traffic_type: %d)\n", pc5s_header->traffic_type); + LOG_D(PDCP,"Received PC5-S message, rbid: %d)\n", pc5s_header->rb_id); + LOG_D(PDCP,"Received PC5-S message, data_size: %d)\n", pc5s_header->data_size); + LOG_D(PDCP,"Received PC5-S message, inst: %d)\n", pc5s_header->inst); + LOG_D(PDCP,"Received PC5-S message,sourceL2Id: 0x%08x\n)\n", pc5s_header->sourceL2Id); + LOG_D(PDCP,"Received PC5-S message,destinationL1Id: 0x%08x\n)\n", pc5s_header->destinationL2Id); - if (len<=0) { - // nothing in pdcp NAS socket - //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); - } else { - - msg_len = len; - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; - NLMSG_OK (nas_nlh_rx, msg_len); - nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, msg_len)) { - - if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); - //return; - } - - if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); - } - - if (pdcp_read_state_g == 0) { - if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { - pdcp_read_state_g = 1; //get - memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d\n", - pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size); - } else { - LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", - nas_nlh_rx->nlmsg_len); - } - } else { - pdcp_read_state_g = 0; - // print_active_requests() +#endif + +#ifdef OAI_EMU + + // overwrite function input parameters, because only one netlink socket for all instances + if (pc5s_header->inst < oai_emulation.info.nb_enb_local) { + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ENB_FLAG_YES; + ctxt.module_id = pc5s_header.inst + oai_emulation.info.first_enb_local; + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pc5s_header->rb_id / maxDRB + oai_emulation.info.first_ue_local]; + rab_id = pc5s_header->rb_id % maxDRB; + } else { + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ENB_FLAG_NO; + ctxt.module_id = pc5s_header->inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; + rab_id = pc5s_header->rb_id % maxDRB; + } + + CHECK_CTXT_ARGS(&ctxt); + AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); + /*LGpdcp_read_header.inst = (pc5s_header.inst >= oai_emulation.info.nb_enb_local) ? \ + pc5s_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : + pc5s_header.inst + oai_emulation.info.first_enb_local;*/ +#else // OAI_EMU + /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ + // pc5s_header.inst = 0; + //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; + + LOG_I(PDCP, "[PDCP] pc5s_header->rb_id = %d\n", pc5s_header->rb_id); + + if (ctxt_cpy.enb_flag) { + ctxt.module_id = 0; + rab_id = pc5s_header->rb_id % maxDRB; + ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index]; + } else { + ctxt.module_id = 0; + rab_id = pc5s_header->rb_id % maxDRB; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; + } +#endif + + //UE + if (!ctxt.enb_flag) { + if (rab_id != 0) { + if (rab_id == UE_IP_DEFAULT_RAB_ID) { + LOG_I(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } else { + rab_id = rab_id % maxDRB; + LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } + + if (h_rc == HASH_TABLE_OK) { + rab_id = pdcp_p->rb_id; #ifdef PDCP_DEBUG - LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n", - nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); + LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", + ctxt.frame, + pc5s_header->inst, + bytes_received, + pc5s_header->rb_id); + + LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); +#endif + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header.inst, + pc5s_header.rb_id, + rab_id, + pc5s_header.data_size); + + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pc5s_header->data_size, + (unsigned char *)receive_buf, + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,&pc5s_header->sourceL2Id + ,&pc5s_header->destinationL2Id +#endif + ); + } else { + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header.inst, + pc5s_header.rb_id, + rab_id, + pc5s_header.data_size); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + rab_id, + key); + } + } else { //if (rab_id == 0) + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL,0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header->inst, + pc5s_header->rb_id, + DEFAULT_RAB_ID, + pc5s_header->data_size); + + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pc5s_header->data_size, + (unsigned char *)receive_buf, + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,&pc5s_header->sourceL2Id + ,&pc5s_header->destinationL2Id +#endif + ); + } + } + free (sl_pc5s_msg_recv); + free (sl_pc5s_msg_send); + } + } + #endif - /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ -// pdcp_read_header_g.inst = 0; -//#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ctxt_cpy.enb_flag; + while ((len > 0) && (rlc_data_req_flag !=0)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); + len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); + + if (len<=0) { + // nothing in pdcp NAS socket + //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); + } else { + + msg_len = len; + for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; + NLMSG_OK (nas_nlh_rx, msg_len); + nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, msg_len)) { + if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); + //return; + } + + if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); + } + + if (pdcp_read_state_g == 0) { + if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { + pdcp_read_state_g = 1; //get + memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); + LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n", + pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id ); + } else { + LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", + nas_nlh_rx->nlmsg_len); + } + } else { + pdcp_read_state_g = 0; + // print_active_requests() #ifdef PDCP_DEBUG - LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d\n", pdcp_read_header_g.rb_id); + LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n", + nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); #endif +#ifdef OAI_EMU + + + // overwrite function input parameters, because only one netlink socket for all instances + if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) { + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ENB_FLAG_YES; + ctxt.module_id = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local; + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_read_header_g.rb_id / maxDRB + oai_emulation.info.first_ue_local]; + rab_id = pdcp_read_header_g.rb_id % maxDRB; + } else { + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ENB_FLAG_NO; + ctxt.module_id = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; + rab_id = pdcp_read_header_g.rb_id % maxDRB; + } + + CHECK_CTXT_ARGS(&ctxt); + AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); + /*LGpdcp_read_header.inst = (pdcp_read_header_g.inst >= oai_emulation.info.nb_enb_local) ? \ + pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : + pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/ +#else // OAI_EMU + /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ + // pdcp_read_header_g.inst = 0; + //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; + +#ifdef PDCP_DEBUG + LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d, source L2Id = 0x%08x, destination L2Id = 0x%08x \n", pdcp_read_header_g.rb_id, pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id); +#endif if (ctxt_cpy.enb_flag) { ctxt.module_id = 0; rab_id = pdcp_read_header_g.rb_id % maxDRB; @@ -562,208 +933,235 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; } +#endif + if (ctxt.enb_flag) { if (rab_id != 0) { rab_id = rab_id % maxDRB; key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - if (h_rc == HASH_TABLE_OK) { + + if (h_rc == HASH_TABLE_OK) { #ifdef PDCP_DEBUG - LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", - ctxt.frame, - pdcp_read_header_g.inst, - len, - nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); -#endif - - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", - ctxt_cpy.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - - pdcp_data_req(&ctxt, + LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + ctxt.frame, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); +#endif + + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", + ctxt_cpy.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + + pdcp_data_req(&ctxt, SRB_FLAG_NO, rab_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pdcp_read_header_g.data_size, (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA); - } else { - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - } - } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast - // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs -//#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES - for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { - if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { - ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA); - } - } - } - } else { // enb_flag - if (rab_id != 0) { - if (rab_id == UE_IP_DEFAULT_RAB_ID) { - LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - } else { - rab_id = rab_id % maxDRB; - LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); - } - - if (h_rc == HASH_TABLE_OK) { - rab_id = pdcp_p->rb_id; + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,NULL, NULL +#endif + ); + } else { + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + } + } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast + // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs + //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES + for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { + if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,NULL, NULL +#endif + ); + } + } + } + } else { // enb_flag + if (rab_id != 0) { + if (rab_id == UE_IP_DEFAULT_RAB_ID) { + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } else { + rab_id = rab_id % maxDRB; + LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } + + if (h_rc == HASH_TABLE_OK) { + rab_id = pdcp_p->rb_id; #ifdef PDCP_DEBUG - LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", - ctxt.frame, - pdcp_read_header_g.inst, - len, - nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); - - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); -#endif - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA); - } else { - MSC_LOG_RX_DISCARDED_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - LOG_D(PDCP, - "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id, - key); - } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL,0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - DEFAULT_RAB_ID, - pdcp_read_header_g.data_size); - - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA); - } - } + LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + ctxt.frame, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); + + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); +#endif + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,&pdcp_read_header_g.sourceL2Id + ,&pdcp_read_header_g.destinationL2Id +#endif + ); + } else { + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id, + key); + } + } else { + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL,0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + DEFAULT_RAB_ID, + pdcp_read_header_g.data_size); + + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,&pdcp_read_header_g.sourceL2Id + ,&pdcp_read_header_g.destinationL2Id +#endif + ); + } + } - } + } + } } - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); - } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); + } - return len; + + return len; # endif #else // neither PDCP_USE_NETLINK nor PDCP_USE_RT_FIFO - return 0; + return 0; #endif // PDCP_USE_NETLINK +#endif /* #else UE_NAS_USE_TUN */ } @@ -775,9 +1173,6 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) // we need to add conditions to avoid transmitting data when the UE is not RRC connected. if ((otg_enabled==1) && (ctxt_pP->enb_flag == ENB_FLAG_YES)) { // generate DL traffic - - - PROTOCOL_CTXT_SET_BY_MODULE_ID( &ctxt, ctxt_pP->module_id, @@ -787,10 +1182,47 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) ctxt_pP->subframe, ctxt_pP->module_id); - for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { + for (dst_id = 0; dst_id<MAX_MOBILES_PER_ENB; dst_id++) { ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id]; - } } } + +//TTN for D2D (PC5S) +#ifdef Rel14 + +void +pdcp_pc5_socket_init() { + //pthread_attr_t attr; + //struct sched_param sched_param; + int optval; // flag value for setsockopt + //int n; // message byte size + + //create PDCP socket + pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (pdcp_pc5_sockfd < 0){ + LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + optval = 1; + setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR, + (const void *)&optval , sizeof(int)); + + fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK); + + bzero((char *) &pdcp_sin, sizeof(pdcp_sin)); + pdcp_sin.sin_family = AF_INET; + pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY); + pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO); + // associate the parent socket with a port + if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin, + sizeof(pdcp_sin)) < 0) { + LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n"); + exit(1); + } + +} + +#endif diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c index 0df8e59e6d4536bd09654ac739d5651c11fc78d5..f0b15d9888d7d0268be4d43df309f89519e1c5f4 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c @@ -55,7 +55,7 @@ #include "UTIL/LOG/log.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OCG/OCG_extern.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "pdcp.h" #include "pdcp_primitives.h" diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h index afcc2fdd0255dc0f11d15df8e670ee29dec8119f..a939543432674fabc3568ce499ec32095656c675 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_proto_extern.h @@ -52,7 +52,12 @@ extern int reception_from_rohc_bs(void); #else extern BOOL pdcp_data_ind (module_id_t module_idP, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t * sduP, uint8_t is_data_plane); extern BOOL pdcp_data_req (module_id_t module_id, uint32_t frame, uint8_t eNB_flag, rb_id_t rab_id, uint32_t muiP, uint32_t confirmP, sdu_size_t sdu_buffer_size, unsigned char* sdu_buffer, - uint8_t is_data_pdu); + uint8_t is_data_pdu +#ifdef Rel14 + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id +#endif + ); //extern BOOL pdcp_data_req (struct pdcp_entity *pdcpP, mem_block * sduP); extern void send_pdcp_control_primitive (struct pdcp_entity *pdcpP, mem_block * cprimitiveP); extern void control_pdcp (struct pdcp_entity *pdcpP); @@ -63,4 +68,7 @@ extern void pdcp_process_input_sdus_tr (struct pdcp_entity *pdcpP); extern void init_pdcp (struct pdcp_entity *pdcpP, struct rb_dispatcher *rbP, uint8_t rb_idP); extern void *pdcp_tx (void *argP); #endif + +extern void pdcp_pc5_socket_init(void); + #endif diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c index 2554eb145ab9de975100795e207efe6276e39978..2c29053297d67a5b5daf836a8a99fe60b7bd8b58 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c @@ -34,7 +34,7 @@ #include "UTIL/LOG/vcd_signal_dumper.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "pdcp.h" #include "msc.h" diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c b/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c index 8282c5fffa78fe3ebecd4f77dcbeabb07ec11db2..8df93d3ba4e0c2af08bac97c4abf026494620d34 100644 --- a/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c +++ b/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c @@ -39,10 +39,10 @@ #include <time.h> #include "proto_agent_common.h" -#include "PHY/extern.h" +#include "PHY/phy_extern.h" #include "log.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rrc_eNB_UE_context.h" //#include "LAYER2/PDCP_v10.1.0/pdcp_primitives.h" @@ -438,7 +438,19 @@ int proto_agent_pdcp_data_req_ack(mid_t mod_id, const void *params, Protocol__Fl memcpy(pdcp_pdu_p->data, rlc_data->fsp_pdu->fsp_pdu_data.data, pdcp_pdu_size); - result = rlc_data_req((const protocol_ctxt_t*) ctxt_pP, (const srb_flag_t) srb_flagP, (const MBMS_flag_t) flag_MBMS, (const rb_id_t) rb_idP, (const mui_t) muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p); + result = rlc_data_req((const protocol_ctxt_t*) ctxt_pP + ,(const srb_flag_t) srb_flagP + ,(const MBMS_flag_t) flag_MBMS + ,(const rb_id_t) rb_idP + ,(const mui_t) muiP + ,confirmP + ,pdcp_pdu_size + ,pdcp_pdu_p + #ifdef Rel14 + ,NULL + ,NULL + #endif + ); if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_RLC_DATA_REQ_ACK, &header) != 0) goto error; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 0e21d5cfac8c8d79237b472a1ce691512eede2cb..0e9452cf210f3582e2362832080b19dfa1aa1721 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -37,7 +37,7 @@ #include "mac_primitives.h" #include "rlc_primitives.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UL-AM-RLC.h" #include "DL-AM-RLC.h" @@ -240,7 +240,7 @@ config_req_rlc_am ( uint16_t pollPDU_tab[PollPDU_pInfinity+1]= {4,8,16,32,64,128,256,RLC_AM_POLL_PDU_INFINITE}; //PollPDU_pInfinity is chosen to 0xFFFF for now uint32_t maxRetxThreshold_tab[UL_AM_RLC__maxRetxThreshold_t32+1]= {1,2,3,4,6,8,16,32}; uint32_t pollByte_tab[PollByte_spare1]= {25000,50000,75000,100000,125000,250000,375000,500000,750000,1000000,1250000,1500000,2000000,3000000,RLC_AM_POLL_BYTE_INFINITE}; // PollByte_kBinfinity is chosen to 0xFFFFFFFF for now -#if defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) uint32_t PollRetransmit_tab[T_PollRetransmit_spare5]= {5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,300,350,400,450,500,800,1000,2000,4000}; uint32_t am_t_Reordering_tab[32]= {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200,1600}; uint32_t t_StatusProhibit_tab[T_StatusProhibit_spare2]= {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,300,350,400,450,500,800,1000,1200,1600,2000,2400}; @@ -271,7 +271,7 @@ void config_req_rlc_am_asn1 ( if ((config_am_pP->ul_AM_RLC.maxRetxThreshold <= UL_AM_RLC__maxRetxThreshold_t32) && (config_am_pP->ul_AM_RLC.pollPDU<=PollPDU_pInfinity) && (config_am_pP->ul_AM_RLC.pollByte<PollByte_spare1) && -#if defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (config_am_pP->ul_AM_RLC.t_PollRetransmit<T_PollRetransmit_spare5) && (config_am_pP->dl_AM_RLC.t_Reordering<32) && (config_am_pP->dl_AM_RLC.t_StatusProhibit<T_StatusProhibit_spare2) ) { diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h index 5130bde38b9f32f6a8d3b18c6d4d8e139c388c84..040145f7f03c1da8db15b77f979d0c155ef9e1cf 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -71,6 +71,7 @@ # include "rlc_am_reassembly.h" # include "rlc_am_init.h" # include "RLC-Config.h" +# include "assertions.h" //# include "rlc_am_test.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c index a133ce09920157695402118420de43ab601e610b..996dd96f353f17bf4e11d0f810eef14ce0472930 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c @@ -30,7 +30,7 @@ #define RLC_AM_IN_SDU_C 1 //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #define TRACE_RLC_AM_FREE_SDU 0 diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c index 01a635656e24ce819f112c399f70f99ccf7a3e1a..0b0a55bd2b66ee32560704e02ef7b29766e64a47 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c @@ -24,7 +24,7 @@ #include <string.h> //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- void diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h index 2ee7d040ab36b65b0a617dacd8a24e69aa34d996..c69fd3766e4554e043598825f3f61ca68b3de987 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h @@ -55,7 +55,7 @@ //----------------------------------------------------------------------------- #include "platform_types.h" #include "platform_constants.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" /*! \struct rlc_am_info_t diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c index d0b5b52395417f9e01e6581402111ec51d2c05de..83b0dfd46b86b583eedf242c09fe8671818610ce 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c @@ -30,7 +30,7 @@ #include "rlc.h" #include "rlc_am.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +//#include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" #include "msc.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c index b1facdfb023671b9e948280b6031c1ade079e285..be4b43d1a075db6c89e0dc0dd8b2539fbaae2ba6 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c @@ -28,7 +28,7 @@ #include "rlc.h" #include "rlc_am.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c index 9e1db8a95bb07d58a4f582c302088156425c8f0e..42e84986238fd9d669e06061222a6492eb74a674 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -26,7 +26,7 @@ //----------------------------------------------------------------------------- #include "rlc_am.h" #include "rlc.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c index dc1ed2116341ed9d395a9546c103b61f022c25e3..c0ce57708b0cf3033f0ced09a5857f8a54e2268a 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c @@ -27,7 +27,7 @@ #include "assertions.h" #include "list.h" #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h index d2f0740b33de9530a97e531f442f955562ba2d42..9dcc75223dc6d543f1be05dfdfc43af51473760b 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h @@ -56,7 +56,7 @@ //----------------------------------------------------------------------------- #include "platform_types.h" #include "platform_constants.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" //----------------------------------------------------------------------------- /*! \fn rlc_am_rx_pdu_status_t rlc_am_rx_list_check_duplicate_insert_pdu(const protocol_ctxt_t* const ctxt_pP,rlc_am_entity_t* const rlc_pP,mem_block_t* const tb_pP) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c index c16e897bb6f67fdadddb2111694cb95e7ad11097..fe99e137a43bfc413f31b0e93ce5ebf03906f71d 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -29,7 +29,7 @@ #include "msc.h" #include "list.h" #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 092c7c65f135f05827e36fcf46bc5c56f4d72a86..3ace3cc51f827022f0ee136092d0568c36385229 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -32,7 +32,6 @@ #include "assertions.h" #include "list.h" #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" # if ENABLE_ITTI diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h index e09189fcd6060c9b303c59b6b3a6a75cd98df10a..41f214d7c6cc54c87d4fcc6b5aefeece7ebd6efc 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h @@ -55,7 +55,7 @@ //----------------------------------------------------------------------------- #include "platform_types.h" #include "platform_constants.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" //----------------------------------------------------------------------------- /*! \fn uint16_t rlc_am_read_bit_field (uint8_t** dataP, unsigned int* bit_posP, const signed int bits_to_readP) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c index 0b88e7c650fe4e3d4b9fb23e93eb7fbfb45c9f00..1e3b8b916d5d4b0392fe15282920aeb4360b2b06 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c @@ -27,7 +27,7 @@ #include "platform_constants.h" //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c index b9383980a4231cd9f84dba7b276bf7c1787dd3be..fd0feceeb0d13181b2545e04e089aafb6daad358 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c @@ -26,7 +26,7 @@ #include "platform_constants.h" //----------------------------------------------------------------------------- #include "rlc_am.h" -# include "LAYER2/MAC/extern.h" +# include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c index 13d4205c2800cd1f7de367f46547ce928e9efe53..84c0edbefd52730a8b73d4c36af1611bf8115062 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c @@ -26,7 +26,7 @@ #include "platform_constants.h" //----------------------------------------------------------------------------- #include "rlc_am.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c index ee2ff57c1eae1a9a48d9e4013a1abe76907ec9bc..23a4d0eb0478c9aab4e00880f9428d121fafe5e6 100644 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c @@ -29,7 +29,7 @@ #include "mac_primitives.h" #include "rlc_primitives.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" //----------------------------------------------------------------------------- void rlc_tm_send_sdu ( diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c index 15dc90f175a183dab9d247afeb081aad21db975a..70c1f37221d6d2193e1a29b6f659a5d7976ec51e 100644 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -23,7 +23,7 @@ #define RLC_TM_INIT_C 1 //----------------------------------------------------------------------------- #include "rlc_tm.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" //----------------------------------------------------------------------------- void config_req_rlc_tm ( const protocol_ctxt_t* const ctxt_pP, diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index 7bd0da83a903e40f909f8538a73d5f1c7c192232..0be2ef168644dbf1575a3f29d071d3fbeb5e557b 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -35,7 +35,7 @@ #include "list.h" #include "rlc_primitives.h" #include "mac_primitives.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c index 4e2723a8f476489bb16fe1eb677f6e0ed4550ab2..fcd88acbb7e96c250c59741345d7ef0873485ad1 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c @@ -28,7 +28,7 @@ #include "rlc_primitives.h" #include "list.h" #include "rrm_config_structs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "rlc_um_control_primitives.h" @@ -78,7 +78,7 @@ void config_req_rlc_um ( } } //----------------------------------------------------------------------------- -#if defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) const uint32_t t_Reordering_tab[32] = {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200,1600}; #else const uint32_t t_Reordering_tab[T_Reordering_spare1] = {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200}; @@ -93,7 +93,12 @@ void config_req_rlc_um_asn1 ( const UL_UM_RLC_t * const ul_rlc_pP, const DL_UM_RLC_t * const dl_rlc_pP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP) + const logical_chan_id_t chan_idP +#ifdef Rel14 + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id +#endif + ) { uint32_t ul_sn_FieldLength = 0; uint32_t dl_sn_FieldLength = 0; @@ -103,7 +108,7 @@ void config_req_rlc_um_asn1 ( hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hashtable_rc_t h_rc; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mbms_flagP) { AssertFatal(dl_rlc_pP, "No RLC UM DL config"); @@ -117,10 +122,14 @@ void config_req_rlc_um_asn1 ( mbms_service_idP, mbms_session_idP); rlc_p = &rlc_union_p->rlc.um; + } + if ((sourceL2Id >0 ) && (destinationL2Id >0)){ + key = RLC_COLL_KEY_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, sourceL2Id, destinationL2Id, srb_flagP); } else #endif { - key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); + key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); + } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %u, srb flag %u", ctxt_pP->module_id, @@ -129,7 +138,6 @@ void config_req_rlc_um_asn1 ( rb_idP, srb_flagP); rlc_p = &rlc_union_p->rlc.um; - } //----------------------------------------------------------------------------- LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ timer_reordering=%dms sn_field_length= RB %u \n", @@ -198,7 +206,7 @@ void config_req_rlc_um_asn1 ( return; } -#if defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (dl_rlc_pP->t_Reordering<32) { #else if (dl_rlc_pP->t_Reordering<T_Reordering_spare1) { diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h index 5847a8bb13bbe08b445284efaed347331faf8740..fc64e95d995983184a55e99077f0ae474f7890b6 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h @@ -115,7 +115,12 @@ public_rlc_um_control_primitives( void config_req_rlc_um_asn1 ( const UL_UM_RLC_t * const ul_rlc_pP, const DL_UM_RLC_t * const dl_rlc_pP, const rb_id_t rb_idP, - const logical_chan_id_t chan_idP);) + const logical_chan_id_t chan_idP +#ifdef Rel14 + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id +#endif + );) /*! \fn void rlc_um_init (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP) * \brief Initialize a RLC UM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC UM protocol instance will be in RLC_NULL_STATE state. diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c index 758630b3cce88476ea49df4a253a60d7d36c9879..bc61ed302ecda6cc92a3502114ff0fbc3e2b5cb3 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c @@ -24,7 +24,7 @@ #include "platform_types.h" //----------------------------------------------------------------------------- #include "rlc_um.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c index 91e1ba66d1bfa662eb29f75cdd286260c48e5147..65aaadb9fa38106defed77ef211b9f497c327e5d 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c @@ -33,7 +33,7 @@ #include "rlc_um.h" #include "rlc_primitives.h" #include "list.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "msc.h" diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index bacde60c73210500b9c07675c707b7509ab43f0d..2fc8ca33afc404cf7d85bf87e81ec6ea5a7b85da 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -29,7 +29,7 @@ #define RLC_C #include "rlc.h" #include "mem_block.h" -#include "../MAC/extern.h" +#include "../MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/OCG/OCG_vars.h" #include "UTIL/LOG/vcd_signal_dumper.h" @@ -378,7 +378,12 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, const mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, - mem_block_t *sdu_pP) + mem_block_t *sdu_pP +#ifdef Rel14 + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id +#endif + ) { //----------------------------------------------------------------------------- @@ -389,7 +394,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) rlc_mbms_id_t *mbms_id_p = NULL; logical_chan_id_t log_ch_id = 0; #endif @@ -403,7 +408,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, sdu_sizeP, sdu_pP); #endif -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #else AssertFatal(MBMS_flagP == 0, "MBMS_flagP %u", MBMS_flagP); #endif @@ -422,13 +427,13 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, DevAssert(sdu_pP != NULL); DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); -#if !defined(Rel10) && !defined(Rel14) +#if (RRC_VERSION < MAKE_VERSION(10, 0, 0)) DevCheck(MBMS_flagP == 0, MBMS_flagP, 0, 0); #endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_IN); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flagP == TRUE) { if (ctxt_pP->enb_flag) { @@ -440,6 +445,10 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, } key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); + } + if (sourceL2Id && destinationL2Id){ + key = RLC_COLL_KEY_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, *sourceL2Id, *destinationL2Id, srb_flagP); + //key_lcid = RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, *sourceL2Id, *destinationL2Id, srb_flagP); } else #endif { @@ -452,7 +461,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - AssertFatal (0 , "RLC not configured key %ju\n", key); + //AssertFatal (0 , "RLC not configured key %ju\n", key); } if (MBMS_flagP == 0) { @@ -564,7 +573,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) } else { /* MBMS_flag != 0 */ // LOG_I(RLC,"DUY rlc_data_req: mbms_rb_id in RLC instant is: %d\n", mbms_rb_id); if (sdu_pP != NULL) { @@ -692,8 +701,8 @@ rlc_module_init (void) rlc_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, rb_free_rlc_union); AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed"); - for (module_id1=0; module_id1 < NUMBER_OF_UE_MAX; module_id1++) { -#if defined(Rel10) || defined(Rel14) + for (module_id1=0; module_id1 < MAX_MOBILES_PER_ENB; module_id1++) { +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) for (k=0; k < RLC_MAX_MBMS_LC; k++) { rlc_mbms_lcid2service_session_id_ue[module_id1][k].service_id = 0; @@ -708,7 +717,7 @@ rlc_module_init (void) } for (module_id1=0; module_id1 < NUMBER_OF_eNB_MAX; module_id1++) { -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) for (k=0; k < RLC_MAX_MBMS_LC; k++) { rlc_mbms_lcid2service_session_id_eNB[module_id1][k].service_id = 0; diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index 8d4acbf83502dbe9983546fdbcef7b8964eb4e4c..d23c01502a44809b7a30e26140bda22c2d5a09d6 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -47,7 +47,7 @@ # include "asn1_constants.h" # include "UTIL/LOG/log.h" # include "mem_block.h" -# include "PHY/defs.h" +//# include "PHY/defs.h" # include "RLC-Config.h" # include "DRB-ToAddMod.h" # include "DRB-ToAddModList.h" @@ -55,13 +55,6 @@ # include "SRB-ToAddModList.h" # include "DRB-ToReleaseList.h" -// for proto_agent operation -//#include "UTIL/LOG/log.h" -//#include "ENB_APP/enb_config.h" - - - - #if defined(Rel10) || defined(Rel14) #include "PMCH-InfoList-r9.h" #endif @@ -181,7 +174,7 @@ typedef struct { //----------------------------------------------------------------------------- #define RLC_MAX_MBMS_LC (maxSessionPerPMCH * maxServiceCount) -#define RLC_MAX_LC ((max_val_DRB_Identity+1)* NUMBER_OF_UE_MAX) +#define RLC_MAX_LC ((max_val_DRB_Identity+1)* MAX_MOBILES_PER_ENB) protected_rlc(void (*rlc_rrc_data_ind)( const protocol_ctxt_t* const ctxtP, @@ -231,7 +224,7 @@ typedef struct rlc_mbms_id_s { mbms_session_id_t session_id; } rlc_mbms_id_t; -#if !defined(Rel10) && !defined(Rel14) +#if (RRC_VERSION < MAKE_VERSION(10, 0, 0)) # if !defined(maxServiceCount) //unused arrays rlc_mbms_array_ue rlc_mbms_array_eNB # define maxServiceCount 1 @@ -241,10 +234,10 @@ typedef struct rlc_mbms_id_s { # define maxSessionPerPMCH 1 # endif #endif -//public_rlc(rlc_mbms_t rlc_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +//public_rlc(rlc_mbms_t rlc_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h //public_rlc(rlc_mbms_t rlc_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h -public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_ue[NUMBER_OF_UE_MAX][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h -public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[NUMBER_OF_eNB_MAX][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_ue[MAX_MOBILES_PER_ENB][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h +public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[MAX_eNB][RLC_MAX_MBMS_LC];) // some constants from openair2/RRC/LITE/MESSAGES/asn1_constants.h #define rlc_mbms_enb_get_lcid_by_rb_id(Enb_mOD,rB_iD) rlc_mbms_rbid2lcid_eNB[Enb_mOD][rB_iD] ; @@ -260,8 +253,8 @@ public_rlc(rlc_mbms_id_t rlc_mbms_lcid2service_session_id_eNB[NUMBER_OF_e rlc_mbms_rbid2lcid_ue[uE_mOD][rB_iD] = lOG_cH_iD; \ } while (0); -public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_ue [NUMBER_OF_UE_MAX][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ -public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_eNB[NUMBER_OF_eNB_MAX][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ +public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_ue [MAX_MOBILES_PER_ENB][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ +public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_eNB[MAX_eNB][NB_RB_MBMS_MAX];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ #define RLC_COLL_KEY_VALUE(eNB_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ @@ -282,6 +275,23 @@ public_rlc(logical_chan_id_t rlc_mbms_rbid2lcid_eNB[NUMBER_OF_eNB_MAX][NB_RB_ (((hash_key_t)(iS_sRB)) << 33) | \ (((hash_key_t)(0x0a)) << 34)) +#define RLC_COLL_KEY_SOURCE_DEST_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, sOURCE_iD, dEST_iD, iS_sRB) \ + ((hash_key_t)eNB_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(lC_iD)) << 25) | \ + (((hash_key_t)(dEST_iD)) << 33) | \ + (((hash_key_t)(0x05)) << 57)) + +#define RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(eNB_iD, rNTI, iS_eNB, lC_iD, sOURCE_iD, dEST_iD, iS_sRB) \ + ((hash_key_t)eNB_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(lC_iD)) << 25) | \ + (((hash_key_t)(dEST_iD)) << 33) | \ + (((hash_key_t)(0x0a)) << 57)) + + // service id max val is maxServiceCount = 16 (asn1_constants.h) #define RLC_COLL_KEY_MBMS_VALUE(eNB_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \ @@ -316,7 +326,7 @@ private_rlc_mac(struct mac_data_ind mac_rlc_deserialize_tb (char*, tb_size_t, //----------------------------------------------------------------------------- // PUBLIC INTERFACE WITH RRC //----------------------------------------------------------------------------- -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) /*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const SRB_ToAddMod_t* const srb2addmod, const DRB_ToAddModList_t* const drb2add_listP, const DRB_ToReleaseList_t* const drb2release_listP, const PMCH_InfoList_r9_t * const pmch_info_listP) * \brief Function for RRC to configure a Radio Bearer. * \param[in] ctxtP Running context. @@ -331,7 +341,9 @@ public_rlc_rrc( rlc_op_status_t rrc_rlc_config_asn1_req ( const SRB_ToAddModList_t* const , const DRB_ToAddModList_t* const , const DRB_ToReleaseList_t* const , - const PMCH_InfoList_r9_t * const pmch_info_listP);) + const PMCH_InfoList_r9_t * const pmch_info_listP , + const uint32_t , + const uint32_t );) #else /*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t* const ctxtP, const SRB_ToAddModList_t* const srb2add_listP, const DRB_ToAddModList_t* const drb2add_listP, const DRB_ToReleaseList_t* const drb2release_listP) * \brief Function for RRC to configure a Radio Bearer. @@ -386,7 +398,12 @@ public_rlc_rrc(rlc_op_status_t rrc_rlc_remove_rlc (const protocol_ctxt_t* cons * \param[in] rlc_modeP Mode of RLC (AM, UM, TM). * \return A status about the processing, OK or error code. */ -private_rlc_rrc(rlc_union_t* rrc_rlc_add_rlc (const protocol_ctxt_t* const, const srb_flag_t, const MBMS_flag_t MBMS_flagP, const rb_id_t, logical_chan_id_t, rlc_mode_t);) +private_rlc_rrc(rlc_union_t* rrc_rlc_add_rlc (const protocol_ctxt_t* const, const srb_flag_t, const MBMS_flag_t MBMS_flagP, const rb_id_t, logical_chan_id_t, rlc_mode_t +#ifdef Rel14 + ,const uint32_t sourceL2Id, + const uint32_t destinationL2Id +#endif +);) /*! \fn rlc_op_status_t rrc_rlc_config_req ( const protocol_ctxt_t* const ctxtP, @@ -447,7 +464,12 @@ public_rlc_rrc(void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_d * \param [in,out] bufferP Memory area to fill with the bytes requested by MAC. * \return A status about the processing, OK or error code. */ -public_rlc_mac(tbs_size_t mac_rlc_data_req (const module_id_t, const rnti_t, const eNB_index_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, const tb_size_t,char*);) +public_rlc_mac(tbs_size_t mac_rlc_data_req (const module_id_t, const rnti_t, const eNB_index_t, const frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, const tb_size_t,char* +#ifdef Rel14 + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id +#endif +);) /*! \fn void mac_rlc_data_ind (const module_id_t mod_idP, const rnti_t rntiP, const frame_t frameP, const eNB_flag_t eNB_flagP, const MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, uint32_t frameP, char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs) * \brief Interface with MAC layer, deserialize the transport blocks sent by MAC, then map data indication to the RLC instance corresponding to the radio bearer identifier. @@ -477,7 +499,12 @@ public_rlc_mac(void mac_rlc_data_ind (const module_id_t, co * \param[in] tb_sizeP Size of a transport block set in bytes. * \return The maximum number of bytes that the RLC instance can send in the next transmission sequence. */ -public_rlc_mac(mac_rlc_status_resp_t mac_rlc_status_ind (const module_id_t, const rnti_t, const eNB_index_t, const frame_t, const sub_frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, tb_size_t );) +public_rlc_mac(mac_rlc_status_resp_t mac_rlc_status_ind (const module_id_t, const rnti_t, const eNB_index_t, const frame_t, const sub_frame_t, const eNB_flag_t, const MBMS_flag_t, logical_chan_id_t, tb_size_t +#ifdef Rel14 + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id +#endif + );) /*! \fn rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind(const module_id_t module_idP, const rnti_t rntiP, const eNB_index_t eNB_index, const frame_t frameP, const sub_frame_t subframeP,const eNB_flag_t enb_flagP, const logical_chan_id_t channel_idP) * \brief Interface with MAC layer, UE only: request and get the number of bytes scheduled for transmission by the RLC instance corresponding to the radio bearer identifier. @@ -527,7 +554,12 @@ public_rlc(rlc_op_status_t rlc_data_req ( const mui_t , const confirm_t , const sdu_size_t , - mem_block_t * const);) + mem_block_t * const +#ifdef Rel14 + ,const uint32_t * const + ,const uint32_t * const +#endif + );) /*! \fn void rlc_data_ind (const protocol_ctxt_t* const ctxtP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const sdu_size_t sdu_sizeP, mem_block_t* sduP) { * \brief Interface with higher layers, route SDUs coming from RLC protocol instances to upper layer instance. diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 497937d073841cdb37ce5ddf17b0f8aadee419cf..c4fc2872c682a87f1fd3a1cf23634f518d946124 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -30,7 +30,7 @@ //----------------------------------------------------------------------------- #define RLC_MAC_C #include "rlc.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" #include "UTIL/OCG/OCG_vars.h" #include "hashtable.h" @@ -126,7 +126,12 @@ tbs_size_t mac_rlc_data_req( const MBMS_flag_t MBMS_flagP, const logical_chan_id_t channel_idP, const tb_size_t tb_sizeP, - char *buffer_pP) + char *buffer_pP +#ifdef Rel14 + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id +#endif + ) { //----------------------------------------------------------------------------- struct mac_data_req data_request; @@ -143,7 +148,7 @@ tbs_size_t mac_rlc_data_req( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_REQ,VCD_FUNCTION_IN); #ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n", + LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d\n", PROTOCOL_CTXT_ARGS((&ctxt)), channel_idP, RLC_MAX_LC, @@ -166,6 +171,10 @@ tbs_size_t mac_rlc_data_req( } } else { key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); +#ifdef Rel14 + if ((sourceL2Id > 0) && (destinationL2Id > 0)) + key = RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(module_idP, rntiP, enb_flagP, channel_idP, sourceL2Id, destinationL2Id, srb_flag); +#endif } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -189,7 +198,7 @@ tbs_size_t mac_rlc_data_req( break; case RLC_MODE_UM: - if (!enb_flagP) rlc_um_set_nb_bytes_requested_by_mac(&rlc_union_p->rlc.um,tb_sizeP); + if (!enb_flagP) rlc_um_set_nb_bytes_requested_by_mac(&rlc_union_p->rlc.um,tb_sizeP); data_request = rlc_um_mac_data_request(&ctxt, &rlc_union_p->rlc.um,enb_flagP); ret_tb_size = mac_rlc_serialize_tb(buffer_pP, data_request.data); break; @@ -308,7 +317,12 @@ mac_rlc_status_resp_t mac_rlc_status_ind( const eNB_flag_t enb_flagP, const MBMS_flag_t MBMS_flagP, const logical_chan_id_t channel_idP, - const tb_size_t tb_sizeP) + const tb_size_t tb_sizeP +#ifdef Rel14 + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id +#endif + ) { //----------------------------------------------------------------------------- mac_rlc_status_resp_t mac_rlc_status_resp; @@ -337,16 +351,26 @@ mac_rlc_status_resp_t mac_rlc_status_ind( key = RLC_COLL_KEY_MBMS_VALUE(module_idP, rntiP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id); } else { +#ifdef Rel14 + if ((sourceL2Id > 0) && (destinationL2Id > 0)) { + key = RLC_COLL_KEY_SOURCE_DEST_VALUE(module_idP, rntiP, enb_flagP, channel_idP, sourceL2Id, destinationL2Id, srb_flag); + } else +#endif + { + //LOG_I(RLC, "Panos-D mac_rlc_status_ind 1 enb_flagP: %d, channel_idP: %d, srb_flag: %d \n", enb_flagP, channel_idP, srb_flag); key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); - } + } +} + //LOG_I(RLC, "Panos-D mac_rlc_status_ind 2 enb_flagP: %d, channel_idP: %d, srb_flag: %d \n", enb_flagP, channel_idP, srb_flag); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - //LOG_W(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); + //LOG_D(RLC , "Panos-D: mac_rlc_status_ind() In RLC_MODE_NONE \n"); + //LOG_W(RLC , "[%s] RLC not configured lcid %u module %u!\n", __FUNCTION__, channel_idP, module_idP); //LOG_D(RLC , "[%s] RLC not configured rb id %u lcid %u module %u!\n", __FUNCTION__, rb_id, channel_idP, ue_module_idP); } diff --git a/openair2/LAYER2/RLC/rlc_mpls.c b/openair2/LAYER2/RLC/rlc_mpls.c index 34e4f028aec13ccc4f6a234413cffca1791c0643..900741fe2672300f22522a07133b9ef280bed8de 100644 --- a/openair2/LAYER2/RLC/rlc_mpls.c +++ b/openair2/LAYER2/RLC/rlc_mpls.c @@ -40,6 +40,10 @@ rlc_op_status_t mpls_rlc_data_req ( { //----------------------------------------------------------------------------- // third arg should be set to 1 or 0 - return rlc_data_req(ctxtP, SRB_FLAG_NO, MBMS_FLAG_NO, rb_idP, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, sdu_sizeP, sduP); + return rlc_data_req(ctxtP, SRB_FLAG_NO, MBMS_FLAG_NO, rb_idP, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, sdu_sizeP, sduP +#ifdef Rel14 + ,NULL, NULL +#endif + ); } diff --git a/openair2/LAYER2/RLC/rlc_proto_agent_primitives.h b/openair2/LAYER2/RLC/rlc_proto_agent_primitives.h index 0084e725f14c842aa24d1f74d24a634c7cd7898f..75ccc9fcdd001cd20a8a83a26b10a7755d517be5 100644 --- a/openair2/LAYER2/RLC/rlc_proto_agent_primitives.h +++ b/openair2/LAYER2/RLC/rlc_proto_agent_primitives.h @@ -2,7 +2,7 @@ #ifndef __PROTO_AGENT_RLC_PRIMITIVES_H__ #define __PROTO_AGENT_RLC_PRIMITIVES_H__ -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "LAYER2/PROTO_AGENT/proto_agent.h" // PROTO AGENT pthread_t async_server_thread; @@ -13,4 +13,4 @@ pthread_mutex_t async_server_lock; pthread_cond_t async_server_notify; int async_server_shutdown; -#endif \ No newline at end of file +#endif diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index dee6ba700017d6dc48151b32ccac8f7a82eead0c..34e4dee37aad2791ec962cfdde188956a918b0df 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -39,19 +39,21 @@ #include "SRB-ToAddMod.h" #include "SRB-ToAddModList.h" #include "DL-UM-RLC.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "PMCH-InfoList-r9.h" #endif -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "assertions.h" //----------------------------------------------------------------------------- rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, const SRB_ToAddModList_t * const srb2add_listP, const DRB_ToAddModList_t * const drb2add_listP, const DRB_ToReleaseList_t * const drb2release_listP -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,const PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP + ,const uint32_t sourceL2Id + ,const uint32_t destinationL2Id #endif ) { @@ -66,7 +68,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP rlc_union_t *rlc_union_p = NULL; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) int i, j; MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL; @@ -104,7 +106,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; case RLC_Config_PR_am: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_am_asn1 ( ctxt_pP, SRB_FLAG_YES, @@ -119,7 +126,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; case RLC_Config_PR_um_Bi_Directional: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_um_asn1( ctxt_pP, SRB_FLAG_YES, @@ -128,7 +140,11 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.ul_UM_RLC, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.dl_UM_RLC, - rb_id, lc_id); + rb_id, lc_id +#ifdef Rel14 + ,0, 0 +#endif + ); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -138,7 +154,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; case RLC_Config_PR_um_Uni_Directional_UL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_um_asn1( ctxt_pP, SRB_FLAG_YES, @@ -147,7 +168,11 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_UL.ul_UM_RLC, NULL, - rb_id, lc_id); + rb_id, lc_id +#ifdef Rel14 + ,0, 0 +#endif + ); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -157,7 +182,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; case RLC_Config_PR_um_Uni_Directional_DL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_um_asn1( ctxt_pP, SRB_FLAG_YES, @@ -166,7 +196,11 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, NULL, &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_DL.dl_UM_RLC, - rb_id, lc_id); + rb_id, lc_id +#ifdef Rel14 + ,0, 0 +#endif + ); } else { LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n", PROTOCOL_CTXT_ARGS(ctxt_pP), @@ -195,7 +229,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP config_am_pP->ul_AM_RLC.pollByte = PollByte_kBinfinity; config_am_pP->ul_AM_RLC.maxRetxThreshold = UL_AM_RLC__maxRetxThreshold_t4; - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_am_asn1 ( ctxt_pP, SRB_FLAG_YES, @@ -252,7 +291,6 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP LOG_D(RLC, "Adding DRB %ld, lc_id %d\n",drb_id,lc_id); - if (drb_toaddmod_p->rlc_Config) { switch (drb_toaddmod_p->rlc_Config->present) { @@ -260,7 +298,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; case RLC_Config_PR_am: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_AM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_AM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_am_asn1 ( ctxt_pP, SRB_FLAG_NO, @@ -271,7 +314,12 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; case RLC_Config_PR_um_Bi_Directional: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM +#ifdef Rel14 + ,sourceL2Id, + destinationL2Id +#endif + ) != NULL) { config_req_rlc_um_asn1( ctxt_pP, SRB_FLAG_NO, @@ -280,13 +328,23 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.ul_UM_RLC, &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.dl_UM_RLC, - drb_id, lc_id); + drb_id, lc_id +#ifdef Rel14 + ,sourceL2Id, + destinationL2Id +#endif + ); } break; case RLC_Config_PR_um_Uni_Directional_UL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_um_asn1( ctxt_pP, SRB_FLAG_NO, @@ -295,13 +353,22 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_UL.ul_UM_RLC, NULL, - drb_id, lc_id); + drb_id, lc_id +#ifdef Rel14 + ,0, 0 +#endif + ); } break; case RLC_Config_PR_um_Uni_Directional_DL: - if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM) != NULL) { + if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { config_req_rlc_um_asn1( ctxt_pP, SRB_FLAG_NO, @@ -310,7 +377,11 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP UNUSED_PARAM_MBMS_SERVICE_ID, NULL, &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_DL.dl_UM_RLC, - drb_id, lc_id); + drb_id, lc_id +#ifdef Rel14 + ,0, 0 +#endif + ); } break; @@ -335,7 +406,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (pmch_InfoList_r9_pP != NULL) { for (i=0; i<pmch_InfoList_r9_pP->list.count; i++) { @@ -372,7 +443,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP MBMS_FLAG_YES, rb_id, lc_id, - RLC_MODE_UM); + RLC_MODE_UM, 0, 0); AssertFatal(rlc_union_p != NULL, "ADD MBMS RLC UM FAILED"); } @@ -394,7 +465,11 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP mbms_service_id, NULL, &dl_um_rlc, - rb_id, lc_id); + rb_id, lc_id +#ifdef Rel14 + ,0, 0 +#endif + ); } } } @@ -478,14 +553,14 @@ rlc_op_status_t rrc_rlc_remove_rlc ( hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_lcid_rc; rlc_union_t *rlc_union_p = NULL; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) rlc_mbms_id_t *mbms_id_p = NULL; #endif /* for no gcc warnings */ (void)lcid; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flagP == TRUE) { if (ctxt_pP->enb_flag) { @@ -571,25 +646,32 @@ rlc_union_t* rrc_rlc_add_rlc ( const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const logical_chan_id_t chan_idP, - const rlc_mode_t rlc_modeP) + const rlc_mode_t rlc_modeP +#ifdef Rel14 + ,const uint32_t sourceL2Id, + const uint32_t destinationL2Id +#endif +) { + //----------------------------------------------------------------------------- hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; hash_key_t key_lcid = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_lcid_rc; rlc_union_t *rlc_union_p = NULL; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) rlc_mbms_id_t *mbms_id_p = NULL; logical_chan_id_t lcid = 0; #endif + if (MBMS_flagP == FALSE) { AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); AssertFatal (chan_idP < RLC_MAX_LC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC); } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flagP == TRUE) { if (ctxt_pP->enb_flag) { @@ -608,6 +690,10 @@ rlc_union_t* rrc_rlc_add_rlc ( } key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_id_p->service_id, mbms_id_p->session_id); + } + if ((sourceL2Id > 0) && (destinationL2Id > 0) ){ + key = RLC_COLL_KEY_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, sourceL2Id, destinationL2Id, srb_flagP); + key_lcid = RLC_COLL_KEY_LCID_SOURCE_DEST_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, sourceL2Id, destinationL2Id, srb_flagP); } else #endif { @@ -631,7 +717,7 @@ rlc_union_t* rrc_rlc_add_rlc ( h_lcid_rc = hashtable_insert(rlc_coll_p, key_lcid, rlc_union_p); if ((h_rc == HASH_TABLE_OK) && (h_lcid_rc == HASH_TABLE_OK)) { -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flagP == TRUE) { LOG_I(RLC, PROTOCOL_CTXT_FMT" RLC service id %u session id %u rrc_rlc_add_rlc\n", @@ -668,7 +754,6 @@ rlc_union_t* rrc_rlc_add_rlc ( rb_idP, (srb_flagP) ? "SRB" : "DRB"); } - return NULL; } //----------------------------------------------------------------------------- @@ -692,7 +777,12 @@ rlc_op_status_t rrc_rlc_config_req ( switch (actionP) { case CONFIG_ACTION_ADD: - if (rrc_rlc_add_rlc(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, rb_idP, rlc_infoP.rlc_mode) != NULL) { + if (rrc_rlc_add_rlc(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, rb_idP, rlc_infoP.rlc_mode +#ifdef Rel14 + ,0, + 0 +#endif + ) != NULL) { return RLC_OP_STATUS_INTERNAL_ERROR; } @@ -766,7 +856,11 @@ rlc_op_status_t rrc_rlc_data_req ( if (sdu != NULL) { memcpy (sdu->data, sduP, sdu_sizeP); - return rlc_data_req(ctxt_pP, SRB_FLAG_YES, MBMS_flagP, rb_idP, muiP, confirmP, sdu_sizeP, sdu); + return rlc_data_req(ctxt_pP, SRB_FLAG_YES, MBMS_flagP, rb_idP, muiP, confirmP, sdu_sizeP, sdu +#ifdef Rel14 + ,NULL, NULL +#endif + ); } else { return RLC_OP_STATUS_INTERNAL_ERROR; } diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c index 019c2bd9aee423e4b4ebe44fd78765583c5ce1dc..58d29b14563dde61050bfd74251a423c3d0b1861 100644 --- a/openair2/LAYER2/openair2_proc.c +++ b/openair2/LAYER2/openair2_proc.c @@ -32,8 +32,8 @@ #include <inttypes.h> #include "LAYER2/RLC/rlc.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" #include "UTIL/LOG/log.h" #include "common/ran_context.h" diff --git a/openair2/NETWORK_DRIVER/UE_IP/common.c b/openair2/NETWORK_DRIVER/UE_IP/common.c index 99712cc5d2fc7e749109280c01a59e808b1e28e1..e8ff5fc7ac66d9917f1624e0615a5ee94899e70a 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/common.c +++ b/openair2/NETWORK_DRIVER/UE_IP/common.c @@ -248,6 +248,13 @@ ue_ip_common_ip2wireless( //--------------------------------------------------------------------------- struct pdcp_data_req_header_s pdcph; ue_ip_priv_t *priv_p=netdev_priv(ue_ip_dev[instP]); +#ifdef Rel14 + ipversion_t *ipv_p = NULL; + unsigned int hard_header_len = 0; + unsigned char *src_addr = 0; + unsigned char *dst_addr = 0; +#endif + #ifdef LOOPBACK_TEST int i; #endif @@ -278,6 +285,37 @@ ue_ip_common_ip2wireless( pdcph.inst = instP; + //pass source/destination IP addresses to PDCP header + hard_header_len = ue_ip_dev[instP]->hard_header_len; + ipv_p = (ipversion_t *)((void *)&(skb_pP->data[hard_header_len])); + + switch (ipv_p->version) { + case 6: + printk("[UE_IP_DRV][%s] receive IPv6 message\n",__FUNCTION__); + //TODO + break; + + case 4: + src_addr = (unsigned char *)&((struct iphdr *)&skb_pP->data[hard_header_len])->saddr; + if (src_addr) { + printk("[UE_IP_DRV][%s] Source %d.%d.%d.%d\n",__FUNCTION__, src_addr[0],src_addr[1],src_addr[2],src_addr[3]); + } + dst_addr = (unsigned char *)&((struct iphdr *)&skb_pP->data[hard_header_len])->daddr; + if (dst_addr) { + printk("[UE_IP_DRV][%s] Dest %d.%d.%d.%d\n",__FUNCTION__, dst_addr[0],dst_addr[1],dst_addr[2],dst_addr[3]); + } + + //get Ipv4 address and pass to PCDP header + printk("[UE_IP_DRV] source Id: 0x%08x\n",pdcph.sourceL2Id ); + printk("[UE_IP_DRV] destinationL2Id Id: 0x%08x\n",pdcph.destinationL2Id ); + pdcph.sourceL2Id = ntohl( ((struct iphdr *)&skb_pP->data[hard_header_len])->saddr) & 0x00FFFFFF; + pdcph.destinationL2Id = ntohl( ((struct iphdr *)&skb_pP->data[hard_header_len])->daddr) & 0x00FFFFFF; + break; + + default: + break; + } + bytes_wrote = ue_ip_netlink_send((char *)&pdcph,UE_IP_PDCPH_SIZE); #ifdef OAI_DRV_DEBUG_SEND diff --git a/openair2/NETWORK_DRIVER/UE_IP/constant.h b/openair2/NETWORK_DRIVER/UE_IP/constant.h index faff970dcdb3cb32e8ade1d2a3e8ee0cae1e3600..ccd992dd4ea63c7763cd56b61bace3be6961619b 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/constant.h +++ b/openair2/NETWORK_DRIVER/UE_IP/constant.h @@ -52,7 +52,7 @@ -#define UE_IP_NB_INSTANCES_MAX NUMBER_OF_UE_MAX +#define UE_IP_NB_INSTANCES_MAX NUMBER_OF_UE_MAX /*MAX_MOBILES_PER_ENB*/ #endif diff --git a/openair2/NETWORK_DRIVER/UE_IP/local.h b/openair2/NETWORK_DRIVER/UE_IP/local.h index ac3b0409954daab75466448b14a1727c94d76ada..976222967d326d885dc02288b12562e7bc953665 100644 --- a/openair2/NETWORK_DRIVER/UE_IP/local.h +++ b/openair2/NETWORK_DRIVER/UE_IP/local.h @@ -89,6 +89,10 @@ typedef struct pdcp_data_req_header_s { sdu_size_t data_size; signed int inst; ip_traffic_type_t traffic_type; +#ifdef Rel14 + uint32_t sourceL2Id; + uint32_t destinationL2Id; +#endif } pdcp_data_req_header_t; typedef struct pdcp_data_ind_header_s { @@ -96,6 +100,10 @@ typedef struct pdcp_data_ind_header_s { sdu_size_t data_size; signed int inst; ip_traffic_type_t dummy_traffic_type; +#ifdef Rel14 + uint32_t sourceL2Id; + uint32_t destinationL2Id; +#endif } pdcp_data_ind_header_t; diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index d0b8e5755858bbaf3ac64711016a8debce09b04c..997f42019f91ed1e8322bb17d3f644c27e6f0394 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -1,8 +1,8 @@ -#include "openair1/PHY/defs.h" +#include "openair1/PHY/defs_eNB.h" #include "openair2/PHY_INTERFACE/IF_Module.h" -#include "openair1/PHY/extern.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" +#include "openair1/PHY/phy_extern.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" #include "common/ran_context.h" #define MAX_IF_MODULES 100 @@ -33,13 +33,13 @@ void handle_rach(UL_IND_t *UL_info) { UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble, UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,0 #endif ); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) if (UL_info->rach_ind_br.rach_indication_body.number_of_preambles>0) { AssertFatal(UL_info->rach_ind_br.rach_indication_body.number_of_preambles<5,"More than 4 preambles not supported\n"); diff --git a/openair2/PHY_INTERFACE/IF_Module.h b/openair2/PHY_INTERFACE/IF_Module.h index 3b1c88dda03b5857f99c40a3a724b1a072a469e5..0390a9055179d236615b399b9717b6f021c369e4 100644 --- a/openair2/PHY_INTERFACE/IF_Module.h +++ b/openair2/PHY_INTERFACE/IF_Module.h @@ -34,9 +34,10 @@ #include <stdint.h> -#include "openair1/PHY/LTE_TRANSPORT/defs.h" +//#include "openair1/PHY/LTE_TRANSPORT/transport_eNB.h" #include "nfapi_interface.h" - +#include "platform_constants.h" +#include "platform_types.h" #define MAX_NUM_DL_PDU 100 #define MAX_NUM_UL_PDU 100 @@ -75,7 +76,7 @@ typedef struct{ /// RACH indication list nfapi_rach_indication_t rach_ind; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /// RACH indication list for BR UEs nfapi_rach_indication_t rach_ind_br; #endif diff --git a/openair2/PHY_INTERFACE/UE_MAC_interface.h b/openair2/PHY_INTERFACE/UE_MAC_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..0e4777d0b028cf0e5af141fc23a538e77448503f --- /dev/null +++ b/openair2/PHY_INTERFACE/UE_MAC_interface.h @@ -0,0 +1,498 @@ +/* + * 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 + */ + +/* This is the interface module between PHY + * Provided the FAPI style interface structures for P7. + */ + +/*! \file openair2/PHY_INTERFACE/IF_Module.h +* \brief data structures for PHY/MAC interface modules +* \author EURECOM/NTUST +* \date 2017 +* \version 0.1 +* \company Eurecom +* \email: raymond.knopp@eurecom.fr +* \note +* \warning +*/ +#ifndef __UE_MAC_INTERFACE__H__ +#define __UE_MAC_INTERFACE__H__ + +#include "nfapi_interface.h" +#include "openair1/PHY/impl_defs_lte.h" +#include "targets/COMMON/openairinterface5g_limits.h" + + + +#define MAX_NUM_DL_PDU 100 +#define MAX_NUM_UL_PDU 100 +#define MAX_NUM_HI_DCI0_PDU 100 +#define MAX_NUM_TX_REQUEST_PDU 100 + +#define MAX_NUM_HARQ_IND 100 +#define MAX_NUM_CRC_IND 100 +#define MAX_NUM_SR_IND 100 +#define MAX_NUM_CQI_IND 100 +#define MAX_NUM_RACH_IND 100 +#define MAX_NUM_SRS_IND 100 + + +// UE_MAC enums +typedef enum { + UE_MAC_DL_IND_PDSCH_PDU_TYPE =0, + UE_MAC_DL_IND_SI_PDSCH_PDU_TYPE, + UE_MAC_DL_IND_P_PDSCH_PDU_TYPE, + UE_MAC_DL_IND_DLSCH_RAR_PDU_TYPE +} UE_MAC_dl_ind_pdu_type_e; + +// UE_MAC enums +typedef enum { + UE_MAC_Tx_IND_Msg1_TYPE =0, + UE_MAC_Tx_IND_Msg3_TYPE +} UE_MAC_Tx_ind_type_e; + + + +// *** UE_UL_Config.request related structures + + +typedef struct{ + //module_id_t module_idP; + //int CC_id; + //frame_t frameP; + uint8_t eNB_id; + //uint16_t rnti; + //sub_frame_t subframe_tx; + uint32_t SR_payload; //0 or 1 +}UE_MAC_ul_config_SR; + + + +typedef struct{ + //module_id_t module_idP; + //int CC_id; + //frame_t frameP; + uint8_t eNB_indexP; + //sub_frame_t subframeP; + + uint8_t ra_RACH_MaskIndex; + int8_t ra_PREAMBLE_RECEIVED_TARGET_POWER; + uint8_t ra_TDD_map_index; + uint16_t ra_RNTI; + uint8_t *Msg3; +}UE_MAC_ul_config_rach; + +typedef struct { + union { + UE_MAC_ul_config_rach ue_rach_config; + //UE_MAC_ul_config_ULSCH ue_ULSCH_pdu; + UE_MAC_ul_config_SR ue_SR_config; + }; +} UE_MAC_ul_config_request_list; + +typedef struct { + nfapi_tl_t tl; + uint16_t length_list; + UE_MAC_ul_config_request_list* ue_ul_config_list; +} UE_MAC_ul_config_request_body_t; + +typedef struct { + //nfapi_p7_message_header_t header; + uint16_t sfn_sf; + UE_MAC_ul_config_request_body_t ue_ul_config_request_body; //nfapi_dl_config_request_body_t +} UE_MAC_ul_config_request_t; + + + + + + + + + +// *** UE_Tx.request related structures + +typedef struct { + uint16_t pdu_length; + uint16_t pdu_index; + uint8_t num_segments; + struct { + uint32_t segment_length; + uint8_t* segment_data; + } segments[NFAPI_TX_MAX_SEGMENTS]; +} UE_MAC_tx_request_pdu_t; + + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_pdus; + UE_MAC_tx_request_pdu_t* ue_tx_pdu_list; +} UE_MAC_tx_request_body_t; + + +typedef struct { + //nfapi_p7_message_header_t header; + uint16_t sfn_sf; + UE_MAC_tx_request_body_t ue_tx_request_body; +} UE_MAC_tx_request_t; + + +typedef struct{ + + +}UE_MAC_sl_config_request_Tx_t; + +typedef struct{ + + +}UE_MAC_sl_config_request_Rx_t; + + +typedef struct{ + + +}UE_MAC_sl_tx_request_t; + + + + + + +// *** UE_DL.indication related structures + +typedef struct{ + unsigned char eNB_index; + uint8_t first_sync; //boolean 0 or 1 + uint8_t sync; // boolean 0 or 1 to indicate whether rrc_out_of_sync_ind() or dl_phy_sync_success() + // should be called from the handler function of the interface respectively. +}UE_MAC_bch_indication_pdu_t; + + +typedef struct{ + nfapi_tl_t tl; + UE_MAC_bch_indication_pdu_t* bch_ind_list; +}UE_MAC_BCH_indication_body_t; + + +// Panos: Corresponding to inputs of MAC functions: ue_send_sdu(), ue_decode_si(), ue_decode_p(). +typedef struct{ + uint8_t* data; + uint16_t data_len; +}UE_MAC_dlsch_pdu; + + +// Panos: Corresponding to inputs of MAC function: process_rar(). +typedef struct{ + rnti_t ra_rnti; + uint8_t* rar_input_buffer; // Originating from PHY + rnti_t* t_crnti; + uint8_t preamble_index; + uint8_t* rar_output_buffer; //should be returned to PHY: dlsch0->harq_processes[0]->b +}UE_MAC_dlsch_rar_pdu; + + +typedef struct{ + uint8_t pdu_type; + uint8_t eNB_index; + union{ + UE_MAC_dlsch_pdu dlsch_pdu_ind; + UE_MAC_dlsch_rar_pdu dlsch_rar_pdu_ind; + }; +}UE_MAC_dlsch_indication_pdu_t; + + +typedef struct{ + nfapi_tl_t tl; + uint16_t number_of_pdus; + UE_MAC_dlsch_indication_pdu_t* dlsch_ind_list; +}UE_MAC_DLSCH_indication_body_t; + + + + + + +// *** UE_SL.indication related structures + +typedef struct{ + +}ue_sci_indication_body_t; + + +typedef struct{ + +}ue_SLSCH_indication_body_t; + + +typedef struct{ + +}ue_SLDCH_indication_body_t; + +typedef struct{ + +}ue_SLBCH_indication_body_t; + + +// *** UE_Config_common.request related structures + +typedef struct { + uint8_t subframeAssignment; + uint8_t specialSubframePatterns; +}UE_PHY_tdd_frame_structure_t; + + +typedef struct { + uint16_t rootSequenceIndex; + uint8_t prach_Config_enabled; + uint8_t prach_ConfigIndex; + uint8_t highSpeedFlag; + uint8_t zeroCorrelationZoneConfig; + uint8_t prach_FreqOffset; +}UE_PHY_prach_config_t; + +typedef struct { + uint8_t deltaPUCCH_Shift; + uint8_t nRB_CQI; + uint8_t nCS_AN; + uint16_t n1PUCCH_AN; +}UE_PHY_pucch_config_t; + + +typedef struct { + int8_t referenceSignalPower; + uint8_t p_b; +}UE_PHY_pdsch_config_t; + + +typedef struct { + uint8_t n_SB; + PUSCH_HOPPING_t hoppingMode; + uint8_t pusch_HoppingOffset; + uint8_t enable64QAM; + uint8_t groupHoppingEnabled; + uint8_t groupAssignmentPUSCH; + uint8_t sequenceHoppingEnabled; + uint8_t cyclicShift; +}UE_PHY_pusch_config_t; + + +typedef struct{ + uint8_t enabled_flag; + uint8_t srs_BandwidthConfig; + uint8_t srs_SubframeConfig; + uint8_t ackNackSRS_SimultaneousTransmission; + uint8_t srs_MaxUpPts; +}UE_PHY_SRS_config_t; + +typedef struct{ + int8_t p0_NominalPUSCH; + PUSCH_alpha_t alpha; + int8_t p0_NominalPUCCH; + int8_t deltaPreambleMsg3; + long deltaF_PUCCH_Format1; + long deltaF_PUCCH_Format1b; + long deltaF_PUCCH_Format2; + long deltaF_PUCCH_Format2a; + long deltaF_PUCCH_Format2b; +}UE_PHY_UL_power_control_config_t; + + +typedef struct{ + uint8_t maxHARQ_Msg3Tx; +}UE_PHY_HARQ_Msg3_config_t; + +typedef struct{ + uint8_t nb_antennas_tx; +}UE_PHY_antenna_config_t; + +typedef struct{ + PHICH_RESOURCE_t phich_resource; + PHICH_DURATION_t phich_duration; +}UE_PHY_phich_config_t; + + +typedef struct { + UE_PHY_tdd_frame_structure_t ue_tdd_frame_structure_config; + UE_PHY_prach_config_t ue_prach_config; + UE_PHY_pucch_config_t ue_pucch_config; + UE_PHY_pdsch_config_t ue_pdsch_config; + UE_PHY_pusch_config_t ue_pusch_config; + UE_PHY_SRS_config_t ue_srs_config; + UE_PHY_UL_power_control_config_t ue_ul_pow_cntl_config; + UE_PHY_HARQ_Msg3_config_t ue_harq_msg3_config; + /* Where can we find the types and values of the configuration for the PCH? + UE_MAC_pusch_config_t ue_pch_config + radioResourceConfigCommon->pcch_Config.defaultPagingCycle, radioResourceConfigCommon->pcch_Config.nB*/ + UE_PHY_antenna_config_t ue_ant_config; + UE_PHY_phich_config_t ue_phich_config; + /* MBSFN?*/ +}UE_PHY_config_common_request_t; + + + + + + + +// *** UE_Config_dedicated. request related structures + +typedef struct{ + PA_t p_a; +}UE_PHY_pdsch_config_dedicated_t; + + +typedef struct{ + uint8_t ackNackRepetition; + ANFBmode_t tdd_AckNackFeedbackMode; + //ACKNAKREP_t repetitionFactor; + //uint16_t n1PUCCH_AN_Rep; +}UE_PHY_pucch_config_dedicated_t; + + +typedef struct{ + uint16_t betaOffset_ACK_Index; + uint16_t betaOffset_RI_Index; + uint16_t betaOffset_CQI_Index; +}UE_PHY_pusch_config_dedicated_t; + + +typedef struct{ + int8_t p0_UE_PUSCH; + uint8_t deltaMCS_Enabled; + uint8_t accumulationEnabled; + int8_t p0_UE_PUCCH; + int8_t pSRS_Offset; + uint8_t filterCoefficient; +}UE_PHY_ul_power_control_config_dedicated_t; + + +typedef struct{ + uint16_t sr_PUCCH_ResourceIndex; + uint8_t sr_ConfigIndex; + DSR_TRANSMAX_t dsr_TransMax; +}UE_PHY_SR_config_dedicated_t; + + +typedef struct{ + uint8_t srsConfigDedicatedSetup; + uint8_t duration; + uint8_t cyclicShift; + uint8_t freqDomainPosition; + uint8_t srs_Bandwidth; + uint16_t srs_ConfigIndex; + uint8_t srs_HoppingBandwidth; + uint8_t transmissionComb; + //uint8_t srsCellSubframe; + //uint8_t srsUeSubframe; +}UE_PHY_srs_ul_config_dedicated_t; + + +typedef struct{ + CQI_REPORTMODEAPERIODIC cqi_ReportModeAperiodic; + CQI_REPORTPERIODIC CQI_ReportPeriodic; + //int8_t nomPDSCH_RS_EPRE_Offset; +}UE_PHY_cqi_report_config_dedicated_t; + + + +typedef struct{ + uint8_t transmission_mode [NUMBER_OF_CONNECTED_eNB_MAX]; + UE_PHY_pdsch_config_dedicated_t ue_pdsch_config; + UE_PHY_pucch_config_dedicated_t ue_pucch_config; + UE_PHY_pusch_config_dedicated_t ue_pusch_config; + UE_PHY_ul_power_control_config_dedicated_t ue_ul_pow_cntrl_config; + UE_PHY_SR_config_dedicated_t ue_SR_config; + UE_PHY_srs_ul_config_dedicated_t ue_srs_ul_config; + UE_PHY_cqi_report_config_dedicated_t ue_cqi_report_config; +}UE_PHY_config_dedicated_request_t; + +#endif + + + + + + + + + + + + + + + + + + + +/* +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t num_tlv; + nfapi_subframe_config_t subframe_config; + nfapi_rf_config_t rf_config; + nfapi_phich_config_t phich_config; + nfapi_sch_config_t sch_config; + nfapi_prach_config_t prach_config; + nfapi_pusch_config_t pusch_config; + nfapi_pucch_config_t pucch_config; + nfapi_srs_config_t srs_config; + nfapi_uplink_reference_signal_config_t uplink_reference_signal_config; + nfapi_laa_config_t laa_config; + nfapi_emtc_config_t emtc_config; + nfapi_tdd_frame_structure_t tdd_frame_structure_config; + nfapi_l23_config_t l23_config; + nfapi_nb_iot_config_t nb_iot_config; + + // addition nfapi tlvs as per table 2-16 in idle or configure + nfapi_nfapi_t nfapi_config; + + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_config_request_t; + + + + + +typedef struct { + nfapi_tl_t tl; + uint8_t dci_format; + uint8_t cce_index; + uint8_t aggregation_level; + uint16_t rnti; + uint8_t resource_block_start; + uint8_t number_of_resource_block; + uint8_t mcs_1; + uint8_t cyclic_shift_2_for_drms; + uint8_t frequency_hopping_enabled_flag; + uint8_t frequency_hopping_bits; + uint8_t new_data_indication_1; + uint8_t ue_tx_antenna_seleciton; + uint8_t tpc; + uint8_t cqi_csi_request; + uint8_t ul_index; + uint8_t dl_assignment_index; + uint32_t tpc_bitmap; + uint16_t transmission_power; +} nfapi_hi_dci0_dci_pdu_rel8_t; + +*/ diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h deleted file mode 100644 index deb07443f18fcddf3a1555821fece15ca0acd7c4..0000000000000000000000000000000000000000 --- a/openair2/PHY_INTERFACE/defs.h +++ /dev/null @@ -1,373 +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 PHY_INTERFACE/defs.h -* \brief mac phy interface primitives -* \author Raymond Knopp and Navid Nikaein -* \date 2011 -* \version 0.5 -* \mail navid.nikaein@eurecom.fr or openair_tech@eurecom.fr -*/ - -#ifndef __MAC_PHY_PRIMITIVES_H__ -# define __MAC_PHY_PRIMITIVES_H__ - -#include "LAYER2/MAC/defs.h" - - -#define MAX_NUMBER_OF_MAC_INSTANCES 16 - -#define NULL_PDU 255 -#define DCI 0 -#define DLSCH 1 -#define ULSCH 2 - -#define mac_exit_wrapper(sTRING) \ -do { \ - char temp[300]; \ - snprintf(temp, sizeof(temp), "%s in file "__FILE__" at line %d\n", sTRING, __LINE__); \ - mac_xface->macphy_exit(temp); \ -} while(0) - -/** @defgroup _phy_if MAC-PHY interface - * @ingroup _oai2 - * @{ - */ -/*! \brief MACPHY Interface */ -/* -typedef struct { - /// Pointer function that initializes L2 - int (*macphy_init)(int eMBMS_active, char *uecap_xer, uint8_t CBA_active,uint8_t HO_active); - - /// Pointer function that stops the low-level scheduler due an exit condition - void (*macphy_exit)(const char *); - - // eNB functions - /// Invoke dlsch/ulsch scheduling procedure for new subframe - void (*eNB_dlsch_ulsch_scheduler)(module_id_t Mod_id,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP);//, int calibration_flag); - - /// Fill random access response sdu, passing timing advance - uint16_t (*fill_rar)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t *dlsch_buffer,uint16_t N_RB_UL, uint8_t input_buffer_length); - - /// Initiate the RA procedure upon reception (hypothetical) of a valid preamble - void (*initiate_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframe,uint8_t f_id); - - /// cancel an ongoing RA procedure - void (*cancel_ra_proc)(module_id_t Mod_id,int CC_id,frame_t frameP,uint16_t preamble); - - /// Inform MAC layer that an uplink is scheduled for Msg3 in given subframe. - /// This is used so that the MAC scheduler marks as busy the RBs used by the Msg3. - void (*set_msg3_subframe)(module_id_t Mod_id, - int CC_id, - int frame, - int subframe, - int rnti, - int Msg3_frame, - int Msg3_subframe); - - /// Get DCI for current subframe from MAC - DCI_PDU* (*get_dci_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe); - - /// Get DLSCH sdu for particular RNTI and Transport block index - uint8_t* (*get_dlsch_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,uint8_t TB_index); - - /// Send ULSCH sdu to MAC for given rnti - void (*rx_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP, sub_frame_t sub_frameP,rnti_t rnti, uint8_t *sdu,uint16_t sdu_len, int harq_pid,uint8_t *msg3_flag); - - /// Indicate failure to synch to external source - void (*mrbch_phy_sync_failure) (module_id_t Mod_id,frame_t frameP, uint8_t free_eNB_index); - - /// Indicate Scheduling Request from UE - void (*SR_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe); - /// Indicate UL Failure to eNodeB MAC - void (*UL_failure_indication)(module_id_t Mod_id,int CC_id,frame_t frameP,rnti_t rnti,sub_frame_t subframe); - - /// Configure Common PHY parameters from SIB1 - void (*phy_config_mib_eNB)(module_id_t Mod_id,int CC_id, - int eutra_band, - int N_RB_DL, - PHICH_Config_t *phich_Config, - int Nid_cell, - int Ncp, - int p_eNB, - uint32_t dl_CarrierFreq, - uint32_t ul_CarrierFreq); - - /// Configure Common PHY parameters from SIB1 - void (*phy_config_sib1_eNB)(module_id_t Mod_id,int CC_id, - TDD_Config_t *tdd_config, - uint8_t SIwindowsize, - uint16_t SIperiod); - - /// Configure Common PHY parameters from SIB2 - void (*phy_config_sib2_eNB)(module_id_t Mod_id, int CC_id, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - ARFCN_ValueEUTRA_t *ul_CArrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList); - -#if defined(Rel10) || defined(Rel14) - /// Configure Common PHY parameters from SIB13 - void (*phy_config_sib13_eNB)(module_id_t Mod_id,int CC_id, int mbsfn_Area_idx, - long mbsfn_AreaId_r9); - - void (*phy_config_dedicated_scell_eNB)(uint8_t Mod_id, - uint16_t rnti, - SCellToAddMod_r10_t *sCellToAddMod_r10, - int CC_id); -#endif - - /// PHY-Config-Dedicated eNB - void (*phy_config_dedicated_eNB)(module_id_t Mod_id,int CC_id,rnti_t rnti, - struct PhysicalConfigDedicated *physicalConfigDedicated); - -#if defined(Rel10) || defined(Rel14) - /// Get MCH sdu and corresponding MCS for particular MBSFN subframe - MCH_PDU* (*get_mch_sdu)(module_id_t Mod_id, int CC_id, frame_t frameP,sub_frame_t subframe); -#endif - // configure the cba rnti at the physical layer - void (*phy_config_cba_rnti)(module_id_t Mod_id,int CC_id,eNB_flag_t eNB_flag, uint8_t index, uint16_t cba_rnti, uint8_t cba_group_id, uint8_t num_active_cba_groups); - /// get delta mcs for fast UL AMC - int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs); - - int (*mac_phy_remove_ue)(module_id_t Mod_idP,rnti_t rntiP); - /// UE functions - - /// reset the ue phy - void (*phy_reset_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Indicate loss of synchronization of PBCH for this eNB to MAC layer - void (*out_of_sync_ind)(module_id_t Mod_id,frame_t frameP,uint16_t eNB_index); - - /// Send a received SI sdu - void (*ue_decode_si)(module_id_t Mod_id,int CC_id,frame_t frameP, uint8_t CH_index, void *pdu, uint16_t len); - - /// Send a received Paging sdu - void (*ue_decode_p)(module_id_t Mod_id,int CC_id,frame_t frameP, uint8_t CH_index, void *pdu, uint16_t len); - - /// Send a received DLSCH sdu to MAC - void (*ue_send_sdu)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,sub_frame_t subframe,uint8_t *sdu,uint16_t sdu_len,uint8_t CH_index); - -#if defined(Rel10) || defined(Rel14) - /// Send a received MCH sdu to MAC - void (*ue_send_mch_sdu)(module_id_t Mod_id,uint8_t CC_id, frame_t frameP,uint8_t *sdu,uint16_t sdu_len,uint8_t eNB_index,uint8_t sync_area); - - /// Function to check if UE PHY needs to decode MCH for MAC - /// get the sync area id, and return MCS value if need to decode, otherwise -1 - int (*ue_query_mch)(module_id_t Mod_id, uint8_t CC_id,frame_t frameP,sub_frame_t subframe,uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active); -#endif - - /// Retrieve ULSCH sdu from MAC - void (*ue_get_sdu)(module_id_t Mod_id,int CC_id,frame_t frameP,sub_frame_t subframe, uint8_t CH_index,uint8_t *ulsch_buffer,uint16_t buflen,uint8_t *access_mode); - - /// Retrieve RRCConnectionReq from MAC - PRACH_RESOURCES_t* (*ue_get_rach)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t Msg3_flag,sub_frame_t subframe); - - /// Process Random-Access Response - uint16_t (*ue_process_rar)(module_id_t Mod_id,int CC_id,frame_t frameP, uint16_t ra_rnti, uint8_t *dlsch_buffer, uint16_t *t_crnti,uint8_t preamble_index, uint8_t* selected_rar_buffer); - - /// Get SR payload (0,1) from UE MAC - uint32_t (*ue_get_SR)(module_id_t Mod_id,int CC_id,frame_t frameP,uint8_t eNB_id,rnti_t rnti,sub_frame_t subframe); - - /// Indicate synchronization with valid PBCH - void (*dl_phy_sync_success) (module_id_t Mod_id,frame_t frameP, uint8_t CH_index,uint8_t first_sync); - - /// Only calls the PDCP for now - UE_L2_STATE_t (*ue_scheduler)(module_id_t Mod_id, frame_t rxFrameP,sub_frame_t rxSubframe, frame_t txFrameP,sub_frame_t txSubframe, lte_subframe_t direction, uint8_t eNB_id, int CC_id); - - /// PHY-Config-Dedicated UE - void (*phy_config_dedicated_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - struct PhysicalConfigDedicated *physicalConfigDedicated); - - /// PHY-Config-harq UE - void (*phy_config_harq_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - uint16_t max_harq_tx); - /// Configure Common PHY parameters from SIB1 - void (*phy_config_sib1_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - TDD_Config_t *tdd_config, - uint8_t SIwindowsize, - uint16_t SIperiod); - - /// Configure Common PHY parameters from SIB2 - void (*phy_config_sib2_ue)(module_id_t Mod_id,int CC_id,uint8_t CH_index, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - ARFCN_ValueEUTRA_t *ul_CArrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList); - -#if defined(Rel10) || defined(Rel14) - /// Configure Common PHY parameters from SIB13 - void (*phy_config_sib13_ue)(uint8_t Mod_id,int CC_id, uint8_t eNB_index,int mbsfn_Area_idx, - long mbsfn_AreaId_r9); - - void (*phy_config_dedicated_scell_ue)(uint8_t Mod_id, - uint8_t eNB_index, - SCellToAddMod_r10_t *sCellToAddMod_r10, - int CC_id); -#endif - /// Configure Common PHY parameters from mobilityControlInfo - void (*phy_config_afterHO_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t CH_index, - MobilityControlInfo_t *mobilityControlInfo, - uint8_t ho_failed); - - /// Function to indicate failure of contention resolution or RA procedure - void (*ra_failed)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index); - - /// Function to indicate success of contention resolution or RA procedure - void (*ra_succeeded)(module_id_t Mod_id,uint8_t CC_id, uint8_t eNB_index); - - /// Function to indicate the transmission of msg1/rach to MAC - void (*Msg1_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id); - - /// Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer - void (*Msg3_transmitted)(module_id_t Mod_id,uint8_t CC_id,frame_t frameP,uint8_t eNB_id); - - /// Function to pass inter-cell measurement parameters to PHY (cell Ids) - void (*phy_config_meas_ue)(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,uint32_t *adj_cell_id); - - // PHY Helper Functions - - /// RIV computation from PHY - uint16_t (*computeRIV)(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); - - /// Downlink TBS table lookup from PHY - uint32_t (*get_TBS_DL)(uint8_t mcs, uint16_t nb_rb); - - /// Uplink TBS table lookup from PHY - uint32_t (*get_TBS_UL)(uint8_t mcs, uint16_t nb_rb); - - /// Function to retrieve the HARQ round index for a particular UL/DLSCH and harq_pid - int (*get_ue_active_harq_pid)(module_id_t Mod_id, uint8_t CC_id,rnti_t rnti, int frame, uint8_t subframe, uint8_t *harq_pid, uint8_t *round, uint8_t ul_flag); - - /// Function to retrieve number of CCE - uint16_t (*get_nCCE_max)(module_id_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe); - - - int (*get_nCCE_offset)(int *CCE_table, - const unsigned char L, - const int nCCE, - const int common_dci, - const unsigned short rnti, - const unsigned char subframe); - - /// Function to retrieve number of PRB in an rb_alloc - uint32_t (*get_nb_rb)(uint8_t ra_header, uint32_t rb_alloc, int n_rb_dl); - - /// Function to convert VRB to PRB for distributed allocation - uint32_t (*get_prb)(int N_RB_DL,int odd_slot,int vrb,int Ngap); - - /// Function to retrieve transmission mode for UE - uint8_t (*get_transmission_mode)(module_id_t Mod_id,uint8_t CC_id,rnti_t rnti); - - /// Function to retrieve rb_alloc bitmap from dci rballoc field and VRB type - uint32_t (*get_rballoc)(vrb_t vrb_type, uint16_t rb_alloc_dci); - - /// Function for UE MAC to retrieve current PHY connectivity mode (PRACH,RA_RESPONSE,PUSCH) - UE_MODE_t (*get_ue_mode)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to retrieve measured Path Loss - int16_t (*get_PL)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to retrieve the rssi - uint32_t (*get_RSSI)(uint8_t Mod_id,uint8_t CC_id); - - /// Function for UE MAC to retrieve the total gain - uint32_t (*get_rx_total_gain_dB)(uint8_t Mod_id,uint8_t CC_id); - - /// Function for UE MAC to retrieve the number of adjustent cells - uint8_t (*get_n_adj_cells)(uint8_t Mod_id,uint8_t CC_id); - - /// Function for UE MAC to retrieve RSRP/RSRQ measurements - uint32_t (*get_RSRP)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to retrieve RSRP/RSRQ measurements - uint32_t (*get_RSRQ)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements - uint8_t (*set_RSRP_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp); - - /// Function for UE MAC to set the layer3 filtered RSRP/RSRQ measurements - uint8_t (*set_RSRQ_filtered)(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp); - - /// Function for UE/eNB MAC to retrieve number of PRACH in TDD - uint8_t (*get_num_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms); - - /// Function for UE/eNB MAC to retrieve f_id of particular PRACH resource in TDD - uint8_t (*get_fid_prach_tdd)(LTE_DL_FRAME_PARMS *frame_parms,uint8_t tdd_map_index); - - /// Function for eNB MAC to retrieve subframe direction - lte_subframe_t (*get_subframe_direction)(module_id_t Mod_id, uint8_t CC_id, uint8_t subframe); - - // MAC Helper functions - /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (Po_NOMINAL_PUSCH parameter) - int8_t (*get_Po_NOMINAL_PUSCH)(module_id_t Mod_id,uint8_t CC_id); - - /// Function for UE/PHY to compute PUSCH transmit power in power-control procedure (deltaP_rampup parameter) - int8_t (*get_deltaP_rampup)(module_id_t Mod_id,uint8_t CC_id); - - /// Function for UE/PHY to compute PHR - int8_t (*get_PHR)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index); - - /// Function for UE to process the timing advance command - void (*process_timing_advance)(module_id_t Mod_id,uint8_t CC_id, int16_t timing_advance); - - /// Function for MAC to get the UE stats from the PHY - LTE_eNB_UE_stats* (*get_eNB_UE_stats)(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); - - /// get the frame parameters from the PHY - LTE_DL_FRAME_PARMS* (*get_lte_frame_parms)(module_id_t Mod_id, uint8_t CC_id); - - /// get the Multiuser mimo mode - MU_MIMO_mode* (*get_mu_mimo_mode) (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); - - /// get the delta TF for Uplink Power Control Calculation - int16_t (*get_hundred_times_delta_TF) (module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid); - /// get target PUSCH received power - int16_t (*get_target_pusch_rx_power) (module_id_t module_idP, uint8_t CC_id); - /// get target PUSCH received power - int16_t (*get_target_pucch_rx_power) (module_id_t module_idP, uint8_t CC_id); - - unsigned char is_cluster_head; - unsigned char is_primary_cluster_head; - unsigned char is_secondary_cluster_head; - unsigned char cluster_head_index; - - /// PHY Frame Configuration - LTE_DL_FRAME_PARMS *frame_parms; - - uint8_t (*get_prach_prb_offset)(LTE_DL_FRAME_PARMS *frame_parms, uint8_t tdd_mapindex, uint16_t Nf); - - int (*is_prach_subframe)(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe); - - /// ICIC algos - uint8_t (*get_SB_size)(uint8_t n_rb_dl); - ///end ALU's algo - -} MAC_xface; - -*/ - -#endif - - -/** @} */ diff --git a/openair2/PHY_INTERFACE/phy_interface.h b/openair2/PHY_INTERFACE/phy_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..f275e91ec1b619059f81be20977c215c6345d922 --- /dev/null +++ b/openair2/PHY_INTERFACE/phy_interface.h @@ -0,0 +1,55 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY_INTERFACE/defs.h +* \brief mac phy interface primitives +* \author Raymond Knopp and Navid Nikaein +* \date 2011 +* \version 0.5 +* \mail navid.nikaein@eurecom.fr or openair_tech@eurecom.fr +*/ + +#ifndef __PHY_INTERFACE_H__ +# define __PHY_INTERFACE_H__ + +#include "LAYER2/MAC/mac.h" + + +#define MAX_NUMBER_OF_MAC_INSTANCES 16 + +#define NULL_PDU 255 +#define DCI 0 +#define DLSCH 1 +#define ULSCH 2 + +#define mac_exit_wrapper(sTRING) \ +do { \ + char temp[300]; \ + snprintf(temp, sizeof(temp), "%s in file "__FILE__" at line %d\n", sTRING, __LINE__); \ + mac_xface->macphy_exit(temp); \ +} while(0) + + + +#endif + + +/** @} */ diff --git a/openair2/PHY_INTERFACE/extern.h b/openair2/PHY_INTERFACE/phy_interface_extern.h similarity index 100% rename from openair2/PHY_INTERFACE/extern.h rename to openair2/PHY_INTERFACE/phy_interface_extern.h diff --git a/openair2/PHY_INTERFACE/vars.h b/openair2/PHY_INTERFACE/phy_interface_vars.h similarity index 98% rename from openair2/PHY_INTERFACE/vars.h rename to openair2/PHY_INTERFACE/phy_interface_vars.h index 566f4347b6e5e264ff19a5a28193b1c96258ab97..5f205d302443ddc84274a7cb33e6dc9f8477c197 100644 --- a/openair2/PHY_INTERFACE/vars.h +++ b/openair2/PHY_INTERFACE/phy_interface_vars.h @@ -23,7 +23,7 @@ #define __PHY_INTERFACE_VARS_H__ //#include "SIMULATION/PHY_EMULATION/spec_defs.h" -#include "defs.h" +#include "phy_interface.h" #ifdef PHY_EMUL #include "SIMULATION/PHY_EMULATION/DEVICE_DRIVER/defs.h" diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c new file mode 100644 index 0000000000000000000000000000000000000000..588cde5231d917d1db71b172563c13ab1eee3a26 --- /dev/null +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -0,0 +1,1022 @@ + +//#include "openair1/PHY/defs.h" +//#include "openair2/PHY_INTERFACE/IF_Module.h" +//#include "openair1/PHY/extern.h" +#include "openair2/LAYER2/MAC/mac_extern.h" +#include "openair2/LAYER2/MAC/mac.h" +#include "openair2/LAYER2/MAC/mac_proto.h" +//#include "openair2/LAYER2/MAC/vars.h" +#include "openair1/SCHED_UE/sched_UE.h" +#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h" +//#include "common/ran_context.h" +#include "openair2/PHY_INTERFACE/phy_stub_UE.h" +#include "openair2/ENB_APP/L1_paramdef.h" +#include "openair2/ENB_APP/enb_paramdef.h" +#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" +#include "common/config/config_load_configmodule.h" +#include "common/config/config_userapi.h" + +//#define DEADLINE_SCHEDULER 1 + + +extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); +extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); +extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); +void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port); + + + + +//extern uint8_t nfapi_pnf; +//UL_IND_t *UL_INFO; +extern nfapi_tx_request_pdu_t* tx_request_pdu[1023][10][10]; +//extern int timer_subframe; +//extern int timer_frame; + +extern uint16_t sf_ahead; + +void Msg1_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); +void Msg3_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); + + + +void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t* UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index) +{ + nfapi_rx_indication_pdu_t *pdu; + + int timing_advance_update; + + + pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + + + UL_INFO->rx_ind.sfn_sf = frame<<4| subframe; + UL_INFO->rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + UL_INFO->rx_ind.vendor_extension = ul_config_req->vendor_extension; + + + pdu = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus]; + //pdu = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[index]; + + // pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; + pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + //pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; + pdu->rx_indication_rel8.length = buflen; + pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation + pdu->data = ulsch_buffer; + // estimate timing advance for MAC + //sync_pos = lte_est_timing_advance_pusch(eNB,UE_id); + timing_advance_update = 0; //Panos: Don't know what to put here + pdu->rx_indication_rel8.timing_advance = timing_advance_update; + + int SNRtimes10 = 640; + + if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0; + else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; + else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; + + + UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; + UL_INFO->rx_ind.sfn_sf = frame<<4 | subframe; + pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + + +} + +void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti) { + + + pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + + nfapi_sr_indication_t *sr_ind = &UL_INFO->sr_ind; + nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body; + nfapi_sr_indication_pdu_t *pdu = &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs]; + UL_INFO->sr_ind.vendor_extension = ul_config_req->vendor_extension; + + //nfapi_sr_indication_pdu_t *pdu = &UL_INFO->sr_ind.sr_indication_body.sr_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus]; + + sr_ind->sfn_sf = frame<<4|subframe; + sr_ind->header.message_id = NFAPI_RX_SR_INDICATION; + + sr_ind_body->tl.tag = NFAPI_SR_INDICATION_BODY_TAG; + + pdu->instance_length = 0; // don't know what to do with this + // pdu->rx_ue_information.handle = handle; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; //UE_mac_inst[Mod_id].crnti;; //Panos: Is this the right RNTI? + + + // Panos dependency from PHY not sure how to substitute this. Should we hardcode it? + //int SNRtimes10 = dB_fixed_times10(stat) - 200;//(10*eNB->measurements.n0_power_dB[0]); + int SNRtimes10 = 640; + + pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + + + if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; + else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; + else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5; + pdu->ul_cqi_information.channel = 0; + + //UL_INFO->rx_ind.rx_indication_body.number_of_pdus++; + sr_ind_body->number_of_srs++; + pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); +} + + +void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti) { + + pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + + //Panos: REMEMBER HAVE EXCHANGED THE FOLLOWING TWO LINES HERE! + nfapi_crc_indication_pdu_t *pdu = &UL_INFO->crc_ind.crc_indication_body.crc_pdu_list[UL_INFO->crc_ind.crc_indication_body.number_of_crcs]; + + UL_INFO->crc_ind.sfn_sf = frame<<4| subframe; + UL_INFO->crc_ind.vendor_extension = ul_config_req->vendor_extension; + UL_INFO->crc_ind.header.message_id = NFAPI_CRC_INDICATION; + UL_INFO->crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG; + + pdu->instance_length = 0; // don't know what to do with this + // pdu->rx_ue_information.handle = handle; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + + //pdu->rx_ue_information.rnti = UE_mac_inst[Mod_id].crnti; + pdu->rx_ue_information.rnti = rnti; + pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; + pdu->crc_indication_rel8.crc_flag = crc_flag; + + UL_INFO->crc_ind.crc_indication_body.number_of_crcs++; + + LOG_D(PHY, "%s() rnti:%04x pdus:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, UL_INFO->crc_ind.crc_indication_body.number_of_crcs); + + pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); +} + +void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI) { + + LOG_D(MAC, "fill_rach_indication_UE_MAC 1 \n"); + pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t)); + + UL_INFO->rach_ind.rach_indication_body.number_of_preambles = 1; + + //eNB->UL_INFO.rach_ind.preamble_list = &eNB->preamble_list[0]; + UL_INFO->rach_ind.header.message_id = NFAPI_RACH_INDICATION; + UL_INFO->rach_ind.sfn_sf = frame<<4 | subframe; + UL_INFO->rach_ind.vendor_extension = NULL; + + UL_INFO->rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + + + UL_INFO->rach_ind.rach_indication_body.preamble_list = (nfapi_preamble_pdu_t*)malloc(UL_INFO->rach_ind.rach_indication_body.number_of_preambles*sizeof(nfapi_preamble_pdu_t)); + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance = 0; //Panos: Not sure about that + + //Panos: The two following should get extracted from the call to get_prach_resources(). + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble = ra_PreambleIndex; + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti = ra_RNTI; + //UL_INFO->rach_ind.rach_indication_body.number_of_preambles++; + + + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel13.rach_resource_type = 0; + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].instance_length = 0; + + + LOG_E(PHY,"\n\n\n\nDJP - this needs to be sent to VNF **********************************************\n\n\n\n"); + LOG_E(PHY,"UE Filling NFAPI indication for RACH : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble, + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti, + UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel13.rach_resource_type); + + //Panos: This function is currently defined only in the nfapi-RU-RAU-split so we should call it when we merge + // with that branch. + oai_nfapi_rach_ind(&UL_INFO->rach_ind); + free(UL_INFO->rach_ind.rach_indication_body.preamble_list); + free(UL_INFO); + + //} + pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + +} + +void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti) { + + pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + nfapi_cqi_indication_pdu_t *pdu = &UL_INFO->cqi_ind.cqi_pdu_list[UL_INFO->cqi_ind.number_of_cqis]; + nfapi_cqi_indication_raw_pdu_t *raw_pdu = &UL_INFO->cqi_ind.cqi_raw_pdu_list[UL_INFO->cqi_ind.number_of_cqis]; + + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; + //Panos: Since we assume that CRC flag is always 0 (ACK) I guess that data_offset should always be 0. + pdu->cqi_indication_rel9.data_offset = 0; + + // by default set O to rank 1 value + //pdu->cqi_indication_rel9.length = (ulsch_harq->Or1>>3) + ((ulsch_harq->Or1&7) > 0 ? 1 : 0); + // Panos: Not useful field for our case + pdu->cqi_indication_rel9.tl.tag = NFAPI_CQI_INDICATION_REL9_TAG; + pdu->cqi_indication_rel9.length = 0; + pdu->cqi_indication_rel9.ri[0] = 0; + + + pdu->cqi_indication_rel9.timing_advance = 0; + pdu->cqi_indication_rel9.number_of_cc_reported = 1; + pdu->ul_cqi_information.channel = 1; // PUSCH + + //Panos: Not sure how to substitute this. This should be the actual CQI value? So can + // we hardcode it to a specific value? + //memcpy((void*)raw_pdu->pdu,ulsch_harq->o,pdu->cqi_indication_rel9.length); + raw_pdu->pdu[0] = 7; + + + + UL_INFO->cqi_ind.number_of_cqis++; + pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + +} + +void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti) +{ + + pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + nfapi_harq_indication_pdu_t *pdu = &UL_INFO->harq_ind.harq_indication_body.harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs]; + int i; + + UL_INFO->harq_ind.header.message_id = NFAPI_HARQ_INDICATION; + UL_INFO->harq_ind.sfn_sf = frame<<4|subframe; + UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension; + + UL_INFO->harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + + pdu->instance_length = 0; // don't know what to do with this + // pdu->rx_ue_information.handle = handle; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + pdu->rx_ue_information.rnti = rnti; + + //Panos: For now we consider only FDD + //if (eNB->frame_parms.frame_type == FDD) { + 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 = harq_information->harq_information_rel10.harq_size; + + //Panos: Could this be wrong? Is the number_of_ack_nack field equivalent to O_ACK? + //pdu->harq_indication_fdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK; + + for (i=0;i<harq_information->harq_information_rel10.harq_size;i++) { + + pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 1; //Panos: Assuming always an ACK (No NACK or DTX) + + } + + UL_INFO->harq_ind.harq_indication_body.number_of_harqs++; + pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); +} + + +void fill_uci_harq_indication_UE_MAC(int Mod_id, + int frame, + int subframe, + UL_IND_t *UL_INFO, + nfapi_ul_config_harq_information *harq_information, + uint16_t rnti + /*uint8_t tdd_mapping_mode, + uint16_t tdd_multiplexing_mask*/) { + + + pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + nfapi_harq_indication_t *ind = &UL_INFO->harq_ind; + nfapi_harq_indication_body_t *body = &ind->harq_indication_body; + nfapi_harq_indication_pdu_t *pdu = &body->harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs]; + + UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension; + + ind->sfn_sf = frame<<4|subframe; + ind->header.message_id = NFAPI_HARQ_INDICATION; + + body->tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; + pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + + pdu->instance_length = 0; // don't know what to do with this + // pdu->rx_ue_information.handle = handle; + pdu->rx_ue_information.rnti = rnti; + + pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; + + int SNRtimes10 = 640; + + + if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; + else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; + else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5; + pdu->ul_cqi_information.channel = 0; + if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) && + (harq_information->harq_information_rel9_fdd.harq_size == 1)) { + + 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] = 1; //Panos: Assuming always an ACK (No NACK or DTX) + + + } + else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) && + (harq_information->harq_information_rel9_fdd.harq_size == 2)) { + 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; + pdu->harq_indication_fdd_rel13.harq_tb_n[0] = 1; //Panos: Assuming always an ACK (No NACK or DTX) + pdu->harq_indication_fdd_rel13.harq_tb_n[1] = 1; //Panos: Assuming always an ACK (No NACK or DTX) + + } + else AssertFatal(1==0,"only format 1a/b for now, received \n"); + + + UL_INFO->harq_ind.harq_indication_body.number_of_harqs++; + LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", UL_INFO->harq_ind.harq_indication_body.number_of_harqs); + pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex); + +} + + +void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, + nfapi_ul_config_request_pdu_t *ul_config_pdu, + uint16_t frame,uint8_t subframe,uint8_t srs_present, int index) +{ + nfapi_ul_config_ulsch_pdu_rel8_t *rel8 = &ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8; + + if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) { + LOG_D(PHY,"Applying UL config for UE, rnti %x for frame %d, subframe %d\n", + rel8->rnti,frame,subframe); + uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); + uint16_t buflen = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size; + + uint16_t rnti = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti; + uint8_t access_mode=SCHEDULED_ACCESS; + if(buflen>0){ + if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case + LOG_D(MAC, "handle_nfapi_ul_pdu_UE_MAC 2.2, Mod_id:%d, SFN/SF: %d/%d \n", Mod_id, frame, subframe); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); + Msg3_transmitted(Mod_id, 0, frame, 0); + // Panos: Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + + // Panos: This should be done after the reception of the respective hi_dci0 + //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } + else { + //LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 2.3 \n"); + ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); + } + } + } + + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) { + + //AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, + // "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti); + uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); + uint16_t buflen = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.size; + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = &ul_config_pdu->ulsch_harq_pdu.harq_information; + uint16_t rnti = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + uint8_t access_mode=SCHEDULED_ACCESS; + if(buflen>0){ + if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); + Msg3_transmitted(Mod_id, 0, frame, 0); + //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + // Panos: Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } + else { + //LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 3.1 \n"); + ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); + } + + } + if(ulsch_harq_information!=NULL) + fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) { + uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); + uint16_t buflen = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size; + + uint16_t rnti = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + uint8_t access_mode=SCHEDULED_ACCESS; + if(buflen>0){ + if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); + Msg3_transmitted(Mod_id, 0, frame, 0); + //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + // Panos: Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } + else { + ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); + } + } + fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); + + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) { + + uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32))); + uint16_t buflen = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size; + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information; + + uint16_t rnti = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti; + uint8_t access_mode=SCHEDULED_ACCESS; + if(buflen>0){ + if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index); + Msg3_transmitted(Mod_id, 0, frame, 0); + //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + // Panos: Modification + UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } + else { + ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode); + fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti); + fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index); + } + } + + if(ulsch_harq_information!=NULL) + fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti); + fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); + + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) { + + uint16_t rnti = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti; + + nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_harq_pdu.harq_information; + if(ulsch_harq_information != NULL) + fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,ulsch_harq_information, rnti); + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) { + AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE not handled yet\n"); + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) { + AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE not handled yet\n"); + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) { + AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n"); + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) { + + uint16_t rnti = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti; + + if (ue_get_SR(Mod_id ,0,frame, 0, rnti, subframe)) + fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti); + + } + else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) { + //AssertFatal((UE_id = find_uci(rel8->rnti,proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0, + // "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti); + + uint16_t rnti = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti; + + // We fill the sr_indication only if ue_get_sr() would normally instruct PHY to send a SR. + if (ue_get_SR(Mod_id ,0,frame, 0, rnti, subframe)) + fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,rnti); + + nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_sr_harq_pdu.harq_information; + if (ulsch_harq_information != NULL) + fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,ulsch_harq_information, rnti); + + } + +} + + + + + + +int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int timer_subframe, module_id_t Mod_id) +{ + //if (req!=NULL){ // && req->ul_config_request_body.ul_config_pdu_list !=NULL){ + LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n", + __FUNCTION__, + NFAPI_SFNSF2DEC(req->sfn_sf), + req->ul_config_request_body.number_of_pdus, + req->ul_config_request_body.rach_prach_frequency_resources, + req->ul_config_request_body.srs_present + ); + + int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); + int sf = NFAPI_SFNSF2SF(req->sfn_sf); + + + LOG_D(MAC, "ul_config_req_UE_MAC() TOTAL NUMBER OF UL_CONFIG PDUs: %d, SFN/SF: %d/%d \n", req->ul_config_request_body.number_of_pdus, timer_frame, timer_subframe); + + + + for (int i=0;i<req->ul_config_request_body.number_of_pdus;i++) + { + + if ( + (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || + (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || + (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || + (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) || + (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_cqi_harq_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) || + (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_sr_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) || + (req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) + ) + { + + handle_nfapi_ul_pdu_UE_MAC(Mod_id,&req->ul_config_request_body.ul_config_pdu_list[i],sfn,sf,req->ul_config_request_body.srs_present, i); + + } + else + { + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", __FUNCTION__, i, ul_config_pdu_list[i].pdu_type); + } + } + +// } + + return 0; +} + + + +int tx_req_UE_MAC(nfapi_tx_request_t* req) +{ + uint16_t sfn = NFAPI_SFNSF2SFN(req->sfn_sf); + uint16_t sf = NFAPI_SFNSF2SF(req->sfn_sf); + + LOG_D(PHY,"%s() SFN/SF:%d/%d PDUs:%d\n", __FUNCTION__, sfn, sf, req->tx_request_body.number_of_pdus); + + + for (int i=0; i<req->tx_request_body.number_of_pdus; i++) + { + LOG_D(PHY,"%s() SFN/SF:%d/%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n", + __FUNCTION__, + sfn, sf, + req->tx_request_body.number_of_pdus, + i, + req->tx_request_body.tx_pdu_list[i].pdu_length, + req->tx_request_body.tx_pdu_list[i].pdu_index, + req->tx_request_body.tx_pdu_list[i].num_segments + ); + + } + + return 0; +} + + +int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //, nfapi_tx_request_pdu_t* tx_request_pdu_list) +{ + //if (req!=NULL && tx_request_pdu_list!=NULL){ + int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); + int sf = NFAPI_SFNSF2SF(req->sfn_sf); + //Mod_id = 0; // Currently static (only for one UE) but this should change. + + /*struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; + eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0];*/ + nfapi_dl_config_request_pdu_t* dl_config_pdu_list = req->dl_config_request_body.dl_config_pdu_list; + nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp; + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d sfn_sf:%d DCI:%d PDU:%d\n", __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, NFAPI_SFNSF2DEC(req->sfn_sf), req->dl_config_request_body.number_dci, req->dl_config_request_body.number_pdu); + + + + //LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%d%d dl_pdu:%d tx_req:%d hi_dci0:%d ul_cfg:%d num_pdcch_symbols:%d\n", + // frame,subframe,number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu, eNB->pdcch_vars[subframe&1].num_pdcch_symbols); + + for (int i=0;i<req->dl_config_request_body.number_pdu;i++) + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size); + //LOG_E(MAC, "dl_config_req_UE_MAC 2 Received real ones: sfn/sf:%d.%d PDU[%d] size:%d\n", sfn, sf, i, dl_config_pdu_list[i].pdu_size); + + if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + { + if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1) { + // C-RNTI (Normal DLSCH case) + dl_config_pdu_tmp = &dl_config_pdu_list[i+1]; + if (dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && UE_mac_inst[Mod_id].crnti == dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti){ + + /*nfapi_tx_request_pdu_t *ptr = tx_request_pdu_list; + ptr += dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index*(sizeof(nfapi_tx_request_pdu_t)); + nfapi_tx_request_pdu_t temp; + memset(&temp, 0, sizeof(nfapi_tx_request_pdu_t)); + //if (!memcmp(&temp, ptr, sizeof(temp)) ... + if( *(char*)ptr != 0){ + //if(tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data!= NULL && tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length >0){ + */ + + if(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){ + //if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ + + LOG_E(MAC, "dl_config_req_UE_MAC 2 Received data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d, tx_req_num_elems: %d \n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, tx_req_num_elems); + + ue_send_sdu(Mod_id, 0, sfn, sf, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length, + 0); + i++; + } + else{ + LOG_E(MAC,"dl_config_req_UE_MAC 2: Problem with receiving data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index); + i++; + } + } + else { + LOG_E(MAC,"[UE %d] Frame %d, subframe %d : DLSCH PDU from NFAPI not for this UE \n",Mod_id, sfn,sf); + i++; + } + } + else if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) { + dl_config_pdu_tmp = &dl_config_pdu_list[i+1]; + if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFF && UE_mac_inst[Mod_id].UE_mode[0] != NOT_SYNCHED){ //&& UE_mac_inst[Mod_id].UE_mode[0] != NOT_SYNCHED + + if(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){ + //if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ + ue_decode_si(Mod_id, 0, sfn, 0, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); + i++; + } + else{ + LOG_E(MAC,"dl_config_req_UE_MAC 3: Problem with receiving SI: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index); + i++; + } + } + else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFE){ + // P_RNTI case + //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; + + if (dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){ + //if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ + ue_decode_p(Mod_id, 0, sfn, 0, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); + i++; + } + else{ + LOG_E(MAC,"dl_config_req_UE_MAC: Problem with receiving Paging: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index); + i++; + } + } + else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { + // RA-RNTI case + LOG_E(MAC,"dl_config_req_UE_MAC 4 Received RAR? \n"); + // RNTI parameter not actually used. Provided only to comply with existing function definition. + // Not sure about parameters to fill the preamble index. + //rnti_t c_rnti = UE_mac_inst[Mod_id].crnti; + rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI; + if ((UE_mac_inst[Mod_id].UE_mode[0] != PUSCH) && + (UE_mac_inst[Mod_id].RA_prach_resources.Msg3!=NULL) && (ra_rnti== dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti) && + //(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL)) { + (dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1)) { + LOG_E(MAC,"dl_config_req_UE_MAC 5 Received RAR, PreambleIndex: %d \n", UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex); + ue_process_rar(Mod_id, 0, sfn, + ra_rnti, //RA-RNTI + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + &dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti + UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data); + UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; //Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first ULSCH Txon for the UE) + } + i++; + } + else { + LOG_E(MAC,"[UE %d] Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI 2\n",Mod_id, sfn, sf); + i++; + } + + } + } + else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) + { + // BCH case + // Last parameter is 1 if first time synchronization and zero otherwise. Not sure which value to put + // for our case. + //LOG_E(MAC,"dl_config_req_UE_MAC 4 Received MIB: sfn/sf: %d.%d \n", sfn, sf); + if(UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED){ + dl_phy_sync_success(Mod_id,sfn,0, 1); + LOG_E(MAC,"dl_config_req_UE_MAC 5 Received MIB: UE_mode: %d, sfn/sf: %d.%d\n", UE_mac_inst[Mod_id].UE_mode[0], sfn, sf); + UE_mac_inst[Mod_id].UE_mode[0]=PRACH; + } + else + dl_phy_sync_success(Mod_id,sfn,0, 0); + + } + + else + { + //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_config_pdu_list[i].pdu_type); + } + } + + return 0; + +} + + +int hi_dci0_req_UE_MAC(nfapi_hi_dci0_request_t* req, module_id_t Mod_id) +{ + if (req!=NULL && req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){ + LOG_D(PHY,"[UE-PHY_STUB] hi dci0 request sfn_sf:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi); + + + + for (int i=0; i<req->hi_dci0_request_body.number_of_dci + req->hi_dci0_request_body.number_of_hi; i++) + { + LOG_D(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); + + if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) + { + LOG_D(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_DCI_PDU_TYPE not used \n", NFAPI_SFNSF2DEC(req->sfn_sf), i); + + } + else if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) + { + //LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); + + nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = &req->hi_dci0_request_body.hi_dci0_pdu_list[i]; + + // This is meaningful only after ACKnowledging the first ULSCH Txon (i.e. Msg3) + if(hi_dci0_req_pdu->hi_pdu.hi_pdu_rel8.hi_value == 1 && UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ + //LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ 2 sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i); + //UE_mac_inst[Mod_id].UE_mode[0] = PUSCH; + //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0; + } + + } + else + { + LOG_E(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); + } + } + + } + + + return 0; +} + + + + + +// The following set of memcpy functions should be getting called as callback functions from +// pnf_p7_subframe_ind. +int memcpy_dl_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) +{ + + //module_id_t Mod_id = 0; //Panos: Currently static (only for one UE) but this should change. + + //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++){ + + dl_config_req = (nfapi_dl_config_request_t*)malloc(sizeof(nfapi_dl_config_request_t)); + //LOG_I(MAC, "Panos-D: memcpy_dl_config_req 1, Mod_id:%d \n", Mod_id); + + + //UE_mac_inst[Mod_id].dl_config_req->header = req->header; + dl_config_req->sfn_sf = req->sfn_sf; + + dl_config_req->vendor_extension = req->vendor_extension; + + dl_config_req->dl_config_request_body.number_dci = req->dl_config_request_body.number_dci; + dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; + dl_config_req->dl_config_request_body.number_pdsch_rnti = req->dl_config_request_body.number_pdsch_rnti; + dl_config_req->dl_config_request_body.number_pdu = req->dl_config_request_body.number_pdu; + + dl_config_req->dl_config_request_body.tl.tag = req->dl_config_request_body.tl.tag; + dl_config_req->dl_config_request_body.tl.length = req->dl_config_request_body.tl.length; + + dl_config_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*) calloc(req->dl_config_request_body.number_pdu, sizeof(nfapi_dl_config_request_pdu_t)); + for(int i=0; i<dl_config_req->dl_config_request_body.number_pdu; i++) { + dl_config_req->dl_config_request_body.dl_config_pdu_list[i] = req->dl_config_request_body.dl_config_pdu_list[i]; + } + + //} + + return 0; + +} + +int memcpy_ul_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) +{ + //LOG_D(MAC, "Panos-D: memcpy_ul_config_req 1 \n"); + + //module_id_t Mod_id = 0; //Panos: Currently static (only for one UE) but this should change. + + + //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++){ + + ul_config_req = (nfapi_ul_config_request_t*)malloc(sizeof(nfapi_ul_config_request_t)); + + ul_config_req->sfn_sf = req->sfn_sf; + ul_config_req->vendor_extension = req->vendor_extension; + + + ul_config_req->ul_config_request_body.number_of_pdus = req->ul_config_request_body.number_of_pdus; + ul_config_req->ul_config_request_body.rach_prach_frequency_resources = req->ul_config_request_body.rach_prach_frequency_resources; + ul_config_req->ul_config_request_body.srs_present = req->ul_config_request_body.srs_present; + + ul_config_req->ul_config_request_body.tl.tag = req->ul_config_request_body.tl.tag; + ul_config_req->ul_config_request_body.tl.length = req->ul_config_request_body.tl.length; + + //LOG_D(MAC, "memcpy_ul_config_req 1 #ofULPDUs: %d \n", UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.number_of_pdus); //req->ul_config_request_body.number_of_pdus); + ul_config_req->ul_config_request_body.ul_config_pdu_list = (nfapi_ul_config_request_pdu_t*) malloc(req->ul_config_request_body.number_of_pdus*sizeof(nfapi_ul_config_request_pdu_t)); + for(int i=0; i<ul_config_req->ul_config_request_body.number_of_pdus; i++) { + ul_config_req->ul_config_request_body.ul_config_pdu_list[i] = req->ul_config_request_body.ul_config_pdu_list[i]; + } + //} + + return 0; +} + + + + +int memcpy_tx_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) +{ + //module_id_t Mod_id = 0; //Panos: Currently static (only for one UE) but this should change. + + + tx_req_num_elems = req->tx_request_body.number_of_pdus; + tx_request_pdu_list = (nfapi_tx_request_pdu_t*) calloc(tx_req_num_elems, sizeof(nfapi_tx_request_pdu_t)); + for (int i=0; i<tx_req_num_elems; i++) { + tx_request_pdu_list[i].num_segments = req->tx_request_body.tx_pdu_list[i].num_segments; + tx_request_pdu_list[i].pdu_index = req->tx_request_body.tx_pdu_list[i].pdu_index; + tx_request_pdu_list[i].pdu_length = req->tx_request_body.tx_pdu_list[i].pdu_length; + for (int j=0; j<req->tx_request_body.tx_pdu_list[i].num_segments; j++){ + //*tx_request_pdu_list[i].segments[j].segment_data = *req->tx_request_body.tx_pdu_list[i].segments[j].segment_data; + tx_request_pdu_list[i].segments[j].segment_length = req->tx_request_body.tx_pdu_list[i].segments[j].segment_length; + if(tx_request_pdu_list[i].segments[j].segment_length > 0){ + tx_request_pdu_list[i].segments[j].segment_data = (uint8_t*)malloc(tx_request_pdu_list[i].segments[j].segment_length*sizeof (uint8_t)); + memcpy(tx_request_pdu_list[i].segments[j].segment_data, req->tx_request_body.tx_pdu_list[i].segments[j].segment_data, tx_request_pdu_list[i].segments[j].segment_length); + } + } + + } + + return 0; +} + +int memcpy_hi_dci0_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) +{ + + //if(req!=0){ + //module_id_t Mod_id = 0; //Panos: Currently static (only for one UE) but this should change. + + //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++){ + hi_dci0_req = (nfapi_hi_dci0_request_t*)malloc(sizeof(nfapi_hi_dci0_request_t)); + + hi_dci0_req->sfn_sf = req->sfn_sf; + hi_dci0_req->vendor_extension = req->vendor_extension; + + hi_dci0_req->hi_dci0_request_body.number_of_dci = req->hi_dci0_request_body.number_of_dci; + hi_dci0_req->hi_dci0_request_body.number_of_hi = req->hi_dci0_request_body.number_of_hi; + hi_dci0_req->hi_dci0_request_body.sfnsf = req->hi_dci0_request_body.sfnsf; + + //UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.tl = req->hi_dci0_request_body.tl; + hi_dci0_req->hi_dci0_request_body.tl.tag = req->hi_dci0_request_body.tl.tag; + hi_dci0_req->hi_dci0_request_body.tl.length = req->hi_dci0_request_body.tl.length; + + int total_pdus = hi_dci0_req->hi_dci0_request_body.number_of_dci + hi_dci0_req->hi_dci0_request_body.number_of_hi; + + hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*) malloc(total_pdus*sizeof(nfapi_hi_dci0_request_pdu_t)); + + for(int i=0; i<total_pdus; i++){ + hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i] = req->hi_dci0_request_body.hi_dci0_pdu_list[i]; + //LOG_I(MAC, "Original hi_dci0 req. type:%d, Copy type: %d \n",req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type, UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type); + } + + //} + return 0; +} + + + +void UE_config_stub_pnf(void) { + int j; + paramdef_t L1_Params[] = L1PARAMS_DESC; + paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0}; + + config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL); + if (L1_ParamList.numelt > 0) { + for (j=0; j<L1_ParamList.numelt; j++){ + //nb_L1_CC = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr); // Number of component carriers is of no use for the + // phy_stub mode UE pnf. Maybe we can completely skip it. + + if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { + sf_ahead = 4; // Need 4 subframe gap between RX and TX + } + // Panos: Right now that we have only one UE (thread) it is ok to put the eth_params in the UE_mac_inst. + // Later I think we have to change that to attribute eth_params to a global element for all the UEs. + else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { + stub_eth_params.local_if_name = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr)); + stub_eth_params.my_addr = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr)); + stub_eth_params.remote_addr = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr)); + stub_eth_params.my_portc = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr); + stub_eth_params.remote_portc = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr); + stub_eth_params.my_portd = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr); + stub_eth_params.remote_portd = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr); + stub_eth_params.transp_preference = ETH_UDP_MODE; + + sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2 + //configure_nfapi_pnf(UE_mac_inst[0].eth_params_n.remote_addr, UE_mac_inst[0].eth_params_n.remote_portc, UE_mac_inst[0].eth_params_n.my_addr, UE_mac_inst[0].eth_params_n.my_portd, UE_mac_inst[0].eth_params_n.remote_portd); + configure_nfapi_pnf(stub_eth_params.remote_addr, stub_eth_params.remote_portc, stub_eth_params.my_addr, stub_eth_params.my_portd, stub_eth_params.remote_portd); + } + else { // other midhaul + } + } + } + else { + + } +} + + +/* Dummy functions*/ + +void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) +{ + +} + + +void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) +{ + +} + + +void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, + int frame, int subframe, + eNB_rxtx_proc_t *proc, + nfapi_dl_config_request_pdu_t *dl_config_pdu) +{ + +} + + +void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, + nfapi_dl_config_request_pdu_t *dl_config_pdu, + uint8_t *sdu) +{ + +} + + +void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, + nfapi_dl_config_request_pdu_t *dl_config_pdu, + uint8_t codeword_index, + uint8_t *sdu) +{ + +} + + +void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, + nfapi_ul_config_request_pdu_t *ul_config_pdu, + uint16_t frame,uint8_t subframe,uint8_t srs_present) +{ + +} + +void phy_config_request(PHY_Config_t *phy_config) { + +} + +uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) { return(0);} + +int32_t get_uldl_offset(int eutra_bandP) { return(0);} + +int l1_north_init_eNB(void) { +return 0; +} + +void init_eNB_afterRU(void) { + +} + diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.h b/openair2/PHY_INTERFACE/phy_stub_UE.h new file mode 100644 index 0000000000000000000000000000000000000000..9865be3eebb2eab81fd10acde8b97bafe6fe2846 --- /dev/null +++ b/openair2/PHY_INTERFACE/phy_stub_UE.h @@ -0,0 +1,118 @@ +/* + * phy_stub_UE.h + * + * Created on: Sep 14, 2017 + * Author: montre + */ + + +#ifndef __PHY_STUB_UE__H__ +#define __PHY_STUB_UE__H__ + +#include <stdint.h> +#include "openair2/PHY_INTERFACE/IF_Module.h" +#include "nfapi_interface.h" +#include "nfapi_pnf_interface.h" +//#include "openair1/PHY/LTE_TRANSPORT/defs.h" +//#include "openair1/PHY/defs.h" +//#include "openair1/PHY/LTE_TRANSPORT/defs.h" + +UL_IND_t *UL_INFO; + +nfapi_tx_request_pdu_t* tx_request_pdu_list; +// New +/// Panos: Pointers to config_request types. Used from nfapi callback functions. +nfapi_dl_config_request_t* dl_config_req; +nfapi_ul_config_request_t* ul_config_req; +nfapi_hi_dci0_request_t* hi_dci0_req; + +int tx_req_num_elems; + +int next_ra_frame; +module_id_t next_Mod_id; +eth_params_t stub_eth_params; + + + + +// Panos: This function should return all the sched_response config messages which concern a specific UE. Inside this +// function we should somehow make the translation of config message's rnti to Mod_ID. +Sched_Rsp_t get_nfapi_sched_response(uint8_t Mod_id); + +// This function will be processing DL_config and Tx.requests and trigger all the MAC Rx related calls at the UE side, +// namely:ue_send_sdu(), or ue_decode_si(), or ue_decode_p(), or ue_process_rar() based on the rnti type. +//void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id); + +int pnf_ul_config_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req); + +// This function will be processing UL and HI_DCI0 config requests to trigger all the MAC Tx related calls +// at the UE side, namely: ue_get_SR(), ue_get_rach(), ue_get_sdu() based on the pdu configuration type. +// The output of these calls will be put to an UL_IND_t structure which will then be the input to +// send_nfapi_UL_indications(). +UL_IND_t generate_nfapi_UL_indications(Sched_Rsp_t sched_response); + +// This function should pass the UL indication messages to the eNB side through the socket interface. +void send_nfapi_UL_indications(UL_IND_t UL_INFO); + +// This function should be filling the nfapi ULSCH indications at the MAC level of the UE in a similar manner +// as fill_rx_indication() does. It should get called from ue_get_SDU() + +//void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe); + +void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index); + + +// This function should be indicating directly to the eNB when there is a planned scheduling request at the MAC layer +// of the UE. It should get called from ue_get_SR() +void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti); + +// In our case the this function will be always indicating ACK to the MAC of the eNB (i.e. always assuming) +// successful decoding. +void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti); + + +void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI); + + +void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti); + + +void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti); + +void fill_uci_harq_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO,nfapi_ul_config_harq_information *harq_information, uint16_t rnti + /*uint8_t tdd_mapping_mode, + uint16_t tdd_multiplexing_mask*/); + +int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int frame, int subframe, module_id_t Mod_id); + +void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, + nfapi_ul_config_request_pdu_t *ul_config_pdu, + uint16_t frame,uint8_t subframe,uint8_t srs_present, int index); + +//int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, nfapi_tx_request_pdu_t* tx_request_pdu_list); +int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id); + +int tx_req_UE_MAC(nfapi_tx_request_t* req); + + +int hi_dci0_req_UE_MAC(nfapi_hi_dci0_request_t* req, module_id_t Mod_id); + +// The following set of memcpy functions should be getting called as callback functions from +// pnf_p7_subframe_ind. + +int memcpy_dl_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req); + + +int memcpy_ul_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req); + + +int memcpy_tx_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req); + + +int memcpy_hi_dci0_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req); + +void UE_config_stub_pnf(void); + + + +#endif /* PHY_STUB_UE_H_ */ diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c similarity index 97% rename from openair2/RRC/LITE/L2_interface.c rename to openair2/RRC/LTE/L2_interface.c index 8a5136792cab52e08550b50fcc558d253a7411cd..5ac00ac35261e767bfb8db7dc768ba3f906980e2 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -29,26 +29,14 @@ */ #include "platform_types.h" -//#include "openair_defs.h" -//#include "openair_proto.h" -#include "defs.h" -#include "extern.h" -//#include "mac_lchan_interface.h" -//#include "openair_rrc_utils.h" -//#include "openair_rrc_main.h" +#include "rrc_defs.h" +#include "rrc_extern.h" #include "UTIL/LOG/log.h" #include "rrc_eNB_UE_context.h" #include "pdcp.h" #include "msc.h" #include "common/ran_context.h" -#ifdef PHY_EMUL -#include "SIMULATION/simulation_defs.h" -extern EMULATION_VARS *Emul_vars; -extern eNB_MAC_INST *eNB_mac_inst; -extern UE_MAC_INST *UE_mac_inst; -#endif - #if defined(ENABLE_ITTI) # include "intertask_interface.h" #endif @@ -285,7 +273,7 @@ mac_rrc_data_req( return (Sdu_size); } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if((Srb_id & RAB_OFFSET) == MCCH) { if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) { @@ -338,9 +326,9 @@ mac_rrc_data_req( //return(0); } -#endif //Rel10 || Rel14 +#endif // #if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR){ memcpy(&buffer_pP[0], RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR, diff --git a/openair2/RRC/LITE/L2_interface_common.c b/openair2/RRC/LTE/L2_interface_common.c similarity index 94% rename from openair2/RRC/LITE/L2_interface_common.c rename to openair2/RRC/LTE/L2_interface_common.c index 1b832521528ec231b8b8dc9d016e62584ff97191..d72cc2f5bee1aa2d10fbb61838c9fda1eac997c8 100644 --- a/openair2/RRC/LITE/L2_interface_common.c +++ b/openair2/RRC/LTE/L2_interface_common.c @@ -29,26 +29,14 @@ */ #include "platform_types.h" -//#include "openair_defs.h" -//#include "openair_proto.h" -#include "defs.h" -#include "extern.h" -//#include "mac_lchan_interface.h" -//#include "openair_rrc_utils.h" -//#include "openair_rrc_main.h" +#include "rrc_defs.h" +#include "rrc_extern.h" #include "UTIL/LOG/log.h" #include "rrc_eNB_UE_context.h" #include "pdcp.h" #include "msc.h" #include "common/ran_context.h" -#ifdef PHY_EMUL -#include "SIMULATION/simulation_defs.h" -extern EMULATION_VARS *Emul_vars; -extern eNB_MAC_INST *eNB_mac_inst; -extern UE_MAC_INST *UE_mac_inst; -#endif - #if defined(ENABLE_ITTI) # include "intertask_interface.h" #endif diff --git a/openair2/RRC/LITE/L2_interface_ue.c b/openair2/RRC/LTE/L2_interface_ue.c similarity index 92% rename from openair2/RRC/LITE/L2_interface_ue.c rename to openair2/RRC/LTE/L2_interface_ue.c index 244f0d2253bbd6cd78f5724650be5b3dcf7a29d3..569e2f008b13dcc0db29f65e42f266efcb176ba3 100644 --- a/openair2/RRC/LITE/L2_interface_ue.c +++ b/openair2/RRC/LTE/L2_interface_ue.c @@ -29,13 +29,8 @@ */ #include "platform_types.h" -//#include "openair_defs.h" -//#include "openair_proto.h" -#include "defs.h" -#include "extern.h" -//#include "mac_lchan_interface.h" -//#include "openair_rrc_utils.h" -//#include "openair_rrc_main.h" +#include "rrc_defs.h" +#include "rrc_extern.h" #include "UTIL/LOG/log.h" #include "rrc_eNB_UE_context.h" #include "pdcp.h" @@ -71,6 +66,21 @@ mac_rrc_data_req_ue( LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); #endif + +#ifdef Rel14 + LOG_D(RRC,"[UE %d] Frame %d Filling SL DISCOVERY SRB_ID %d\n",Mod_idP,frameP,Srb_id); + LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size); + + //TTN (for D2D) + if (Srb_id == SL_DISCOVERY && UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size > 0){ + memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size); + uint8_t Ret_size=UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size; + LOG_I(RRC,"[UE %d] Sending SL_Discovery, size %d bytes\n",Mod_idP,Ret_size); + UE_rrc_inst[Mod_idP].SL_Discovery[eNB_index].Tx_buffer.payload_size = 0; + return(Ret_size); + } +#endif + LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id); LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); @@ -211,7 +221,7 @@ mac_rrc_data_ind_ue( } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if ((srb_idP & RAB_OFFSET) == MCCH) { LOG_T(RRC,"[UE %d] Frame %d: Received SDU on MBSFN sync area %d for MCCH on SRB %d from eNB %d\n", @@ -241,8 +251,13 @@ mac_rrc_data_ind_ue( decode_MCCH_Message(&ctxt, eNB_indexP, sduP, sdu_lenP, mbsfn_sync_areaP); #endif } + //TTN (for D2D) + if(srb_idP == SL_DISCOVERY) { + LOG_I(RRC,"[UE %d] Received SDU (%d bytes) for SL_DISCOVERY on SRB %d from eNB %d\n",module_idP, sdu_lenP, srb_idP,eNB_indexP); + decode_SL_Discovery_Message(&ctxt, eNB_indexP, sduP, sdu_lenP); + } -#endif // Rel10 || Rel14 +#endif // #if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) return(0); @@ -315,7 +330,11 @@ rrc_data_req_ue( confirmP, sdu_sizeP, buffer_pP, - modeP); + modeP +#ifdef Rel14 + ,NULL, NULL +#endif + ); #endif } @@ -384,6 +403,7 @@ void rrc_in_sync_ind(module_id_t Mod_idP, frame_t frameP, uint16_t eNB_index) UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt=0; if (UE_rrc_inst[Mod_idP].Info[eNB_index].T310_active==1) { + LOG_D(RRC, "Panos-D: rrc_in_sync_ind 1 \n"); UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt++; } diff --git a/openair2/RRC/LITE/MESSAGES/Makefile.inc b/openair2/RRC/LTE/MESSAGES/Makefile.inc similarity index 100% rename from openair2/RRC/LITE/MESSAGES/Makefile.inc rename to openair2/RRC/LTE/MESSAGES/Makefile.inc diff --git a/openair2/RRC/LITE/MESSAGES/README.txt b/openair2/RRC/LTE/MESSAGES/README.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/README.txt rename to openair2/RRC/LTE/MESSAGES/README.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c similarity index 72% rename from openair2/RRC/LITE/MESSAGES/asn1_msg.c rename to openair2/RRC/LTE/MESSAGES/asn1_msg.c index 45b331a33007002c1fccb40a4fbc6b6edee43ee6..7d1d932be187033b5e39a062e8c35af57272e6ec 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -52,13 +52,13 @@ #include "RRCConnectionSetup.h" #include "SRB-ToAddModList.h" #include "DRB-ToAddModList.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #include "MCCH-Message.h" //#define MRB1 1 #endif -#include "RRC/LITE/defs.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_defs.h" +#include "RRC/LTE/rrc_extern.h" #include "RRCConnectionSetupComplete.h" #include "RRCConnectionReconfigurationComplete.h" #include "RRCConnectionReconfiguration.h" @@ -70,8 +70,10 @@ #include "SIB-Type.h" #include "BCCH-DL-SCH-Message.h" +#include "SBCCH-SL-BCH-MessageType.h" +#include "SBCCH-SL-BCH-Message.h" -#include "PHY/defs.h" +//#include "PHY/defs.h" #include "MeasObjectToAddModList.h" #include "ReportConfigToAddModList.h" @@ -229,7 +231,7 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich mib->message.systemFrameNumber.size = 1; mib->message.systemFrameNumber.bits_unused=0; mib->message.spare.buf = (uint8_t *)spare; -#ifndef Rel14 +#if (RRC_VERSION < MAKE_VERSION(14, 0, 0)) mib->message.spare.size = 2; mib->message.spare.bits_unused = 6; // This makes a spare of 10 bits #else @@ -272,6 +274,67 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich return((enc_rval.encoded+7)/8); } +//TTN for D2D +// 3GPP 36.331 (Section 5.10.7.4) +uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, uint32_t frame, uint8_t subframe, uint8_t in_coverage, uint8_t mode) +{ + + asn_enc_rval_t enc_rval; + SBCCH_SL_BCH_MessageType_t *mib_sl = &UE_rrc_inst[ctxt_pP->module_id].mib_sl[eNB_index]; + uint8_t sfn = (uint8_t)((frame>>2)&0xff); + UE_rrc_inst[ctxt_pP->module_id].MIB = (uint8_t*) malloc16(4); + + if (in_coverage > 0 ){ + //in coverage + mib_sl->inCoverage_r12 = TRUE; + mib_sl->sl_Bandwidth_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth; + if (UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config) { + mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config->subframeAssignment; + } else { + mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = TDD_ConfigSL_r12__subframeAssignmentSL_r12_none; + } + //if triggered by sl communication + if (UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){ + mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; + } + //if triggered by sl discovery + if (UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){ + mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; + } + //Todo - if triggered by v2x + } else { + //Todo - out of coverage for V2X + // Todo - UE has a selected SyncRef UE + mib_sl->inCoverage_r12 = FALSE; + //set sl-Bandwidth, subframeAssignmentSL and reserved from the pre-configured parameters + } + + //set FrameNumber, subFrameNumber + mib_sl->directFrameNumber_r12.buf = &sfn; + mib_sl->directFrameNumber_r12.size = 1; + mib_sl->directFrameNumber_r12.bits_unused=0; + mib_sl->directSubframeNumber_r12 = subframe; + + + LOG_I(RRC,"[MIB-SL] sfn %x, subframe %x\n", (uint32_t)sfn, (uint8_t)subframe); + + + enc_rval = uper_encode_to_buffer(&asn_DEF_SBCCH_SL_BCH_Message, NULL, + (void*)mib_sl, + UE_rrc_inst[ctxt_pP->module_id].MIB, + 24); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + + + if (enc_rval.encoded==-1) { + return(-1); + } + + return((enc_rval.encoded+7)/8); +} + + uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, int Mod_id,int CC_id #if defined(ENABLE_ITTI) @@ -414,6 +477,22 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type); ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo); +#if 0 + /* TODO: this is disabled for the moment because OAI UE does + * not connect to OAI eNB with the current software. + * See also TODO comment in do_SIB23. + */ + //TTN - This is for SIB18 + sib_type=SIB_Type_sibType18_v1250; + ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type); + ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo); + + //TTN - This is for SIB19 + sib_type=SIB_Type_sibType19_v1250; + ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type); + ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo); +#endif + // ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,NULL); #if defined(ENABLE_ITTI) @@ -487,8 +566,22 @@ uint8_t do_SIB23(uint8_t Mod_id, #endif ) { + struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib2_part,*sib3_part; -#if defined(Rel10) || defined(Rel14) + +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + //TTN - for D2D + struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib18_part, *sib19_part, *sib21_part; + SL_CommRxPoolList_r12_t *SL_CommRxPoolList; //for SIB18 + struct SL_CommResourcePool_r12 *SL_CommResourcePool; //for SIB18 + SL_DiscRxPoolList_r12_t *SL_DiscRxPoolList; //for SIB19 (discRxPool) + struct SL_DiscResourcePool_r12 *SL_DiscResourcePool; //for SIB19 (discRxPool) + //SL_DiscRxPoolList_r12_t *SL_DiscRxPoolPSList; //for SIB19 (discRxPoolPS) + //struct SL_DiscResourcePool_r12 *SL_DiscResourcePoolPS; //for SIB19 (discRxPoolPS) + //struct SL_V2X_ConfigCommon_r14 *SL_V2X_ConfigCommon; +#endif + +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part; MBSFN_SubframeConfigList_t *MBSFNSubframeConfigList; MBSFN_AreaInfoList_r9_t *MBSFNArea_list; @@ -500,11 +593,18 @@ uint8_t do_SIB23(uint8_t Mod_id, BCCH_DL_SCH_Message_t *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation; SystemInformationBlockType2_t **sib2 = &RC.rrc[Mod_id]->carrier[CC_id].sib2; SystemInformationBlockType3_t **sib3 = &RC.rrc[Mod_id]->carrier[CC_id].sib3; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) SystemInformationBlockType13_r9_t **sib13 = &RC.rrc[Mod_id]->carrier[CC_id].sib13; uint8_t MBMS_flag = RC.rrc[Mod_id]->carrier[CC_id].MBMS_flag; #endif +#if defined(Rel10) || defined(Rel14) + //TTN - for D2D + SystemInformationBlockType18_r12_t **sib18 = &RC.rrc[Mod_id]->carrier[CC_id].sib18; + SystemInformationBlockType19_r12_t **sib19 = &RC.rrc[Mod_id]->carrier[CC_id].sib19; + SystemInformationBlockType21_r14_t **sib21 = &RC.rrc[Mod_id]->carrier[CC_id].sib21; +#endif + if (bcch_message) { memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t)); } else { @@ -522,7 +622,7 @@ uint8_t do_SIB23(uint8_t Mod_id, exit(-1); } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) LOG_I(RRC,"[eNB %d] Configuration SIB2/3, MBMS = %d\n", Mod_id, MBMS_flag); #else LOG_I(RRC,"[eNB %d] Configuration SIB2/3\n", Mod_id); @@ -538,7 +638,7 @@ uint8_t do_SIB23(uint8_t Mod_id, *sib2 = &sib2_part->choice.sib2; *sib3 = &sib3_part->choice.sib3; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0) { sib13_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); @@ -549,10 +649,30 @@ uint8_t do_SIB23(uint8_t Mod_id, #endif +#if defined(Rel10) || defined(Rel14) + //TTN - for D2D + sib18_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); + sib19_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); + sib21_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); + memset(sib18_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); + memset(sib19_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); + memset(sib21_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); + + sib18_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250; + sib19_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250; + sib21_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430; + + *sib18 = &sib18_part->choice.sib18_v1250; + *sib19 = &sib19_part->choice.sib19_v1250; + *sib21 = &sib21_part->choice.sib21_v1430; + +#endif + + // sib2 (*sib2)->ac_BarringInfo = NULL; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #if 0 (*sib2)->ssac_BarringForMMTEL_Voice_r9 = NULL; (*sib2)->ssac_BarringForMMTEL_Video_r9 = NULL; @@ -641,7 +761,7 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->pucch_nRB_CQI[CC_id]; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = configuration->pucch_nCS_AN[CC_id]; -#if !defined(Rel10) && !defined(Rel14) +#if (RRC_VERSION < MAKE_VERSION(10, 0, 0)) (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = configuration->pucch_n1_AN[CC_id]; #endif @@ -799,7 +919,7 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->freqInfo.ul_Bandwidth = NULL; // (*sib2)->mbsfn_SubframeConfigList = NULL; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0) { LOG_I(RRC,"Adding MBSFN subframe Configuration 1 to SIB2\n"); @@ -848,7 +968,7 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->timeAlignmentTimerCommon=TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120; /// (*SIB3) -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (*sib3)->ext1 = NULL; #if 0 (*sib3)->s_IntraSearch_v920=NULL; @@ -883,7 +1003,7 @@ uint8_t do_SIB23(uint8_t Mod_id, // SIB13 // fill in all elements of SIB13 if present -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0 ) { // Notification for mcch change @@ -942,6 +1062,298 @@ uint8_t do_SIB23(uint8_t Mod_id, #endif + +#if defined(Rel10) || defined(Rel14) + //TTN - for D2D + // SIB18 + //commRxPool_r12 + (*sib18)->commConfig_r12 = CALLOC (1, sizeof(*(*sib18)->commConfig_r12)); + SL_CommRxPoolList= &(*sib18)->commConfig_r12->commRxPool_r12; + memset(SL_CommRxPoolList,0,sizeof(*SL_CommRxPoolList)); + + SL_CommResourcePool = CALLOC(1, sizeof(*SL_CommResourcePool)); + memset(SL_CommResourcePool,0,sizeof(*SL_CommResourcePool)); + + SL_CommResourcePool->sc_CP_Len_r12 = configuration->rxPool_sc_CP_Len[CC_id]; + SL_CommResourcePool->sc_Period_r12 = configuration->rxPool_sc_Period[CC_id]; + SL_CommResourcePool->data_CP_Len_r12 = configuration->rxPool_data_CP_Len[CC_id]; + //sc_TF_ResourceConfig_r12 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_Num_r12 = configuration->rxPool_ResourceConfig_prb_Num[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_Start_r12 = configuration->rxPool_ResourceConfig_prb_Start[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.prb_End_r12 = configuration->rxPool_ResourceConfig_prb_End[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = configuration->rxPool_ResourceConfig_offsetIndicator_present[CC_id]; + + if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) { + SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){ + SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } + + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = configuration->rxPool_ResourceConfig_subframeBitmap_present[CC_id]; + if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){ + //for BS4 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){ + //for BS8 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){ + //for BS12 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){ + //for BS16 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){ + //for BS30 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){ + //for BS40 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){ + //for BS42 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } + + //dataHoppingConfig_r12 + SL_CommResourcePool->dataHoppingConfig_r12.hoppingParameter_r12 = 0; + SL_CommResourcePool->dataHoppingConfig_r12.numSubbands_r12 = SL_HoppingConfigComm_r12__numSubbands_r12_ns1; + SL_CommResourcePool->dataHoppingConfig_r12.rb_Offset_r12 = 0; + + //ue_SelectedResourceConfig_r12 + SL_CommResourcePool->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->ue_SelectedResourceConfig_r12)); + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Start_r12 = 5; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_End_r12 = 44; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = SL_OffsetIndicator_r12_PR_small_r12; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0 ; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = SubframeBitmapSL_r12_PR_bs40_r12; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = 5; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = CALLOC(1,5); + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = 0; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[0] = 0xF0; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[1] = 0xFF; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[2] = 0xFF; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[3] = 0xFF; + SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[4] = 0xFF; + //SL_CommResourcePool->ue_SelectedResourceConfig_r12->trpt_Subset_r12 = CALLOC (1, sizeof(*SL_CommResourcePool->ue_SelectedResourceConfig_r12->trpt_Subset_r12)); + //rxParametersNCell_r12 + SL_CommResourcePool->rxParametersNCell_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->rxParametersNCell_r12)); + SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12)); + SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12->subframeAssignment = 0 ; + SL_CommResourcePool->rxParametersNCell_r12->tdd_Config_r12->specialSubframePatterns = 0; + SL_CommResourcePool->rxParametersNCell_r12->syncConfigIndex_r12 = 0; + //txParameters_r12 + SL_CommResourcePool->txParameters_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->txParameters_r12)); + SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.alpha_r12 = Alpha_r12_al0; + SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0; + + SL_CommResourcePool->ext1 = NULL ; + //end SL_CommResourcePool + //add SL_CommResourcePool to SL_CommRxPoolList + ASN_SEQUENCE_ADD(&SL_CommRxPoolList->list,SL_CommResourcePool); + //end commRxPool_r12 + + //TODO: commTxPoolNormalCommon_r12, similar to commRxPool_r12 + //TODO: commTxPoolExceptional_r12 + //TODO: commSyncConfig_r12 + // may add commTxResourceUC-ReqAllowed with Ext1 + (*sib18)->ext1 = NULL; + (*sib18)->lateNonCriticalExtension = NULL; + // end SIB18 + + // SIB19 + // fill in all elements of SIB19 if present + + //discConfig_r12 + (*sib19)->discConfig_r12 = CALLOC (1, sizeof(*(*sib19)->discConfig_r12)); + SL_DiscRxPoolList = &(*sib19)->discConfig_r12->discRxPool_r12; + memset(SL_DiscRxPoolList,0,sizeof(*SL_DiscRxPoolList)); + //fill SL_DiscResourcePool + SL_DiscResourcePool = CALLOC(1, sizeof(*SL_DiscResourcePool)); + + SL_DiscResourcePool->cp_Len_r12 = configuration->discRxPool_cp_Len[CC_id]; + SL_DiscResourcePool->discPeriod_r12 = configuration->discRxPool_discPeriod[CC_id]; + //sc_TF_ResourceConfig_r12 + SL_DiscResourcePool->numRetx_r12 = configuration->discRxPool_numRetx[CC_id]; + SL_DiscResourcePool->numRepetition_r12 = configuration->discRxPool_numRepetition[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPool_ResourceConfig_prb_Num[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPool_ResourceConfig_prb_Start[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPool_ResourceConfig_prb_End[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPool_ResourceConfig_offsetIndicator_present[CC_id]; + if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) { + SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){ + SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPool_ResourceConfig_subframeBitmap_present[CC_id]; + if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){ + //for BS4 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){ + //for BS8 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){ + //for BS12 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){ + //for BS16 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){ + //for BS30 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){ + //for BS40 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){ + //for BS42 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } + + //add SL_DiscResourcePool to SL_DiscRxPoolList + ASN_SEQUENCE_ADD(&SL_DiscRxPoolList->list,SL_DiscResourcePool); + +/* + //for DiscRxPoolPS + (*sib19)->ext1 = CALLOC (1, sizeof(*(*sib19)->ext1)); + (*sib19)->ext1->discConfigPS_13 = CALLOC (1, sizeof(*((*sib19)->ext1->discConfigPS_13))); + + SL_DiscRxPoolPSList = &(*sib19)->ext1->discConfigPS_13->discRxPoolPS_r13; + memset(SL_DiscRxPoolPSList,0,sizeof(*SL_DiscRxPoolPSList)); + //fill SL_DiscResourcePool + SL_DiscResourcePoolPS = CALLOC(1, sizeof(*SL_DiscResourcePoolPS)); + + SL_DiscResourcePoolPS->cp_Len_r12 = configuration->discRxPoolPS_cp_Len[CC_id]; + SL_DiscResourcePoolPS->discPeriod_r12 = configuration->discRxPoolPS_discPeriod[CC_id]; + //sc_TF_ResourceConfig_r12 + SL_DiscResourcePoolPS->numRetx_r12 = configuration->discRxPoolPS_numRetx[CC_id]; + SL_DiscResourcePoolPS->numRepetition_r12 = configuration->discRxPoolPS_numRepetition[CC_id]; + + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Num[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Start[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPoolPS_ResourceConfig_prb_End[CC_id]; + + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_present[CC_id]; + if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) { + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){ + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; + } + + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_present[CC_id]; + if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){ + //for BS4 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){ + //for BS8 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){ + //for BS12 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){ + //for BS16 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){ + //for BS30 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){ + //for BS40 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){ + //for BS42 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } + + //add SL_DiscResourcePool to SL_DiscRxPoolList + ASN_SEQUENCE_ADD(&SL_DiscRxPoolPSList->list,SL_DiscResourcePoolPS); +*/ + + (*sib19)->lateNonCriticalExtension = NULL; + //end SIB19 + + //SIB21 + (*sib21)->sl_V2X_ConfigCommon_r14 = CALLOC (1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14)); + //SL_V2X_ConfigCommon= (*sib21)->sl_V2X_ConfigCommon_r14; + memset((*sib21)->sl_V2X_ConfigCommon_r14,0,sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14)); + + struct SL_CommRxPoolListV2X_r14 *SL_CommRxPoolListV2X; + struct SL_CommResourcePoolV2X_r14 *SL_CommResourcePoolV2X; + (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14 = CALLOC(1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14)); + SL_CommRxPoolListV2X = (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14; + + SL_CommResourcePoolV2X = CALLOC(1, sizeof(*SL_CommResourcePoolV2X)); + memset(SL_CommResourcePoolV2X,0,sizeof(*SL_CommResourcePoolV2X)); + + SL_CommResourcePoolV2X->sl_OffsetIndicator_r14 = CALLOC(1, sizeof(*SL_CommResourcePoolV2X->sl_OffsetIndicator_r14)); + SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->present = SL_OffsetIndicator_r12_PR_small_r12; + SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->choice.small_r12 = 0; + SL_CommResourcePoolV2X->sl_Subframe_r14.present = SubframeBitmapSL_r14_PR_bs40_r14; + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.size = 5; + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf = CALLOC(1,5); + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.bits_unused = 0; + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[0] = 0xF0; + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[1] = 0xFF; + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[2] = 0xFF; + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[3] = 0xFF; + SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[4] = 0xFF; + + SL_CommResourcePoolV2X->adjacencyPSCCH_PSSCH_r14 = 1; + SL_CommResourcePoolV2X->sizeSubchannel_r14 = 10; + SL_CommResourcePoolV2X->numSubchannel_r14 = 5; + SL_CommResourcePoolV2X->startRB_Subchannel_r14 = 10; + + //rxParametersNCell_r12 + SL_CommResourcePoolV2X->rxParametersNCell_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14)); + SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14)); + SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->subframeAssignment = 0 ; + SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->specialSubframePatterns = 0; + SL_CommResourcePoolV2X->rxParametersNCell_r14->syncConfigIndex_r14 = 0; + + ASN_SEQUENCE_ADD(&SL_CommRxPoolListV2X->list,SL_CommResourcePoolV2X); + //end SIB21 +#endif + + bcch_message->message.present = BCCH_DL_SCH_MessageType_PR_c1; bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType__c1_PR_systemInformation; @@ -950,7 +1362,6 @@ uint8_t do_SIB23(uint8_t Mod_id, sizeof(SystemInformation_t));*/ bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = SystemInformation__criticalExtensions_PR_systemInformation_r8; - bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0; // asn_set_empty(&systemInformation->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list);//.size=0; @@ -959,14 +1370,26 @@ uint8_t do_SIB23(uint8_t Mod_id, sib2_part); ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib3_part); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0) { ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,sib13_part); } +#if 0 + /* TODO: this is disabled for the moment. + * Maybe we shouldn't put this together with SIBs 2/3. + * The problem is that the MAC message is now 92 bytes, which + * is too much in the SIB scheduler (the scheduler allocates + * 4 RBs with max MCS 8). + */ + //for D2D + ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib18_part); + ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib19_part); + ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, sib21_part); #endif +#endif #ifdef XER_PRINT xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message); @@ -1091,6 +1514,176 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) } + +//TTN for D2D - 3GPP TS 36.331 (Section 5.10.2.3) +uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode) +{ + + asn_enc_rval_t enc_rval; + UL_DCCH_Message_t ul_dcch_msg; + SidelinkUEInformation_r12_t *sidelinkUEInformation; + ARFCN_ValueEUTRA_r9_t carrierFreq = 25655;//sidelink communication frequency (hardcoded - should come from SIB2) + + memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); + ul_dcch_msg.message.present = UL_DCCH_MessageType_PR_messageClassExtension; + ul_dcch_msg.message.choice.messageClassExtension.present = UL_DCCH_MessageType__messageClassExtension_PR_c2; + ul_dcch_msg.message.choice.messageClassExtension.choice.c2.present = UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12; + sidelinkUEInformation = &ul_dcch_msg.message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12; + + //3GPP TS 36.331 (Section 5.10.2.3) + sidelinkUEInformation->criticalExtensions.present = SidelinkUEInformation_r12__criticalExtensions_PR_c1; + sidelinkUEInformation->criticalExtensions.choice.c1.present = SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12; + switch(mode) { + //if SIB18 is available + case SL_RECEIVE_COMMUNICATION: // to receive sidelink communication + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12)); + memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12, (void*)&carrierFreq, + sizeof(ARFCN_ValueEUTRA_r9_t)); + break; + + case SL_TRANSMIT_NON_RELAY_ONE_TO_MANY: //to transmit non-relay related one-to-many sidelink communication + //commTxResourceReq + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12)); + memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12, (void*)&carrierFreq, + sizeof(ARFCN_ValueEUTRA_r9_t)); + memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12, + destinationInfoList, + sizeof(SL_DestinationInfoList_r12_t)); + break; + + case SL_TRANSMIT_NON_RELAY_ONE_TO_ONE://transmit non-relay related one-to-one sidelink communication + //if commTxResourceUC-ReqAllowed is included in SIB18 + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12)); + memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12, (void*)&carrierFreq, + sizeof (ARFCN_ValueEUTRA_r9_t)); + memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12, + destinationInfoList, + sizeof(SL_DestinationInfoList_r12_t)); + break; + + case SL_TRANSMIT_RELAY_ONE_TO_ONE: //transmit relay related one-to-one sidelink communication + //if SIB19 includes discConfigRelay and UE acts a relay or UE has a selected relay + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13= CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13)); + memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12, + destinationInfoList, + sizeof(*destinationInfoList)); + //set ue-type to relayUE or remoteUE + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 =SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; + //sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12->nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 =SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_remoteUE; + break; + + case SL_TRANSMIT_RELAY_ONE_TO_MANY: //transmit relay related one-to-many sidelink communication + //if SIB19 includes discConfigRelay and UE acts a relay + //set ue-type to relayUE + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13= CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 =SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; + memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12, + destinationInfoList, + sizeof(*destinationInfoList)); + break; + + //if SIB19 is available + //we consider only one frequency - a serving frequency + case SL_RECEIVE_DISCOVERY: //receive sidelink discovery announcements + + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12)); + *sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12 = SidelinkUEInformation_r12_IEs__discRxInterest_r12_true; + break; + case SL_TRANSMIT_NON_PS_DISCOVERY://to transmit non-PS related sidelink discovery announcements + //for the first frequency + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12)); + + memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12, + (void*)discTxResourceReq, + sizeof(long)); + //for additional frequency + break; + + case SL_TRANSMIT_PS_DISCOVERY://to transmit PS related sidelink discovery announcements + //if to transmit non-relay PS related discovery announcements and SIB19 includes discConfigPS + //if UE is acting as relay UE and SIB includes discConfigRelay (relay threshold condition) + //if relay UE/has a selected relay UE and if SIB19 includes discConfigRelay + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13 = CALLOC(1, + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13 = *discTxResourceReq; + break; + //SIB21 + case SL_RECEIVE_V2X: + //TODO + break; + case SL_TRANSMIT_V2X: + //TODO + break; + //TODO: request sidelink discovery transmission/reception gaps + //TODO: report the system information parameters related to sidelink discovery of carriers other than the primary + default: + break; + } + +#ifdef XER_PRINT + xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); +#endif + + + enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, NULL, + (void*)&ul_dcch_msg, + buffer, + 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + +#if defined(ENABLE_ITTI) +# if !defined(DISABLE_XER_SPRINT) + { + char message_string[20000]; + size_t message_string_size; + + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { + MessageDef *msg_p; + + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); + + itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); + } + } +# endif +#endif + +#ifdef USER_MODE + LOG_D(RRC,"SidelinkUEInformation Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); +#endif + + return((enc_rval.encoded+7)/8); + +} + + uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS) { @@ -1411,7 +2004,7 @@ do_RRCConnectionSetup( // CQI ReportConfig physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic)); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic= CQI_ReportModeAperiodic_rm30; #else *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CQI_ReportConfig__cqi_ReportModeAperiodic_rm30; // HLC CQI, no PMI @@ -1798,11 +2391,13 @@ do_RRCConnectionReconfiguration( RSRP_Range_t *rsrp, C_RNTI_t *cba_rnti, struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList - *dedicatedInfoNASList - -#if defined(Rel10) || defined(Rel14) + *dedicatedInfoNASList, + SL_CommConfig_r12_t *sl_CommConfig, + SL_DiscConfig_r12_t *sl_DiscConfig +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , SCellToAddMod_r10_t *SCell_config #endif + ) //------------------------------------------------------------------------------ { @@ -1893,6 +2488,45 @@ do_RRCConnectionReconfiguration( rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.dedicatedInfoNASList = dedicatedInfoNASList; rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.securityConfigHO = NULL; + + //TTN for D2D + //allocate dedicated resource pools for SL communication (sl_CommConfig_r12) + if (sl_CommConfig != NULL) { + LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL communication \n"); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12)); + memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, (void*)sl_CommConfig, + sizeof(SL_CommConfig_r12_t)); + } + + //allocate dedicated resource pools for SL discovery (sl_DiscConfig) + if (sl_DiscConfig != NULL){ + LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL discovery \n"); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12)); + memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12, (void*)sl_DiscConfig, + sizeof(SL_DiscConfig_r12_t)); + } enc_rval = uper_encode_to_buffer(&asn_DEF_DL_DCCH_Message, NULL, (void*)&dl_dcch_msg, @@ -2298,7 +2932,7 @@ uint8_t do_RRCConnectionRelease( uint8_t TMGI[5] = {4,3,2,1,0};//TMGI is a string of octet, ref. TS 24.008 fig. 10.5.4a -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, uint8_t sync_area, uint8_t *buffer, @@ -2470,7 +3104,7 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension)); measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measId=measid; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrpResult=rsrp_s; measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrqResult=rsrq_s; #else diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h similarity index 93% rename from openair2/RRC/LITE/MESSAGES/asn1_msg.h rename to openair2/RRC/LTE/MESSAGES/asn1_msg.h index 05396bf727961b03a8278f00ddbbf606da6bd629..a4da38c0196a23efc250e90ac9f4d3fa3d1d83bc 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -39,7 +39,8 @@ #include <asn_application.h> #include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */ -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" +#include "SL-DestinationInfoList-r12.h" /* * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC) @@ -103,6 +104,14 @@ routine only generates an mo-data establishment cause. uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv); +/** +\brief Generate an SidelinkUEInformation UL-DCCH-Message (UE). +@param destinationInfoList Pointer to a list of destination for which UE requests E-UTRAN to assign dedicated resources +@param discTxResourceReq Pointer to number of discovery messages for discovery announcements for which UE requests E-UTRAN to assign dedicated resources +@param mode Indicates different requests from upper layers +@returns Size of encoded bit stream in bytes*/ +uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode); + /** \brief Generate an RRCConnectionSetupComplete UL-DCCH-Message (UE) @param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU @returns Size of encoded bit stream in bytes*/ @@ -186,8 +195,10 @@ do_RRCConnectionReconfiguration( struct MeasConfig__speedStatePars *speedStatePars, RSRP_Range_t *rsrp, C_RNTI_t *cba_rnti, - struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList* dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) + struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList* dedicatedInfoNASList, + SL_CommConfig_r12_t *sl_CommConfig, + SL_DiscConfig_r12_t *sl_DiscConfig +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , SCellToAddMod_r10_t *SCell_config #endif ); @@ -250,7 +261,7 @@ uint8_t do_RRCConnectionRelease(uint8_t Mod_id, uint8_t *buffer,int Transaction_ * @returns Size of encoded bit stream in bytes */ uint8_t do_MCCHMessage(uint8_t *buffer); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) /*** * \brief Generate an MCCH-Message (eNB). This routine configures MBSFNAreaConfiguration (PMCH-InfoList and Subframe Allocation for MBMS data) * @param buffer Pointer to PER-encoded ASN.1 description of MCCH-Message PDU diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c similarity index 99% rename from openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c rename to openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c index 7583be251f3ad8568fc5f92edcf6238a17dad055..59e3735e49a5b6aa91f7ced9983ce530e6a48225 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c @@ -53,7 +53,7 @@ #include "RRCConnectionSetup-NB.h" #include "SRB-ToAddModList-NB-r13.h" #include "DRB-ToAddModList-NB-r13.h" -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" #include "RRCConnectionSetupComplete-NB.h" #include "RRCConnectionReconfigurationComplete-NB.h" #include "RRCConnectionReconfiguration-NB.h" diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h b/openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h rename to openair2/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.h diff --git a/openair2/RRC/LITE/MESSAGES/asn1_patch b/openair2/RRC/LTE/MESSAGES/asn1_patch similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1_patch rename to openair2/RRC/LTE/MESSAGES/asn1_patch diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-860.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-860.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-860.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-860.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-a20.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-a20.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-a20.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-a20.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-ah0.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-c60.txt b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-c60.txt similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/36331-c60.txt rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/36331-c60.txt diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-86.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-a20.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-ah0.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-InterNodeDefinitions-c60.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20-lola.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-a20.asn.orig diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-ah0.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-c60.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-86.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-a20.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-ah0.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/EUTRA-UE-Variables-c60.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/RRC-e30.asn diff --git a/openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl similarity index 100% rename from openair2/RRC/LITE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl rename to openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/extract_asn1_from_spec.pl diff --git a/openair2/RRC/LITE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h similarity index 98% rename from openair2/RRC/LITE/defs_NB_IoT.h rename to openair2/RRC/LTE/defs_NB_IoT.h index c8565d52bd59beed4d64b822ef04bea122acfc39..7da9c014f1c0e9b22a6757f52306ef5789846053 100644 --- a/openair2/RRC/LITE/defs_NB_IoT.h +++ b/openair2/RRC/LTE/defs_NB_IoT.h @@ -88,7 +88,7 @@ /*I will change the name of the structure for compile purposes--> hope not to undo this process*/ typedef unsigned int uid_NB_IoT_t; -#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((NUMBER_OF_UE_MAX_NB_IoT/8)/sizeof(unsigned int)) + 1) +#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((MAX_MOBILES_PER_ENB_NB_IoT/8)/sizeof(unsigned int)) + 1) typedef struct uid_linear_allocator_NB_IoT_s { unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT]; @@ -122,7 +122,7 @@ typedef struct UE_RRC_INFO_NB_IoT_s { uint8_t SIB1systemInfoValueTag; uint32_t SIStatus; uint32_t SIcnt; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA #endif uint8_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40 @@ -150,7 +150,7 @@ typedef struct UE_RRC_INFO_NB_IoT_s { // HO_STATE is not supported by NB-IoT -//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG +//#define MAX_MOBILES_PER_ENB MAX_MOBILES_PER_RG #define RRM_FREE(p) if ( (p) != NULL) { free(p) ; p=NULL ; } #define RRM_MALLOC(t,n) (t *) malloc16( sizeof(t) * n ) #define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n) @@ -513,7 +513,7 @@ typedef struct UE_RRC_INST_NB_IoT_s { SystemInformationBlockType10_t *sib10[NB_CNX_UE]; SystemInformationBlockType11_t *sib11[NB_CNX_UE]; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t MBMS_flag; uint8_t *MCCH_MESSAGE[NB_CNX_UE]; uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE]; diff --git a/openair2/RRC/LITE/extern_NB_IoT.h b/openair2/RRC/LTE/extern_NB_IoT.h similarity index 98% rename from openair2/RRC/LITE/extern_NB_IoT.h rename to openair2/RRC/LTE/extern_NB_IoT.h index f5e2f325756006d2841bb81f674d778ea68515f8..f136b57b4787613605ad3f579f779b6005963598 100644 --- a/openair2/RRC/LITE/extern_NB_IoT.h +++ b/openair2/RRC/LTE/extern_NB_IoT.h @@ -30,7 +30,7 @@ #ifndef __OPENAIR_RRC_EXTERN_NB_IOT_H__ #define __OPENAIR_RRC_EXTERN_NB_IOT_H__ -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" #include "PHY_INTERFACE/IF_Module_NB_IoT.h" #include "LAYER2/RLC/rlc.h" #include "LogicalChannelConfig-NB-r13.h" diff --git a/openair2/RRC/LITE/plmn_data.h b/openair2/RRC/LTE/plmn_data.h similarity index 100% rename from openair2/RRC/LITE/plmn_data.h rename to openair2/RRC/LTE/plmn_data.h diff --git a/openair2/RRC/LITE/proto_NB_IoT.h b/openair2/RRC/LTE/proto_NB_IoT.h similarity index 99% rename from openair2/RRC/LITE/proto_NB_IoT.h rename to openair2/RRC/LTE/proto_NB_IoT.h index b2218517fc8761da2f7311554e25821f02f9f06a..de09d39fab7b100b9335489cae95a513068baea2 100644 --- a/openair2/RRC/LITE/proto_NB_IoT.h +++ b/openair2/RRC/LTE/proto_NB_IoT.h @@ -30,7 +30,7 @@ * @{ */ -#include "RRC/LITE/defs_NB_IoT.h" +#include "RRC/LTE/defs_NB_IoT.h" #include "pdcp.h" #include "rlc.h" #include "extern_NB_IoT.h" diff --git a/openair2/RRC/LITE/rrc_2_rrm_msg.c b/openair2/RRC/LTE/rrc_2_rrm_msg.c similarity index 100% rename from openair2/RRC/LITE/rrc_2_rrm_msg.c rename to openair2/RRC/LTE/rrc_2_rrm_msg.c diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c similarity index 72% rename from openair2/RRC/LITE/rrc_UE.c rename to openair2/RRC/LTE/rrc_UE.c index 1ebfde38909cecd98010103d3e90929eba19f04a..d40a8c2d6c0b1a7717b1db99efcf792228d0b106 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -30,20 +30,21 @@ #define RRC_UE #define RRC_UE_C +#define _GNU_SOURCE #include "assertions.h" #include "hashtable.h" #include "asn1_conversions.h" -#include "defs.h" -#include "PHY/TOOLS/dB_routines.h" -#include "extern.h" +#include "rrc_defs.h" +#include "rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "openair1/PHY/LTE_ESTIMATION/lte_estimation.h" #include "LAYER2/RLC/rlc.h" #include "COMMON/mac_rrc_primitives.h" #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" #ifndef CELLULAR -#include "RRC/LITE/MESSAGES/asn1_msg.h" +#include "RRC/LTE/MESSAGES/asn1_msg.h" #endif #include "RRCConnectionRequest.h" #include "RRCConnectionReconfiguration.h" @@ -53,7 +54,7 @@ #include "DL-DCCH-Message.h" #include "BCCH-DL-SCH-Message.h" #include "PCCH-Message.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #include "MCCH-Message.h" #endif #include "MeasConfig.h" @@ -80,21 +81,27 @@ # include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus +#include "openair2/LAYER2/MAC/mac_extern.h" -#ifdef PHY_EMUL -extern EMULATION_VARS *Emul_vars; -#endif -extern eNB_MAC_INST *eNB_mac_inst; -extern UE_MAC_INST *UE_mac_inst; -#ifdef BIGPHYSAREA -extern void *bigphys_malloc(int); +#ifdef Rel14 +#include "SL-Preconfiguration-r12.h" + +//for D2D +int ctrl_sock_fd; +#define BUFSIZE 1024 +struct sockaddr_in prose_app_addr; +int slrb_id; +int send_ue_information = 0; #endif +// for malloc_clear +#include "PHY/defs_UE.h" + //#define XER_PRINT -//extern int8_t dB_fixed2(uint32_t x,uint32_t y); + extern void pdcp_config_set_security( const protocol_ctxt_t* const ctxt_pP, @@ -139,8 +146,9 @@ static uint8_t check_trigger_meas_event( Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys, Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) static void decode_MBSFNAreaConfiguration(module_id_t module_idP, uint8_t eNB_index, frame_t frameP,uint8_t mbsfn_sync_area); +uint8_t rrc_ue_generate_SidelinkUEInformation( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index,SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode); #endif @@ -274,9 +282,13 @@ static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ UE_rrc_inst[ctxt_pP->module_id].sib9[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType9_t) ); UE_rrc_inst[ctxt_pP->module_id].sib10[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType10_t) ); UE_rrc_inst[ctxt_pP->module_id].sib11[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType11_t) ); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) UE_rrc_inst[ctxt_pP->module_id].sib12[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType12_r9_t) ); UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType13_r9_t) ); + UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType18_r12_t) ); + UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType19_r12_t) ); + UE_rrc_inst[ctxt_pP->module_id].sib21[eNB_index] = malloc16_clear( sizeof(SystemInformationBlockType21_r14_t) ); + #endif UE_rrc_inst[ctxt_pP->module_id].SI[eNB_index] = (uint8_t*)malloc16_clear( 64 ); @@ -286,10 +298,184 @@ static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt = 0; } +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) +void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index ) +{ + LOG_I(RRC,"Initializing Sidelink Pre-configuration for UE\n"); + + UE->SL_Preconfiguration[eNB_index] = malloc16_clear( sizeof(struct SL_Preconfiguration_r12) ); + UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.rohc_Profiles_r12.profile0x0001_r12 = true; + UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.carrierFreq_r12 = 3350; + UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.maxTxPower_r12 = 0; + UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.additionalSpectrumEmission_r12 = 0; + UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.sl_bandwidth_r12 = SL_PreconfigGeneral_r12__sl_bandwidth_r12_n50; + UE->SL_Preconfiguration[eNB_index]->preconfigGeneral_r12.tdd_ConfigSL_r12.subframeAssignmentSL_r12 = TDD_ConfigSL_r12__subframeAssignmentSL_r12_none; + + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncCP_Len_r12 = SL_CP_Len_r12_normal; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncOffsetIndicator1_r12 = 0; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncOffsetIndicator2_r12 = 0; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncTxParameters_r12 = 0; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncTxThreshOoC_r12 = 0; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.filterCoefficient_r12 = FilterCoefficient_fc0; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncRefMinHyst_r12 = SL_PreconfigSync_r12__syncRefMinHyst_r12_dB0; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.syncRefDiffHyst_r12 = SL_PreconfigSync_r12__syncRefDiffHyst_r12_dB0; + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.ext1 = malloc16_clear(sizeof(struct SL_PreconfigSync_r12__ext1)); + UE->SL_Preconfiguration[eNB_index]->preconfigSync_r12.ext1->syncTxPeriodic_r13 = NULL; + + struct SL_PreconfigCommPool_r12 *preconfigpool = malloc16_clear(sizeof(struct SL_PreconfigCommPool_r12)); + preconfigpool->sc_CP_Len_r12 = SL_CP_Len_r12_normal; + preconfigpool->sc_Period_r12 = SL_PeriodComm_r12_sf40; + // 20 PRBs for SL communications + preconfigpool->sc_TF_ResourceConfig_r12.prb_Num_r12 = 20; + preconfigpool->sc_TF_ResourceConfig_r12.prb_Start_r12 = 5; + preconfigpool->sc_TF_ResourceConfig_r12.prb_End_r12 = 44; + // Offset set to 0 subframes + preconfigpool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = SL_OffsetIndicator_r12_PR_small_r12; + preconfigpool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0; + // 40 ms SL Period + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = SubframeBitmapSL_r12_PR_bs40_r12; + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = CALLOC(1,5); + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = 5; + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = 0; + // 1st 4 subframes for PSCCH + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[0] = 0xF; + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[1] = 0; + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[2] = 0; + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[3] = 0; + preconfigpool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[4] = 0; + preconfigpool->sc_TxParameters_r12 = 0; + + preconfigpool->data_CP_Len_r12 = SL_CP_Len_r12_normal; + // 20 PRBs for SL communications + preconfigpool->data_TF_ResourceConfig_r12.prb_Num_r12 = 20; + preconfigpool->data_TF_ResourceConfig_r12.prb_Start_r12 = 5; + preconfigpool->data_TF_ResourceConfig_r12.prb_End_r12 = 44; + // Offset set to 0 subframes + preconfigpool->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = SL_OffsetIndicator_r12_PR_small_r12; + preconfigpool->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0; + // 40 ms SL Period + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = SubframeBitmapSL_r12_PR_bs40_r12; + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = CALLOC(1,5); + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = 5; + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = 0; + // last 36 subframes for PSCCH + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[0] = 0xF0; + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[1] = 0xFF; + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[2] = 0xFF; + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[3] = 0xFF; + preconfigpool->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf[5] = 0xFF; + + preconfigpool->dataHoppingConfig_r12.hoppingParameter_r12 = 0; + preconfigpool->dataHoppingConfig_r12.numSubbands_r12 = SL_HoppingConfigComm_r12__numSubbands_r12_ns1; + preconfigpool->dataHoppingConfig_r12.rb_Offset_r12 = 0; + + preconfigpool->dataTxParameters_r12 = 0; + + ASN_SEQUENCE_ADD(&UE->SL_Preconfiguration[eNB_index]->preconfigComm_r12.list,preconfigpool); + + // Rel13 extensions + UE->SL_Preconfiguration[eNB_index]->ext1 = NULL; +/* + // Establish a SLRB (using DRB 3 for now) + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0); + + UE->DRB_config[0][0] = CALLOC(1,sizeof(struct DRB_ToAddMod)); + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + UE->DRB_config[0][0]->drb_Identity = 3; + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(UE->DRB_config[0][0]->eps_BearerIdentity) = 3; + UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + // TTN - Establish a new SLRB for PC5-S (using DRB 10 for now) + UE->DRB_config[0][1] = CALLOC(1,sizeof(struct DRB_ToAddMod)); + UE->DRB_config[0][1]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + UE->DRB_config[0][1]->drb_Identity = 10; + UE->DRB_config[0][1]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(UE->DRB_config[0][1]->eps_BearerIdentity) = 10; + UE->DRB_config[0][1]->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(UE->DRB_config[0][1]->logicalChannelIdentity) = UE->DRB_config[0][1]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + struct RLC_Config *DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config)); + struct PDCP_Config *DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config)); + struct PDCP_Config__rlc_UM *PDCP_rlc_UM = CALLOC(1,sizeof(struct PDCP_Config__rlc_UM)); + struct LogicalChannelConfig *DRB_lchan_config = CALLOC(1,sizeof(struct LogicalChannelConfig)); + struct LogicalChannelConfig__ul_SpecificParameters + *DRB_ul_SpecificParameters = CALLOC(1, sizeof(struct LogicalChannelConfig__ul_SpecificParameters)); + long *logicalchannelgroup_drb = CALLOC(1, sizeof(long)); + + DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; + UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config; + UE->DRB_config[0][1]->rlc_Config = DRB_rlc_config; + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config; + UE->DRB_config[0][1]->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + // avoid gcc warnings + (void)PDCP_rlc_UM; + + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; + + UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config; + UE->DRB_config[0][1]->logicalChannelConfig = DRB_lchan_config; + DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); + DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; + + DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer + DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + DRB_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) + + *logicalchannelgroup_drb = 1; + DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; + + UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t)); + ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]); + ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][1]); + + rrc_pdcp_config_asn1_req(&ctxt, + (SRB_ToAddModList_t *) NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*) NULL, + 0xff, NULL, NULL, NULL +#if defined(Rel10) || defined(Rel14) + , (PMCH_InfoList_r9_t *) NULL +#endif + ,NULL); + + rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*)NULL #if defined(Rel10) || defined(Rel14) + ,(PMCH_InfoList_r9_t *)NULL +#endif + ); +*/ +} + +#endif + +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //----------------------------------------------------------------------------- #if 0 -static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) +void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) { int i; UE_rrc_inst[ue_mod_idP].sizeof_MCCH_MESSAGE[eNB_index] = 0; @@ -305,7 +491,7 @@ static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) #endif //----------------------------------------------------------------------------- -static void openair_rrc_ue_init_security( const protocol_ctxt_t* const ctxt_pP ) +void openair_rrc_ue_init_security( const protocol_ctxt_t* const ctxt_pP ) { #if defined(ENABLE_SECURITY) // uint8_t *kRRCenc; @@ -347,7 +533,7 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_ UE_rrc_inst[ctxt.module_id].Srb2[eNB_index].Active=0; UE_rrc_inst[ctxt.module_id].HandoverInfoUe.measFlag=1; UE_rrc_inst[ctxt.module_id].ciphering_algorithm = CipheringAlgorithm_r12_eea0; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 2, 0)) UE_rrc_inst[ctxt.module_id].integrity_algorithm = SecurityAlgorithmConfig__integrityProtAlgorithm_eia0_v920; #else UE_rrc_inst[ctxt.module_id].integrity_algorithm = SecurityAlgorithmConfig__integrityProtAlgorithm_reserved; @@ -358,6 +544,12 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_ LOG_D(RRC,PROTOCOL_RRC_CTXT_FMT" INIT: phy_sync_2_ch_ind\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); + + +#ifndef NO_RRM + send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ctxt.module_id,eNB_index,UE_rrc_inst[ctxt.module_id].Mac_id)); +#endif + #ifndef NO_RRM send_msg(&S_rrc,msg_rrc_phy_synch_to_CH_ind(ctxt.module_id,eNB_index,UE_rrc_inst[ctxt.module_id].Mac_id)); #endif @@ -530,7 +722,7 @@ static void rrc_ue_generate_RRCConnectionSetupComplete( const protocol_ctxt_t* c } //----------------------------------------------------------------------------- -static void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ) +void rrc_ue_generate_RRCConnectionReconfigurationComplete( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t Transaction_id ) { uint8_t buffer[32], size; @@ -594,6 +786,7 @@ int rrc_ue_decode_ccch( const protocol_ctxt_t* const ctxt_pP, const SRB_INFO* co char message_string[10000]; size_t message_string_size; + //LOG_I(RRC, "Panos-D: rrc_ue_decode_ccch, Before xer_sprint() \n"); if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_CCCH_Message, (void *)dl_ccch_msg)) > 0) { MessageDef *msg_p; @@ -873,7 +1066,7 @@ rrc_ue_process_measConfig( rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -890,7 +1083,7 @@ rrc_ue_process_measConfig( NULL, NULL, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,0, (MBSFN_AreaInfoList_r9_t *)NULL, (PMCH_InfoList_r9_t *)NULL @@ -900,6 +1093,12 @@ rrc_ue_process_measConfig( , 0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); } @@ -1335,7 +1534,7 @@ rrc_ue_process_radioResourceConfigDedicated( kRRCenc, kRRCint, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,(PMCH_InfoList_r9_t *)NULL #endif ,NULL); @@ -1345,8 +1544,9 @@ rrc_ue_process_radioResourceConfigDedicated( radioResourceConfigDedicated->srb_ToAddModList, (DRB_ToAddModList_t*)NULL, (DRB_ToReleaseList_t*)NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,(PMCH_InfoList_r9_t *)NULL + , 0, 0 #endif ); @@ -1385,7 +1585,7 @@ rrc_ue_process_radioResourceConfigDedicated( rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index], -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -1402,7 +1602,7 @@ rrc_ue_process_radioResourceConfigDedicated( NULL, NULL, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *)NULL, @@ -1412,6 +1612,12 @@ rrc_ue_process_radioResourceConfigDedicated( , 0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); } @@ -1443,7 +1649,7 @@ rrc_ue_process_radioResourceConfigDedicated( rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index], -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -1460,7 +1666,7 @@ rrc_ue_process_radioResourceConfigDedicated( NULL, NULL, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *)NULL, @@ -1471,6 +1677,12 @@ rrc_ue_process_radioResourceConfigDedicated( , 0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); } @@ -1517,7 +1729,7 @@ rrc_ue_process_radioResourceConfigDedicated( NULL, NULL, kUPenc -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,(PMCH_InfoList_r9_t *)NULL #endif , UE_rrc_inst[ctxt_pP->module_id].defaultDRB); @@ -1527,8 +1739,9 @@ rrc_ue_process_radioResourceConfigDedicated( (SRB_ToAddModList_t*)NULL, radioResourceConfigDedicated->drb_ToAddModList, (DRB_ToReleaseList_t*)NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,(PMCH_InfoList_r9_t *)NULL + , 0, 0 #endif ); @@ -1551,7 +1764,7 @@ rrc_ue_process_radioResourceConfigDedicated( rrc_mac_config_req_ue(ctxt_pP->module_id,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, UE_rrc_inst[ctxt_pP->module_id].physicalConfigDedicated[eNB_index], -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif @@ -1568,7 +1781,7 @@ rrc_ue_process_radioResourceConfigDedicated( NULL, NULL, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *)NULL, @@ -1578,13 +1791,19 @@ rrc_ue_process_radioResourceConfigDedicated( , UE_rrc_inst[ue_mod_idP].num_active_cba_groups, // UE_rrc_inst[ue_mod_idP].cba_rnti[0] +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); - + } } } - + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_CONNECTED; LOG_I(RRC,"[UE %d] State = RRC_CONNECTED (eNB %d)\n",ctxt_pP->module_id,eNB_index); } @@ -1607,8 +1826,8 @@ rrc_ue_process_securityModeCommand( uint8_t buffer[200]; int i, securityMode; - LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (eNB %d)\n", - ctxt_pP->module_id,ctxt_pP->frame,eNB_index); + LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (eNB %d)\n", + ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, eNB_index); switch (securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm) { case CipheringAlgorithm_r12_eea0: @@ -1665,8 +1884,10 @@ rrc_ue_process_securityModeCommand( ul_dcch_msg.message.present = UL_DCCH_MessageType_PR_c1; if (securityMode >= NO_SECURITY_MODE) { + LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode complete case \n"); ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeComplete; } else { + LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode failure case \n"); ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeFailure; } @@ -1717,11 +1938,11 @@ rrc_ue_process_securityModeCommand( | (UE_rrc_inst[ctxt_pP->module_id].integrity_algorithm << 4), kRRCenc, kRRCint, kUPenc); } else { - LOG_W(RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", + LOG_I(RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", securityMode); } } else { - LOG_W(RRC, "Could not get PDCP instance where key=0x%ld\n", key); + LOG_I(RRC, "Could not get PDCP instance where key=0x%ld\n", key); } #endif //#if defined(ENABLE_SECURITY) @@ -1736,8 +1957,8 @@ rrc_ue_process_securityModeCommand( ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.choice.securityModeComplete_r8.nonCriticalExtension =NULL; - LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d)\n", - ctxt_pP->module_id,ctxt_pP->frame,eNB_index); + LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d), rrc_TransactionIdentifier: %ld\n", + ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, eNB_index, securityModeCommand->rrc_TransactionIdentifier); enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, NULL, (void*)&ul_dcch_msg, @@ -1756,6 +1977,7 @@ rrc_ue_process_securityModeCommand( char message_string[20000]; size_t message_string_size; + //LOG_I(RRC, "Panos-D: rrc_ue_process_securityModeCommand, Before xer_sprint() \n"); if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { MessageDef *msg_p; @@ -1836,7 +2058,7 @@ rrc_ue_process_ueCapabilityEnquiry( UECapabilityEnquiry->criticalExtensions.present,UECapabilityEnquiry__criticalExtensions_PR_c1); if (UECapabilityEnquiry->criticalExtensions.choice.c1.present != UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8) - LOG_W(RRC,"UECapabilityEnquiry->criticalExtensions.choice.c1.present (%d) != UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8)\n", + LOG_I(RRC,"UECapabilityEnquiry->criticalExtensions.choice.c1.present (%d) != UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8)\n", UECapabilityEnquiry->criticalExtensions.choice.c1.present); ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.present = UECapabilityInformation__criticalExtensions_PR_c1; @@ -1867,6 +2089,7 @@ rrc_ue_process_ueCapabilityEnquiry( char message_string[20000]; size_t message_string_size; + //LOG_I(RRC, "Panos-D: rrc_ue_process_ueCapabilityEnquiry, Before xer_sprint() \n"); if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) { MessageDef *msg_p; @@ -1881,7 +2104,7 @@ rrc_ue_process_ueCapabilityEnquiry( #endif - LOG_D(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_I(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) { LOG_T(RRC, "%02x.", buffer[i]); @@ -1940,6 +2163,45 @@ rrc_ue_process_rrcConnectionReconfiguration( rrc_ue_process_radioResourceConfigDedicated(ctxt_pP,eNB_index, rrcConnectionReconfiguration_r8->radioResourceConfigDedicated); } + //TTN for D2D + //if RRCConnectionReconfiguration message includes the sl-CommConfig + if ((rrcConnectionReconfiguration_r8->nonCriticalExtension != NULL) + && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension + != NULL) + && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + != NULL) + && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + != NULL) + && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + != NULL) + && (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 + != NULL)) { + if (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12->commTxResources_r12->present != SL_CommConfig_r12__commTxResources_r12_PR_NOTHING){ + LOG_I(RRC,"sl-CommConfig is present\n"); + //process sl-CommConfig + rrc_ue_process_sidelink_radioResourceConfig(ctxt_pP->module_id,eNB_index, + (SystemInformationBlockType18_r12_t *)NULL, + (SystemInformationBlockType19_r12_t *)NULL, + rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, + (SL_DiscConfig_r12_t *)NULL + ); + } + } + +/* + //if RRCConnectionReconfiguration message includes the sl-DiscConfig + if (rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12->discTxResources_r12->present != SL_DiscConfig_r12__discTxResources_r12_PR_NOTHING ){ + LOG_I(RRC,"sl-DiscConfig is present\n"); + //process sl-DiscConfig + rrc_ue_process_sidelink_radioResourceConfig(ctxt_pP->module_id,eNB_index, + (SystemInformationBlockType18_r12_t *)NULL, + (SystemInformationBlockType19_r12_t *)NULL, + (SL_CommConfig_r12_t* )NULL, + rrcConnectionReconfiguration_r8->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 + ); + } +*/ + #if defined(ENABLE_ITTI) /* Check if there is dedicated NAS information to forward to NAS */ @@ -2062,7 +2324,7 @@ rrc_ue_process_mobilityControlInfo( NULL, // key rrc encryption NULL, // key rrc integrity NULL // key encryption -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) ,NULL #endif ,NULL); @@ -2071,7 +2333,7 @@ rrc_ue_process_mobilityControlInfo( NULL,// SRB_ToAddModList NULL,// DRB_ToAddModList drb2release_list // DRB_ToReleaseList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) ,NULL #endif ,NULL); @@ -2106,7 +2368,7 @@ rrc_ue_process_mobilityControlInfo( eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -2123,7 +2385,7 @@ rrc_ue_process_mobilityControlInfo( NULL, NULL, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,0, (MBSFN_AreaInfoList_r9_t *)NULL, (PMCH_InfoList_r9_t *)NULL @@ -2131,9 +2393,15 @@ rrc_ue_process_mobilityControlInfo( #ifdef CBA ,0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); - + // Re-establish PDCP for all RBs that are established // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH); // rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, ue_mod_idP+DCCH1); @@ -2216,6 +2484,7 @@ rrc_ue_decode_dcch( char message_string[30000]; size_t message_string_size; + //LOG_I(RRC, "Panos-D: rrc_ue_decode_dcch, Before xer_sprint() \n"); if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_DCCH_Message, (void *)dl_dcch_msg)) > 0) { msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_DCCH, message_string_size + sizeof (IttiMsgText)); msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; @@ -2431,6 +2700,22 @@ rrc_ue_decode_dcch( } + //TTN test D2D (should not be here - in reality, this message will be triggered from ProSeApp) + if (send_ue_information == 0) { + LOG_I(RRC, "TEST SidelinkUEInformation [UE %d] Received (eNB %d)\n", + ctxt_pP->module_id, eNB_indexP); + SL_DestinationInfoList_r12_t *destinationInfoList = CALLOC(1, sizeof(SL_DestinationInfoList_r12_t)); + SL_DestinationIdentity_r12_t *sl_destination_identity = CALLOC(1, sizeof(SL_DestinationIdentity_r12_t)); + sl_destination_identity->size = 3; + sl_destination_identity->buf = CALLOC(1,3); + sl_destination_identity->buf[0] = 0x00; + sl_destination_identity->buf[1] = 0x00; + sl_destination_identity->buf[2] = 0x01; + sl_destination_identity->bits_unused = 0; + ASN_SEQUENCE_ADD(&destinationInfoList->list,sl_destination_identity); + rrc_ue_generate_SidelinkUEInformation(ctxt_pP, eNB_indexP, destinationInfoList, NULL, SL_TRANSMIT_NON_RELAY_ONE_TO_ONE); + send_ue_information ++; + } break; case DL_DCCH_MessageType__c1_PR_rrcConnectionRelease: @@ -2476,11 +2761,11 @@ rrc_ue_decode_dcch( case DL_DCCH_MessageType__c1_PR_counterCheck: break; -#if defined(Rel10) || defined(Rel14) - +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) case DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9: break; - +#endif +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) case DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10: break; @@ -2491,7 +2776,7 @@ rrc_ue_decode_dcch( case DL_DCCH_MessageType__c1_PR_spare1: case DL_DCCH_MessageType__c1_PR_spare2: case DL_DCCH_MessageType__c1_PR_spare3: -#if !defined(Rel14) +#if (RRC_VERSION < MAKE_VERSION(14, 0, 0)) case DL_DCCH_MessageType__c1_PR_spare4: #endif break; @@ -2514,7 +2799,7 @@ const char SIBType[12][6] = {"SIB3","SIB4","SIB5","SIB6","SIB7","SIB8","SIB9","S const char SIBPeriod[8][6]= {"rf8","rf16","rf32","rf64","rf128","rf256","rf512","ERR"}; int siPeriod_int[7] = {80,160,320,640,1280,2560,5120}; -static const char* SIBreserved( long value ) +const char* SIBreserved( long value ) { if (value < 0 || value > 1) return "ERR"; @@ -2524,7 +2809,7 @@ static const char* SIBreserved( long value ) return "reserved"; } -static const char* SIBbarred( long value ) +const char* SIBbarred( long value ) { if (value < 0 || value > 1) return "ERR"; @@ -2534,7 +2819,7 @@ static const char* SIBbarred( long value ) return "barred"; } -static const char* SIBallowed( long value ) +const char* SIBallowed( long value ) { if (value < 0 || value > 1) return "ERR"; @@ -2544,7 +2829,7 @@ static const char* SIBallowed( long value ) return "allowed"; } -static const char* SIB2SoundingPresent( int value ) +const char* SIB2SoundingPresent( int value ) { switch (value) { case SoundingRS_UL_ConfigCommon_PR_NOTHING: @@ -2559,7 +2844,7 @@ static const char* SIB2SoundingPresent( int value ) return "ERR"; } -static const char* SIB2numberOfRA_Preambles( long value ) +const char* SIB2numberOfRA_Preambles( long value ) { static char temp[4] = {0}; @@ -2570,7 +2855,7 @@ static const char* SIB2numberOfRA_Preambles( long value ) temp[3] = 0; // terminate string return temp; } -static const char* SIB2powerRampingStep( long value ) +const char* SIB2powerRampingStep( long value ) { if (value < 0 || value > 3) return "ERR"; @@ -2578,7 +2863,7 @@ static const char* SIB2powerRampingStep( long value ) static const char str[4][4] = {"dB0","dB2","dB4","dB6"}; return str[value]; } -static const char* SIB2preambleInitialReceivedTargetPower( long value ) +const char* SIB2preambleInitialReceivedTargetPower( long value ) { static char temp[8] = {0}; @@ -2589,7 +2874,7 @@ static const char* SIB2preambleInitialReceivedTargetPower( long value ) temp[7] = 0; // terminate string return temp; } -static const char* SIB2preambleTransMax( long value ) +const char* SIB2preambleTransMax( long value ) { static char temp[5] = {0}; @@ -2621,7 +2906,7 @@ static const char* SIB2preambleTransMax( long value ) /* unreachable but gcc warns... */ return "ERR"; } -static const char* SIB2ra_ResponseWindowSize( long value ) +const char* SIB2ra_ResponseWindowSize( long value ) { static char temp[4] = {0}; @@ -2634,7 +2919,7 @@ static const char* SIB2ra_ResponseWindowSize( long value ) snprintf( temp, sizeof(temp), "sf%ld", value+2 ); return temp; } -static const char* SIB2mac_ContentionResolutionTimer( long value ) +const char* SIB2mac_ContentionResolutionTimer( long value ) { static char temp[5] = {0}; @@ -2644,7 +2929,7 @@ static const char* SIB2mac_ContentionResolutionTimer( long value ) snprintf( temp, sizeof(temp), "sf%ld", 8 + value*8 ); return temp; } -static const char* SIB2modificationPeriodCoeff( long value ) +const char* SIB2modificationPeriodCoeff( long value ) { static char temp[32] = {0}; @@ -2654,7 +2939,7 @@ static const char* SIB2modificationPeriodCoeff( long value ) snprintf( temp, sizeof(temp), "n%d", (int)pow(2,value+1) ); return temp; } -static const char* SIB2defaultPagingCycle( long value ) +const char* SIB2defaultPagingCycle( long value ) { static char temp[32] = {0}; @@ -2664,7 +2949,7 @@ static const char* SIB2defaultPagingCycle( long value ) snprintf( temp, sizeof(temp), "rf%d", (int)pow(2,value+4) ); return temp; } -static const char* SIB2nB( long value ) +const char* SIB2nB( long value ) { if (value < 0 || value > 7) return "ERR"; @@ -2735,6 +3020,7 @@ int decode_BCCH_DLSCH_Message( char message_string[15000]; size_t message_string_size; + //LOG_I(RRC, "Panos-D: decode_BCCH_DLSCH_Message, Before xer_sprint() \n"); if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) { MessageDef *msg_p; @@ -2759,6 +3045,9 @@ int decode_BCCH_DLSCH_Message( (void*)&bcch_message->message.choice.c1.choice.systemInformationBlockType1, sizeof(SystemInformationBlockType1_t) ); LOG_D( RRC, "[UE %"PRIu8"] Decoding First SIB1\n", ctxt_pP->module_id ); + + //LOG_I( RRC, "Panos-D: decode_BCCH_DLSCH_Message1 BEFORE decode_SIB1"); + //printf("Panos-D: decode_BCCH_DLSCH_Message1 BEFORE decode_SIB1"); decode_SIB1( ctxt_pP, eNB_index, rsrq, rsrp ); } } @@ -2777,8 +3066,11 @@ int decode_BCCH_DLSCH_Message( LOG_D( RRC, "[UE %"PRIu8"] Decoding SI for frameP %"PRIu32"\n", ctxt_pP->module_id, ctxt_pP->frame ); - + //LOG_I( RRC, "Panos-D: decode_BCCH_DLSCH_Message1 BEFORE OTHER decode_SI"); + //printf("Panos-D: decode_BCCH_DLSCH_Message1 BEFORE OTHER decode_SI"); decode_SI( ctxt_pP, eNB_index ); + //if (nfapi_mode == 3) + UE_mac_inst[ctxt_pP->module_id].SI_Decoded = 1; } break; @@ -2838,7 +3130,7 @@ int decode_PCCH_DLSCH_Message( } //----------------------------------------------------------------------------- -static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp ) +int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t rsrq, const uint8_t rsrp ) { SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]; @@ -2962,7 +3254,7 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -2979,7 +3271,7 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ NULL, NULL, (MBSFN_SubframeConfigList_t *)NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,0, (MBSFN_AreaInfoList_r9_t *)NULL, (PMCH_InfoList_r9_t *)NULL @@ -2989,9 +3281,15 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ , 0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); - + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1; UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag; @@ -3069,7 +3367,7 @@ static int decode_SIB1( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ //----------------------------------------------------------------------------- -static void dump_sib2( SystemInformationBlockType2_t *sib2 ) + void dump_sib2( SystemInformationBlockType2_t *sib2 ) { // ac_BarringInfo if (sib2->ac_BarringInfo) { @@ -3237,7 +3535,7 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 ) LOG_I( RRC, "radioResourceConfigCommon.ul_CyclicPrefixLength : %ld\n", sib2->radioResourceConfigCommon.ul_CyclicPrefixLength ); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 2, 0)) // UplinkPowerControlCommon_v1020 // ... #endif @@ -3269,13 +3567,14 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 ) LOG_I( RRC, "timeAlignmentTimerCommon : %ld\n", sib2->timeAlignmentTimerCommon ); -#if defined(Rel10) || defined(Rel14) - +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) if (sib2->lateNonCriticalExtension) { LOG_I( RRC, "lateNonCriticalExtension : %p\n", sib2->lateNonCriticalExtension ); } else LOG_I( RRC, "lateNonCriticalExtension : not defined\n" ); +#endif +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) if (sib2->ext1 && sib2->ext1->ssac_BarringForMMTEL_Voice_r9) { LOG_I( RRC, "ssac_BarringForMMTEL_Voice_r9->ac_BarringFactor : %ld\n", sib2->ext1->ssac_BarringForMMTEL_Voice_r9->ac_BarringFactor ); @@ -3295,7 +3594,9 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 ) BIT_STRING_to_uint32(&sib2->ext1->ssac_BarringForMMTEL_Video_r9->ac_BarringForSpecialAC) ); } else LOG_I( RRC, "ssac_BarringForMMTEL_Video_r9 : not defined\n" ); +#endif +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (sib2->ext2 && sib2->ext2->ac_BarringForCSFB_r10) { LOG_I( RRC, "ac_BarringForCSFB_r10->ac_BarringFactor : %ld\n", sib2->ext2->ac_BarringForCSFB_r10->ac_BarringFactor ); @@ -3310,7 +3611,7 @@ static void dump_sib2( SystemInformationBlockType2_t *sib2 ) } //----------------------------------------------------------------------------- -static void dump_sib3( SystemInformationBlockType3_t *sib3 ) + void dump_sib3( SystemInformationBlockType3_t *sib3 ) { LOG_I( RRC, "Dumping SIB3 (see TS36.331 V8.21.0)\n" ); @@ -3385,7 +3686,7 @@ int Qoffsettab[31] = {-24,-22,-20,-18,-16,-14,-12,-10,-8,-6,-5,-4,-3,-2,-1,0,1,2 int PhysCellIdRange[16] = {4,8,12,16,24,32,48,64,84,96,128,168,252,504,0,0}; uint64_t arfcn_to_freq(long arfcn) { - + if (arfcn < 600) // Band 1 return((uint64_t)2110000000 + (arfcn*100000)); else if (arfcn <1200) // Band 2 @@ -3459,14 +3760,14 @@ uint64_t arfcn_to_freq(long arfcn) { exit(1); } } -static void dump_sib5( SystemInformationBlockType5_t *sib5 ) + void dump_sib5( SystemInformationBlockType5_t *sib5 ) { InterFreqCarrierFreqList_t interFreqCarrierFreqList = sib5->interFreqCarrierFreqList; int i,j; InterFreqCarrierFreqInfo_t *ifcfInfo; LOG_I( RRC, "Dumping SIB5 (see TS36.331 V8.21.0)\n" ); - + for (i=0;i<interFreqCarrierFreqList.list.count;i++) { LOG_I(RRC, "SIB5 InterFreqCarrierFreq element %d/%d\n",i,interFreqCarrierFreqList.list.count); ifcfInfo = interFreqCarrierFreqList.list.array[i]; @@ -3520,16 +3821,16 @@ static void dump_sib5( SystemInformationBlockType5_t *sib5 ) if (ifcfInfo->q_OffsetFreq) LOG_I(RRC," Q_OffsetFreq : %d\n",Qoffsettab[*ifcfInfo->q_OffsetFreq]); if (ifcfInfo->interFreqNeighCellList) { - + for (j=0;j<ifcfInfo->interFreqNeighCellList->list.count;j++) { LOG_I(RRC," Cell %d\n", j); LOG_I(RRC," PhysCellId : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->physCellId); LOG_I(RRC," Q_OffsetRange : %ld\n",ifcfInfo->interFreqNeighCellList->list.array[j]->q_OffsetCell); - + } } if (ifcfInfo->interFreqBlackCellList) { - + for (j=0;j<ifcfInfo->interFreqBlackCellList->list.count;j++) { LOG_I(RRC," Cell %d\n", j); LOG_I(RRC," PhysCellId start: %ld\n",ifcfInfo->interFreqBlackCellList->list.array[j]->start); @@ -3538,21 +3839,21 @@ static void dump_sib5( SystemInformationBlockType5_t *sib5 ) } } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) if (ifcfInfo->ext1 && ifcfInfo->ext1->q_QualMin_r9) LOG_I(RRC," Q_QualMin_r9 : %ld\n",*ifcfInfo->ext1->q_QualMin_r9); - + if (ifcfInfo->ext1 && ifcfInfo->ext1->threshX_Q_r9) { LOG_I(RRC," threshX_HighQ_r9 : %ld\n",ifcfInfo->ext1->threshX_Q_r9->threshX_HighQ_r9); LOG_I(RRC," threshX_LowQ_r9: %ld\n",ifcfInfo->ext1->threshX_Q_r9->threshX_LowQ_r9); } #endif } - + } - -#if defined(Rel10) || defined(Rel14) -static void dump_sib13( SystemInformationBlockType13_r9_t *sib13 ) + +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) + void dump_sib13( SystemInformationBlockType13_r9_t *sib13 ) { LOG_I( RRC, "[UE] Dumping SIB13\n" ); LOG_I( RRC, "[UE] dumping sib13 second time\n" ); @@ -3560,34 +3861,88 @@ static void dump_sib13( SystemInformationBlockType13_r9_t *sib13 ) LOG_I( RRC, "[UE] NotificationOffset-r9 : %d\n", (int)sib13->notificationConfig_r9.notificationOffset_r9 ); LOG_I( RRC, "[UE] NotificationSF-Index-r9 : %d\n", (int)sib13->notificationConfig_r9.notificationSF_Index_r9 ); } -#endif + +//TTN - SIB18 //----------------------------------------------------------------------------- -static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index ) -{ + void dump_sib18(SystemInformationBlockType18_r12_t *sib18){ + LOG_I( RRC, "[UE] Dumping SIB18\n" ); + for (int i = 0; i < sib18->commConfig_r12->commRxPool_r12.list.count; i++) { + LOG_I(RRC, " Contents of SIB18 %d/%d \n", i+1, sib18->commConfig_r12->commRxPool_r12.list.count); + LOG_I(RRC, " SIB18 rxPool_sc_CP_Len: %ld \n", sib18->commConfig_r12->commRxPool_r12.list.array[i]->sc_CP_Len_r12); + LOG_I(RRC, " SIB18 sc_Period_r12: %ld \n", sib18->commConfig_r12->commRxPool_r12.list.array[i]->sc_Period_r12); + LOG_I(RRC, " SIB18 data_CP_Len_r12: %ld \n", sib18->commConfig_r12->commRxPool_r12.list.array[i]->data_CP_Len_r12); + LOG_I(RRC, " SIB18 prb_Num_r12: %ld \n", sib18->commConfig_r12->commRxPool_r12.list.array[i]->sc_TF_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, " SIB18 prb_Start_r12: %ld \n", sib18->commConfig_r12->commRxPool_r12.list.array[i]->sc_TF_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, " SIB18 prb_End_r12: %ld \n", sib18->commConfig_r12->commRxPool_r12.list.array[i]->sc_TF_ResourceConfig_r12.prb_End_r12); + //to add more log + } +} + +//TTN - SIB19 +//----------------------------------------------------------------------------- + void dump_sib19(SystemInformationBlockType19_r12_t *sib19){ + LOG_I( RRC, "[UE] Dumping SIB19\n" ); + for (int i = 0; i < sib19->discConfig_r12->discRxPool_r12.list.count; i++) { + LOG_I(RRC, " Contents of SIB19 %d/%d \n", i+1, sib19->discConfig_r12->discRxPool_r12.list.count); + LOG_I(RRC, " SIB19 cp_Len_r12: %ld \n", sib19->discConfig_r12->discRxPool_r12.list.array[i]->cp_Len_r12); + LOG_I(RRC, " SIB19 discPeriod_r12: %ld \n", sib19->discConfig_r12->discRxPool_r12.list.array[i]->discPeriod_r12); + LOG_I(RRC, " SIB19 numRetx_r12: %ld \n", sib19->discConfig_r12->discRxPool_r12.list.array[i]->numRetx_r12); + LOG_I(RRC, " SIB19 numRepetition_r12: %ld \n", sib19->discConfig_r12->discRxPool_r12.list.array[i]->numRepetition_r12); + LOG_I(RRC, " SIB19 prb_Num_r12: %ld \n", sib19->discConfig_r12->discRxPool_r12.list.array[i]->tf_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, " SIB19 prb_Start_r12: %ld \n", sib19->discConfig_r12->discRxPool_r12.list.array[i]->tf_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, " SIB19 prb_End_r12: %ld \n", sib19->discConfig_r12->discRxPool_r12.list.array[i]->tf_ResourceConfig_r12.prb_End_r12); + //to add more log + } +} + void dump_sib21(SystemInformationBlockType21_r14_t *sib21){ + if ((sib21->sl_V2X_ConfigCommon_r14 != NULL) && (sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14 !=NULL) ){ + for (int i = 0; i < sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14->list.count; i++) { + LOG_I(RRC, " Contents of SIB21 %d/%d \n", i+1, sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14->list.count); + LOG_I(RRC, " SIB21 sl_Subframe_r14: %d \n", sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14->list.array[i]->sl_Subframe_r14.present); + LOG_I(RRC, " SIB21 adjacencyPSCCH_PSSCH_r14: %d \n", sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14->list.array[i]->adjacencyPSCCH_PSSCH_r14); + LOG_I(RRC, " SIB21 sizeSubchannel_r14: %ld \n", sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14->list.array[i]->sizeSubchannel_r14); + LOG_I(RRC, " SIB21 numSubchannel_r14: %ld \n", sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14->list.array[i]->numSubchannel_r14); + LOG_I(RRC, " SIB21 startRB_Subchannel_r14: %ld \n", sib21->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14->list.array[i]->startRB_Subchannel_r14); + //to add more log + } + } + } + + +#endif +//----------------------------------------------------------------------------- + int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index ) +{ + //LOG_D( RRC, "Panos-D: decode_SI 1 \n"); SystemInformation_t** si = &UE_rrc_inst[ctxt_pP->module_id].si[eNB_index]; int new_sib = 0; SystemInformationBlockType1_t* sib1 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]; + //LOG_D( RRC, "Panos-D: decode_SI 2 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_IN ); // Dump contents - if ((*si)->criticalExtensions.present == SystemInformation__criticalExtensions_PR_systemInformation_r8) { + if ((*si)->criticalExtensions.present == SystemInformation__criticalExtensions_PR_systemInformation_r8 || + (*si)->criticalExtensions.present == SystemInformation__criticalExtensions_PR_criticalExtensionsFuture) { LOG_D( RRC, "[UE] (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count %d\n", (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count ); } else { + //LOG_D( RRC, "Panos-D: decode_SI 2.3 \n"); LOG_D( RRC, "[UE] Unknown criticalExtension version (not Rel8)\n" ); return -1; } + LOG_D( RRC, "Panos-D: decode_SI 3 \n"); for (int i=0; i<(*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count; i++) { - LOG_D( RRC, "SI count %d\n", i ); + //LOG_I( RRC, "Panos-D: SI count %d\n", i ); struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *typeandinfo; typeandinfo = (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.array[i]; switch(typeandinfo->present) { case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2: + //LOG_D( RRC, "Panos-D: decode_SI 4 \n"); if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&2) == 0) { UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=2; new_sib=1; @@ -3600,7 +3955,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index, &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->radioResourceConfigCommon, (struct PhysicalConfigDedicated *)NULL, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, #endif (MeasObjectToAddMod_t **)NULL, @@ -3616,7 +3971,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth, &UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission, UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->mbsfn_SubframeConfigList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,0, (MBSFN_AreaInfoList_r9_t *)NULL, (PMCH_InfoList_r9_t *)NULL @@ -3625,18 +3980,24 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in #ifdef CBA ,0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); // After SI is received, prepare RRCConnectionRequest -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (UE_rrc_inst[ctxt_pP->module_id].MBMS_flag < 3) // see -Q option #endif #if !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)) rrc_ue_generate_RRCConnectionRequest( ctxt_pP, eNB_index ); - + #endif - + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_IDLE) { LOG_I( RRC, "[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n", ctxt_pP->module_id ); UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State = RRC_SI_RECEIVED; @@ -3644,7 +4005,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in { MessageDef *message_ral_p = NULL; rrc_ral_system_information_ind_t ral_si_ind; - + message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_SYSTEM_INFORMATION_IND); memset(&ral_si_ind, 0, sizeof(rrc_ral_system_information_ind_t)); ral_si_ind.plmn_id.MCCdigit2 = '0'; @@ -3671,6 +4032,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in break; // case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3: + //LOG_D( RRC, "Panos-D: decode_SI 5 \n"); if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4) == 0) { UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4; new_sib=1; @@ -3695,7 +4057,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&16) == 0) { UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=16; new_sib=1; - + memcpy( UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index], &typeandinfo->choice.sib5, sizeof(SystemInformationBlockType5_t) ); LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB5 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); dump_sib5(UE_rrc_inst[ctxt_pP->module_id].sib5[eNB_index]); @@ -3706,7 +4068,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&32) == 0) { UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=32; new_sib=1; - + memcpy( UE_rrc_inst[ctxt_pP->module_id].sib6[eNB_index], &typeandinfo->choice.sib6, sizeof(SystemInformationBlockType6_t) ); LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB6 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); } @@ -3734,7 +4096,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&256) == 0) { UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=256; new_sib=1; - + memcpy( UE_rrc_inst[ctxt_pP->module_id].sib9[eNB_index], &typeandinfo->choice.sib9, sizeof(SystemInformationBlockType9_t) ); LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB9 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); } @@ -3759,7 +4121,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in } break; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 2, 0)) case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920: if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&2048) == 0) { @@ -3769,12 +4131,12 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB12 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); } break; - + case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920: if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&4096) == 0) { UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=4096; new_sib=1; - + memcpy( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index], &typeandinfo->choice.sib13_v920, sizeof(SystemInformationBlockType13_r9_t) ); LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB13 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); dump_sib13( UE_rrc_inst[ctxt_pP->module_id].sib13[eNB_index] ); @@ -3804,10 +4166,84 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in #ifdef CBA ,0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); break; } +#endif + +#if defined(Rel10) || defined(Rel14) + //SIB18 + case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250: + if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&8192) == 0) { + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=8192; + new_sib=1; + + memcpy( UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index], &typeandinfo->choice.sib18_v1250, sizeof(SystemInformationBlockType18_r12_t) ); + LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB18 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); + dump_sib18( UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index] ); + // adding here function to store necessary parameters to transfer to PHY layer + LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB18 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", + ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); + + //process SIB18 to transfer SL-related parameters to PHY + rrc_ue_process_sidelink_radioResourceConfig(ctxt_pP->module_id,eNB_index, + UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index], + (SystemInformationBlockType19_r12_t *)NULL, + (SL_CommConfig_r12_t *)NULL, + (SL_DiscConfig_r12_t *)NULL + ); + + } + break; + + //SIB19 + case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250: + if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&16384) == 0) { + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=16384; + new_sib=1; + + memcpy( UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index], &typeandinfo->choice.sib19_v1250, sizeof(SystemInformationBlockType19_r12_t) ); + LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB19 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); + dump_sib19( UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index] ); + // adding here function to store necessary parameters to transfer to PHY layer + LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB19 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", + ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); + //process SIB19 to transfer SL-related parameters to PHY + rrc_ue_process_sidelink_radioResourceConfig(ctxt_pP->module_id,eNB_index, + (SystemInformationBlockType18_r12_t *)NULL, + UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index], + (SL_CommConfig_r12_t *)NULL, + (SL_DiscConfig_r12_t *)NULL + ); + + } + break; + + //SIB21 + case SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430: + if ((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&32768) == 0) { + UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus|=32768; + new_sib=1; + + memcpy( UE_rrc_inst[ctxt_pP->module_id].sib21[eNB_index], &typeandinfo->choice.sib21_v1430, sizeof(SystemInformationBlockType21_r14_t) ); + LOG_I( RRC, "[UE %"PRIu8"] Frame %"PRIu32" Found SIB21 from eNB %"PRIu8"\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index ); + dump_sib21( UE_rrc_inst[ctxt_pP->module_id].sib21[eNB_index] ); + // adding here function to store necessary parameters to transfer to PHY layer + LOG_I( RRC, "[FRAME %05"PRIu32"][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB21 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n", + ctxt_pP->frame, ctxt_pP->module_id, eNB_index, ctxt_pP->module_id); + //process SIB21 + //TODO + } + break; + + #endif default: break; @@ -3820,7 +4256,7 @@ static int decode_SI( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_in if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt == sib1->schedulingInfoList.list.count) rrc_set_sub_state( ctxt_pP->module_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE ); - LOG_I(RRC,"SIStatus %x, SIcnt %d/%d\n", + LOG_I(RRC,"SIStatus %x, SIcnt %d/%d\n", UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus, UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIcnt, sib1->schedulingInfoList.list.count); @@ -3893,7 +4329,7 @@ void ue_meas_filtering( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ //Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 //----------------------------------------------------------------------------- -static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, uint8_t eNB_index ) + void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, uint8_t eNB_index ) { uint8_t buffer[32], size; @@ -3961,7 +4397,11 @@ static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t* const ctxt_pP, ui size = do_MeasurementReport(ctxt_pP->module_id, buffer,measId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", ctxt_pP->module_id, ctxt_pP->frame, eNB_index); - result = pdcp_data_req(ctxt_pP, SRB_FLAG_YES, DCCH, rrc_mui++, 0, size, buffer, PDCP_TRANSMISSION_MODE_DATA); + result = pdcp_data_req(ctxt_pP, SRB_FLAG_YES, DCCH, rrc_mui++, 0, size, buffer, PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,NULL, NULL +#endif + ); AssertFatal (result == TRUE, "PDCP data request failed!\n"); //LOG_D(RRC, "[UE %d] Frame %d Sending MeasReport (%d bytes) through DCCH%d to PDCP \n",ue_mod_idP,frameP, size, DCCH); } @@ -4087,7 +4527,7 @@ void ue_measurement_report_triggering(protocol_ctxt_t* const ctxt_pP, const uint //check_trigger_meas_event(ue_mod_idP, frameP, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms) //----------------------------------------------------------------------------- -static uint8_t check_trigger_meas_event( + uint8_t check_trigger_meas_event( module_id_t ue_mod_idP, frame_t frameP, uint8_t eNB_index, @@ -4150,7 +4590,7 @@ static uint8_t check_trigger_meas_event( return 0; } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //----------------------------------------------------------------------------- int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, const uint8_t* const Sdu, const uint8_t Sdu_len, const uint8_t mbsfn_sync_area ) { @@ -4214,7 +4654,7 @@ int decode_MCCH_Message( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB } //----------------------------------------------------------------------------- -static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_index, frame_t frameP, uint8_t mbsfn_sync_area ) + void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_index, frame_t frameP, uint8_t mbsfn_sync_area ) { protocol_ctxt_t ctxt; @@ -4225,7 +4665,7 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i rrc_mac_config_req_ue(ue_mod_idP,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -4242,7 +4682,7 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i NULL, NULL, (MBSFN_SubframeConfigList_t *)NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *)NULL, @@ -4253,9 +4693,15 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i , 0, 0 +#endif +#if defined(Rel14) + , + 0, + NULL, + NULL #endif ); - + UE_rrc_inst[ue_mod_idP].Info[eNB_index].MCCHStatus[mbsfn_sync_area] = 1; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_idP, ENB_FLAG_NO, UE_rrc_inst[ue_mod_idP].Info[eNB_index].rnti, frameP, 0,eNB_index); @@ -4269,7 +4715,7 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i NULL, // key rrc encryption NULL, // key rrc integrity NULL // key encryption -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) ,&(UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9) #endif ,NULL); @@ -4278,8 +4724,9 @@ static void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_i NULL,// SRB_ToAddModList NULL,// DRB_ToAddModList NULL,// DRB_ToReleaseList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) &(UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->pmch_InfoList_r9) + , 0, 0 #endif ); // */ @@ -4382,7 +4829,7 @@ void *rrc_ue_task( void *args_p ) RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); break; -# if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) case RRC_MAC_MCCH_DATA_IND: LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d, mbsfn SA %d\n", ue_mod_id, msg_name, @@ -4397,6 +4844,15 @@ void *rrc_ue_task( void *args_p ) RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area); break; + + /* //TTN (for D2D) + case RRC_MAC_SL_DISCOVERY_DATA_IND: + LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", ue_mod_id, msg_name, + RRC_MAC_SL_DISCOVERY_DATA_IND (msg_p).frame, RRC_MAC_SL_DISCOVERY_DATA_IND (msg_p).enb_index); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, M_RNTI, RRC_MAC_SL_DISCOVERY_DATA_IND (msg_p).frame, 0,RRC_MAC_SL_DISCOVERY_DATA_IND (msg_p).enb_index); + //send to ProSeApp + break; +*/ # endif /* PDCP messages */ @@ -4576,7 +5032,7 @@ void *rrc_ue_task( void *args_p ) /* Transfer data to PDCP */ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, ENB_FLAG_NO, UE_rrc_inst[ue_mod_id].Info[0].rnti, 0, 0,0); - // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) + // check if SRB2 is created, if yes request data_req on DCCH1 (SRB2) if(UE_rrc_inst[ue_mod_id].SRB2_config[0] == NULL) { rrc_data_req_ue (&ctxt, @@ -4597,7 +5053,7 @@ void *rrc_ue_task( void *args_p ) } break; } - + # endif # if ENABLE_RAL @@ -4805,7 +5261,7 @@ openair_rrc_top_init_ue( UE_rrc_inst[module_id].UECapability_size = UECap->sdu_size; } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) LOG_I(RRC,"[UE] eMBMS active state is %d \n", eMBMS_active); for (module_id=0; module_id<NB_UE_INST; module_id++) { @@ -4813,6 +5269,14 @@ openair_rrc_top_init_ue( } #endif + +#ifdef Rel14 + /* TODO: this is disabled for the moment because the standard UE + * crashes when calling this function. + */ + //init_SL_preconfig(&UE_rrc_inst[module_id],0); +#endif + } else { UE_rrc_inst = NULL; } @@ -4828,11 +5292,1091 @@ rrc_top_cleanup_ue( { if (NB_UE_INST > 0) free (UE_rrc_inst); - + } +//----------------------------------------------------------------------------- +uint8_t rrc_ue_generate_SidelinkUEInformation( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index,SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode) +{ + uint8_t size=0; + uint8_t buffer[100]; + + //Generate SidelinkUEInformation + if (((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&8192) > 0) && (destinationInfoList != NULL)) {//if SIB18 is available + size = do_SidelinkUEInformation(ctxt_pP->module_id, buffer, destinationInfoList, NULL, mode); + LOG_I(RRC,"[UE %d][RRC_UE] Frame %d : Logical Channel UL-DCCH, Generating SidelinkUEInformation (bytes%d, eNB %d)\n", + ctxt_pP->module_id,ctxt_pP->frame, size, eNB_index); + //return size; + } + if (((UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus&16384) > 0) && (discTxResourceReq != NULL)) {//if SIB19 is available + size = do_SidelinkUEInformation(ctxt_pP->module_id, buffer, NULL, discTxResourceReq, mode); + LOG_I(RRC,"[UE %d][RRC_UE] Frame %d : Logical Channel UL-DCCH, Generating SidelinkUEInformation (bytes%d, eNB %d)\n", + ctxt_pP->module_id,ctxt_pP->frame, size, eNB_index); + //return size; + } + + rrc_data_req_ue ( + ctxt_pP, + DCCH, + rrc_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + return size; +} + + +// 3GPP 36.331 (Section 5.10.7.3) +uint8_t fill_SLSS(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, SLSSID_r12_t *slss_id, uint8_t *subframe, uint8_t mode) +{ + long syncOffsetIndicator = 0; + switch(mode) { + case 1: //if triggered by SL discovery announcement and in-coverage + //discSyncConfig_r12 contains only one element + *slss_id = UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->slssid_r12; + syncOffsetIndicator = UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->syncOffsetIndicator_r12; + //select subframe for SLSS + break; + case 2: //if triggered by SL communication and in-coverage + + if (UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12) { + *slss_id = UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->slssid_r12; + syncOffsetIndicator = UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->syncOffsetIndicator_r12; + + //if RRC_CONNECTED (Todo: and if networkControlledSyncTx (RRCConnectionReconfiguration) is configured and set to On) + if (UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].State == RRC_CONNECTED){ + //select subframe(s) indicated by syncOffsetIndicator + *subframe = syncOffsetIndicator; + } else { + //select subframe(s) indicated by syncOffsetIndicator within SC period + } + break; + case 3: //if triggered by V2X communication and in coverage + + break; + case 4: //if triggered by V2X communication and out-of-coverage + + break; + case 5: //if triggered by V2X communication and UE has GNSS as the synchronization reference + + default: + //if UE has a selected SyncRefUE + //TODO + //else (no SyncRefUE Selected) + //Todo if trigger by V2X + //else randomly select an SLSSID from the set defined for out-of-coverage + *slss_id = 170;//hardcoded + //select the subframe according to syncOffsetIndicator1/2 from the preconfigured parameters + break; + } + } + return 0; +} + + +//----------------------------------------------------------------------------- +void +rrc_ue_process_sidelink_radioResourceConfig( + module_id_t Mod_idP, + uint8_t eNB_index, + SystemInformationBlockType18_r12_t *sib18, + SystemInformationBlockType19_r12_t *sib19, + SL_CommConfig_r12_t* sl_CommConfig, + SL_DiscConfig_r12_t* sl_DiscConfig +) +//----------------------------------------------------------------------------- +{ + //process SIB18, configure MAC/PHY for receiving SL communication (RRC_IDLE and RRC_CONNECTED), for transmitting SL communication (RRC_IDLE) + if (sib18 != NULL) { + if (sib18->commConfig_r12 != NULL) { + //do not consider commTXPoolExceptional for the moment + //configure PHY/MAC to receive SL communication by using the RPs indicated by commRxPool + //sib18->commConfig_r12->commRxPool_r12 + //TODO + + if (sib18->commConfig_r12->commTxPoolNormalCommon_r12 !=NULL) { //commTxPoolNormalCommon - to transmit SL communication in RRC_IDLE + //maybe we don't consider this case for the moment since UE will immediately establish a RRC connection after receiving SIB messages + //configure PHY/MAC to transmit SL communication using the RPs indicated by the first entry in commTxPoolNormalCommon + //SL_CommResourcePool_r12_t sl_CommResourcePool = sib18->commConfig_r12->commTxPoolNormalCommon_r12->list.array[0]; + } + } + } + + //process SIB19, configure MAC/PHY for receiving SL discovery (RRC_IDLE and RRC_CONNECTED), for transmitting SL discovery (RRC_IDLE) + if (sib19 != NULL) { + //to receive non-PS related discovery announcements (discRxPool) + //sib19->discConfig_r12->discRxPool_r12; + + //to receive PS related discovery announcements (discRxPoolPS) + //sib19->ext1->discConfigPS_13->discRxPoolPS_r13; + + //to transmit non-PS related discovery in RRC_IDLE + //sib19->discConfig_r12->discTxPoolCommon_r12; + + //to transmit PS related discovery in RRC_IDLE + //sib19->ext1->discConfigPS_13->discTxPoolPS_Common_r13; + } + + //process sl_CommConfig, configure MAC/PHY for transmitting SL communication (RRC_CONNECTED) + if (sl_CommConfig != NULL) { + + if (sl_CommConfig->commTxResources_r12 != NULL) { + switch (sl_CommConfig->commTxResources_r12->present){ + case SL_CommConfig_r12__commTxResources_r12_PR_setup: + if (sl_CommConfig->commTxResources_r12->choice.setup.present == SL_CommConfig_r12__commTxResources_r12__setup_PR_scheduled_r12 ){ + + LOG_I(RRC,"[UE %d][RRC_UE] scheduled resource for SL, sl_RNTI size %d \n", + Mod_idP, sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.size ); + LOG_I(RRC,"[UE %d][RRC_UE] scheduled resource for SL, sl_RNTI buf 0x%p \n", + Mod_idP, sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf ); + LOG_I(RRC,"[UE %d][RRC_UE] scheduled resource for SL, Mac_MainConfig_r12.retx_BSR_TimerSL %ld \n", + Mod_idP, sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mac_MainConfig_r12.retx_BSR_TimerSL ); + LOG_I(RRC,"[UE %d][RRC_UE] scheduled resource for SL, sc_CommTxConfig %ld \n", + Mod_idP, sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mac_MainConfig_r12.retx_BSR_TimerSL ); + //configure scheduled resource for SL + //TODO + } else if (sl_CommConfig->commTxResources_r12->choice.setup.present == SL_CommConfig_r12__commTxResources_r12__setup_PR_ue_Selected_r12){ + //configure dedicated resources (commTxPoolNormalDedicated) for SL from which UE can autonomously select + //sl_CommConfig->commTxResources_r12->choice.setup.choice.ue_Selected_r12.commTxPoolNormalDedicated_r12; + + //for the moment, only pass the first entry (e.g., do not consider priorityList in commTxPoolNormalDedicated (3GPP 36.331 Section 5.10.4 1>2>3>4)) + //sl_CommConfig->commTxResources_r12->choice.setup.choice.ue_Selected_r12.commTxPoolNormalDedicated_r12.poolToAddModList_r12->list.array[0]; + } else { + //SL_CommConfig_r12__commTxResources_r12__setup_PR_NOTHING /* No components present */ + } + break; + + case SL_CommConfig_r12__commTxResources_r12_PR_release: + //release dedicated resources for SL communication + break; + + case SL_CommConfig_r12__commTxResources_r12_PR_NOTHING: /* No components present */ + break; + + default: + break; + } + } + + } + + //process sl_DiscConfig, configure MAC/PHY for transmitting SL discovery announcements (RRC_CONNECTED) + if (sl_DiscConfig != NULL) { + //dedicated resources for transmitting non-PS related discovery + if (sl_DiscConfig->discTxResources_r12 != NULL) { + + switch (sl_DiscConfig->discTxResources_r12->present) { + case SL_DiscConfig_r12__discTxResources_r12_PR_setup: + if (sl_DiscConfig->discTxResources_r12->choice.setup.present == SL_DiscConfig_r12__discTxResources_r12__setup_PR_scheduled_r12) { + //sl_DiscConfig->discTxResources_r12->choice.setup.choice.scheduled_r12.discHoppingConfig_r12; + //sl_DiscConfig->discTxResources_r12->choice.setup.choice.scheduled_r12.discTF_IndexList_r12; + //sl_DiscConfig->discTxResources_r12->choice.setup.choice.scheduled_r12.discTxConfig_r12; + } else if (sl_DiscConfig->discTxResources_r12->choice.setup.present == SL_DiscConfig_r12__discTxResources_r12__setup_PR_ue_Selected_r12) { + //sl_DiscConfig->discTxResources_r12->choice.setup.choice.ue_Selected_r12.discTxPoolDedicated_r12; + } else { + //SL_DiscConfig_r12__discTxResources_r12__setup_PR_NOTHING, /* No components present */ + } + break; + case SL_DiscConfig_r12__discTxResources_r12_PR_release: + //release dedicated resources for SL discovery + break; + case SL_DiscConfig_r12__discTxResources_r12_PR_NOTHING: /* No components present */ + break; + default: + break; + } + + } + //dedicated resources for transmitting PS related discovery + if (sl_DiscConfig->ext2->discTxResourcesPS_r13 != NULL){ + switch (sl_DiscConfig->ext2->discTxResourcesPS_r13->present) { + case SL_DiscConfig_r12__ext2__discTxResourcesPS_r13_PR_setup: + if (sl_DiscConfig->ext2->discTxResourcesPS_r13->choice.setup.present == SL_DiscConfig_r12__ext2__discTxResourcesPS_r13__setup_PR_scheduled_r13) { + //sl_DiscConfig->ext2->discTxResourcesPS_r13->choice.setup.choice.scheduled_r13.discHoppingConfig_r13; + //sl_DiscConfig->ext2->discTxResourcesPS_r13->choice.setup.choice.scheduled_r13.discTxConfig_r13 + } else if (sl_DiscConfig->ext2->discTxResourcesPS_r13->choice.setup.present == SL_DiscConfig_r12__ext2__discTxResourcesPS_r13__setup_PR_ue_Selected_r13) { + //sl_DiscConfig->ext2->discTxResourcesPS_r13->choice.setup.choice.ue_Selected_r13.discTxPoolPS_Dedicated_r13; + } else { + //SL_DiscConfig_r12__ext2__discTxResourcesPS_r13__setup_PR_NOTHING, /* No components present */ + } + + break; + case SL_DiscConfig_r12__ext2__discTxResourcesPS_r13_PR_release: + break; + case SL_DiscConfig_r12__ext2__discTxResourcesPS_r13_PR_NOTHING: + /* No components present */ + break; + default: + break; + } + } + } +} + +#ifdef Rel14 +//----------------------------------------------------------- +void +rrc_control_socket_init(){ + + struct sockaddr_in rrc_ctrl_socket_addr; + pthread_attr_t attr; + struct sched_param sched_param; + int optval; // flag value for setsockopt + //int n; // message byte size + + + // create the control socket + ctrl_sock_fd = socket(AF_INET, SOCK_DGRAM, 0); + if (ctrl_sock_fd == -1) { + LOG_E(RRC,"[rrc_control_socket_init] :Error opening socket %d (%d:%s)\n",ctrl_sock_fd,errno, strerror(errno)); + exit(EXIT_FAILURE); + } + // if (ctrl_sock_fd < 0) + // error("ERROR: Failed on opening socket"); + optval = 1; + setsockopt(ctrl_sock_fd, SOL_SOCKET, SO_REUSEADDR, + (const void *)&optval , sizeof(int)); + + //build the server's address + bzero((char *) &rrc_ctrl_socket_addr, sizeof(rrc_ctrl_socket_addr)); + rrc_ctrl_socket_addr.sin_family = AF_INET; + rrc_ctrl_socket_addr.sin_addr.s_addr = htonl(INADDR_ANY); + rrc_ctrl_socket_addr.sin_port = htons(CONTROL_SOCKET_PORT_NO); + // associate the parent socket with a port + if (bind(ctrl_sock_fd, (struct sockaddr *) &rrc_ctrl_socket_addr, + sizeof(rrc_ctrl_socket_addr)) < 0) { + LOG_E(RRC,"[rrc_control_socket_init] ERROR: Failed on binding the socket\n"); + exit(1); + } + //create thread to listen to incoming packets + if (pthread_attr_init(&attr) != 0) { + LOG_E(RRC, "[rrc_control_socket_init]Failed to initialize pthread attribute for ProSe -> RRC communication (%d:%s)\n", + errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + sched_param.sched_priority = 10; + + pthread_attr_setschedpolicy(&attr, SCHED_RR); + pthread_attr_setschedparam(&attr, &sched_param); + + pthread_t rrc_control_socket_thread; + + if (pthread_create(&rrc_control_socket_thread, &attr, rrc_control_socket_thread_fct, NULL) != 0) { + LOG_E(RRC, "[rrc_control_socket_init]Failed to create new thread for RRC/ProSeApp communication (%d:%s)\n", + errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + pthread_setname_np( rrc_control_socket_thread, "RRC Control Socket" ); + +} + +//-------------------------------------------------------- +void *rrc_control_socket_thread_fct(void *arg) +{ + + int prose_addr_len; + char send_buf[BUFSIZE]; + char receive_buf[BUFSIZE]; + //int optval; + int n; + struct sidelink_ctrl_element *sl_ctrl_msg_recv = NULL; + struct sidelink_ctrl_element *sl_ctrl_msg_send = NULL; + uint32_t sourceL2Id, groupL2Id, destinationL2Id; + module_id_t module_id = 0; //hardcoded for testing only + uint8_t type; + UE_RRC_INST *UE = NULL; + protocol_ctxt_t ctxt; + struct RLC_Config *DRB_rlc_config = NULL; + struct PDCP_Config *DRB_pdcp_config = NULL; + struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; + struct LogicalChannelConfig *DRB_lchan_config = NULL; + struct LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters = NULL; + long *logicalchannelgroup_drb = NULL; + int j = 0; + int i = 0; + + //from the main program, listen for the incoming messages from control socket (ProSe App) + prose_addr_len = sizeof(prose_app_addr); + //int enable_notification = 1; + while (1) { + LOG_I(RRC,"Listening to incoming connection from ProSe App \n"); + // receive a message from ProSe App + memset(receive_buf, 0, BUFSIZE); + n = recvfrom(ctrl_sock_fd, receive_buf, BUFSIZE, 0, + (struct sockaddr *) &prose_app_addr, (socklen_t *)&prose_addr_len); + if (n < 0){ + LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n"); + exit(EXIT_FAILURE); + } + //TODO: should store the address of ProSeApp [UE_rrc_inst] to be able to send UE state notification to the App + + //sl_ctrl_msg_recv = (struct sidelink_ctrl_element *) receive_buf; + sl_ctrl_msg_recv = calloc(1, sizeof(struct sidelink_ctrl_element)); + memcpy((void *)sl_ctrl_msg_recv, (void *)receive_buf, sizeof(struct sidelink_ctrl_element)); + + //process the message + switch (sl_ctrl_msg_recv->type) { + case SESSION_INIT_REQ: +#ifdef DEBUG_CTRL_SOCKET + LOG_I(RRC,"Received SessionInitializationRequest on socket from ProSe App (msg type: %d)\n", sl_ctrl_msg_recv->type); +#endif + //TODO: get SL_UE_STATE from lower layer + + LOG_I(RRC,"Send UEStateInformation to ProSe App \n"); + memset(send_buf, 0, BUFSIZE); + + sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); + sl_ctrl_msg_send->type = UE_STATUS_INFO; + sl_ctrl_msg_send->sidelinkPrimitive.ue_state = UE_STATE_OFF_NETWORK; //off-network + memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); + free(sl_ctrl_msg_send); + + prose_addr_len = sizeof(prose_app_addr); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + if (n < 0) { + LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } + + +#ifdef DEBUG_CTRL_SOCKET + struct sidelink_ctrl_element *ptr_ctrl_msg = NULL; + ptr_ctrl_msg = (struct sidelink_ctrl_element *) send_buf; + LOG_I(RRC,"[UEStateInformation] msg type: %d\n",ptr_ctrl_msg->type); + LOG_I(RRC,"[UEStateInformation] UE state: %d\n",ptr_ctrl_msg->sidelinkPrimitive.ue_state); +#endif + + /* if (enable_notification > 0) { + //create thread to send status notification (for testing purpose, status notification will be sent e.g., every 20 seconds) + pthread_t notification_thread; + if( pthread_create( ¬ification_thread , NULL , send_UE_status_notification , (void*) &sockfd) < 0) + error("ERROR: could not create thread"); + } + enable_notification = 0; + */ + break; + + case GROUP_COMMUNICATION_ESTABLISH_REQ: + sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id; + groupL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id; + +#ifdef DEBUG_CTRL_SOCKET + LOG_I(RRC,"[GroupCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type); + LOG_I(RRC,"[GroupCommunicationEstablishReq] source Id: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id); + LOG_I(RRC,"[GroupCommunicationEstablishReq] group Id: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id); + LOG_I(RRC,"[GroupCommunicationEstablishReq] group IP Address: " IPV4_ADDR "\n",IPV4_ADDR_FORMAT(sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupIpAddress)); +#endif + + //store sourceL2Id/groupL2Id + UE_rrc_inst[module_id].sourceL2Id = sourceL2Id; + UE_rrc_inst[module_id].groupL2Id = groupL2Id; + j = 0; + i = 0; + for (i=0; i< MAX_NUM_DEST; i++) { + if ((UE_rrc_inst[module_id].destinationList[i] == 0) && (j == 0)) j = i+1; + if (UE_rrc_inst[module_id].destinationList[i] == groupL2Id) break; //group already exists! + } + if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[module_id].destinationList[j-1] = groupL2Id; + + // configure lower layers PDCP/MAC/PHY for this communication + //Establish a new RBID/LCID for this communication + // Establish a SLRB (using DRB 3 for now) + UE = &UE_rrc_inst[module_id]; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0); + + UE->DRB_config[0][0] = CALLOC(1,sizeof(struct DRB_ToAddMod)); + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + UE->DRB_config[0][0]->drb_Identity = 3; + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(UE->DRB_config[0][0]->eps_BearerIdentity) = 3; + UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config)); + DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config)); + PDCP_rlc_UM = CALLOC(1,sizeof(struct PDCP_Config__rlc_UM)); + DRB_lchan_config = CALLOC(1,sizeof(struct LogicalChannelConfig)); + DRB_ul_SpecificParameters = CALLOC(1, sizeof(struct LogicalChannelConfig__ul_SpecificParameters)); + logicalchannelgroup_drb = CALLOC(1, sizeof(long)); + + DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; + UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config; + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + /* avoid gcc warnings */ + (void)PDCP_rlc_UM; + + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; + + UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config; + DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); + DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; + + DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer + DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + DRB_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) + + *logicalchannelgroup_drb = 1; + DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; + + UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t)); + ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]); + + rrc_pdcp_config_asn1_req(&ctxt, + (SRB_ToAddModList_t *) NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*) NULL, + 0xff, NULL, NULL, NULL +#if defined(Rel10) || defined(Rel14) + , (PMCH_InfoList_r9_t *) NULL +#endif + ,NULL); + + + rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*)NULL +#if defined(Rel10) || defined(Rel14) + ,(PMCH_InfoList_r9_t *)NULL + , 0, 0 +#endif + ); + + rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*)NULL +#ifdef Rel14 + ,(PMCH_InfoList_r9_t *)NULL + , sourceL2Id, groupL2Id +#endif + ); + + + //configure MAC with sourceL2Id/groupL2ID + rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0 + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, +#if defined(Rel10) || defined(Rel14) + (SCellToAddMod_r10_t *)NULL, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, +#endif + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 3, //LCID + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +#if defined(Rel10) || defined(Rel14) + ,0, + (MBSFN_AreaInfoList_r9_t *)NULL, + (PMCH_InfoList_r9_t *)NULL + +#endif +#ifdef CBA + , + 0, + 0 +#endif +#if defined(Rel10) || defined(Rel14) + ,CONFIG_ACTION_ADD, + &sourceL2Id, + &groupL2Id +#endif + ); + + LOG_I(RRC,"Send GroupCommunicationEstablishResp to ProSe App\n"); + memset(send_buf, 0, BUFSIZE); + sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); + sl_ctrl_msg_send->type = GROUP_COMMUNICATION_ESTABLISH_RSP; + sl_ctrl_msg_send->sidelinkPrimitive.slrb_id = 3; //slrb_id + + memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); + free(sl_ctrl_msg_send); + + prose_addr_len = sizeof(prose_app_addr); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + if (n < 0){ + LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } + + +#ifdef DEBUG_CTRL_SOCKET + ptr_ctrl_msg = (struct sidelink_ctrl_element *) send_buf; + LOG_I(RRC,"[GroupCommunicationEstablishResponse] msg type: %d\n",ptr_ctrl_msg->type); + LOG_I(RRC,"[GroupCommunicationEstablishResponse] slrb_id: %d\n",ptr_ctrl_msg->sidelinkPrimitive.slrb_id); +#endif + break; + + case GROUP_COMMUNICATION_RELEASE_REQ: + printf("-----------------------------------\n"); +#ifdef DEBUG_CTRL_SOCKET + LOG_I(RRC,"[GroupCommunicationReleaseRequest] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type); + LOG_I(RRC,"[GroupCommunicationReleaseRequest] Slrb Id: %i\n",sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id); +#endif + //reset groupL2ID from MAC LAYER + UE_rrc_inst[module_id].groupL2Id = 0x00000000; + sourceL2Id = UE_rrc_inst[module_id].sourceL2Id; + + rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0 + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, + #if defined(Rel10) || defined(Rel14) + (SCellToAddMod_r10_t *)NULL, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, + #endif + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 0, + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL + #if defined(Rel10) || defined(Rel14) + ,0, + (MBSFN_AreaInfoList_r9_t *)NULL, + (PMCH_InfoList_r9_t *)NULL + + #endif + #ifdef CBA + , + 0, + 0 + #endif + #if defined(Rel10) || defined(Rel14) + ,CONFIG_ACTION_REMOVE, + &sourceL2Id, + &destinationL2Id + #endif + ); + + + LOG_I(RRC,"Send GroupCommunicationReleaseResponse to ProSe App \n"); + memset(send_buf, 0, BUFSIZE); + + sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); + sl_ctrl_msg_send->type = GROUP_COMMUNICATION_RELEASE_RSP; + //if the requested id exists -> release this ID + if (sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id == slrb_id) { + sl_ctrl_msg_send->sidelinkPrimitive.group_comm_release_rsp = GROUP_COMMUNICATION_RELEASE_OK; + slrb_id = 0; //Reset slrb_id + } else { + sl_ctrl_msg_send->sidelinkPrimitive.group_comm_release_rsp = GROUP_COMMUNICATION_RELEASE_FAILURE; + } + memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); + free(sl_ctrl_msg_send); + + prose_addr_len = sizeof(prose_app_addr); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + if (n < 0){ + LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } + break; + + + case DIRECT_COMMUNICATION_ESTABLISH_REQ: + sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.direct_comm_establish_req.sourceL2Id; + destinationL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.direct_comm_establish_req.destinationL2Id; + +#ifdef DEBUG_CTRL_SOCKET + LOG_I(RRC,"[DirectCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type); + LOG_I(RRC,"[DirectCommunicationEstablishReq] source Id: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id); + LOG_I(RRC,"[DirectCommunicationEstablishReq] destination Id: 0x%08x\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id); +#endif + + //store sourceL2Id/destinationL2Id + UE_rrc_inst[module_id].sourceL2Id = sourceL2Id; + i = 0; + j = 0; + for (i=0; i< MAX_NUM_DEST; i++) { + if ((UE_rrc_inst[module_id].destinationList[i] == 0) && (j == 0)) j = i+1; + if (UE_rrc_inst[module_id].destinationList[i] == destinationL2Id) break; //destination already exists! + } + if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[module_id].destinationList[j-1] = destinationL2Id; + + // configure lower layers PDCP/MAC/PHY for this communication + //Establish a new RBID/LCID for this communication + // Establish a SLRB (using DRB 3 for now) + UE = &UE_rrc_inst[module_id]; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0); + + UE->DRB_config[0][0] = CALLOC(1,sizeof(struct DRB_ToAddMod)); + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + UE->DRB_config[0][0]->drb_Identity = 3; + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(UE->DRB_config[0][0]->eps_BearerIdentity) = 3; + UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config)); + DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config)); + PDCP_rlc_UM = CALLOC(1,sizeof(struct PDCP_Config__rlc_UM)); + DRB_lchan_config = CALLOC(1,sizeof(struct LogicalChannelConfig)); + DRB_ul_SpecificParameters = CALLOC(1, sizeof(struct LogicalChannelConfig__ul_SpecificParameters)); + logicalchannelgroup_drb = CALLOC(1, sizeof(long)); + + DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; + UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config; + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + /* avoid gcc warnings */ + (void)PDCP_rlc_UM; + + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; + + UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config; + DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); + DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; + + DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer + DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + DRB_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) + + *logicalchannelgroup_drb = 1; + DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; + + UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t)); + ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]); + + rrc_pdcp_config_asn1_req(&ctxt, + (SRB_ToAddModList_t *) NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*) NULL, + 0xff, NULL, NULL, NULL +#if defined(Rel10) || defined(Rel14) + , (PMCH_InfoList_r9_t *) NULL +#endif + ,NULL); + + + rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*)NULL +#if defined(Rel10) || defined(Rel14) + ,(PMCH_InfoList_r9_t *)NULL + , 0, 0 +#endif + ); + + rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*)NULL +#ifdef Rel14 + ,(PMCH_InfoList_r9_t *)NULL + , sourceL2Id, destinationL2Id +#endif + ); + + + //configure MAC with sourceL2Id/destinationL2Id + rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0 + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, +#if defined(Rel10) || defined(Rel14) + (SCellToAddMod_r10_t *)NULL, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, +#endif + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 3, //LCID + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +#if defined(Rel10) || defined(Rel14) + ,0, + (MBSFN_AreaInfoList_r9_t *)NULL, + (PMCH_InfoList_r9_t *)NULL + +#endif +#ifdef CBA + , + 0, + 0 +#endif +#if defined(Rel10) || defined(Rel14) + ,CONFIG_ACTION_ADD, + &sourceL2Id, + &destinationL2Id +#endif + ); + + LOG_I(RRC,"Send DirectCommunicationEstablishResp to ProSe App\n"); + memset(send_buf, 0, BUFSIZE); + sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); + sl_ctrl_msg_send->type = DIRECT_COMMUNICATION_ESTABLISH_RSP; + sl_ctrl_msg_send->sidelinkPrimitive.slrb_id = 3; //slrb_id + + memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); + free(sl_ctrl_msg_send); + + prose_addr_len = sizeof(prose_app_addr); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + if (n < 0){ + LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } + + +#ifdef DEBUG_CTRL_SOCKET + ptr_ctrl_msg = (struct sidelink_ctrl_element *) send_buf; + LOG_I(RRC,"[DirectCommunicationEstablishResponse] msg type: %d\n",ptr_ctrl_msg->type); + LOG_I(RRC,"[DirectCommunicationEstablishResponse] slrb_id: %d\n",ptr_ctrl_msg->sidelinkPrimitive.slrb_id); +#endif + break; + + case PC5S_ESTABLISH_REQ: + type = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type; + sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id; +#ifdef DEBUG_CTRL_SOCKET + LOG_I(RRC,"[PC5EstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type); + LOG_I(RRC,"[PC5EstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.type); //RX/TX + LOG_I(RRC,"[PC5EstablishReq] source Id: 0x%08x \n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.sourceL2Id); +#endif + if (type > 0) { + destinationL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.destinationL2Id; +#ifdef DEBUG_CTRL_SOCKET + LOG_I(RRC,"[PC5EstablishReq] destination Id: 0x%08x \n",sl_ctrl_msg_recv->sidelinkPrimitive.pc5s_establish_req.destinationL2Id); +#endif + } + + //store sourceL2Id/destinationL2Id + if (type > 0) { //TX + UE_rrc_inst[module_id].sourceL2Id = sourceL2Id; + j = 0; + i = 0; + for (i=0; i< MAX_NUM_DEST; i++) { + if ((UE_rrc_inst[module_id].destinationList[i] == 0) && (j == 0)) j = i+1; + if (UE_rrc_inst[module_id].destinationList[i] == destinationL2Id) break; //group already exists! + } + if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[module_id].destinationList[j-1] = destinationL2Id; + } else {//RX + UE_rrc_inst[module_id].sourceL2Id = sourceL2Id; + } + + // configure lower layers PDCP/MAC/PHY for this communication + //Establish a new RBID/LCID for this communication + // Establish a SLRB (using DRB 10 for now) + UE = &UE_rrc_inst[module_id]; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, 0x1234, 0, 0,0); + + UE->DRB_config[0][0] = CALLOC(1,sizeof(struct DRB_ToAddMod)); + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + UE->DRB_config[0][0]->drb_Identity = 10; + UE->DRB_config[0][0]->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(UE->DRB_config[0][0]->eps_BearerIdentity) = 10; + UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config)); + DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config)); + PDCP_rlc_UM = CALLOC(1,sizeof(struct PDCP_Config__rlc_UM)); + DRB_lchan_config = CALLOC(1,sizeof(struct LogicalChannelConfig)); + DRB_ul_SpecificParameters = CALLOC(1, sizeof(struct LogicalChannelConfig__ul_SpecificParameters)); + logicalchannelgroup_drb = CALLOC(1, sizeof(long)); + + DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; + UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config; + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + /* avoid gcc warnings */ + (void)PDCP_rlc_UM; + + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; + + UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config; + DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); + DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; + + DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer + DRB_ul_SpecificParameters->prioritisedBitRate =LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + DRB_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) + + *logicalchannelgroup_drb = 1; + DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; + + UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t)); + ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]); + + rrc_pdcp_config_asn1_req(&ctxt, + (SRB_ToAddModList_t *) NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*) NULL, + 0xff, NULL, NULL, NULL +#if defined(Rel10) || defined(Rel14) + , (PMCH_InfoList_r9_t *) NULL +#endif + ,NULL); + + + rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*)NULL +#if defined(Rel10) || defined(Rel14) + ,(PMCH_InfoList_r9_t *)NULL + , 0, 0 +#endif + ); + + //TX + if (type > 0) { + rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + UE->DRB_configList, + (DRB_ToReleaseList_t*)NULL +#ifdef Rel14 + ,(PMCH_InfoList_r9_t *)NULL + , sourceL2Id, destinationL2Id +#endif + ); + + //configure MAC with sourceL2Id/groupL2ID + rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0 + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, +#if defined(Rel10) || defined(Rel14) + (SCellToAddMod_r10_t *)NULL, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, +#endif + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 10, //LCID + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +#if defined(Rel10) || defined(Rel14) + ,0, + (MBSFN_AreaInfoList_r9_t *)NULL, + (PMCH_InfoList_r9_t *)NULL + +#endif +#ifdef CBA + , + 0, + 0 +#endif +#if defined(Rel10) || defined(Rel14) + ,CONFIG_ACTION_ADD, + &sourceL2Id, + &destinationL2Id +#endif + ); + } else {//RX + //configure MAC with sourceL2Id/groupL2ID + rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0 + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, +#if defined(Rel10) || defined(Rel14) + (SCellToAddMod_r10_t *)NULL, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, +#endif + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 10, //LCID + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +#if defined(Rel10) || defined(Rel14) + ,0, + (MBSFN_AreaInfoList_r9_t *)NULL, + (PMCH_InfoList_r9_t *)NULL + +#endif +#ifdef CBA + , + 0, + 0 +#endif +#if defined(Rel10) || defined(Rel14) + ,CONFIG_ACTION_ADD, + &sourceL2Id, + NULL +#endif + ); + + } + + LOG_I(RRC,"Send PC5EstablishRsp to ProSe App\n"); + memset(send_buf, 0, BUFSIZE); + sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); + sl_ctrl_msg_send->type = PC5S_ESTABLISH_RSP; + sl_ctrl_msg_send->sidelinkPrimitive.pc5s_establish_rsp.slrbid_lcid28 = 10; + sl_ctrl_msg_send->sidelinkPrimitive.pc5s_establish_rsp.slrbid_lcid29 = 10; + sl_ctrl_msg_send->sidelinkPrimitive.pc5s_establish_rsp.slrbid_lcid30 = 10; + memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); + + prose_addr_len = sizeof(prose_app_addr); + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); +// free(sl_ctrl_msg_send); + if (n < 0){ + LOG_E(RRC, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } + break; + + + case PC5_DISCOVERY_MESSAGE: + + #ifdef DEBUG_CTRL_SOCKET + LOG_I(RRC,"[PC5DiscoveryMessage] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type); + #endif + //prepare SL_Discovery buffer + if (UE_rrc_inst) { + memcpy((void*)&UE_rrc_inst[module_id].SL_Discovery[0].Tx_buffer.Payload[0], (void*)&sl_ctrl_msg_recv->sidelinkPrimitive.pc5_discovery_message.payload[0], PC5_DISCOVERY_PAYLOAD_SIZE); + UE_rrc_inst[module_id].SL_Discovery[0].Tx_buffer.payload_size = PC5_DISCOVERY_PAYLOAD_SIZE; + LOG_I(RRC,"[PC5DiscoveryMessage] Copied %d bytes\n",PC5_DISCOVERY_PAYLOAD_SIZE); + } + break; + default: + break; + } + } + free (sl_ctrl_msg_recv); + return 0; +} + + +//----------------------------------------------------------------------------- +int decode_SL_Discovery_Message( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t* Sdu, + const uint8_t Sdu_len) +{ + + int prose_addr_len; + char send_buf[BUFSIZE]; + int n; + struct sidelink_ctrl_element *sl_ctrl_msg_send = NULL; + + //from the main program, listen for the incoming messages from control socket (ProSe App) + prose_addr_len = sizeof(prose_app_addr); + + //Store in Rx_buffer + memcpy((void*)&UE_rrc_inst[ctxt_pP->module_id].SL_Discovery[0].Rx_buffer.Payload[0], (void*)Sdu, Sdu_len); + UE_rrc_inst[ctxt_pP->module_id].SL_Discovery[0].Rx_buffer.payload_size = Sdu_len; + + memset(send_buf, 0, BUFSIZE); + //send to ProSeApp + memcpy((void *)send_buf, (void*)Sdu, Sdu_len); + prose_addr_len = sizeof(prose_app_addr); + + sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element)); + sl_ctrl_msg_send->type = PC5_DISCOVERY_MESSAGE; + // TODO: Add a check for the SDU size. + memcpy((void*)&sl_ctrl_msg_send->sidelinkPrimitive.pc5_discovery_message.payload[0], (void*) Sdu, PC5_DISCOVERY_PAYLOAD_SIZE); + + memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element)); + free(sl_ctrl_msg_send); + + prose_addr_len = sizeof(prose_app_addr); + + n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len); + if (n < 0){ + // TODO: We should not just exit if the Prose App has not yet attached. It creates a race condition. + LOG_I(RRC, "ERROR: Failed to send to ProSe App\n"); + //exit(EXIT_FAILURE); + } + + + + return(0); +} + +#endif + //----------------------------------------------------------------------------- RRC_status_t rrc_rx_tx_ue( @@ -4945,3 +6489,4 @@ rrc_rx_tx_ue( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return (RRC_OK); } + diff --git a/openair2/RRC/LITE/rrc_UE_ral.c b/openair2/RRC/LTE/rrc_UE_ral.c similarity index 100% rename from openair2/RRC/LITE/rrc_UE_ral.c rename to openair2/RRC/LTE/rrc_UE_ral.c diff --git a/openair2/RRC/LITE/rrc_UE_ral.h b/openair2/RRC/LTE/rrc_UE_ral.h similarity index 100% rename from openair2/RRC/LITE/rrc_UE_ral.h rename to openair2/RRC/LTE/rrc_UE_ral.h diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LTE/rrc_common.c similarity index 90% rename from openair2/RRC/LITE/rrc_common.c rename to openair2/RRC/LTE/rrc_common.c index a6a2bbb613b8f2d46a554b422ca2cab4f78bbaac..0acb0d77010a41c8753b3fae87cafa014bf34be2 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LTE/rrc_common.c @@ -28,9 +28,9 @@ * \email: navid.nikaein@eurecom.fr and raymond.knopp@eurecom.fr */ -#include "defs.h" -#include "extern.h" -#include "LAYER2/MAC/extern.h" +#include "rrc_defs.h" +#include "rrc_extern.h" +#include "LAYER2/MAC/mac_extern.h" #include "COMMON/openair_defs.h" #include "COMMON/platform_types.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" @@ -43,10 +43,6 @@ #include "rrc_eNB_UE_context.h" #include "common/ran_context.h" -#ifdef LOCALIZATION -#include <sys/time.h> -#endif - #define DEBUG_RRC 1 extern RAN_CONTEXT_t RC; extern UE_MAC_INST *UE_mac_inst; @@ -61,33 +57,6 @@ rrc_init_global_param( //----------------------------------------------------------------------------- { - // Rrc_xface = (RRC_XFACE*)malloc16(sizeof(RRC_XFACE)); - - // Rrc_xface->openair_rrc_top_init = openair_rrc_top_init; - // Rrc_xface->openair_rrc_eNB_init = openair_rrc_eNB_init; - // Rrc_xface->openair_rrc_UE_init = openair_rrc_ue_init; - // Rrc_xface->mac_rrc_data_ind = mac_rrc_data_ind; - //Rrc_xface->mac_rrc_data_req = mac_rrc_data_req; - // Rrc_xface->rrc_data_indP = (void *)rlcrrc_data_ind; - // Rrc_xface->rrc_rx_tx = rrc_rx_tx; - // Rrc_xface->mac_rrc_meas_ind = mac_rrc_meas_ind; - // Rrc_xface->get_rrc_status = get_rrc_status; - - //Rrc_xface->rrc_get_status = ... - - // Mac_rlc_xface->mac_out_of_sync_ind=mac_out_of_sync_ind; - -#ifndef NO_RRM - // Rrc_xface->fn_rrc=fn_rrc; -#endif - // LOG_D(RRC, "[RRC]INIT_GLOBAL_PARAM: Mac_rlc_xface %p, rrc_rlc_register %p,rlcrrc_data_ind%p\n",Mac_rlc_xface,Mac_rlc_xface->rrc_rlc_register_rrc,rlcrrc_data_ind); - /* - if((Mac_rlc_xface==NULL) || (Mac_rlc_xface->rrc_rlc_register_rrc==NULL) || - (rlcrrc_data_ind==NULL)) { - LOG_E(RRC,"Data structured is not initialized \n"); - return -1; - } - */ rrc_rlc_register_rrc (rrc_data_ind, NULL); //register with rlc DCCH_LCHAN_DESC.transport_block_size = 4; diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LTE/rrc_defs.h similarity index 82% rename from openair2/RRC/LITE/defs.h rename to openair2/RRC/LTE/rrc_defs.h index 08ac30f8363f9453921c73598a3b8447fc7abc93..4719eebd614d5ef178efdd9762936fe929d5877e 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -/*! \file RRC/LITE/defs.h +/*! \file RRC/LTE/defs.h * \brief RRC struct definitions and function prototypes * \author Navid Nikaein and Raymond Knopp * \date 2010 - 2014 @@ -37,13 +37,138 @@ #include "collection/tree.h" #include "rrc_types.h" -#include "PHY/defs.h" +//#include "PHY/phy_defs.h" #include "LAYER2/RLC/rlc.h" #include "COMMON/platform_constants.h" #include "COMMON/platform_types.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" + +//for D2D +#define DEBUG_CTRL_SOCKET +#define BUFSIZE 1024 +#define CONTROL_SOCKET_PORT_NO 8888 +#define MAX_NUM_DEST 10 +//netlink +//#define DEBUG_PDCP +#define UE_IP_PDCP_NETLINK_ID 31 +#define PDCP_PID 1 +#define NETLINK_HEADER_SIZE 16 +#define SL_DEFAULT_RAB_ID 3 +#define SLRB_ID 3 + +#define MAX_PAYLOAD 1024 /* maximum payload size*/ + +#define UE_STATE_NOTIFICATION_INTERVAL 50 + +#define IPV4_ADDR "%u.%u.%u.%u" +#define IPV4_ADDR_FORMAT(aDDRESS) \ + (uint8_t)((aDDRESS) & 0x000000ff), \ + (uint8_t)(((aDDRESS) & 0x0000ff00) >> 8 ), \ + (uint8_t)(((aDDRESS) & 0x00ff0000) >> 16), \ + (uint8_t)(((aDDRESS) & 0xff000000) >> 24) + + +//----------------------------------------------------- +// header for Control socket + +//Primitives +#define SESSION_INIT_REQ 1 +#define UE_STATUS_INFO 2 +#define GROUP_COMMUNICATION_ESTABLISH_REQ 3 +#define GROUP_COMMUNICATION_ESTABLISH_RSP 4 +#define DIRECT_COMMUNICATION_ESTABLISH_REQ 5 +#define DIRECT_COMMUNICATION_ESTABLISH_RSP 6 +#define GROUP_COMMUNICATION_RELEASE_REQ 7 +#define GROUP_COMMUNICATION_RELEASE_RSP 8 +#define PC5S_ESTABLISH_REQ 9 +#define PC5S_ESTABLISH_RSP 10 +#define PC5_DISCOVERY_MESSAGE 11 + + +#define PC5_DISCOVERY_PAYLOAD_SIZE 29 + + +typedef enum { + UE_STATE_OFF_NETWORK, + UE_STATE_ON_NETWORK +} SL_UE_STATE_t; + +typedef enum { + GROUP_COMMUNICATION_RELEASE_OK = 0, + GROUP_COMMUNICATION_RELEASE_FAILURE +} Group_Communication_Status_t; + +struct GroupCommunicationEstablishReq { + uint32_t sourceL2Id; + uint32_t groupL2Id; + uint32_t groupIpAddress; + uint8_t pppp; +}; + +struct GroupCommunicationReleaseReq { + uint32_t sourceL2Id; + uint32_t groupL2Id; + int slrb_id; +}; + +struct DirectCommunicationEstablishReq { + uint32_t sourceL2Id; + uint32_t destinationL2Id; + uint32_t pppp; +}; + +struct PC5SEstablishReq{ + uint8_t type; + uint32_t sourceL2Id; + uint32_t destinationL2Id; +}; + +struct PC5SEstablishRsp{ + uint32_t slrbid_lcid28; + uint32_t slrbid_lcid29; + uint32_t slrbid_lcid30; +}; + + +//PC5_DISCOVERY MESSAGE +typedef struct { + unsigned char payload[PC5_DISCOVERY_PAYLOAD_SIZE]; + uint32_t measuredPower; +} __attribute__((__packed__)) PC5DiscoveryMessage ; + + +struct sidelink_ctrl_element { + unsigned short type; + union { + struct GroupCommunicationEstablishReq group_comm_establish_req; + struct DirectCommunicationEstablishReq direct_comm_establish_req; + Group_Communication_Status_t group_comm_release_rsp; + //struct DirectCommunicationReleaseReq direct_comm_release_req; + SL_UE_STATE_t ue_state; + int slrb_id; + struct PC5SEstablishReq pc5s_establish_req; + struct PC5SEstablishRsp pc5s_establish_rsp; + PC5DiscoveryMessage pc5_discovery_message; + } sidelinkPrimitive; +}; + + +//global variables +extern struct sockaddr_in clientaddr; +extern int slrb_id; +extern pthread_mutex_t slrb_mutex; + +//the thread function +void *send_UE_status_notification(void *); + + + +//#include "COMMON/openair_defs.h" +#ifndef USER_MODE +//#include <rtai.h> +#endif #include "SystemInformationBlockType1.h" #include "SystemInformation.h" @@ -54,16 +179,20 @@ #include "RRCConnectionRequest.h" #include "RRCConnectionReestablishmentRequest.h" #include "BCCH-DL-SCH-Message.h" +#include "SBCCH-SL-BCH-MessageType.h" #include "BCCH-BCH-Message.h" -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "MCCH-Message.h" #include "MBSFNAreaConfiguration-r9.h" +#endif +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #include "SCellToAddMod-r10.h" #endif #include "AS-Config.h" #include "AS-Context.h" #include "UE-EUTRA-Capability.h" #include "MeasResults.h" +#include "SidelinkUEInformation-r12.h" /* for ImsiMobileIdentity_t */ #include "MobileIdentity.h" @@ -71,7 +200,7 @@ /* correct Rel(8|10)/Rel14 differences * the code is in favor of Rel14, those defines do the translation */ -#if !defined(Rel14) +#if (RRC_VERSION < MAKE_VERSION(14, 0, 0)) # define CipheringAlgorithm_r12_t e_SecurityAlgorithmConfig__cipheringAlgorithm # define CipheringAlgorithm_r12_eea0 SecurityAlgorithmConfig__cipheringAlgorithm_eea0 # define CipheringAlgorithm_r12_eea1 SecurityAlgorithmConfig__cipheringAlgorithm_eea1 @@ -120,7 +249,7 @@ #endif // This corrects something generated by asn1c which is different between Rel8 and Rel10 -#if !defined(Rel10) && !defined(Rel14) +#if (RRC_VERSION <= MAKE_VERSION(10, 0, 0)) #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2 #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3 @@ -141,7 +270,7 @@ #define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE /* -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib12_v920 #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib13_v920 #endif @@ -171,7 +300,7 @@ //-------- typedef unsigned int uid_t; -#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_UE_MAX/8)/sizeof(unsigned int)) + 1) +#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((MAX_MOBILES_PER_ENB/8)/sizeof(unsigned int)) + 1) typedef struct uid_linear_allocator_s { unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE]; } uid_allocator_t; @@ -185,7 +314,7 @@ typedef struct uid_linear_allocator_s { #define PROTOCOL_RRC_CTXT_FMT PROTOCOL_CTXT_FMT #define PROTOCOL_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp) -/** @defgroup _rrc RRC +/** @defgroup _rrc RRC * @ingroup _oai2 * @{ */ @@ -219,7 +348,22 @@ typedef enum HO_STATE_e { HO_COMPLETE // initiated by the target eNB } HO_STATE_t; -//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG +typedef enum SL_TRIGGER_e { + SL_RECEIVE_COMMUNICATION=0, + SL_TRANSMIT_RELAY_ONE_TO_ONE, + SL_TRANSMIT_RELAY_ONE_TO_MANY, + SL_TRANSMIT_NON_RELAY_ONE_TO_ONE, + SL_TRANSMIT_NON_RELAY_ONE_TO_MANY, + SL_RECEIVE_DISCOVERY, + SL_TRANSMIT_NON_PS_DISCOVERY, + SL_TRANSMIT_PS_DISCOVERY, + SL_RECEIVE_V2X, + SL_TRANSMIT_V2X, + SL_REQUEST_DISCOVERY_TRANSMISSION_GAPS, + SL_REQUEST_DISCOVERY_RECEPTION_GAPS +} SL_TRIGGER_t; + +//#define MAX_MOBILES_PER_ENB MAX_MOBILES_PER_RG #define RRM_FREE(p) if ( (p) != NULL) { free(p) ; p=NULL ; } #define RRM_MALLOC(t,n) (t *) malloc16( sizeof(t) * n ) #define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n) @@ -261,7 +405,7 @@ typedef struct UE_RRC_INFO_s { uint8_t SIB1systemInfoValueTag; uint32_t SIStatus; uint32_t SIcnt; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA #endif uint8_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40 @@ -355,7 +499,7 @@ typedef struct SRB_INFO_TABLE_ENTRY_s { SRB_INFO Srb_info; uint8_t Active; uint8_t Status; - uint32_t Next_check_frame; + uint32_t Next_check_frame; } SRB_INFO_TABLE_ENTRY; typedef struct MEAS_REPORT_LIST_s { @@ -371,7 +515,7 @@ typedef struct HANDOVER_INFO_UE_s { typedef struct eNB_RRC_UE_s { uint8_t primaryCC_id; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) SCellToAddMod_r10_t sCell_config[2]; #endif SRB_ToAddModList_t* SRB_configList; @@ -485,7 +629,7 @@ typedef struct { uint8_t sizeof_SIB1; uint8_t *SIB23; uint8_t sizeof_SIB23; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) uint8_t *SIB1_BR; uint8_t sizeof_SIB1_BR; uint8_t *SIB23_BR; @@ -504,12 +648,12 @@ typedef struct { SystemInformationBlockType1_t *sib1; SystemInformationBlockType2_t *sib2; SystemInformationBlockType3_t *sib3; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) SystemInformationBlockType1_t *sib1_BR; SystemInformationBlockType2_t *sib2_BR; SystemInformationBlockType2_t *sib3_BR; #endif -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) SystemInformationBlockType13_r9_t *sib13; uint8_t MBMS_flag; uint8_t num_mbsfn_sync_area; @@ -519,10 +663,15 @@ typedef struct { MBSFNAreaConfiguration_r9_t *mcch_message; SRB_INFO MCCH_MESS[8];// MAX_MBSFN_AREA #endif + //TTN - SIB 18,19,21 for D2D + SystemInformationBlockType18_r12_t *sib18; + SystemInformationBlockType19_r12_t *sib19; + SystemInformationBlockType21_r14_t *sib21; + // End - TTN SRB_INFO SI; SRB_INFO Srb0; - uint8_t *paging[NUMBER_OF_UE_MAX]; - uint32_t sizeof_paging[NUMBER_OF_UE_MAX]; + uint8_t *paging[MAX_MOBILES_PER_ENB]; + uint32_t sizeof_paging[MAX_MOBILES_PER_ENB]; } rrc_eNB_carrier_data_t; typedef struct eNB_RRC_INST_s { @@ -610,8 +759,29 @@ typedef struct UE_RRC_INST_s { SystemInformationBlockType9_t *sib9[NB_CNX_UE]; SystemInformationBlockType10_t *sib10[NB_CNX_UE]; SystemInformationBlockType11_t *sib11[NB_CNX_UE]; + uint8_t *MIB; +#ifdef Rel14 + //SIB18 + SystemInformationBlockType18_r12_t *sib18[NB_CNX_UE]; + SystemInformationBlockType19_r12_t *sib19[NB_CNX_UE]; + SystemInformationBlockType21_r14_t *sib21[NB_CNX_UE]; + + SBCCH_SL_BCH_MessageType_t mib_sl[NB_CNX_UE]; + /// Preconfiguration for Sidelink + struct SL_Preconfiguration_r12 *SL_Preconfiguration[NB_CNX_UE]; + //source L2 Id + uint32_t sourceL2Id; + //group L2 Id + uint32_t groupL2Id; + //current destination + uint32_t destinationL2Id; + //List of destinations + uint32_t destinationList[MAX_NUM_DEST]; + //sl_discovery.. + SRB_INFO SL_Discovery[NB_CNX_UE]; +#endif -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t MBMS_flag; uint8_t *MCCH_MESSAGE[NB_CNX_UE]; uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE]; @@ -657,6 +827,11 @@ typedef struct UE_RRC_INST_s { /* Used integrity/ciphering algorithms */ CipheringAlgorithm_r12_t ciphering_algorithm; e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; + +#ifdef Rel14 + /// Used for Sidelink Preconfiguration + DRB_ToAddModList_t *DRB_configList; +#endif } UE_RRC_INST; typedef struct UE_PF_PO_s { @@ -667,7 +842,7 @@ typedef struct UE_PF_PO_s { uint32_t T; /* DRX cycle */ } UE_PF_PO_t; -#include "proto.h" +#include "rrc_proto.h" #endif /** @} */ diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c similarity index 90% rename from openair2/RRC/LITE/rrc_eNB.c rename to openair2/RRC/LTE/rrc_eNB.c index 8bb244a34d24d77f1891bf4b187b8141061ce0b5..81102f606416a2e2fa05bd465e57c52f5bfa42ff 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -30,17 +30,17 @@ #define RRC_ENB #define RRC_ENB_C -#include "defs.h" -#include "extern.h" +#include "rrc_defs.h" +#include "rrc_extern.h" #include "assertions.h" #include "common/ran_context.h" #include "asn1_conversions.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "LAYER2/RLC/rlc.h" -#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/mac_proto.h" #include "UTIL/LOG/log.h" #include "COMMON/mac_rrc_primitives.h" -#include "RRC/LITE/MESSAGES/asn1_msg.h" +#include "RRC/LTE/MESSAGES/asn1_msg.h" #include "RRCConnectionRequest.h" #include "RRCConnectionReestablishmentRequest.h" //#include "ReestablishmentCause.h" @@ -52,15 +52,17 @@ #include "TDD-Config.h" #include "HandoverCommand.h" #include "rlc.h" -#include "SIMULATION/ETH_TRANSPORT/extern.h" #include "rrc_eNB_UE_context.h" #include "platform_types.h" #include "msc.h" +#include "SL-CommConfig-r12.h" +#include "PeriodicBSR-Timer-r12.h" +#include "RetxBSR-Timer-r12.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "T.h" -//#if defined(Rel10) || defined(Rel14) +//#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) #include "MeasResults.h" //#endif @@ -93,7 +95,7 @@ # include "rrc_eNB_ral.h" #endif -#include "SIMULATION/TOOLS/defs.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus //#define XER_PRINT @@ -142,11 +144,11 @@ init_SI( ) //----------------------------------------------------------------------------- { -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) int i; #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 1, 0)) SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext=(SystemInformationBlockType1_v1310_IEs_t *)NULL; #endif @@ -159,7 +161,7 @@ init_SI( RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp = configuration->prefix_type[CC_id]; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq = configuration->downlink_frequency[CC_id]; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq = configuration->downlink_frequency[CC_id]+ configuration->uplink_frequency_offset[CC_id]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition = configuration->pbch_repetition[CC_id]; #endif LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", @@ -239,8 +241,8 @@ init_SI( PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. ul_ReferenceSignalsPUSCH.cyclicShift); - -#if defined(Rel10) || defined(Rel14) + +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag > 0) { for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count; i++) { @@ -260,7 +262,8 @@ init_SI( PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); } - + +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) // SIB13 for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) { LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN sync area %d/%d (partial)\n", @@ -274,15 +277,86 @@ init_SI( PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); } +#endif } else memset((void*)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); + + //TTN - SIB 18 + for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count; j++) { + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); + + } + + //TTN - SIB 19 + for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count; j++) { + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); + + } + #endif LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n", PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) && (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR!=NULL)) { AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL, @@ -307,7 +381,7 @@ init_SI( RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition, #endif 0, // rnti @@ -315,12 +389,12 @@ init_SI( &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib, (RadioResourceConfigCommonSIB_t *) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon, -#if defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t *) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon, #endif (struct PhysicalConfigDedicated *)NULL, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -335,20 +409,20 @@ init_SI( RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth, &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission, (MBSFN_SubframeConfigList_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag, (MBSFN_AreaInfoList_r9_t*) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9, (PMCH_InfoList_r9_t *) NULL #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , sib1_v13ext #endif ); } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) /*------------------------------------------------------------------------------*/ static void init_MCCH( @@ -406,17 +480,17 @@ init_MCCH( // LOG_I(RRC, "DUY: session ID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->sessionId_r9->buf[0]); rrc_mac_config_req_eNB(enb_mod_idP, CC_id, 0,0,0,0,0, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 0, #endif 0,//rnti (BCCH_BCH_Message_t *)NULL, (RadioResourceConfigCommonSIB_t *) NULL, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t *) NULL, #endif (struct PhysicalConfigDedicated *)NULL, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -429,16 +503,16 @@ init_MCCH( (MobilityControlInfo_t *)NULL, (SchedulingInfoList_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) -# endif -# ifdef Rel14 +#endif +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , (SystemInformationBlockType1_v1310_IEs_t *)NULL -# endif +#endif ); //LOG_I(RRC,"DUY: lcid after rrc_mac_config_req is %02d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9); @@ -470,16 +544,21 @@ static void init_MBMS( NULL, // key rrc encryption NULL, // key rrc integrity NULL // key encryption -# if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) -# endif +#endif ,NULL); rrc_rlc_config_asn1_req(&ctxt, NULL, // SRB_ToAddModList NULL, // DRB_ToAddModList NULL, // DRB_ToReleaseList - &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9)); + &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) + +#ifdef Rel14 + ,0, 0 +#endif + ); //rrc_mac_config_req(); } @@ -516,7 +595,7 @@ rrc_eNB_get_next_transaction_identifier( // // AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB index invalid (%d/%d)!", enb_mod_idP, NB_eNB_INST); // -// for (i = 0; i < NUMBER_OF_UE_MAX; i++) { +// for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { // if (RC.rrc[enb_mod_idP]->Info.UE_list[i] == UE_identity) { // // UE_identity already registered // reg = TRUE; @@ -640,6 +719,7 @@ void rrc_eNB_emulation_notify_ue_module_id( const uint8_t cell_identity_byte2P, const uint8_t cell_identity_byte3P) { + LOG_I(RRC, "Panos-D: rrc_eNB_emulation_notify_ue_module_id 1 \n"); module_id_t enb_module_id; struct rrc_eNB_ue_context_s* ue_context_p = NULL; int CC_id; @@ -692,7 +772,7 @@ rrc_eNB_free_mem_UE_context( PROTOCOL_RRC_CTXT_UE_FMT" Clearing UE context 0x%p (free internal structs)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ue_context_pP); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[0]); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[1]); #endif @@ -855,16 +935,18 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* #endif for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { eNB_PHY = RC.eNB[enb_mod_idP][CC_id]; - for (i=0; i<NUMBER_OF_UE_MAX; i++) { + for (i=0; i<MAX_MOBILES_PER_ENB; i++) { ulsch = eNB_PHY->ulsch[i]; if((ulsch != NULL) && (ulsch->rnti == rnti)){ + void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); LOG_I(RRC, "clean_eNb_ulsch UE %x \n", rnti); clean_eNb_ulsch(ulsch); } } - for (i=0; i<NUMBER_OF_UE_MAX; i++) { + for (i=0; i<MAX_MOBILES_PER_ENB; i++) { dlsch = eNB_PHY->dlsch[i][0]; if((dlsch != NULL) && (dlsch->rnti == rnti)){ + void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); LOG_I(RRC, "clean_eNb_dlsch UE %x \n", rnti); clean_eNb_dlsch(dlsch); } @@ -1166,17 +1248,17 @@ rrc_eNB_generate_RRCConnectionReestablishment( rrc_mac_config_req_eNB(ctxt_pP->module_id, ue_context_pP->ue_context.primaryCC_id, 0,0,0,0,0, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 0, #endif ctxt_pP->rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t *) NULL, #endif (struct PhysicalConfigDedicated* ) ue_context_pP->ue_context.physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -1189,10 +1271,10 @@ rrc_eNB_generate_RRCConnectionReestablishment( NULL, (SchedulingInfoList_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) ,(SystemInformationBlockType1_v1310_IEs_t *)NULL #endif ); @@ -1747,8 +1829,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( (struct MeasConfig__speedStatePars*)Sparams, // Sparams, (RSRP_Range_t*)rsrp, // rsrp, (C_RNTI_t*)cba_RNTI, // cba_RNTI - (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList //dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, //dedicatedInfoNASList + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , (SCellToAddMod_r10_t*)NULL #endif ); @@ -1813,9 +1897,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id]; for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id]; - for (int i=0; i<NUMBER_OF_UE_MAX; i++) { + for (int i=0; i<MAX_MOBILES_PER_ENB; i++) { ulsch = eNB_PHY->ulsch[i]; if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){ + void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti); clean_eNb_ulsch(ulsch); break; @@ -2182,8 +2267,10 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co (struct SPS_Config*)NULL, // *sps_Config, NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, - (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , (SCellToAddMod_r10_t*)NULL #endif ); @@ -2441,20 +2528,22 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(ctxt_pP, - buffer, - xid, - (SRB_ToAddModList_t*)NULL, - (DRB_ToAddModList_t*)DRB_configList2, - (DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct SPS_Config*)NULL, // *sps_Config, - NULL, NULL, NULL, NULL,NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) - , (SCellToAddMod_r10_t*)NULL + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + xid, + (SRB_ToAddModList_t*)NULL, + (DRB_ToAddModList_t*)DRB_configList2, + (DRB_ToReleaseList_t*)NULL, // DRB2_list, + (struct SPS_Config*)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + , (SCellToAddMod_r10_t*)NULL #endif - ); + ); #ifdef RRC_MSG_PRINT @@ -2573,8 +2662,10 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ NULL, NULL, NULL, - (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , (SCellToAddMod_r10_t*)NULL #endif ); @@ -2669,7 +2760,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; MeasIdToAddModList_t *MeasId_list = NULL; MeasIdToAddMod_t *MeasId0, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) long *sr_ProhibitTimer_r9 = NULL; // uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1); //uint8_t sCellIndexToAdd = 0; @@ -2889,7 +2980,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; // Value dB1 =1 dB, dB3 = 3 dB -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long)); *sr_ProhibitTimer_r9 = 0; // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR mac_MainConfig->ext1 = CALLOC(1, sizeof(struct MAC_MainConfig__ext1)); @@ -2956,7 +3047,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons //feedback mode needs to be set as well //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable printf("setting cqi reporting mode to rm31\n"); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportModeAperiodic_rm31; #else *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI @@ -3301,8 +3392,10 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons (struct MeasConfig__speedStatePars*)Sparams, (RSRP_Range_t*)rsrp, (C_RNTI_t*)cba_RNTI, - (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , (SCellToAddMod_r10_t*)NULL #endif ); @@ -3688,7 +3781,7 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt //feedback mode needs to be set as well //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable printf("setting cqi reporting mode to rm31\n"); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportModeAperiodic_rm31; #else *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI @@ -3891,8 +3984,10 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt (struct MeasConfig__speedStatePars*)Sparams, (RSRP_Range_t*)rsrp, (C_RNTI_t*)cba_RNTI, - (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , (SCellToAddMod_r10_t*)NULL #endif ); @@ -3962,7 +4057,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell( uint8_t size; uint8_t buffer[100]; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t sCellIndexToAdd = 0; //one SCell so far // uint8_t sCellIndexToAdd; @@ -3994,9 +4089,11 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell( (struct MeasConfig__speedStatePars*)NULL, (RSRP_Range_t*)NULL, (C_RNTI_t*)NULL, - (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , ue_context_pP->ue_context.sCell_config #endif ); @@ -4079,7 +4176,7 @@ rrc_eNB_process_MeasurementReport( } } -// #if defined(Rel10) || defined(Rel14) +// #if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) // #else @@ -4285,7 +4382,11 @@ check_handovers( SDU_CONFIRM_NO, ue_context_p->ue_context.handover_info->size, ue_context_p->ue_context.handover_info->buf, - PDCP_TRANSMISSION_MODE_CONTROL); + PDCP_TRANSMISSION_MODE_CONTROL +#ifdef Rel14 + ,NULL, NULL +#endif + ); AssertFatal(result == TRUE, "PDCP data request failed!\n"); ue_context_p->ue_context.handover_info->ho_complete = 0xF2; } @@ -4346,7 +4447,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( // HandoverCommand_t handoverCommand; //uint8_t sourceModId = // get_adjacent_cell_mod_id(ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) long *sr_ProhibitTimer_r9; #endif @@ -4590,17 +4691,17 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( ctxt_pP->module_id, ue_context_pP->ue_context.primaryCC_id, 0,0,0,0,0, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 0, #endif ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t*) NULL, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t*) NULL, #endif ue_context_pP->ue_context.physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -4616,13 +4717,13 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif -# ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , (SystemInformationBlockType1_v1310_IEs_t *)NULL -# endif +#endif ); // Configure target eNB SRB2 @@ -4738,7 +4839,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; // Value dB1 =1 dB, dB3 = 3 dB -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long)); *sr_ProhibitTimer_r9 = 0; // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR mac_MainConfig->ext1 = CALLOC(1, sizeof(struct MAC_MainConfig__ext1)); @@ -5100,7 +5201,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( rrc_pdcp_config_asn1_req(&ctxt, ue_context_pP->ue_context.SRB_configList, (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL, 0xff, NULL, NULL, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (PMCH_InfoList_r9_t *) NULL #endif ,NULL); @@ -5108,8 +5209,9 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( rrc_rlc_config_asn1_req(&ctxt, ue_context_pP->ue_context.SRB_configList, (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (PMCH_InfoList_r9_t *) NULL + , 0, 0 #endif ); @@ -5138,8 +5240,10 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( Sparams, NULL, NULL, - dedicatedInfoNASList -#if defined(Rel10) || defined(Rel14) + dedicatedInfoNASList, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , NULL // SCellToAddMod_r10_t #endif ); @@ -5171,17 +5275,17 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( ctxt_pP->module_id, ue_context_pP->ue_context.primaryCC_id, 0,0,0,0,0, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 0, #endif ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t *) NULL, #endif ue_context_pP->ue_context.physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -5193,13 +5297,13 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( (TDD_Config_t *) NULL, (MobilityControlInfo_t *) mobilityInfo, (SchedulingInfoList_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif -# ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , (SystemInformationBlockType1_v1310_IEs_t *)NULL -# endif +#endif ); /* @@ -5323,7 +5427,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( kRRCenc, kRRCint, kUPenc -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (PMCH_InfoList_r9_t *) NULL #endif ,NULL); @@ -5334,8 +5438,9 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( DRB_configList, // (DRB_ToReleaseList_t *) NULL DRB_Release_configList2 -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (PMCH_InfoList_r9_t *) NULL + , 0, 0 #endif ); @@ -5443,17 +5548,17 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP->module_id, ue_context_pP->ue_context.primaryCC_id, 0,0,0,0,0, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 0, #endif ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t *) NULL, #endif ue_context_pP->ue_context.physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -5466,13 +5571,13 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( NULL, (SchedulingInfoList_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif -# ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , (SystemInformationBlockType1_v1310_IEs_t *)NULL -# endif +#endif ); } else { // remove LCHAN from MAC/PHY @@ -5498,17 +5603,17 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( rrc_mac_config_req_eNB(ctxt_pP->module_id, ue_context_pP->ue_context.primaryCC_id, 0,0,0,0,0, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 0, #endif ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t *) NULL, #endif ue_context_pP->ue_context.physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -5521,13 +5626,13 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( NULL, (SchedulingInfoList_t *) NULL, 0, NULL, NULL, NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif -# ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , (SystemInformationBlockType1_v1310_IEs_t *)NULL -# endif +#endif ); } } @@ -5616,17 +5721,17 @@ rrc_eNB_generate_RRCConnectionSetup( ctxt_pP->module_id, ue_context_pP->ue_context.primaryCC_id, 0,0,0,0,0, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) 0, #endif ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) (RadioResourceConfigCommonSIB_t *) NULL, #endif ue_context_pP->ue_context.physicalConfigDedicated, -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (SCellToAddMod_r10_t *)NULL, //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif @@ -5639,13 +5744,13 @@ rrc_eNB_generate_RRCConnectionSetup( NULL, (SchedulingInfoList_t *) NULL, 0, NULL, NULL, (MBSFN_SubframeConfigList_t *) NULL -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , 0, (MBSFN_AreaInfoList_r9_t *) NULL, (PMCH_InfoList_r9_t *) NULL #endif -# ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(13, 0, 0)) , (SystemInformationBlockType1_v1310_IEs_t *)NULL -# endif +#endif ); break; } @@ -5709,11 +5814,11 @@ openair_rrc_eNB_init( } #endif AssertFatal(RC.rrc[enb_mod_idP] != NULL, "RC.rrc not initialized!"); - AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); + AssertFatal(MAX_MOBILES_PER_ENB < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); #ifdef ENABLE_ITTI AssertFatal(configuration!=NULL,"configuration input is null\n"); #endif - // for (j = 0; j < NUMBER_OF_UE_MAX; j++) + // for (j = 0; j < MAX_MOBILES_PER_ENB; j++) // RC.rrc[ctxt.module_id].Info.UE[j].Status = RRC_IDLE; //CH_READY; // //#if defined(ENABLE_USE_MME) @@ -5722,7 +5827,7 @@ openair_rrc_eNB_init( //#endif // { // /* Init security parameters */ - // for (j = 0; j < NUMBER_OF_UE_MAX; j++) { + // for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { // RC.rrc[ctxt.module_id].ciphering_algorithm[j] = SecurityAlgorithmConfig__cipheringAlgorithm_eea0; // RC.rrc[ctxt.module_id].integrity_algorithm[j] = SecurityAlgorithmConfig__integrityProtAlgorithm_eia2; // rrc_eNB_init_security(enb_mod_idP, j); @@ -5736,13 +5841,13 @@ openair_rrc_eNB_init( uid_linear_allocator_init(&RC.rrc[ctxt.module_id]->uid_allocator); RB_INIT(&RC.rrc[ctxt.module_id]->rrc_ue_head); - // for (j = 0; j < (NUMBER_OF_UE_MAX + 1); j++) { + // for (j = 0; j < (MAX_MOBILES_PER_ENB + 1); j++) { // RC.rrc[enb_mod_idP]->Srb2[j].Active = 0; // } - RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); - RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL); + RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL); + RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL); memcpy(&RC.rrc[ctxt.module_id]->configuration,configuration,sizeof(RrcConfigurationReq)); @@ -5750,14 +5855,14 @@ openair_rrc_eNB_init( LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Checking release \n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) // can clear it at runtime RC.rrc[ctxt.module_id]->carrier[0].MBMS_flag = 0; // This has to come from some top-level configuration // only CC_id 0 is logged -#if defined(Rel10) +#if (RRC_VERSION < MAKE_VERSION(10, 0, 0)) LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel10 RRC detected, MBMS flag %d\n", #else LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel14 RRC detected, MBMS flag %d\n", @@ -5798,7 +5903,7 @@ openair_rrc_eNB_init( , configuration #endif ); - for (int ue_id = 0; ue_id < NUMBER_OF_UE_MAX; ue_id++) { + for (int ue_id = 0; ue_id < MAX_MOBILES_PER_ENB; ue_id++) { RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0; RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t*) malloc16(256); } @@ -5807,7 +5912,7 @@ openair_rrc_eNB_init( rrc_init_global_param(); for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) switch (RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag) { case 1: case 2: @@ -6042,7 +6147,7 @@ rrc_eNB_decode_ccch( ue_context_p->ue_context.ue_release_timer = 0; // insert C-RNTI to map - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (reestablish_rnti_map[i][0] == 0) { reestablish_rnti_map[i][0] = ctxt_pP->rnti; reestablish_rnti_map[i][1] = c_rnti; @@ -6112,17 +6217,18 @@ rrc_eNB_decode_ccch( NULL, NULL, NULL -# if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (PMCH_InfoList_r9_t *) NULL -# endif +#endif ,NULL); rrc_rlc_config_asn1_req(ctxt_pP, ue_context_p->ue_context.SRB_configList, (DRB_ToAddModList_t*) NULL, (DRB_ToReleaseList_t*) NULL -# if defined(Rel10) || defined(Rel14) - , (PMCH_InfoList_r9_t *) NULL +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) + , (PMCH_InfoList_r9_t *) NULL, + 0,0 # endif ); #endif //NO_RRM @@ -6351,18 +6457,19 @@ rrc_eNB_decode_ccch( NULL, NULL, NULL -# if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (PMCH_InfoList_r9_t *) NULL -# endif +#endif ,NULL); rrc_rlc_config_asn1_req(ctxt_pP, ue_context_p->ue_context.SRB_configList, (DRB_ToAddModList_t*) NULL, (DRB_ToReleaseList_t*) NULL -# if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (PMCH_InfoList_r9_t *) NULL -# endif + , 0, 0 +#endif ); #endif //NO_RRM @@ -6666,7 +6773,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0; rnti_t reestablish_rnti = 0; // select C-RNTI from map - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (reestablish_rnti_map[i][0] == ctxt_pP->rnti) { reestablish_rnti = reestablish_rnti_map[i][1]; ue_context_p = rrc_eNB_get_ue_context( @@ -6983,7 +7090,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { break; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) case UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9: T(T_ENB_RRC_UE_INFORMATION_RESPONSE_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), @@ -6996,7 +7103,9 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); break; +#endif +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) case UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10: T(T_ENB_RRC_RECONFIGURATION_COMPLETE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); @@ -7027,6 +7136,53 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { } return 0; + //TTN for D2D + } else if (ul_dcch_msg->message.present == UL_DCCH_MessageType_PR_messageClassExtension){ + LOG_I(RRC, "THINH [UL_DCCH_MessageType_PR_messageClassExtension]\n"); + + switch (ul_dcch_msg->message.choice.messageClassExtension.present) { + case UL_DCCH_MessageType__messageClassExtension_PR_NOTHING: /* No components present */ + break; + case UL_DCCH_MessageType__messageClassExtension_PR_c2: //SidelinkUEInformation + //case UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12: //SidelinkUEInformation + LOG_I(RRC,"THINH [UL_DCCH_MessageType__messageClassExtension_PR_c2]\n"); + +#ifdef RRC_MSG_PRINT + LOG_F(RRC,"[MSG] SidelinkUEInformation\n"); + + for (i = 0; i < sdu_sizeP; i++) { + LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]); + } + + LOG_F(RRC,"\n"); +#endif + + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" SidelinkUEInformation UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); + + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(SidelinkUEInformation) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); + + rrc_eNB_process_SidelinkUEInformation( + ctxt_pP, + ue_context_p, + &ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12); + break; + default: + break; + } + //end TTN } else { LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown error %s:%u\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -7034,6 +7190,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { return -1; } + return 0; } #if defined(ENABLE_ITTI) @@ -7249,7 +7406,7 @@ openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active) RC.rrc[module_id]->HO_flag = (uint8_t)HO_active; } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) LOG_I(RRC,"[eNB] eMBMS active state is %d \n", eMBMS_active); for (module_id=0; module_id<NB_eNB_INST; module_id++) { @@ -7287,6 +7444,283 @@ rrc_top_cleanup_eNB( //----------------------------------------------------------------------------- +//TTN - for D2D +uint8_t +rrc_eNB_process_SidelinkUEInformation( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* ue_context_pP, + SidelinkUEInformation_r12_t * sidelinkUEInformation +) +//----------------------------------------------------------------------------- +{ + SL_DestinationInfoList_r12_t *destinationInfoList; + int n_destinations = 0; + int ue_type = 0; + int n_discoveryMessages = 0; + + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing SidelinkUEInformation from UE (SRB1 Active)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + + //For SL Communication + if (sidelinkUEInformation->criticalExtensions.present == SidelinkUEInformation_r12__criticalExtensions_PR_c1){ + if (sidelinkUEInformation->criticalExtensions.choice.c1.present == SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12){ + // express its interest to receive SL communication + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12 != NULL){ + + } + + // express its interest to transmit non-relay one-to-many SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12 != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12 != NULL)){ + n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.count; + destinationInfoList = CALLOC(1, sizeof(SL_DestinationInfoList_r12_t)); + for (int i=0; i< n_destinations; i++ ){ + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list, sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.array[i]); + } + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + + } + + // express its interest to transmit non-relay one-to-one SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13 != NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12 != NULL){ + n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.count; + destinationInfoList = CALLOC(1, sizeof(SL_DestinationInfoList_r12_t)); + for (int i=0; i< n_destinations; i++ ){ + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list,sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.array[i]); + } + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + } + } + + // express its interest to transmit relay related one-to-one SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) &&(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13 != NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.count > 0) { + n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.count; + ue_type = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13; + destinationInfoList = CALLOC(1, sizeof(SL_DestinationInfoList_r12_t)); + for (int i=0; i< n_destinations; i++ ){ + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list, sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.array[i]); + } + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + } + } + + //express its interest to transmit relay related one-to-many SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13 != NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.count > 0){ + n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.count; + ue_type = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13; + destinationInfoList = CALLOC(1, sizeof(SL_DestinationInfoList_r12_t)); + for (int i=0; i< n_destinations; i++ ){ + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list,sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.array[i]); + } + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + } + } + + //For SL Discovery + //express its interest to receive SL discovery announcements + //express its interest to transmit non-PS related discovery announcements + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12 != NULL){ + n_discoveryMessages = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12); + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, NULL, n_discoveryMessages); + return 0; + } + //express its interest to transmit PS related discovery announcements + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13 !=NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13 > 0){ + n_discoveryMessages = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13; + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, NULL, n_discoveryMessages); + return 0; + } + } + } + } + return 0; +} + +//----------------------------------------------------------------------------- +int +rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + SL_DestinationInfoList_r12_t *destinationInfoList, + int n_discoveryMessages +) +//----------------------------------------------------------------------------- +{ + + uint8_t buffer[RRC_BUF_SIZE]; + uint16_t size = -1; + memset(buffer, 0, RRC_BUF_SIZE); + + // allocate dedicated pools for UE -sl-CommConfig/sl-DiscConfig (sl-V2X-ConfigDedicated) + //populate dedicated resources for SL communication (sl-CommConfig) + if ((destinationInfoList != NULL) && (destinationInfoList->list.count > 0)) { + + LOG_I(RRC,"[eNB %d] Frame %d, Generate RRCConnectionReconfiguration_Sidelink (bytes %d, UE id %x), number of destinations %d\n", + ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti,destinationInfoList->list.count ); + //get dedicated resources from available pool and assign to the UE + SL_CommConfig_r12_t sl_CommConfig[destinationInfoList->list.count]; + //get a RP from the available RPs + sl_CommConfig[0] = rrc_eNB_get_sidelink_commTXPool(ctxt_pP, ue_context_pP, destinationInfoList); + + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id + (SRB_ToAddModList_t*)NULL, + (DRB_ToAddModList_t*)NULL, + (DRB_ToReleaseList_t*)NULL, // DRB2_list, + (struct SPS_Config*)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL, + (SL_CommConfig_r12_t*)&sl_CommConfig, + (SL_DiscConfig_r12_t*)NULL + #if defined(Rel10) || defined(Rel14) + , (SCellToAddMod_r10_t*)NULL + #endif + ); + // + } + //populate dedicated resources for SL discovery (sl-DiscConfig) + if (n_discoveryMessages > 0) { + SL_DiscConfig_r12_t sl_DiscConfig[n_discoveryMessages]; + //get a RP from the available RPs + sl_DiscConfig[0] = rrc_eNB_get_sidelink_discTXPool(ctxt_pP, ue_context_pP, n_discoveryMessages ); + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id + (SRB_ToAddModList_t*)NULL, + (DRB_ToAddModList_t*)NULL, + (DRB_ToReleaseList_t*)NULL, // DRB2_list, + (struct SPS_Config*)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL, + (SL_CommConfig_r12_t*)NULL, + (SL_DiscConfig_r12_t*)&sl_DiscConfig + #if defined(Rel10) || defined(Rel14) + , (SCellToAddMod_r10_t*)NULL + #endif + ); + } + + LOG_I(RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration_Sidelink (bytes %d, UE id %x)\n", + ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + + rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + + // rrc_data_req(); + + return size; +} + +SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, SL_DestinationInfoList_r12_t *destinationInfoList ){ + // for the moment, use scheduled resource allocation + SL_CommConfig_r12_t *sl_CommConfig; + SL_CommResourcePool_r12_t *sc_CommTxConfig; + + sl_CommConfig = CALLOC(1, sizeof(struct SL_CommConfig_r12)); + sl_CommConfig->commTxResources_r12 = CALLOC(1, sizeof(*sl_CommConfig->commTxResources_r12)); + sl_CommConfig->commTxResources_r12->present = SL_CommConfig_r12__commTxResources_r12_PR_setup; + + sl_CommConfig->commTxResources_r12->choice.setup.present = SL_CommConfig_r12__commTxResources_r12__setup_PR_scheduled_r12; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.size = 2; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf = CALLOC(1,2); + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf[0] = 0x00; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf[1] = 0x01;//ctxt_pP->rnti;//rnti + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.bits_unused = 0; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12 = CALLOC(1,sizeof(*sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12)); + //*sl_CommConfig_test->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12 = 12; //Msc + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mac_MainConfig_r12.retx_BSR_TimerSL = RetxBSR_Timer_r12_sf320; //MacConfig, for testing only + //sl_CommConfig_test->commTxResources_r12->choice.setup.choice.scheduled_r12.sc_CommTxConfig_r12; + + sc_CommTxConfig = & sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sc_CommTxConfig_r12; + + sc_CommTxConfig->sc_CP_Len_r12 = SL_CP_Len_r12_normal; + sc_CommTxConfig->sc_Period_r12 = SL_PeriodComm_r12_sf40; + sc_CommTxConfig->data_CP_Len_r12 = SL_CP_Len_r12_normal; + //sc_TF_ResourceConfig_r12 + sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_Num_r12 = 20; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_Start_r12 = 5; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_End_r12 = 44; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = SL_OffsetIndicator_r12_PR_small_r12; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0; + + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = SubframeBitmapSL_r12_PR_bs40_r12; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = 5; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = CALLOC(1,5); + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = 0; + //dataHoppingConfig_r12 + sc_CommTxConfig->dataHoppingConfig_r12.hoppingParameter_r12 = 0; + sc_CommTxConfig->dataHoppingConfig_r12.numSubbands_r12 = SL_HoppingConfigComm_r12__numSubbands_r12_ns1; + sc_CommTxConfig->dataHoppingConfig_r12.rb_Offset_r12 = 0; + //ue_SelectedResourceConfig_r12 + sc_CommTxConfig->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->ue_SelectedResourceConfig_r12)); + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Start_r12 = 5; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_End_r12 = 44; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = SL_OffsetIndicator_r12_PR_small_r12; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0 ; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = SubframeBitmapSL_r12_PR_bs40_r12; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = 5; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = CALLOC(1,5); + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = 0; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[0] = 0xF0; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[1] = 0xFF; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[2] = 0xFF; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[3] = 0xFF; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[4] = 0xFF; + //rxParametersNCell_r12 + sc_CommTxConfig->rxParametersNCell_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->rxParametersNCell_r12)); + sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12 )); + sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12->subframeAssignment = 0 ; + sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12->specialSubframePatterns = 0; + sc_CommTxConfig->rxParametersNCell_r12->syncConfigIndex_r12 = 0; + //txParameters_r12 + sc_CommTxConfig->txParameters_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->txParameters_r12)); + sc_CommTxConfig->txParameters_r12->sc_TxParameters_r12.alpha_r12 = Alpha_r12_al0; + sc_CommTxConfig->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0; + sc_CommTxConfig->ext1 = NULL ; + + return *sl_CommConfig; +} + + +SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, int n_discoveryMessages ){ + //TODO + SL_DiscConfig_r12_t sl_DiscConfig; + sl_DiscConfig.discTxResources_r12 = CALLOC(1,sizeof(*sl_DiscConfig.discTxResources_r12)); + sl_DiscConfig.discTxResources_r12->present = SL_DiscConfig_r12__discTxResources_r12_PR_setup; + sl_DiscConfig.discTxResources_r12->choice.setup.present = SL_DiscConfig_r12__discTxResources_r12__setup_PR_scheduled_r12; + //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discHoppingConfig_r12; + //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTF_IndexList_r12; + //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTxConfig_r12; + return sl_DiscConfig; +} RRC_status_t rrc_rx_tx( protocol_ctxt_t* const ctxt_pP, @@ -7368,7 +7802,7 @@ rrc_rx_tx( ue_context_p->ue_context.ue_release_timer++; if (ue_context_p->ue_context.ue_release_timer >= ue_context_p->ue_context.ue_release_timer_thres) { - LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); + LOG_I(RRC,"Removing UE %x instance, Release timer: %d, Release timer thres.: %d \n",ue_context_p->ue_context.rnti, ue_context_p->ue_context.ue_release_timer, ue_context_p->ue_context.ue_release_timer_thres); ue_to_be_removed = ue_context_p; break; } diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c similarity index 97% rename from openair2/RRC/LITE/rrc_eNB_GTPV1U.c rename to openair2/RRC/LTE/rrc_eNB_GTPV1U.c index e5f2c5aaae1c469c4da1ffbcda1a41a0d7c264d4..135c6fea8d82e5279036ad7c11ae08df8d3d8683 100644 --- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c @@ -28,9 +28,9 @@ */ #if defined(ENABLE_USE_MME) -# include "defs.h" -# include "extern.h" -# include "RRC/LITE/MESSAGES/asn1_msg.h" +# include "rrc_defs.h" +# include "rrc_extern.h" +# include "RRC/LTE/MESSAGES/asn1_msg.h" # include "rrc_eNB_GTPV1U.h" # include "rrc_eNB_UE_context.h" # include "msc.h" diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.h b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_GTPV1U.h rename to openair2/RRC/LTE/rrc_eNB_GTPV1U.h diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c similarity index 99% rename from openair2/RRC/LITE/rrc_eNB_S1AP.c rename to openair2/RRC/LTE/rrc_eNB_S1AP.c index 9c58a05b59dd2344cf4e15c6f08b5cf47cba0264..f12b1194f5e7174ef4e2aa88e9441a0f26ed6c9c 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -27,13 +27,11 @@ * \company Eurecom * \email: navid.nikaein@eurecom.fr */ - #if defined(ENABLE_USE_MME) -# include "defs.h" -# include "extern.h" +# include "rrc_defs.h" +# include "rrc_extern.h" # include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -# include "RRC/LITE/MESSAGES/asn1_msg.h" -# include "RRC/LITE/defs.h" +# include "RRC/LTE/MESSAGES/asn1_msg.h" # include "rrc_eNB_UE_context.h" # include "rrc_eNB_S1AP.h" # include "enb_config.h" @@ -57,7 +55,7 @@ #include "UERadioAccessCapabilityInformation.h" #include "gtpv1u_eNB_task.h" -#include "RRC/LITE/rrc_eNB_GTPV1U.h" +#include "RRC/LTE/rrc_eNB_GTPV1U.h" #include "TLVDecoder.h" #include "S1ap-NAS-PDU.h" @@ -76,7 +74,7 @@ static const uint16_t S1AP_ENCRYPTION_EEA2_MASK = 0x4000; static const uint16_t S1AP_INTEGRITY_EIA1_MASK = 0x8000; static const uint16_t S1AP_INTEGRITY_EIA2_MASK = 0x4000; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 2, 0)) # define INTEGRITY_ALGORITHM_NONE SecurityAlgorithmConfig__integrityProtAlgorithm_eia0_v920 #else #ifdef EXMIMO_IOT @@ -1996,7 +1994,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance /* insert data to UE_PF_PO or update data in UE_PF_PO */ pthread_mutex_lock(&ue_pf_po_mutex); uint8_t i = 0; - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value)) || (UE_PF_PO[CC_id][i].enable_flag != TRUE)) { /* set T = min(Tc,Tue) */ diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.h b/openair2/RRC/LTE/rrc_eNB_S1AP.h similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_S1AP.h rename to openair2/RRC/LTE/rrc_eNB_S1AP.h diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.c b/openair2/RRC/LTE/rrc_eNB_UE_context.c similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_UE_context.c rename to openair2/RRC/LTE/rrc_eNB_UE_context.c diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.h b/openair2/RRC/LTE/rrc_eNB_UE_context.h similarity index 98% rename from openair2/RRC/LITE/rrc_eNB_UE_context.h rename to openair2/RRC/LTE/rrc_eNB_UE_context.h index 0e813cdee526819145296ff477ee620f39b00b1d..289b4d69d69275e75659a819a17b57d85fb2861c 100644 --- a/openair2/RRC/LITE/rrc_eNB_UE_context.h +++ b/openair2/RRC/LTE/rrc_eNB_UE_context.h @@ -30,7 +30,7 @@ #ifndef __RRC_ENB_UE_CONTEXT_H__ #include "collection/tree.h" #include "COMMON/platform_types.h" -#include "defs.h" +#include "rrc_defs.h" void diff --git a/openair2/RRC/LITE/rrc_eNB_ral.c b/openair2/RRC/LTE/rrc_eNB_ral.c similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_ral.c rename to openair2/RRC/LTE/rrc_eNB_ral.c diff --git a/openair2/RRC/LITE/rrc_eNB_ral.h b/openair2/RRC/LTE/rrc_eNB_ral.h similarity index 100% rename from openair2/RRC/LITE/rrc_eNB_ral.h rename to openair2/RRC/LTE/rrc_eNB_ral.h diff --git a/openair2/RRC/LITE/extern.h b/openair2/RRC/LTE/rrc_extern.h similarity index 91% rename from openair2/RRC/LITE/extern.h rename to openair2/RRC/LTE/rrc_extern.h index b45dbd11e9557db9667b6c2ea24f1906eb67f774..6c19fa9c7076202b934664657e2e9cc3c3c1508a 100644 --- a/openair2/RRC/LITE/extern.h +++ b/openair2/RRC/LTE/rrc_extern.h @@ -30,15 +30,13 @@ #ifndef __OPENAIR_RRC_EXTERN_H__ #define __OPENAIR_RRC_EXTERN_H__ -#include "defs.h" +#include "rrc_defs.h" #include "COMMON/mac_rrc_primitives.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" #include "LAYER2/RLC/rlc.h" extern UE_RRC_INST *UE_rrc_inst; -#include "LAYER2/MAC/extern.h" extern uint8_t DRB2LCHAN[8]; @@ -77,10 +75,10 @@ extern uint32_t timeToTrigger_ms[16]; extern float RSRP_meas_mapping[98]; extern float RSRQ_meas_mapping[35]; -extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +extern UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; extern pthread_mutex_t ue_pf_po_mutex; -extern uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2]; +extern uint16_t reestablish_rnti_map[MAX_MOBILES_PER_ENB][2]; #endif diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LTE/rrc_proto.h similarity index 85% rename from openair2/RRC/LITE/proto.h rename to openair2/RRC/LTE/rrc_proto.h index b92058741940a5aa8ee91b18b664f2cbd5bb0d46..0218456ccb114166b3b202725ce4351637b088f2 100644 --- a/openair2/RRC/LITE/proto.h +++ b/openair2/RRC/LTE/rrc_proto.h @@ -25,13 +25,13 @@ * \date 2010 - 2014 * \email navid.nikaein@eurecom.fr * \version 1.0 - + */ /** \addtogroup _rrc * @{ */ -#include "RRC/LITE/defs.h" +#include "RRC/LTE/rrc_defs.h" #include "flexran_agent_extern.h" @@ -106,6 +106,14 @@ rrc_ue_decode_dcch( const uint8_t eNB_indexP ); +#ifdef Rel14 +int decode_SL_Discovery_Message( + const protocol_ctxt_t* const ctxt_pP, + const uint8_t eNB_index, + const uint8_t* Sdu, + const uint8_t Sdu_len); +#endif + /** \brief Generate/Encodes RRCConnnectionRequest message at UE \param ctxt_pP Running context \param eNB_index Index of corresponding eNB/CH*/ @@ -181,6 +189,28 @@ void rrc_ue_process_radioResourceConfigDedicated( uint8_t eNB_index, RadioResourceConfigDedicated_t *radioResourceConfigDedicated); + +/** \brief Process a RadioResourceConfig and configure PHY/MAC for SL communication/discovery + \param Mod_idP + \param eNB_index Index of corresponding CH/eNB + \param sib18 Pointer to SIB18 from SI message + \param sib19 Pointer to SIB19 from SI message + \param sl_CommConfig Pointer to SL_CommConfig RRCConnectionConfiguration + \param sl_DiscConfig Pointer to SL_DiscConfig RRCConnectionConfiguration */ +void rrc_ue_process_sidelink_radioResourceConfig( + module_id_t Mod_idP, + uint8_t eNB_index, + SystemInformationBlockType18_r12_t *sib18, + SystemInformationBlockType19_r12_t *sib19, + SL_CommConfig_r12_t* sl_CommConfig, + SL_DiscConfig_r12_t* sl_DiscConfig); + +/** \brief Init control socket to listen to incoming packets from ProSe App + * + */ +void rrc_control_socket_init(void); + + // eNB/CH RRC Procedures /**\brief Function to get the next transaction identifier. @@ -327,6 +357,54 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( const uint32_t nas_length ); +/**\brief Generate/decode the RRCConnectionReconfiguration for Sidelink at eNB + \param ctxt_pP Running context + \param ue_context_pP RRC UE context + \param destinationInfoList List of the destinations + \param n_discoveryMessages Number of discovery messages*/ +int +rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + SL_DestinationInfoList_r12_t *destinationInfoList, + int n_discoveryMessages +); + +/** \brief process the received SidelinkUEInformation message at eNB + \param ctxt_pP Running context + \param sidelinkUEInformation sidelinkUEInformation message from UE*/ +uint8_t +rrc_eNB_process_SidelinkUEInformation( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* ue_context_pP, + SidelinkUEInformation_r12_t* sidelinkUEInformation +); + +/** \brief Get a Resource Pool to transmit SL communication + \param ctxt_pP Running context + \param ue_context_pP UE context + \param destinationInfoList Pointer to the list of SL destinations*/ +SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + SL_DestinationInfoList_r12_t *destinationInfoList +); + +/** \brief Get a Resource Pool for Discovery + \param ctxt_pP Running context + \param ue_context_pP UE context + \param n_discoveryMessages Number of discovery messages*/ +SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( + const protocol_ctxt_t* const ctxt_pP, + rrc_eNB_ue_context_t* const ue_context_pP, + int n_discoveryMessages +); + +/** \brief Process request from control socket + * \param arg + */ +void *rrc_control_socket_thread_fct(void *arg); + //L2_interface.c int8_t mac_rrc_data_req( @@ -380,8 +458,8 @@ mac_rrc_data_ind_ue( void mac_sync_ind( module_id_t Mod_instP, uint8_t status); -void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, - const int CC_id, +void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, + const int CC_id, const frame_t frameP, const sub_frame_t subframeP, const rnti_t rnti); diff --git a/openair2/RRC/LITE/rrc_rrm_interface.c b/openair2/RRC/LTE/rrc_rrm_interface.c similarity index 100% rename from openair2/RRC/LITE/rrc_rrm_interface.c rename to openair2/RRC/LTE/rrc_rrm_interface.c diff --git a/openair2/RRC/LITE/rrc_rrm_interface.h b/openair2/RRC/LTE/rrc_rrm_interface.h similarity index 100% rename from openair2/RRC/LITE/rrc_rrm_interface.h rename to openair2/RRC/LTE/rrc_rrm_interface.h diff --git a/openair2/RRC/LITE/rrc_types.h b/openair2/RRC/LTE/rrc_types.h similarity index 100% rename from openair2/RRC/LITE/rrc_types.h rename to openair2/RRC/LTE/rrc_types.h diff --git a/openair2/RRC/LITE/rrc_types_NB_IoT.h b/openair2/RRC/LTE/rrc_types_NB_IoT.h similarity index 100% rename from openair2/RRC/LITE/rrc_types_NB_IoT.h rename to openair2/RRC/LTE/rrc_types_NB_IoT.h diff --git a/openair2/RRC/LITE/vars.h b/openair2/RRC/LTE/rrc_vars.h similarity index 93% rename from openair2/RRC/LITE/vars.h rename to openair2/RRC/LTE/rrc_vars.h index e3bab5f5eb48aa577400a62d92d1397ab2ed25cf..8a718581014a8c9d87fbf5ccffa8c76b1e7db732 100644 --- a/openair2/RRC/LITE/vars.h +++ b/openair2/RRC/LTE/rrc_vars.h @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -/*! \file vars.hles +/*! \file rrc_vars.h * \brief rrc variables * \author Raymond Knopp and Navid Nikaein * \date 2013 @@ -31,15 +31,15 @@ #ifndef __OPENAIR_RRC_VARS_H__ #define __OPENAIR_RRC_VARS_H__ -#include "defs.h" +#include "rrc_defs.h" #include "LAYER2/RLC/rlc.h" #include "COMMON/mac_rrc_primitives.h" -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" -UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][MAX_MOBILES_PER_ENB]; pthread_mutex_t ue_pf_po_mutex; UE_RRC_INST *UE_rrc_inst; -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac_extern.h" #define MAX_U32 0xFFFFFFFF uint8_t DRB2LCHAN[8]; @@ -59,7 +59,7 @@ struct LogicalChannelConfig__ul_SpecificParameters LCSRB2 = {3, }; -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) struct LogicalChannelConfig__ext1 logicalChannelSR_Mask_r9_ext1 = { logicalChannelSR_Mask_r9: &logicalChannelSR_Mask_r9 }; @@ -67,14 +67,14 @@ struct LogicalChannelConfig__ext1 logicalChannelSR_Mask_r9_ext1 = { // These are the default SRB configurations from 36.331 (Chapter 9, p. 176-179 in v8.6) LogicalChannelConfig_t SRB1_logicalChannelConfig_defaultValue = {ul_SpecificParameters: &LCSRB1 -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , ext1: &logicalChannelSR_Mask_r9_ext1 #endif }; LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue = {ul_SpecificParameters: &LCSRB2 -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , ext1: &logicalChannelSR_Mask_r9_ext1 #endif @@ -242,6 +242,6 @@ float RSRQ_meas_mapping[35] = { // [0]: current C-RNTI, [1]: prior C-RNTI // insert one when eNB received RRCConnectionReestablishmentRequest message // delete one when eNB received RRCConnectionReestablishmentComplete message -uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2] = {{0}}; +uint16_t reestablish_rnti_map[MAX_MOBILES_PER_ENB][2] = {{0}}; #endif diff --git a/openair2/RRC/LITE/rrm_2_rrc_msg.c b/openair2/RRC/LTE/rrm_2_rrc_msg.c similarity index 100% rename from openair2/RRC/LITE/rrm_2_rrc_msg.c rename to openair2/RRC/LTE/rrm_2_rrc_msg.c diff --git a/openair2/RRC/LITE/utils.c b/openair2/RRC/LTE/utils.c similarity index 100% rename from openair2/RRC/LITE/utils.c rename to openair2/RRC/LTE/utils.c diff --git a/openair2/UTIL/LOG/log.h b/openair2/UTIL/LOG/log.h index 071ee32d968be701c78fa34b2a1f98b74343a79f..abdfb84636a80c28f643d6ef0d798f3d519efd87 100644 --- a/openair2/UTIL/LOG/log.h +++ b/openair2/UTIL/LOG/log.h @@ -375,9 +375,9 @@ void *log_thread_function(void * list); /* @}*/ static __inline__ uint64_t rdtsc(void) { - uint64_t a, d; + uint32_t a, d; __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d)); - return (d<<32) | a; + return (((uint64_t)d)<<32) | ((uint64_t)a); } #define DEBUG_REALTIME 1 diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.c b/openair2/UTIL/LOG/vcd_signal_dumper.c index b18d2a25ffd714c778e16a96a971db1e081694d9..a026cfb081a70e1ffd8ab833dd711c329b6ee33e 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.c +++ b/openair2/UTIL/LOG/vcd_signal_dumper.c @@ -191,6 +191,9 @@ const char* eurecomVariablesNames[] = { "ue0_trx_write_ns", "ue0_trx_read_ns_missing", "ue0_trx_write_ns_missing", + "enb_thread_rxtx_CPUID", + "ru_thread_CPUID", + "ru_thread_tx_CPUID" }; const char* eurecomFunctionsNames[] = { diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.h b/openair2/UTIL/LOG/vcd_signal_dumper.h index a4c8cd2476e08f0b234e47540b54b89b1d6b52fd..a47cdc059d1a8236b78255b28d457ad8979613e5 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.h +++ b/openair2/UTIL/LOG/vcd_signal_dumper.h @@ -167,6 +167,9 @@ typedef enum { VCD_SIGNAL_DUMPER_VARIABLES_UE0_TRX_WRITE_NS, VCD_SIGNAL_DUMPER_VARIABLES_UE0_TRX_READ_NS_MISSING, VCD_SIGNAL_DUMPER_VARIABLES_UE0_TRX_WRITE_NS_MISSING, + VCD_SIGNAL_DUMPER_VARIABLES_CPUID_ENB_THREAD_RXTX, + VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD, + VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD_TX, VCD_SIGNAL_DUMPER_VARIABLES_END } vcd_signal_dump_variables; diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c index 9c3a50467a785f4f218d3f2eef034e327d5dde78..39447001fab293832c874cfe2957c30476b7ac26 100644 --- a/openair2/UTIL/MEM/mem_block.c +++ b/openair2/UTIL/MEM/mem_block.c @@ -33,8 +33,8 @@ #include "mem_block.h" #include "mem_pool.h" #include "list.h" -#include "LAYER2/MAC/extern.h" - +#include "LAYER2/MAC/mac_extern.h" +#include "assertions.h" /* all function calls are protected by a mutex * to ensure that many threads calling them at * the same time don't mess up. diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h index 855b7a99fdde30ef25bfb70c7c78c8a523104a2b..0495b139ce363e548346c83d9d22213ea32647e3 100644 --- a/openair2/UTIL/OCG/OCG.h +++ b/openair2/UTIL/OCG/OCG.h @@ -36,7 +36,7 @@ #ifndef __OCG_H__ #define __OCG_H__ -#include "PHY/defs.h" +#include "PHY/defs_common.h" #include "PHY/impl_defs_top.h" #include "platform_types.h" diff --git a/openair2/UTIL/OTG/otg_defs.h b/openair2/UTIL/OTG/otg_defs.h index fad0d9510ece3fc190b76889f819cb71aab4d080..6c9944014fd99f08e01e53f2ef4e4330446bf8e3 100644 --- a/openair2/UTIL/OTG/otg_defs.h +++ b/openair2/UTIL/OTG/otg_defs.h @@ -33,7 +33,7 @@ #ifndef __OTG_DEFS_H__ # define __OTG_DEFS_H__ -/* \brief To define the NUMBER_OF_eNB_MAX and NUMBER_OF_UE_MAX */ +/* \brief To define the NUMBER_OF_eNB_MAX and MAX_MOBILES_PER_ENB */ #if STANDALONE==1 #include "openairinterface5g_limits.h" #else @@ -313,13 +313,13 @@ typedef struct { /*this structure constitutes a whole bg-stream with multiple bg typedef struct { int application_type[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION]; /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/ - int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; - int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ - int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ + int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ + int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Duration of traffic generation or use the emuulation time instead */ - int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Inter Departure Time distribution */ + int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Inter Departure Time distribution */ int idt_min[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION]; /*!\brief Min Inter Departure Time, for uniform distrib */ int idt_max[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX][MAX_NUM_APPLICATION]; /*!\brief idt, Max Inter Departure Time, for uniform distrib */ @@ -338,69 +338,69 @@ typedef struct { */ typedef struct { int max_nb_frames; /*!< \brief Max Number of frames*/ - int application_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/ + int application_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief It identify the application of the simulated traffic, could be cbr, m2m, gaming,etc*/ /*!\header info */ - int trans_proto[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Transport Protocol*/ - int ip_v[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief Ip version */ + int trans_proto[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Transport Protocol*/ + int ip_v[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief Ip version */ //int header_compression; /*!\brief Specify if header compression is used or not */ int num_nodes; /*!\brief Number of used nodes in the simulation */ int packet_gen_type; /*!\brief define how the payload is generated: fixed, predefined, random position, random see ALPHABET_GEN */ - unsigned int background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief enable or disable background traffic */ - unsigned int aggregation_level[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /* define packet aggregation level for the case of gateway*/ + unsigned int background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief enable or disable background traffic */ + unsigned int aggregation_level[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /* define packet aggregation level for the case of gateway*/ // src id , dst id, and state // think to the case of several streams per node !!!!! - int idt_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Inter Departure Time distribution */ - int idt_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Inter Departure Time, for uniform distrib */ - int idt_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Max Inter Departure Time, for uniform distrib */ + int idt_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Inter Departure Time distribution */ + int idt_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Inter Departure Time, for uniform distrib */ + int idt_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Max Inter Departure Time, for uniform distrib */ - double idt_std_dev[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Standard Deviation, for guassian distrib */ - double idt_lambda[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, lambda, for exponential/poisson distrib */ - double idt_scale[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ - double idt_shape[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ + double idt_std_dev[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, Standard Deviation, for guassian distrib */ + double idt_lambda[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief idt, lambda, for exponential/poisson distrib */ + double idt_scale[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ + double idt_shape[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ - int size_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Paylolad size distribution */ - int size_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Payload size, for uniform distrib */ - int size_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Max Inter Departure Time, for uniform distrib */ - double size_std_dev[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Standard Deviation, for guassian distrib */ - double size_lambda[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, lambda, for exponential/poisson distrib */ + int size_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Paylolad size distribution */ + int size_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief Min Payload size, for uniform distrib */ + int size_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Max Inter Departure Time, for uniform distrib */ + double size_std_dev[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, Standard Deviation, for guassian distrib */ + double size_lambda[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief payload, lambda, for exponential/poisson distrib */ - double size_scale[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution */ - double size_shape[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ + double size_scale[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief scale :parameter for Pareto, Gamma, Weibull and Cauchy distribution */ + double size_shape[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION][MAX_NUM_TRAFFIC_STATE]; /*!\brief shape :parameter for Pareto, Gamma, Weibull and Cauchy distribution*/ // info for state-based traffic gen - int num_state [NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Number of states for source node*/ - // int state_dist[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_TRAFFIC_STATE]; /*!\brief States distribution */ - double state_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_TRAFFIC_STATE]; /*!\brief State probablity: prob to move from one state to the other one */ + int num_state [NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Number of states for source node*/ + // int state_dist[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_TRAFFIC_STATE]; /*!\brief States distribution */ + double state_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_TRAFFIC_STATE]; /*!\brief State probablity: prob to move from one state to the other one */ // num stream for each src - // int stream [NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; // this requires multi thread for parallel stream for a givcen src + // int stream [NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; // this requires multi thread for parallel stream for a givcen src // emu info - int flow_start_flag[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow start time flag for traffic generation or use the emuulation time instead */ - int flow_start[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow start time of traffic generation or use the emuulation time instead */ - int flow_duration[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!\brief flow duration of traffic generation or use the emuulation time instead */ + int flow_start_flag[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow start time flag for traffic generation or use the emuulation time instead */ + int flow_start[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow start time of traffic generation or use the emuulation time instead */ + int flow_duration[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!\brief flow duration of traffic generation or use the emuulation time instead */ int seed; /*!\brief The seed used to generate the random positions*/ - int dst_port[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Destination port number, for the socket mode*/ - char *dst_ip[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief Destination IP address, for the socket mode*/ + int dst_port[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Destination port number, for the socket mode*/ + char *dst_ip[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief Destination IP address, for the socket mode*/ - int trans_proto_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!\brief define the transport protocol and IP version for background traffic*/ + int trans_proto_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!\brief define the transport protocol and IP version for background traffic*/ - double prob_off_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_off_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_off_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_pu_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_pu_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_ed_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - double prob_ed_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_off_ed[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_off_pu[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_off_pe[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int pu_size_pkts[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int ed_size_pkts[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int m2m[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + double prob_off_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_off_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_off_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_pu_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_pu_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_ed_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + double prob_ed_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_off_ed[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_off_pu[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_off_pe[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int pu_size_pkts[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int ed_size_pkts[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int m2m[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; unsigned int throughput_metric; @@ -409,7 +409,7 @@ typedef struct { unsigned int curve; unsigned int owd_radio_access; unsigned int background_stats; - unsigned int application_idx[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + unsigned int application_idx[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; } otg_t; @@ -485,8 +485,8 @@ typedef struct { unsigned int rx_total_bytes_dl; /*TARMA parameteres*/ - tarmaStream_t *mtarma_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - tarmaVideo_t *mtarma_video[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + tarmaStream_t *mtarma_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + tarmaVideo_t *mtarma_video[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; } otg_multicast_info_t; @@ -505,71 +505,71 @@ typedef struct { int ctime; /*!< \brief Simulation time in ms*/ int ptime_background_ul; /*!< \brief time of last sent background UL data (time in ms)*/ int ptime_background_dl; /*!< \brief time of last sent background DL data (time in ms)*/ - int ptime[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief time of last sent data (time in ms)*/ - int seq_num[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the sender */ - int seq_num_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief the sequence number for background traffic of the sender */ - int seq_num_rx[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the receiver */ - int seq_num_rx_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief the sequence number for background traffic of the receiver */ + int ptime[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief time of last sent data (time in ms)*/ + int seq_num[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the sender */ + int seq_num_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief the sequence number for background traffic of the sender */ + int seq_num_rx[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief the sequence number of the receiver */ + int seq_num_rx_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief the sequence number for background traffic of the receiver */ - int idt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Inter Departure Time for background traffic in ms*/ - int size_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief payload size for background traffic*/ - int idt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief Inter Departure Time in ms*/ - int header_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Define the type of header: Transport layer + IP version*/ + int idt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Inter Departure Time for background traffic in ms*/ + int size_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief payload size for background traffic*/ + int idt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief Inter Departure Time in ms*/ + int header_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Define the type of header: Transport layer + IP version*/ /*!< \brief Statics part: vars updated at each iteration of otg_tx */ - int tx_num_pkt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the tx*/ - int tx_num_bytes[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the tx*/ // get the size and calculate the avg throughput + int tx_num_pkt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the tx*/ + int tx_num_bytes[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the tx*/ // get the size and calculate the avg throughput // vars updated at each iteration of otg_rx - int rx_num_pkt[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the rx */ - int rx_num_bytes[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the rx */ - float rx_pkt_owd[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ - float rx_owd_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_owd_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_pkt_owd_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ - float rx_owd_min_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_owd_max_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_pkt_owd_history[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ - float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ - float rx_pkt_jitter[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime */ - float rx_jitter_min[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_jitter_max[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_jitter_avg[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_pkt_jitter_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief One way delay: rx_ctime - tx_ctime */ - float rx_jitter_min_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ - float rx_jitter_max_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - float rx_jitter_avg_e2e[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - int rx_jitter_sample[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ - int nb_loss_pkts_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for UL*/ - int nb_loss_pkts_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for DL*/ - float owd_const[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief One way delay constant*/ + int rx_num_pkt[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packet in the rx */ + int rx_num_bytes[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of bytes in the rx */ + float rx_pkt_owd[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ + float rx_owd_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_owd_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_pkt_owd_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime, */ + float rx_owd_min_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_owd_max_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_pkt_owd_history[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ + float rx_pkt_owd_history_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][2]; /*!< \brief One way delay histoy used for jitter calculation: rx_ctime - tx_ctime, [2] to keep the owd for the current and previous pkt */ + float rx_pkt_jitter[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime */ + float rx_jitter_min[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_jitter_max[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_jitter_avg[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_pkt_jitter_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief One way delay: rx_ctime - tx_ctime */ + float rx_jitter_min_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay min*/ + float rx_jitter_max_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + float rx_jitter_avg_e2e[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + int rx_jitter_sample[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief One way delay max*/ + int nb_loss_pkts_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for UL*/ + int nb_loss_pkts_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Number of data packets losses for DL*/ + float owd_const[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief One way delay constant*/ /*!< \brief KPI part: calculate the KPIs, total */ - double tx_throughput[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ - double rx_goodput[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Rx goodput: (size of received data)/ctime*/ - float rx_loss_rate[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_EMU_TRAFFIC]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ - //int rx_latency[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Rx Latency */ + double tx_throughput[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ + double rx_goodput[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Rx goodput: (size of received data)/ctime*/ + float rx_loss_rate[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_EMU_TRAFFIC]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ + //int rx_latency[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Rx Latency */ /*!< \brief Background traffic part: SATS + KPIs */ - int tx_num_pkt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background data packet in the rx */ - int tx_num_bytes_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background bytes in the rx */ - int rx_num_pkt_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background data packet in the tx */ - int rx_num_bytes_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background bytes in the tx */ - int nb_loss_pkts_background_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background packets losses for UL*/ - int nb_loss_pkts_background_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Number of background packets losses for DL*/ - double tx_throughput_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ - double rx_goodput_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Rx goodput: (size of received data)/ctime*/ - float rx_loss_rate_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ - - float radio_access_delay[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - int nb_loss_pkts_otg[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int aggregation_level[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - - unsigned int state[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; /*!< \brief current state of src node */ - float state_transition_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_holding_time_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_holding_time_pe_off[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + int tx_num_pkt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background data packet in the rx */ + int tx_num_bytes_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background bytes in the rx */ + int rx_num_pkt_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background data packet in the tx */ + int rx_num_bytes_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background bytes in the tx */ + int nb_loss_pkts_background_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background packets losses for UL*/ + int nb_loss_pkts_background_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Number of background packets losses for DL*/ + double tx_throughput_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Tx throughput: (size of transmitted data)/ctime*/ + double rx_goodput_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Rx goodput: (size of received data)/ctime*/ + float rx_loss_rate_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; /*!< \brief Rx Loss Rate: ratio, unit: bytes*/ + + float radio_access_delay[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + int nb_loss_pkts_otg[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int aggregation_level[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + + unsigned int state[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*!< \brief current state of src node */ + float state_transition_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_holding_time_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_holding_time_pe_off[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; unsigned int tx_total_bytes_dl; unsigned int tx_total_bytes_ul; unsigned int rx_total_bytes_dl; @@ -582,32 +582,32 @@ typedef struct { float average_jitter_ul_e2e; /* VOIP tarffic parameters*/ - float voip_transition_prob[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int voip_state[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_voip_silence[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_silence[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int start_voip_talk[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int c_holding_time_talk[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int silence_time[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int simple_talk_time[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + float voip_transition_prob[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int voip_state[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_voip_silence[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_silence[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int start_voip_talk[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int c_holding_time_talk[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int silence_time[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int simple_talk_time[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*TARMA parameteres*/ - tarmaStream_t *tarma_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - tarmaVideo_t *tarma_video[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; + tarmaStream_t *tarma_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + tarmaVideo_t *tarma_video[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; /*BACKGROUND_USERS parameters*/ - backgroundStream_t *background_stream[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - - unsigned int header_size_app[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; - unsigned int header_size[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int m2m_aggregation[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int flow_id[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int traffic_type[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int traffic_type_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + backgroundStream_t *background_stream[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + + unsigned int header_size_app[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; + unsigned int header_size[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int m2m_aggregation[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int flow_id[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int traffic_type[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int traffic_type_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; // unsigned int traffic_type_multicast[NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_SERVICE_MAX]; - unsigned int hdr_size[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - unsigned int header_type_app[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_NUM_APPLICATION]; ; + unsigned int hdr_size[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + unsigned int header_type_app[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_NUM_APPLICATION]; ; unsigned int gen_pkts; - unsigned int header_size_background[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + unsigned int header_size_background[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; } otg_info_t; @@ -640,14 +640,14 @@ typedef struct { int init_forms; int is_data_plot_ul; int is_data_plot_dl; - float data_owd_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_throughput_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_ctime_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - int idx_ul[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; - float data_owd_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_throughput_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - float data_ctime_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][MAX_SAMPLES]; - int idx_dl[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + float data_owd_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_throughput_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_ctime_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + int idx_ul[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; + float data_owd_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_throughput_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + float data_ctime_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][MAX_SAMPLES]; + int idx_dl[NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB][NUMBER_OF_eNB_MAX + MAX_MOBILES_PER_ENB]; } otg_forms_info_t; diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index 7ba3d88a878e1e294a8d29ca58e7b6d0127b2c38..784245c0d36cb1ef4e1902af160fb3bf4a9fab2e 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -62,6 +62,13 @@ extern boolean_t pdcp_data_req( const confirm_t confirmP, const sdu_size_t sdu_buffer_sizeP, unsigned char *const sdu_buffer_pP, + const pdcp_transmission_mode_t modeP +#ifdef Rel14 + ,const uint32_t * const sourceL2Id + ,const uint32_t * const destinationL2Id +#endif + ); + const pdcp_transmission_mode_t modeP); */ extern unsigned char NB_eNB_INST; @@ -355,7 +362,11 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( SDU_CONFIRM_NO, // confirm buffer_len, buffer, - PDCP_TRANSMISSION_MODE_DATA); + PDCP_TRANSMISSION_MODE_DATA +#ifdef Rel14 + ,NULL, NULL +#endif + ); if ( result == FALSE ) { diff --git a/openair3/S1AP/s1ap_common.h b/openair3/S1AP/s1ap_common.h index 003bdd2d62345371bf57fb520bf4ce545330bafb..a327e18b02a61fbd0893f2219da33edd99d4f4ed 100644 --- a/openair3/S1AP/s1ap_common.h +++ b/openair3/S1AP/s1ap_common.h @@ -333,7 +333,7 @@ inline void ASN_DEBUG(const char *fmt, ...); #include "S1ap-IE.h" #include "S1AP-PDU.h" -#if defined (UPDATE_RELEASE_9) +#if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) # include "S1ap-BroadcastCancelledAreaList.h" # include "S1ap-CancelledCellinEAI.h" # include "S1ap-CancelledCellinEAI-Item.h" @@ -364,9 +364,9 @@ inline void ASN_DEBUG(const char *fmt, ...); # include "S1ap-UplinkUEAssociatedLPPaTransport.h" # include "S1ap-DownlinkNonUEAssociatedLPPaTransport.h" # include "S1ap-UplinkNonUEAssociatedLPPaTransport.h" -#endif /* (UPDATE_RELEASE_9) */ +#endif /* #if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) */ -#if defined(UPDATE_RELEASE_10) +#if (S1AP_VERSION >= MAKE_VERSION(10, 0, 0)) # include "S1ap-PagingPriority.h" # include "S1ap-RelayNode-Indicator.h" # include "S1ap-GWContextReleaseIndication.h" @@ -375,7 +375,7 @@ inline void ASN_DEBUG(const char *fmt, ...); # include "S1ap-PrivacyIndicator.h" # include "S1ap-TrafficLoadReductionIndication.h" # include "S1ap-GUMMEIList.h" -#endif /* (UPDATE_RELEASE_10) */ +#endif /* #if (S1AP_VERSION >= MAKE_VERSION(10, 0, 0)) */ /* Checking version of ASN1C compiler */ #if (ASN1C_ENVIRONMENT_VERSION < ASN1C_MINIMUM_VERSION) diff --git a/openair3/S1AP/s1ap_eNB_decoder.c b/openair3/S1AP/s1ap_eNB_decoder.c index eac52c53ba6fc52cf13340267630a41d1de68c8c..447ca2c81bf2ece7a4032ff63cdc9721dea968e1 100644 --- a/openair3/S1AP/s1ap_eNB_decoder.c +++ b/openair3/S1AP/s1ap_eNB_decoder.c @@ -168,6 +168,22 @@ static int s1ap_eNB_decode_initiating_message(s1ap_message *message, S1AP_INFO("TODO E_RABRelease nitiating message\n"); break; + case S1ap_ProcedureCode_id_ErrorIndication: + ret = s1ap_decode_s1ap_errorindicationies( + &message->msg.s1ap_ErrorIndicationIEs, &initiating_p->value); + s1ap_xer_print_s1ap_errorindication(s1ap_xer__print2sp, message_string, message); + message_id = S1AP_E_RAB_ERROR_INDICATION_LOG; + message_string_size = strlen(message_string); + message_p = itti_alloc_new_message_sized(TASK_S1AP, + message_id, + message_string_size + sizeof (IttiMsgText)); + message_p->ittiMsg.s1ap_e_rab_release_request_log.size = message_string_size; + memcpy(&message_p->ittiMsg.s1ap_error_indication_log.text, message_string, message_string_size); + itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p); + free(message_string); + S1AP_INFO("ErrorIndication initiating message\n"); + break; + default: S1AP_ERROR("Unknown procedure ID (%d) for initiating message\n", (int)initiating_p->procedureCode); diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 0b02fc6db9ee4c0580ec108bdeb50bd162372d52..ab5f93a16d8883b7b49f66043f82212837b3607b 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -141,7 +141,7 @@ s1ap_message_decoded_callback messages_callback[][3] = { { 0, 0, 0 }, /* eNBConfigurationTransfer */ { 0, 0, 0 }, /* MMEConfigurationTransfer */ { 0, 0, 0 }, /* CellTrafficTrace */ -#if defined(UPDATE_RELEASE_9) +#if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) { 0, 0, 0 }, /* Kill */ { 0, 0, 0 }, /* DownlinkUEAssociatedLPPaTransport */ { 0, 0, 0 }, /* UplinkUEAssociatedLPPaTransport */ diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c index d74b1c6d4fed2d65640c1d5989e2ec846c642dcf..7ff3b820dca5e121f585bd3b9c5a5827ddea1e95 100644 --- a/targets/ARCH/COMMON/common_lib.c +++ b/targets/ARCH/COMMON/common_lib.c @@ -117,7 +117,7 @@ int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cf rc=load_lib(device, openair0_cfg, NULL,RAU_LOCAL_RADIO_HEAD ); if ( rc >= 0) { - if ( set_device(device) < 0) { + if ( set_device(device) < 0) { fprintf(stderr, "%s %d:Unsupported radio head\n",__FILE__, __LINE__); return -1; } diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 9b1755954ae84655a75cbe25ba0570291d01097f..a99c9d7a5d01d95060c9909486bf6528be2b547c 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -982,15 +982,20 @@ extern "C" { // workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock); -// args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096"; - // args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096"; uhd::device_addrs_t device_adds = uhd::device::find(args); if(device_adds.size() == 0) { - std::cerr<<"No USRP Device Found. " << std::endl; - free(s); - return -1; + args += ",addr=192.168.30.2"; + + uhd::device_addrs_t device_adds = uhd::device::find(args); + + if(device_adds.size() == 0) { + + std::cerr<<"No USRP Device Found. " << std::endl; + free(s); + return -1; + } } LOG_I(PHY,"Found USRP X300\n"); s->usrp = uhd::usrp::multi_usrp::make(args); @@ -1016,6 +1021,20 @@ extern "C" { LOG_I(PHY,"%s() sample_rate:%u\n", __FUNCTION__, (int)openair0_cfg[0].sample_rate); switch ((int)openair0_cfg[0].sample_rate) { + case 122880000: + // from usrp_time_offset + //openair0_cfg[0].samples_per_packet = 2048; + openair0_cfg[0].tx_sample_advance = 15; //to be checked + openair0_cfg[0].tx_bw = 80e6; + openair0_cfg[0].rx_bw = 80e6; + break; + case 61440000: + // from usrp_time_offset + //openair0_cfg[0].samples_per_packet = 2048; + openair0_cfg[0].tx_sample_advance = 15; + openair0_cfg[0].tx_bw = 40e6; + openair0_cfg[0].rx_bw = 40e6; + break; case 30720000: // from usrp_time_offset //openair0_cfg[0].samples_per_packet = 2048; diff --git a/targets/ARCH/tcp_bridge/README.tcp_bridge_oai b/targets/ARCH/tcp_bridge/README.tcp_bridge_oai new file mode 100644 index 0000000000000000000000000000000000000000..ef0588ddee4fecf4a765a2b42b18fb047c2df96a --- /dev/null +++ b/targets/ARCH/tcp_bridge/README.tcp_bridge_oai @@ -0,0 +1,41 @@ +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 --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] +[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 +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_oai.c b/targets/ARCH/tcp_bridge/tcp_bridge_oai.c new file mode 100644 index 0000000000000000000000000000000000000000..ba6d96db93372c3407d0d1c41ff666e3a2a85606 --- /dev/null +++ b/targets/ARCH/tcp_bridge/tcp_bridge_oai.c @@ -0,0 +1,320 @@ +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <arpa/inet.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> + +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; + int is_enb; +} 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("\x1b[31mtcp_bridge: error: you have to run one UE and one eNB" + " (did you run 'export ENODEB=1' in the eNB terminal?)\x1b[m\n"); + exit(1); + } +} + +int tcp_bridge_start(openair0_device *device) +{ + int port = 4043; + tcp_bridge_state_t *tcp_bridge = device->priv; + int try; + int max_try = 5; + + 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))) { + if (errno == EADDRINUSE) goto client_mode; + { 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; + + printf("tcp_bridge: connection established\n"); + + verify_connection(sock2, tcp_bridge->is_enb); + + return 0; + +client_mode: + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + + for (try = 0; try < max_try; try++) { + if (try != 0) sleep(1); + + printf("tcp_bridge: trying to connect to 127.0.0.1:%d (attempt %d/%d)\n", + port, try+1, max_try); + + if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) { + printf("tcp_bridge: connection established\n"); + tcp_bridge->sock = sock; + verify_connection(sock, tcp_bridge->is_enb); + return 0; + } + + perror("tcp_bridge"); + } + + printf("tcp_bridge: connection failed\n"); + + exit(1); +} + +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; + 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(); + } + 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, nsamps * 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(); + } + + 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*)malloc(sizeof(tcp_bridge_state_t)); + memset(tcp_bridge, 0, sizeof(tcp_bridge_state_t)); + + tcp_bridge->is_enb = getenv("ENODEB") != NULL; + + printf("tcp_bridge: running as %s\n", tcp_bridge->is_enb ? "eNB" : "UE"); + + /* only 25, 50 or 100 PRBs handled for the moment */ + if (openair0_cfg[0].sample_rate != 30720000 && + openair0_cfg[0].sample_rate != 15360000 && + openair0_cfg[0].sample_rate != 7680000) { + printf("tcp_bridge: ERROR: only 25, 50 or 100 PRBs 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/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 1efe6f73eb74a8d518a81015f7c1a3ee0decefbf..391e448deb590584e9a4b917edd4a6210b1fa1a5 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -36,10 +36,12 @@ # include "lteRALue.h" # include "lteRALenb.h" # endif -# include "RRC/LITE/defs.h" +# include "RRC/LTE/rrc_defs.h" # endif # include "enb_app.h" +extern int emulate_rf; + int create_tasks(uint32_t enb_nb) { LOG_D(ENB_APP, "%s(enb_nb:%d\n", __FUNCTION__, enb_nb); @@ -69,10 +71,11 @@ int create_tasks(uint32_t enb_nb) LOG_E(S1AP, "Create task for S1AP failed\n"); return -1; } - - if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { - LOG_E(UDP_, "Create task for UDP failed\n"); - return -1; + if(!emulate_rf){ + if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { + LOG_E(UDP_, "Create task for UDP failed\n"); + return -1; + } } if (itti_create_task (TASK_GTPV1_U, >pv1u_eNB_task, NULL) < 0) { diff --git a/targets/COMMON/create_tasks_ue.c b/targets/COMMON/create_tasks_ue.c index 4af75f56d1379c9874db81634382b2b3c3c54453..7e7d545c9f49a00990a0562fb4bae4a8ee090086 100644 --- a/targets/COMMON/create_tasks_ue.c +++ b/targets/COMMON/create_tasks_ue.c @@ -36,7 +36,7 @@ # include "lteRALue.h" # include "lteRALenb.h" # endif -# include "RRC/LITE/defs.h" +# include "RRC/LTE/rrc_defs.h" # endif # include "enb_app.h" diff --git a/targets/DOCS/nfapi-L2-emulator-setup.txt b/targets/DOCS/nfapi-L2-emulator-setup.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e502e2137edcf25450b06bef409b71bbac9882b --- /dev/null +++ b/targets/DOCS/nfapi-L2-emulator-setup.txt @@ -0,0 +1,31 @@ + +#Build instructions +source oaienv +cd cmake_targets + +#Create lte-uesoftmodem-nos1 (UE) and lte-softmodem-nos1 (eNB) executables +./build_oai --UE --noS1 -x -t ETHERNET + +./build_oai --eNB --noS1 -x -t ETHERNET + +------------------------------------------------------------------------------------------------------------------------------------------------------- + +#Execution instuctions (Currently running eNB (VNF) and UE side (PNF) on the same machine using the loopback interface) +cd cmake_targets/tools + +# Loading nasmesh +source init_nas_nos1 + +# Add a new loopback interface address +sudo ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up + +cd .. +cd lte_noS1_build_oai/build/ + +# Run the eNB process on one terminal (VNF) +sudo ./lte-softmodem-nos1 -O PATH_OF:rcc.band7.tm1.50PRB.nfapi.conf + +# Run the UE process on the other terminal (PNF) (--L2-emul specifying the operation in nfapi-L2-emulation mode +# and it has to be equal to 3, --num_ues specifying the number of UEs) +sudo ./lte-uesoftmodem-nos1 -U -O PATH_OF:oaiL1.nfapi.usrpb210.conf --L2-emul 3 --num-ues 5 > debug_log.txt + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.100PRB.usrpx310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.100PRB.usrpx310.conf new file mode 100644 index 0000000000000000000000000000000000000000..38e471ac545b36c4ee469867efa646d0e3d24780 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.100PRB.usrpx310.conf @@ -0,0 +1,175 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + mobile_network_code = "92"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 38; + downlink_frequency = 2600000000L; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 100; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 32; + rx_gain = 116; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -16; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -90; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -108; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + + ENB_INTERFACE_NAME_FOR_S1U = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + log_config : + { + global_log_level ="debug"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.usrpx310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.usrpx310.conf new file mode 100644 index 0000000000000000000000000000000000000000..2c11ea318701019d3e7a2e81b4889890b4f426a2 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band38.tm1.usrpx310.conf @@ -0,0 +1,175 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + mobile_network_code = "92"; + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 38; + downlink_frequency = 2600000000L; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 32; + rx_gain = 116; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -16; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -90; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -108; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + ENB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + + ENB_INTERFACE_NAME_FOR_S1U = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + log_config : + { + global_log_level ="debug"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + + } +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf new file mode 100644 index 0000000000000000000000000000000000000000..6c7c319a11239189d7c314f3d01c829441301cf2 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf @@ -0,0 +1,209 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + + mobile_network_code = "93"; + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 100; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -27; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "eth6"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth6"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 116; + eNB_instances = [0]; + + } +); + + 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 ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210-d2d.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210-d2d.conf new file mode 100644 index 0000000000000000000000000000000000000000..087f379c4d7afa36127e4a9bbf506f386eb1689c --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210-d2d.conf @@ -0,0 +1,245 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + + mobile_network_code = "93"; + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_eNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 50; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -27; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf80"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 3; + rxPool_ResourceConfig_prb_Start = 4; + rxPool_ResourceConfig_prb_End = 9; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 3; + rxPool_ResourceConfig_subframeBitmap_present = "prBs16"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "1100110011001100"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 16; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf64" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 3; + discRxPool_ResourceConfig_prb_Start = 4; + discRxPool_ResourceConfig_prb_End = 5; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 4; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs16"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "1001100110011001"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 16; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "127.0.0.3"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "lo"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.2/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth0"; + ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.4/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + + + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 125; + eNB_instances = [0]; + + } +); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index 17e89db0727d723403cc81676736858442b0f604..9645b8fbeb5cc2b2e268e340a03650d571bc28ee 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -105,6 +105,40 @@ eNBs = ue_TimersAndConstants_n310 = 20; ue_TimersAndConstants_n311 = 1; ue_TransmissionMode = 1; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf32" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 5; + discRxPool_ResourceConfig_prb_Start = 3; + discRxPool_ResourceConfig_prb_End = 21; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 0; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + } ); @@ -193,6 +227,7 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; + phy_test_mode = 1; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf index 9393872b308ad72f67f4128a47a64e5460193b02..b13962aee90335a968e72b594dc5b02b20edbaf6 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpb210.conf @@ -4,28 +4,47 @@ log_config = { hw_log_level ="info"; hw_log_verbosity ="medium"; phy_log_level ="info"; - phy_log_verbosity ="low"; - mac_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="debug"; mac_log_verbosity ="medium"; rlc_log_level ="info"; rlc_log_verbosity ="medium"; pdcp_log_level ="info"; pdcp_log_verbosity ="medium"; - rrc_log_level ="info"; - rrc_log_verbosity ="medium"; + rrc_log_level ="debug"; + rrc_log_verbosity ="full"; }; + +#L1s = ( +# { +# num_cc = 1; +# tr_n_preference = "nfapi"; +# local_n_if_name = "eno1"; +# remote_n_address = "192.168.1.28"; +# local_n_address = "192.168.1.74"; +# local_n_portc = 50000; +# remote_n_portc = 50001; +# local_n_portd = 50010; +# remote_n_portd = 50011; +# } +#); + + L1s = ( { num_cc = 1; tr_n_preference = "nfapi"; - local_n_if_name = "lo"; + #local_n_if_name = "enp0s31f6"; + #remote_n_address = "10.0.0.2"; + #local_n_address = "10.0.0.1"; + local_n_if_name = "lo"; remote_n_address = "127.0.0.2"; - local_n_address = "127.0.0.1"; - local_n_portc = 50000; - remote_n_portc = 50001; - local_n_portd = 50010; - remote_n_portd = 50011; + local_n_address = "127.0.0.1"; + local_n_portc = 50000; + remote_n_portc = 50001; + local_n_portd = 50010; + remote_n_portd = 50011; } ); @@ -34,11 +53,10 @@ RUs = ( local_rf = "yes" nb_tx = 1 nb_rx = 1 - att_tx = 0 + att_tx = 90 att_rx = 0; bands = [7,38,42,43]; max_pdschReferenceSignalPower = -27; max_rxgain = 125; - eNB_instances = [0]; } -); +); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi-STUB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi-STUB.conf new file mode 100644 index 0000000000000000000000000000000000000000..4de676ec9a42b41a83d2eaa1eda524cd60a1cb0d --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi-STUB.conf @@ -0,0 +1,201 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + + #mobile_network_code = "93"; + mobile_network_code = "92"; + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_eNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + #N_RB_DL = 50; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 115; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 0; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + #pdsch_referenceSignalPower = -27; + pdsch_referenceSignalPower = -30; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + #rach_preambleInitialReceivedTargetPower = -108; + rach_preambleInitialReceivedTargetPower = -104; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.56.102"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "vboxnet0"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.56.1/24"; + ENB_INTERFACE_NAME_FOR_S1U = "vboxnet0"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.56.1/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + local_s_if_name = "eno1"; + remote_s_address = "10.0.0.2"; + #local_s_address = "192.168.1.78"; + local_s_address = "10.0.0.1"; + local_s_portc = 50001; + remote_s_portc = 50000; + local_s_portd = 50011; + remote_s_portd = 50010; + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + } +); + + log_config : + { + global_log_level ="debug"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="debug"; + mac_log_verbosity ="high"; + rlc_log_level ="debug"; + rlc_log_verbosity ="high"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="high"; + }; + + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf index bc2b3b219c316d8750846a61a16d96aeb90e926a..03241ec694a8ea75b99cb2b06a5ba360eb002a7b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.nfapi.conf @@ -105,6 +105,40 @@ eNBs = ue_TimersAndConstants_n310 = 20; ue_TimersAndConstants_n311 = 1; ue_TransmissionMode = 1; + + //Parameters for SIB18 + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; + rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; +/* rxPool_dataHoppingConfig_hoppingParameter = 0; + rxPool_dataHoppingConfig_numSubbands = "ns1"; + rxPool_dataHoppingConfig_rbOffset = 0; + rxPool_commTxResourceUC-ReqAllowed = "TRUE"; +*/ + // Parameters for SIB19 + discRxPool_cp_Len = "normal" + discRxPool_discPeriod = "rf32" + discRxPool_numRetx = 1; + discRxPool_numRepetition = 2; + discRxPool_ResourceConfig_prb_Num = 5; + discRxPool_ResourceConfig_prb_Start = 3; + discRxPool_ResourceConfig_prb_End = 21; + discRxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + discRxPool_ResourceConfig_offsetIndicator_choice = 0; + discRxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff"; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; + discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf index aacc87e5b0c49c18d2432224e849121879a48b8a..771bf094997b62110b0394945f74f3acec5c103d 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf @@ -73,8 +73,7 @@ eNBs = srs_SubframeConfig =; srs_ackNackST =; srs_MaxUpPts =;*/ - - pusch_p0_Nominal = -96; + pusch_p0_Nominal = -104; pusch_alpha = "AL1"; pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf index 24ae36a0a4c7c671f0cc4ad4754f1d6b233397a6..8a0f5feb58687406028e6c81b78a9b4175c3adec 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf @@ -11,7 +11,7 @@ RUs = ( tr_preference = "udp_if4p5"; nb_tx = 1; nb_rx = 1; - max_pdschReferenceSignalPower = -29; + max_pdschReferenceSignalPower = -15; max_rxgain = 120; bands = [7,13]; } diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index 838ec54383f4de0dc6f6165fc374013a3f80e3b8..e50c1831b69ba1e7e49ab33f79f0df523cb15ec0 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,19 +1,19 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Tue Jul 25 20:26:12 2017 +[*] Thu Feb 22 14:46:40 2018 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Tue Jul 25 20:11:55 2017" -[dumpfile_size] 19201475 -[savefile] "/home/papillon/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" -[timestart] 29023604000 -[size] 1236 578 -[pos] 309 0 -*-20.793451 29026062100 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +[dumpfile_mtime] "Thu Feb 22 14:44:26 2018" +[dumpfile_size] 3482761 +[savefile] "/homes/wangts/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" +[timestart] 4525000000 +[size] 1920 1018 +[pos] 0 22 +*-21.506693 4530514310 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 386 -[signals_width] 262 +[signals_width] 344 [sst_expanded] 1 -[sst_vpaned_height] 146 +[sst_vpaned_height] 303 @28 functions.trx_read functions.trx_write @@ -25,12 +25,42 @@ functions.eNB_thread_rxtx0 @24 variables.frame_number_RX0_RU[63:0] variables.subframe_number_RX0_RU[63:0] -@25 variables.frame_number_TX0_RU[63:0] -@24 variables.subframe_number_TX0_RU[63:0] @28 +functions.mac_schedule_dlsch +functions.macxface_eNB_dlsch_ulsch_scheduler +functions.macxface_ue_scheduler +functions.phy_eNB_ofdm_mod_l +@24 +variables.frame_number_RX0_eNB[63:0] +@25 +variables.subframe_number_RX0_eNB[63:0] +@24 +variables.frame_number_TX0_eNB[63:0] +variables.subframe_number_TX0_eNB[63:0] +variables.frame_number_RX1_eNB[63:0] +variables.subframe_number_RX1_eNB[63:0] +variables.frame_number_TX1_eNB[63:0] +variables.subframe_number_TX1_eNB[63:0] +@28 +functions.phy_eNB_dlsch_modulation +functions.phy_eNB_dlsch_encoding +functions.phy_eNB_dlsch_scrambling +functions.phy_eNB_beam_precoding +functions.phy_enb_pdcch_tx +functions.phy_enb_prach_rx +functions.phy_procedures_ru_feprx0 +functions.phy_procedures_eNb_rx_uespec0 +functions.phy_procedures_eNb_rx_uespec1 +functions.phy_enb_sfgen functions.phy_procedures_eNb_tx0 +functions.phy_procedures_eNb_tx1 +functions.phy_procedures_ru_feprx1 +functions.phy_procedures_ru_feptx_ofdm0 +functions.phy_procedures_ru_feptx_ofdm1 +functions.phy_procedures_ru_feptx_prec0 +functions.phy_procedures_ru_feptx_prec1 functions.eNB_thread_rxtx1 functions.phy_enb_sfgen functions.phy_enb_prach_rx diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index e1c5d10de561435bae4171bbf1714f6730b63470..b84a289ffa7fa5eab1b715fb5e1584cf6238f725 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -44,7 +44,12 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/INIT/phy_init.h" + +#include "PHY/defs_eNB.h" +#include "SCHED/sched_eNB.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" + #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all @@ -55,22 +60,14 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/extern.h" - -#include "../../SIMU/USER/init_lte.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" -#include "PHY_INTERFACE/defs.h" -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif +#include "PHY/phy_extern.h" + + +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" @@ -78,7 +75,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "enb_config.h" -//#include "PHY/TOOLS/time_meas.h" + #ifndef OPENAIR2 #include "UTIL/OTG/otg_extern.h" @@ -121,7 +118,9 @@ extern int transmission_mode; extern int oaisim_flag; -uint16_t sf_ahead=4; +//uint16_t sf_ahead=4; +extern uint16_t sf_ahead; + //pthread_t main_eNB_thread; @@ -148,11 +147,13 @@ void exit_fun(const char* s); void init_eNB(int,int); void stop_eNB(int nb_inst); - +int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); +int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc); void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #endif +extern int codingw; extern uint8_t nfapi_mode; extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); @@ -211,14 +212,23 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // if this is IF5 or 3GPP_eNB if (eNB && eNB->RU_list && eNB->RU_list[0] && eNB->RU_list[0]->function < NGFI_RAU_IF4p5) { wakeup_prach_eNB(eNB,NULL,proc->frame_rx,proc->subframe_rx); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) wakeup_prach_eNB_br(eNB,NULL,proc->frame_rx,proc->subframe_rx); #endif } // UE-specific RX processing for subframe n if (nfapi_mode == 0 || nfapi_mode == 1) { - phy_procedures_eNB_uespec_RX(eNB, proc, no_relay ); + phy_procedures_eNB_uespec_RX(eNB, proc); + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 ); + + if(get_nprocs() >= 8){ + if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) { + LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx); + return(-1); + } + if (release_thread(&proc[1].mutex_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) return(-1); } pthread_mutex_lock(&eNB->UL_INFO_mutex); @@ -231,17 +241,12 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam eNB->if_inst->UL_indication(&eNB->UL_INFO); pthread_mutex_unlock(&eNB->UL_INFO_mutex); - - // ***************************************** - // TX processing for subframe n+sf_ahead - // run PHY TX procedures the one after the other for all CCs to avoid race conditions - // (may be relaxed in the future for performance reasons) - // ***************************************** - //if (wait_CCs(proc)<0) return(-1); - - if (oai_exit) return(-1); - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); + if(oai_exit) return(-1); + if(get_nprocs() <= 4){ + phy_procedures_eNB_TX(eNB, proc, 1); + } stop_meas( &softmodem_stats_rxtx_sf ); @@ -293,6 +298,50 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam } +static void* tx_thread(void* param) { + + eNB_proc_t *eNB_proc = (eNB_proc_t*)param; + eNB_rxtx_proc_t *proc = &eNB_proc->proc_rxtx[1]; + PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; + + char thread_name[100]; + sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); + thread_top_init(thread_name,1,470000,500000,500000); + + //wait_sync("tx_thread"); + + while (!oai_exit) { + + + if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + if (oai_exit) break; + // ***************************************** + // TX processing for subframe n+4 + // run PHY TX procedures the one after the other for all CCs to avoid race conditions + // (may be relaxed in the future for performance reasons) + // ***************************************** + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX1_ENB,proc->subframe_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX1_ENB,proc->subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_ENB,proc->frame_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx); + + phy_procedures_eNB_TX(eNB, proc, 1); + if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + + pthread_mutex_lock( &proc->mutex_rxtx ); + proc->pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_rxtx ); + wakeup_txfh(proc,eNB_proc->ru_proc); + } + + return 0; +} + /*! * \brief The RX UE-specific and TX thread of eNB. * \param param is a \ref eNB_proc_t structure which contains the info what to process. @@ -302,36 +351,77 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam static void* eNB_thread_rxtx( void* param ) { static int eNB_thread_rxtx_status; + //eNB_proc_t *eNB_proc = (eNB_proc_t*)param; + eNB_rxtx_proc_t *proc; + + // Working + if(nfapi_mode ==2){ + proc = (eNB_rxtx_proc_t*)param; + } + else{ + eNB_proc_t *eNB_proc = (eNB_proc_t*)param; + proc = &eNB_proc->proc_rxtx[0]; + } + - eNB_rxtx_proc_t *proc = (eNB_rxtx_proc_t*)param; PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; + //RU_proc_t *ru_proc = NULL; char thread_name[100]; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); // set default return value eNB_thread_rxtx_status = 0; - sprintf(thread_name,"RXn_TXnp4_%d",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); - thread_top_init(thread_name,1,850000L,1000000L,2000000L); + sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); + thread_top_init(thread_name,1,470000,500000,500000); + pthread_setname_np( pthread_self(),"rxtx processing"); + LOG_I(PHY,"thread rxtx created id=%ld\n", syscall(__NR_gettid)); + + while (!oai_exit) { + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); + T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_ENB_THREAD_RXTX,sched_getcpu()); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 1 ); + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB,proc->subframe_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_ENB,proc->subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB,proc->frame_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB,proc->frame_rx); + if (oai_exit) break; if (eNB->CC_id==0) { if (rxtx(eNB,proc,thread_name) < 0) break; - } if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + pthread_mutex_lock( &proc->mutex_rxtx ); + proc->pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_rxtx ); + if(get_nprocs() >= 8) wakeup_tx(eNB,eNB->proc.ru_proc); + else + { + phy_procedures_eNB_TX(eNB, proc, 1); + wakeup_txfh(proc,eNB->proc.ru_proc); + } } // while !oai_exit @@ -367,10 +457,12 @@ static void wait_system_ready (char *message, volatile int *start_flag) { -void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) +void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru) { eNB_proc_t *proc = &eNB->proc; eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; + LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; + RU_proc_t *ru_proc=&ru->proc; proc->frame_rx = frame_rx; proc->subframe_rx = subframe_rx; @@ -378,23 +470,115 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) if (!oai_exit) { T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); - proc_rxtx->subframe_rx = proc->subframe_rx; - proc_rxtx->frame_rx = proc->frame_rx; - proc_rxtx->subframe_tx = (proc->subframe_rx+sf_ahead)%10; - proc_rxtx->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (1+proc->frame_rx)&1023 : proc->frame_rx; - proc->frame_tx = proc_rxtx->frame_tx; - proc_rxtx->timestamp_tx = proc->timestamp_tx; + proc_rxtx->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); + proc_rxtx->frame_rx = ru_proc->frame_rx; + proc_rxtx->subframe_rx = ru_proc->subframe_rx; + proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > (9-sf_ahead)) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; + proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + sf_ahead)%10; if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); + ru_proc->timestamp_tx = proc_rxtx->timestamp_tx; + ru_proc->subframe_tx = proc_rxtx->subframe_tx; + ru_proc->frame_tx = proc_rxtx->frame_tx; } } +int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { + + if(ru_proc == NULL) + return(0); + struct timespec wait; + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + + if(wait_on_condition(&ru_proc->mutex_eNBs,&ru_proc->cond_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) { + LOG_E(PHY,"Frame %d, subframe %d: TX FH not ready\n", ru_proc->frame_tx, ru_proc->subframe_tx); + return(-1); + } + if (release_thread(&ru_proc->mutex_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) return(-1); + + if (ru_proc->instance_cnt_eNBs == 0) { + LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc->frame_rx, proc->subframe_rx); + return(-1); + } + if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", ru_proc->subframe_rx&1,ru_proc->instance_cnt_eNBs ); + exit_fun( "error locking mutex_eNB" ); + return(-1); + } + + ++ru_proc->instance_cnt_eNBs; + ru_proc->timestamp_tx = proc->timestamp_tx; + ru_proc->subframe_tx = proc->subframe_tx; + ru_proc->frame_tx = proc->frame_tx; + + // the thread can now be woken up + if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock( &ru_proc->mutex_eNBs ); + + return(0); +} + +int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { + + eNB_proc_t *proc=&eNB->proc; + + eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; + + + struct timespec wait; + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + + + if (proc_rxtx1->instance_cnt_rxtx == 0) { + LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); + return(-1); + } + + if (pthread_mutex_timedlock(&proc_rxtx1->mutex_rxtx,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", proc_rxtx1->subframe_rx&1,proc_rxtx1->instance_cnt_rxtx ); + exit_fun( "error locking mutex_tx" ); + return(-1); + } + + ++proc_rxtx1->instance_cnt_rxtx; + + + proc_rxtx1->subframe_rx = proc_rxtx0->subframe_rx; + proc_rxtx1->frame_rx = proc_rxtx0->frame_rx; + proc_rxtx1->subframe_tx = proc_rxtx0->subframe_tx; + proc_rxtx1->frame_tx = proc_rxtx0->frame_tx; + proc_rxtx1->timestamp_tx = proc_rxtx0->timestamp_tx; + + // the thread can now be woken up + if (pthread_cond_signal(&proc_rxtx1->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock( &proc_rxtx1->mutex_rxtx ); + + return(0); +} int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { eNB_proc_t *proc=&eNB->proc; + RU_proc_t *ru_proc=&ru->proc; - eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + //eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; @@ -426,25 +610,28 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; - /* accept some delay in processing - up to 5ms */ - for (i = 0; i < 10 && proc_rxtx->instance_cnt_rxtx == 0; i++) { - LOG_W( PHY,"[eNB] Frame %d Subframe %d, eNB RXn-TXnp4 thread busy!! (cnt_rxtx %i)\n", proc_rxtx->frame_tx, proc_rxtx->subframe_tx, proc_rxtx->instance_cnt_rxtx); - usleep(500); + + if(wait_on_condition(&proc_rxtx0->mutex_rxtx,&proc_rxtx0->cond_rxtx,&proc_rxtx0->pipe_ready,"wakeup_rxtx")<0) { + LOG_E(PHY,"Frame %d, subframe %d: RXTX0 not ready\n",proc_rxtx0->frame_rx,proc_rxtx0->subframe_rx); + return(-1); } - if (proc_rxtx->instance_cnt_rxtx == 0) { - exit_fun( "TX thread busy" ); + if (release_thread(&proc_rxtx0->mutex_rxtx,&proc_rxtx0->pipe_ready,"wakeup_rxtx")<0) return(-1); + + if (proc_rxtx0->instance_cnt_rxtx == 0) { + LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx0->frame_rx,proc_rxtx0->subframe_rx); return(-1); } // wake up TX for subframe n+sf_ahead // lock the TX mutex and make sure the thread is ready - if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); + if (pthread_mutex_timedlock(&proc_rxtx0->mutex_rxtx,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx0->subframe_rx&1,proc_rxtx0->instance_cnt_rxtx ); exit_fun( "error locking mutex_rxtx" ); return(-1); } - ++proc_rxtx->instance_cnt_rxtx; + + ++proc_rxtx0->instance_cnt_rxtx; // We have just received and processed the common part of a subframe, say n. // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired @@ -452,20 +639,20 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { // 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 - proc_rxtx->timestamp_tx = proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); - proc_rxtx->frame_rx = proc->frame_rx; - proc_rxtx->subframe_rx = proc->subframe_rx; - proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > (9-sf_ahead)) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; - proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + sf_ahead)%10; + proc_rxtx0->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); + proc_rxtx0->frame_rx = ru_proc->frame_rx; + proc_rxtx0->subframe_rx = ru_proc->subframe_rx; + proc_rxtx0->frame_tx = (proc_rxtx0->subframe_rx > (9-sf_ahead)) ? (proc_rxtx0->frame_rx+1)&1023 : proc_rxtx0->frame_rx; + proc_rxtx0->subframe_tx = (proc_rxtx0->subframe_rx + sf_ahead)%10; // the thread can now be woken up - if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { + if (pthread_cond_signal(&proc_rxtx0->cond_rxtx) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - pthread_mutex_unlock( &proc_rxtx->mutex_rxtx ); + pthread_mutex_unlock( &proc_rxtx0->mutex_rxtx ); return(0); } @@ -529,7 +716,7 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { eNB_proc_t *proc = &eNB->proc; @@ -605,8 +792,9 @@ static void* eNB_thread_prach( void* param ) { // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach",1,500000L,1000000L,20000000L); + thread_top_init("eNB_thread_prach",1,500000,1000000,20000000); + //wait_sync("eNB_thread_prach"); while (!oai_exit) { @@ -617,7 +805,7 @@ static void* eNB_thread_prach( void* param ) { LOG_D(PHY,"Running eNB prach procedures\n"); prach_procedures(eNB -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,0 #endif ); @@ -631,7 +819,7 @@ static void* eNB_thread_prach( void* param ) { return &eNB_thread_prach_status; } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /*! * \brief The prach receive thread of eNB for BL/CE UEs. * \param param is a \ref eNB_proc_t structure which contains the info what to process. @@ -647,7 +835,7 @@ static void* eNB_thread_prach_br( void* param ) { // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach_br",1,500000L,1000000L,20000000L); + thread_top_init("eNB_thread_prach_br",1,500000,1000000,20000000); while (!oai_exit) { @@ -671,8 +859,40 @@ static void* eNB_thread_prach_br( void* param ) { #endif -extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); + +extern void init_td_thread(PHY_VARS_eNB *); +extern void init_te_thread(PHY_VARS_eNB *); +extern void kill_td_thread(PHY_VARS_eNB *); +extern void kill_te_thread(PHY_VARS_eNB *); +//////////////////////////////////////need to modified////////////////***** + +static void* process_stats_thread(void* param) { + + PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)param; + + wait_sync("process_stats_thread"); + + while (!oai_exit) { + sleep(1); + if (opp_enabled == 1) { + if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); + if (eNB->te) + { + print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL); + print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_signal_stats,"coding_signal",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_main_stats,"coding_main",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_waiting_stats,"coding_wait",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0,"coding_worker_0",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1,"coding_worker_1",NULL,NULL); + } + print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL); + } + } + return(NULL); +} + void init_eNB_proc(int inst) { @@ -682,8 +902,7 @@ void init_eNB_proc(int inst) { eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL; - //*attr_td=NULL,*attr_te=NULL; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_attr_t *attr_prach_br=NULL; #endif @@ -699,8 +918,11 @@ void init_eNB_proc(int inst) { proc_rxtx = proc->proc_rxtx; proc_rxtx[0].instance_cnt_rxtx = -1; proc_rxtx[1].instance_cnt_rxtx = -1; + proc_rxtx[0].pipe_ready = 0; + proc_rxtx[1].pipe_ready = 0; proc->instance_cnt_prach = -1; proc->instance_cnt_asynch_rxtx = -1; + proc->instance_cnt_synch = -1; proc->CC_id = CC_id; proc->first_rx=1; @@ -724,11 +946,9 @@ void init_eNB_proc(int inst) { pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_asynch_rxtx); - // pthread_attr_init( &proc->attr_td); - // pthread_attr_init( &proc->attr_te); pthread_attr_init( &proc_rxtx[0].attr_rxtx); pthread_attr_init( &proc_rxtx[1].attr_rxtx); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) proc->instance_cnt_prach_br = -1; proc->RU_mask_prach_br=0; pthread_mutex_init( &proc->mutex_prach_br, NULL); @@ -740,13 +960,31 @@ void init_eNB_proc(int inst) { attr0 = &proc_rxtx[0].attr_rxtx; attr1 = &proc_rxtx[1].attr_rxtx; attr_prach = &proc->attr_prach; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) attr_prach_br = &proc->attr_prach_br; #endif // attr_td = &proc->attr_td; // attr_te = &proc->attr_te; #endif + //////////////////////////////////////need to modified////////////////***** + if(get_nprocs() > 2 && codingw) + { + init_te_thread(eNB); + init_td_thread(eNB); + } + //////////////////////////////////////need to modified////////////////***** + //pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); + + //pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc_rxtx ); + + + // Panos: Should we also include here the case where single_thread_flag = 1 ? + if(nfapi_mode!=2){ + pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); + pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc); + } + LOG_I(PHY,"eNB->single_thread_flag:%d\n", eNB->single_thread_flag); @@ -755,7 +993,7 @@ void init_eNB_proc(int inst) { pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); } pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, eNB ); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_create( &proc->pthread_prach_br, attr_prach_br, eNB_thread_prach_br, eNB ); #endif char name[16]; @@ -767,6 +1005,9 @@ void init_eNB_proc(int inst) { } AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); + + + if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); } @@ -792,6 +1033,8 @@ void init_eNB_proc(int inst) { pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); sync_phy_proc.phy_proc_CC_id = 0; + + } @@ -805,21 +1048,22 @@ void kill_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; + int i; for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { eNB=RC.eNB[inst][CC_id]; proc = &eNB->proc; proc_rxtx = &proc->proc_rxtx[0]; + kill_td_thread(eNB); + kill_te_thread(eNB); LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst ); - - if (eNB->single_thread_flag==0) { - pthread_mutex_lock(&proc_rxtx[0].mutex_rxtx); - proc_rxtx[0].instance_cnt_rxtx = 0; - pthread_mutex_unlock(&proc_rxtx[0].mutex_rxtx); - pthread_mutex_lock(&proc_rxtx[1].mutex_rxtx); - proc_rxtx[1].instance_cnt_rxtx = 0; - pthread_mutex_unlock(&proc_rxtx[1].mutex_rxtx); + for (i=0; i<2; i++) { + pthread_mutex_lock(&proc_rxtx[i].mutex_rxtx); + proc_rxtx[i].instance_cnt_rxtx = 0; + proc_rxtx[i].pipe_ready = 0; + pthread_cond_signal(&proc_rxtx[i].cond_rxtx); + pthread_mutex_unlock(&proc_rxtx[i].mutex_rxtx); } proc->instance_cnt_prach = 0; pthread_cond_signal( &proc->cond_prach ); @@ -833,7 +1077,7 @@ void kill_eNB_proc(int inst) { LOG_I(PHY, "Destroying prach mutex/cond\n"); pthread_mutex_destroy( &proc->mutex_prach ); pthread_cond_destroy( &proc->cond_prach ); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) proc->instance_cnt_prach_br = 0; pthread_cond_signal( &proc->cond_prach_br ); pthread_join( proc->pthread_prach_br, (void**)&status ); @@ -842,15 +1086,12 @@ void kill_eNB_proc(int inst) { #endif LOG_I(PHY, "Destroying UL_INFO mutex\n"); pthread_mutex_destroy(&eNB->UL_INFO_mutex); - int i; - if (eNB->single_thread_flag==0) { - for (i=0;i<2;i++) { - LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); - pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); - LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); - pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); - pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); - } + for (i=0;i<2;i++) { + LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); + pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); + LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); + pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); + pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); } } } @@ -986,7 +1227,7 @@ void init_eNB_afterRU(void) { LOG_I(PHY,"Overwriting eNB->prach_vars.rxsigF[0]:%p\n", eNB->prach_vars.rxsigF[0]); eNB->prach_vars.rxsigF[0] = (int16_t**)malloc16(64*sizeof(int16_t*)); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) for (int ce_level=0;ce_level<4;ce_level++) { LOG_I(PHY,"Overwriting eNB->prach_vars_br.rxsigF.rxsigF[0]:%p\n", eNB->prach_vars_br.rxsigF[ce_level]); eNB->prach_vars_br.rxsigF[ce_level] = (int16_t**)malloc16(64*sizeof(int16_t*)); @@ -1009,7 +1250,7 @@ void init_eNB_afterRU(void) { for (i=0;i<eNB->RU_list[ru_id]->nb_rx;aa++,i++) { LOG_I(PHY,"Attaching RU %d antenna %d to eNB antenna %d\n",eNB->RU_list[ru_id]->idx,i,aa); eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[ru_id]->prach_rxsigF[i]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) for (int ce_level=0;ce_level<4;ce_level++) eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[ru_id]->prach_rxsigF_br[ce_level][i]; #endif @@ -1062,7 +1303,7 @@ void init_eNB_afterRU(void) { RC.ru[ru_id]->wakeup_rxtx = wakeup_rxtx; RC.ru[ru_id]->wakeup_prach_eNB = wakeup_prach_eNB; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.ru[ru_id]->wakeup_prach_eNB_br = wakeup_prach_eNB_br; #endif RC.ru[ru_id]->eNB_top = eNB_top; @@ -1094,8 +1335,8 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { #endif - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; + eNB->td = ulsch_decoding_data_all;//(get_nprocs()<=4) ? ulsch_decoding_data : ulsch_decoding_data_2thread; + eNB->te = dlsch_encoding_all;//(get_nprocs()<=4) ? dlsch_encoding : dlsch_encoding_2threads; LOG_I(PHY,"Registering with MAC interface module\n"); diff --git a/targets/RT/USER/lte-ran.c b/targets/RT/USER/lte-ran.c deleted file mode 100644 index 597ceb0654c6a621df341e84637990efb1aa1b74..0000000000000000000000000000000000000000 --- a/targets/RT/USER/lte-ran.c +++ /dev/null @@ -1,1747 +0,0 @@ -/******************************************************************************* - OpenAirInterface - Copyright(c) 1999 - 2014 Eurecom - - OpenAirInterface is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - - OpenAirInterface is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OpenAirInterface.The full GNU General Public License is - included in this distribution in the file called "COPYING". If not, - see <http://www.gnu.org/licenses/>. - - Contact Information - OpenAirInterface Admin: openair_admin@eurecom.fr - OpenAirInterface Tech : openair_tech@eurecom.fr - OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr - - Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE - -*******************************************************************************/ - -/*! \file lte-enb.c - * \brief Top-level threads for eNodeB - * \author R. Knopp, F. Kaltenberger, Navid Nikaein - * \date 2012 - * \version 0.1 - * \company Eurecom - * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr - * \note - * \warning - */ -#define _GNU_SOURCE -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sched.h> -#include <linux/sched.h> -#include <signal.h> -#include <execinfo.h> -#include <getopt.h> -#include <sys/sysinfo.h> -#include "rt_wrapper.h" - -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all - -#include "assertions.h" -#include "msc.h" - -#include "PHY/types.h" - -#include "PHY/defs.h" -#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all -//#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all - -#include "../../ARCH/COMMON/common_lib.h" - -//#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all - -#include "PHY/LTE_TRANSPORT/if4_tools.h" -#include "PHY/LTE_TRANSPORT/if5_tools.h" - -#include "PHY/extern.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/extern.h" - -#include "../../SIMU/USER/init_lte.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" - -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif -#include "UTIL/LOG/log_extern.h" -#include "UTIL/OTG/otg_tx.h" -#include "UTIL/OTG/otg_externs.h" -#include "UTIL/MATH/oml.h" -#include "UTIL/LOG/vcd_signal_dumper.h" -#include "UTIL/OPT/opt.h" -#include "enb_config.h" -//#include "PHY/TOOLS/time_meas.h" - -#ifndef OPENAIR2 -#include "UTIL/OTG/otg_extern.h" -#endif - -#if defined(ENABLE_ITTI) -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -#ifdef PDCP_USE_NETLINK -# include "SIMULATION/ETH_TRANSPORT/proto.h" -#endif -# endif -#endif - -#include "T.h" - -//#define DEBUG_THREADS 1 - -//#define USRP_DEBUG 1 -struct timing_info_t { - //unsigned int frame, hw_slot, last_slot, next_slot; - RTIME time_min, time_max, time_avg, time_last, time_now; - //unsigned int mbox0, mbox1, mbox2, mbox_target; - unsigned int n_samples; -} timing_info; - -// Fix per CC openair rf/if device update -// extern openair0_device openair0; - -#if defined(ENABLE_ITTI) -extern volatile int start_eNB; -extern volatile int start_UE; -#endif -extern volatile int oai_exit; - -extern openair0_config_t openair0_cfg[MAX_CARDS]; - -extern pthread_cond_t sync_cond; -extern pthread_mutex_t sync_mutex; -extern int sync_var; - -//pthread_t main_eNB_thread; - -time_stats_t softmodem_stats_mt; // main thread -time_stats_t softmodem_stats_hw; // hw acquisition -time_stats_t softmodem_stats_rxtx_sf; // total tx time -time_stats_t softmodem_stats_rx_sf; // total rx time -int32_t **rxdata; -int32_t **txdata; - -uint8_t seqno; //sequence number - -static int time_offset[4] = {0,0,0,0}; - -/* mutex, cond and variable to serialize phy proc TX calls - * (this mechanism may be relaxed in the future for better - * performances) - */ -static struct { - pthread_mutex_t mutex_phy_proc_tx; - pthread_cond_t cond_phy_proc_tx; - volatile uint8_t phy_proc_CC_id; -} sync_phy_proc; - -void exit_fun(const char* s); - -void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *,int); -void stop_eNB(int nb_inst); -void init_RU(RAN_CONTEXT *rc, eNB_func_t node_function, RU_if_in_t ru_if_in[], RU_if_timing_t ru_if_timing[], eth_params_t *eth_params); -void stop_RU(); - -// Generic thread initialisation function -static inline void thread_top_init(char *thread_name, - int affinity, - uint64_t runtime, - uint64_t deadline, - uint64_t period) { - - MSC_START_USE(); - -#ifdef DEADLINE_SCHEDULER - struct sched_attr attr; - - unsigned int flags = 0; - - attr.size = sizeof(attr); - attr.sched_flags = 0; - attr.sched_nice = 0; - attr.sched_priority = 0; - - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = runtime; - attr.sched_deadline = deadline; - attr.sched_period = period; - - if (sched_setattr(0, &attr, flags) < 0 ) { - perror("[SCHED] eNB tx thread: sched_setattr failed\n"); - exit_fun("Error setting deadline scheduler"); - } - - LOG_I( HW, "[SCHED] eNB %s deadline thread started on CPU %d\n", thread_name,sched_getcpu() ); - -#else //LOW_LATENCY - int policy, s, j; - struct sched_param sparam; - char cpu_affinity[1024]; - cpu_set_t cpuset; - - /* Set affinity mask to include CPUs 1 to MAX_CPUS */ - /* CPU 0 is reserved for UHD threads */ - /* CPU 1 is reserved for all RX_TX threads */ - /* Enable CPU Affinity only if number of CPUs >2 */ - CPU_ZERO(&cpuset); - -#ifdef CPU_AFFINITY - if (get_nprocs() > 2) - { - if (affinity == 0) - CPU_SET(0,&cpuset); - else - for (j = 1; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); - s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror( "pthread_setaffinity_np"); - exit_fun("Error setting processor affinity"); - } - } -#endif //CPU_AFFINITY - - /* Check the actual affinity mask assigned to the thread */ - s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) { - perror( "pthread_getaffinity_np"); - exit_fun("Error getting processor affinity "); - } - memset(cpu_affinity,0,sizeof(cpu_affinity)); - for (j = 0; j < CPU_SETSIZE; j++) - if (CPU_ISSET(j, &cpuset)) { - char temp[1024]; - sprintf (temp, " CPU_%d", j); - strcat(cpu_affinity, temp); - } - - memset(&sparam, 0, sizeof(sparam)); - sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); - policy = SCHED_FIFO ; - - s = pthread_setschedparam(pthread_self(), policy, &sparam); - if (s != 0) { - perror("pthread_setschedparam : "); - exit_fun("Error setting thread priority"); - } - - s = pthread_getschedparam(pthread_self(), &policy, &sparam); - if (s != 0) { - perror("pthread_getschedparam : "); - exit_fun("Error getting thread priority"); - } - - LOG_I(HW, "[SCHED][eNB] %s started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(),gettid(), - (policy == SCHED_FIFO) ? "SCHED_FIFO" : - (policy == SCHED_RR) ? "SCHED_RR" : - (policy == SCHED_OTHER) ? "SCHED_OTHER" : - "???", - sparam.sched_priority, cpu_affinity ); - -#endif //LOW_LATENCY - - mlockall(MCL_CURRENT | MCL_FUTURE); - -} - -static inline void wait_sync(char *thread_name) { - - printf( "waiting for sync (%s)\n",thread_name); - pthread_mutex_lock( &sync_mutex ); - - while (sync_var<0) - pthread_cond_wait( &sync_cond, &sync_mutex ); - - pthread_mutex_unlock(&sync_mutex); - - printf( "got sync (%s)\n", thread_name); - -} - -// RU OFDM Modulator, used in IF4p5 RRU, RCC/RAU with IF5, eNodeB - -void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) { - - unsigned int aa,slot_offset, slot_offset_F; - int dummy_tx_b[7680*4] __attribute__((aligned(32))); - int i,j, tx_offset; - int slot_sizeF = (phy_vars_eNB->frame_parms.ofdm_symbol_size)* - ((phy_vars_eNB->frame_parms.Ncp==1) ? 6 : 7); - int len,len2; - int16_t *txdata; -// int CC_id = phy_vars_eNB->proc.CC_id; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 ); - - slot_offset_F = (subframe<<1)*slot_sizeF; - - slot_offset = subframe*phy_vars_eNB->frame_parms.samples_per_tti; - - if ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_DL)|| - ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_S))) { - // LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot); - - for (aa=0; aa<phy_vars_eNB->frame_parms.nb_antennas_tx; aa++) { - if (phy_vars_eNB->frame_parms.Ncp == EXTENDED) { - PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F], - dummy_tx_b, - phy_vars_eNB->frame_parms.ofdm_symbol_size, - 6, - phy_vars_eNB->frame_parms.nb_prefix_samples, - CYCLIC_PREFIX); - PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF], - dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1), - phy_vars_eNB->frame_parms.ofdm_symbol_size, - 6, - phy_vars_eNB->frame_parms.nb_prefix_samples, - CYCLIC_PREFIX); - } else { - normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F], - dummy_tx_b, - 7, - &(phy_vars_eNB->frame_parms)); - // if S-subframe generate first slot only - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) - normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF], - dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1), - 7, - &(phy_vars_eNB->frame_parms)); - } - - // if S-subframe generate first slot only - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) - len = phy_vars_eNB->frame_parms.samples_per_tti>>1; - else - len = phy_vars_eNB->frame_parms.samples_per_tti; - /* - for (i=0;i<len;i+=4) { - dummy_tx_b[i] = 0x100; - dummy_tx_b[i+1] = 0x01000000; - dummy_tx_b[i+2] = 0xff00; - dummy_tx_b[i+3] = 0xff000000; - }*/ - - if (slot_offset+time_offset[aa]<0) { - txdata = (int16_t*)&phy_vars_eNB->common_vars.txdata[0][aa][(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)+tx_offset]; - len2 = -(slot_offset+time_offset[aa]); - len2 = (len2>len) ? len : len2; - for (i=0; i<(len2<<1); i++) { - txdata[i] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift; - } - if (len2<len) { - txdata = (int16_t*)&phy_vars_eNB->common_vars.txdata[0][aa][0]; - for (j=0; i<(len<<1); i++,j++) { - txdata[j++] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift; - } - } - } - else if ((slot_offset+time_offset[aa]+len)>(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) { - tx_offset = (int)slot_offset+time_offset[aa]; - txdata = (int16_t*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset]; - len2 = -tx_offset+LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - for (i=0; i<(len2<<1); i++) { - txdata[i] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift; - } - txdata = (int16_t*)&phy_vars_eNB->common_vars.txdata[0][aa][0]; - for (j=0; i<(len<<1); i++,j++) { - txdata[j++] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift; - } - } - else { - tx_offset = (int)slot_offset+time_offset[aa]; - txdata = (int16_t*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset]; - - for (i=0; i<(len<<1); i++) { - txdata[i] = ((int16_t*)dummy_tx_b)[i]<<openair0_cfg[0].iq_txshift; - } - } - - // if S-subframe switch to RX in second subframe - /* - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) { - for (i=0; i<len; i++) { - phy_vars_eNB->common_vars.txdata[0][aa][tx_offset++] = 0x00010001; - } - } - */ - if ((((phy_vars_eNB->frame_parms.tdd_config==0) || - (phy_vars_eNB->frame_parms.tdd_config==1) || - (phy_vars_eNB->frame_parms.tdd_config==2) || - (phy_vars_eNB->frame_parms.tdd_config==6)) && - (subframe==0)) || (subframe==5)) { - // turn on tx switch N_TA_offset before - //LOG_D(HW,"subframe %d, time to switch to tx (N_TA_offset %d, slot_offset %d) \n",subframe,phy_vars_eNB->N_TA_offset,slot_offset); - for (i=0; i<phy_vars_eNB->N_TA_offset; i++) { - tx_offset = (int)slot_offset+time_offset[aa]+i-phy_vars_eNB->N_TA_offset/2; - if (tx_offset<0) - tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - - if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) - tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - - phy_vars_eNB->common_vars.txdata[0][aa][tx_offset] = 0x00000000; - } - } - } - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 0 ); -} - - - -void proc_tx_high0(RU_t *ru, - eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn) { - - int offset = proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB+offset, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB+offset, proc->subframe_tx ); - - phy_procedures_eNB_TX(eNB,proc,r_type,rn,1); - - /* we're done, let the next one proceed */ - if (pthread_mutex_lock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX proc\n"); - exit_fun("nothing to add"); - } - sync_phy_proc.phy_proc_CC_id++; - sync_phy_proc.phy_proc_CC_id %= MAX_NUM_CCs; - pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); - if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX proc\n"); - exit_fun("nothing to add"); - } - -} - -/* -void proc_tx_high(RU_t *ru, - eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn) { - - - // do PHY high - proc_tx_high0(eNB,proc,r_type,rn); - - // if TX fronthaul go ahead - if (eNB->tx_fh) eNB->tx_fh(eNB,proc); - -} - -void proc_tx_full(RU_t *ru, - eNB_rxtx_proc_t *proc, - relaying_type_t r_type, - PHY_VARS_RN *rn) { - - - // do PHY high - proc_tx_high0(eNB,proc,r_type,rn); - - - - -} -*/ - -// RU IF5 TX fronthaul for 16-bit OAI format -static inline void tx_rcc_if5(PHY_vars_eNB_t *ru,ru_proc_t *proc) { - if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, eNB->timestamp_tx&0xffffffff ); - send_IF5(ru, proc->timestamp_txp proc->subframe_tx, &seqno, IF5_RRH_GW_DL); -} - -// RCC IF5 TX fronthaul for Mobipass packet format -static inline void tx_rcc_if5_mobipass(PHY_VARS_eNB_t *eNB,ru_proc_t *proc) { - if (eNB == RC.eNB[0][p]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, eNB->timestamp_tx&0xffffffff ); - send_IF5(ru, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); -} - -// RCC IF4p5 TX fronthaul -static inline void tx_rcc_if4p5(PHY_VARS_eNB_t *eNB,eNB_rxtx_proc_t *proc) { - send_IF4p5(eNB,proc->frame_tx, proc->subframe_tx, IF4p5_PDLFFT, 0); -} - -// RAU IF5 TX fronthaul for 16-bit OAI format -static inline void tx_ru_if5(RU_t *ru) { - if (ru == RC.ru_list[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); - send_IF5(eNB, ru->proc.timestamp_txp ru->proc.subframe_tx, &seqno, IF5_RRH_GW_DL); -} - -// RAU IF5 TX fronthaul for Mobipass packet format -static inline void tx_ru_if5_mobipass(RU_t *ru) { - if (ru == RC.ru_list[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); - send_IF5(eNB, ru->proc.timestamp_tx, ru->proc.subframe_tx, &seqno, IF5_MOBIPASS); -} - -// RAU IF4p5 TX fronthaul -static inline void tx_fh_if4p5(RU_t *ru) { - send_IF4p5(eNB,proc->frame_tx, proc->subframe_tx, IF4p5_PDLFFT, 0); -} - - -// RRU/RAU IF4p5 TX fronthaul receiver. Assumes an if_device on input and if or rf device on output -// receives one subframe's worth of IF4p5 OFDM symbols and precodes (if required for RAU function) modulates via IDFT + prefix insertion (if required for RRU function) -void proc_tx_ru_if4p5(RU_t *ru) { - - uint32_t symbol_number=0; - uint32_t symbol_mask, symbol_mask_full; - uint16_t packet_type; - ru_proc_t = &ru->proc; - - // dump VCD output for first RU in list - if (ru == RC.ru_list[0]) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, proc->subframe_tx ); - } - /// **** incoming IF4p5 from remote RCC/RAU **** /// - symbol_number = 0; - symbol_mask = 0; - symbol_mask_full = (1<<ru->frame_parms.symbols_per_tti)-1; - - for (PHY_VARS_eNB *eNB_tx = ru->eNB_list[0],i=0; eNB_tx[i] != NULL ; i++) { - do { - recv_IF4p5(ru, &proc->frame_tx, &proc->subframe_tx, &packet_type, &symbol_number); - symbol_mask = symbol_mask | (1<<symbol_number); - } while (symbol_mask != symbol_mask_full); - if (ru->do_precoding) ru->do_precoding(i,ru); - } - // do OFDM modulation if needed - if (ru->do_OFDM_mod) ru->do_OFDM_mod(ru); - - // do outgoing TX fronthaul if needed - if (ru->tx_fh) ru->tx_fh(ru); -} - -void proc_tx_ru_if5(RU_t *ru) { - - - if (ru == RC.ru_list[0]) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB, ru->proc.frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB, ru->proc.subframe_tx ); - } - - /// **** recv_IF5 of txdata from BBU **** /// - recv_IF5(eNB, &ru->timestamp_tx, proc->subframe_tx, IF5_RRH_GW_DL); - - // do OFDM modulation if needed - if (ru->do_OFDM_mod) ru->do_OFDM_mod(ru); - - // do outgoing TX fronthaul if needed - if (ru->tx_fh) ru->tx_fh(ru); -} - -int wait_CCs(eNB_rxtx_proc_t *proc) { - - struct timespec wait; - - wait.tv_sec=0; - wait.tv_nsec=5000000L; - - if (pthread_mutex_timedlock(&sync_phy_proc.mutex_phy_proc_tx,&wait) != 0) { - LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX\n"); - exit_fun("nothing to add"); - return(-1); - } - - // wait for our turn or oai_exit - while (sync_phy_proc.phy_proc_CC_id != proc->CC_id && !oai_exit) { - pthread_cond_wait(&sync_phy_proc.cond_phy_proc_tx, - &sync_phy_proc.mutex_phy_proc_tx); - } - - if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX\n"); - exit_fun("nothing to add"); - return(-1); - } - return(0); -} - -static inline int rxtx(PHY_VARS_eNB eNB_t *eNB,eNB_rxtx_proc_t *proc, char *thread_name) { - - start_meas(&softmodem_stats_rxtx_sf); - // **************************************** - // Common RX procedures subframe n - phy_procedures_eNB_common_RX(eNB); - - // UE-specific RX processing for subframe n - if (eNB->proc_uespec_rx) eNB->proc_uespec_rx(eNB, proc, no_relay ); - - // ***************************************** - // TX processing for subframe n+4 - // run PHY TX procedures the one after the other for all CCs to avoid race conditions - // (may be relaxed in the future for performance reasons) - // ***************************************** - //if (wait_CCs(proc)<0) return(-1); - - if (oai_exit) return(-1); - - if (eNB->proc_tx) eNB->proc_tx(eNB, proc, no_relay, NULL ); - - if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1); - - stop_meas( &softmodem_stats_rxtx_sf ); - - return(0); -} - -/*! - * \brief The RX UE-specific and TX thread of eNB. - * \param param is a \ref eNB_proc_t structure which contains the info what to process. - * \returns a pointer to an int. The storage is not on the heap and must not be freed. - */ -static void* eNB_thread_rxtx( void* param ) { - - static int eNB_thread_rxtx_status; - - eNB_rxtx_proc_t *proc = (eNB_rxtx_proc_t*)param; - PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; - - char thread_name[100]; - - - // set default return value - eNB_thread_rxtx_status = 0; - - sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); - thread_top_init(thread_name,1,850000L,1000000L,2000000L); - - while (!oai_exit) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); - - if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 1 ); - - - - if (oai_exit) break; - - if (rxtx(eNB,proc,thread_name) < 0) break; - - } // while !oai_exit - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); - - printf( "Exiting eNB thread RXn_TXnp4\n"); - - eNB_thread_rxtx_status = 0; - return &eNB_thread_rxtx_status; -} - -#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) -/* Wait for eNB application initialization to be complete (eNB registration to MME) */ -static void wait_system_ready (char *message, volatile int *start_flag) { - - static char *indicator[] = {". ", ".. ", "... ", ".... ", ".....", - " ....", " ...", " ..", " .", " "}; - int i = 0; - - while ((!oai_exit) && (*start_flag == 0)) { - LOG_N(EMU, message, indicator[i]); - fflush(stdout); - i = (i + 1) % (sizeof(indicator) / sizeof(indicator[0])); - usleep(200000); - } - - LOG_D(EMU,"\n"); -} -#endif - - -// asynchronous UL with IF4p5 (RCC,RAU,eNodeB_BBU) -void fh_if5_asynch_UL(RU_t *ru,int *frame,int *subframe) { - - eNB_proc_t *proc = &eNB->proc; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - - recv_IF5(eNB, &ru->timestamp_rx, *subframe, IF5_RRH_GW_UL); - - proc->subframe_rx = (ru->timestamp_rx/fp->samples_per_tti)%10; - proc->frame_rx = (ru->timestamp_rx/(10*fp->samples_per_tti))&1023; - - if (proc->first_rx != 0) { - proc->first_rx = 0; - *subframe = proc->subframe_rx; - *frame = proc->frame_rx; - } - else { - if (proc->subframe_rx != *subframe) { - LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); - exit_fun("Exiting"); - } - if (proc->frame_rx != *frame) { - LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->frame_rx,*frame); - exit_fun("Exiting"); - } - } -} // eNodeB_3GPP_BBU - -// asynchronous UL with IF4p5 (RCC,RAU,eNodeB_BBU) -void fh_if4p5_asynch_UL(RU_t *ru,int *frame,int *subframe) { - - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; - - uint16_t packet_type; - uint32_t symbol_number,symbol_mask,symbol_mask_full,prach_rx; - - - symbol_number = 0; - symbol_mask = 0; - symbol_mask_full = (1<<fp->symbols_per_tti)-1; - prach_rx = 0; - - do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! - recv_IF4p5(eNB, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number); - if (proc->first_rx != 0) { - *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - proc->first_rx = 0; - } - else { - if (proc->frame_rx != *frame) { - LOG_E(PHY,"frame_rx %d is not what we expect %d\n",proc->frame_rx,*frame); - exit_fun("Exiting"); - } - if (proc->subframe_rx != *subframe) { - LOG_E(PHY,"subframe_rx %d is not what we expect %d\n",proc->subframe_rx,*subframe); - exit_fun("Exiting"); - } - } - if (packet_type == IF4p5_PULFFT) { - symbol_mask = symbol_mask | (1<<symbol_number); - prach_rx = (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>0) ? 1 : 0; - } else if (packet_type == IF4p5_PRACH) { - prach_rx = 0; - } - } while( (symbol_mask != symbol_mask_full) || (prach_rx == 1)); - - -} - - -void fh_if5_asynch_DL(RU_t *ru,int *frame,int *subframe) { - - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; - int subframe_tx,frame_tx; - openair0_timestamp timestamp_tx; - - recv_IF5(eNB, ×tamp_tx, *subframe, IF5_RRH_GW_DL); - // printf("Received subframe %d (TS %llu) from RCC\n",subframe_tx,timestamp_tx); - - subframe_tx = (timestamp_tx/fp->samples_per_tti)%10; - frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023; - - if (proc->first_tx != 0) { - *subframe = subframe_tx; - *frame = frame_tx; - proc->first_tx = 0; - } - else { - if (subframe_tx != *subframe) { - LOG_E(PHY,"subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); - exit_fun("Exiting"); - } - if (frame_tx != *frame) { - LOG_E(PHY,"frame_tx %d is not what we expect %d\n",frame_tx,*frame); - exit_fun("Exiting"); - } - } -} - -void fh_if4p5_asynch_DL(RU_t *ru,int *frame,int *subframe) { - - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; - - uint16_t packet_type; - uint32_t symbol_number,symbol_mask,symbol_mask_full; - int subframe_tx,frame_tx; - - symbol_number = 0; - symbol_mask = 0; - symbol_mask_full = (1<<fp->symbols_per_tti)-1; - - do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! - recv_IF4p5(eNB, &frame_tx, &subframe_tx, &packet_type, &symbol_number); - if (proc->first_tx != 0) { - *frame = frame_tx; - *subframe = subframe_tx; - proc->first_tx = 0; - } - else { - if (frame_tx != *frame) { - LOG_E(PHY,"frame_tx %d is not what we expect %d\n",frame_tx,*frame); - exit_fun("Exiting"); - } - if (subframe_tx != *subframe) { - LOG_E(PHY,"subframe_tx %d is not what we expect %d\n",subframe_tx,*subframe); - exit_fun("Exiting"); - } - } - if (packet_type == IF4p5_PDLFFT) { - symbol_mask = symbol_mask | (1<<symbol_number); - } - else { - LOG_E(PHY,"Illegal IF4p5 packet type (should only be IF4p5_PDLFFT%d\n",packet_type); - exit_fun("Exiting"); - } - } while (symbol_mask != symbol_mask_full); - - do_OFDM_mod_rt(subframe_tx, eNB); -} - -/*! - * \brief The Asynchronous RX/TX FH thread of RAU/RCC/eNB/RRU. - * This handles the RX FH for an asynchronous RRU/UE - * \param param is a \ref eNB_proc_t structure which contains the info what to process. - * \returns a pointer to an int. The storage is not on the heap and must not be freed. - */ -static void* eNB_thread_asynch_rxtx( void* param ) { - - static int eNB_thread_asynch_rxtx_status; - - eNB_proc_t *proc = (eNB_proc_t*)param; - PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id]; - - - int subframe=0, frame=0; - - thread_top_init("thread_asynch",1,870000L,1000000L,1000000L); - - // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe - - wait_sync("thread_asynch"); - - // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe - printf( "waiting for devices (eNB_thread_asynch_rx)\n"); - - wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch"); - - printf( "devices ok (eNB_thread_asynch_rx)\n"); - - - while (!oai_exit) { - - if (oai_exit) break; - - if (subframe==9) { - subframe=0; - frame++; - frame&=1023; - } else { - subframe++; - } - - if (eNB->fh_asynch) eNB->fh_asynch(eNB,&frame,&subframe); - else AssertFatal(1==0, "Unknown eNB->node_function %d",eNB->node_function); - - } - - eNB_thread_asynch_rxtx_status=0; - return(&eNB_thread_asynch_rxtx_status); -} - - - - - -void rx_rf(RU_t *ru,int *frame,int *subframe) { - - eNB_proc_t *proc = &eNB->proc; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - void *rxp[fp->nb_antennas_rx],*txp[fp->nb_antennas_tx]; - unsigned int rxs,txs; - int i; - int tx_sfoffset = 3;//(eNB->single_thread_flag == 1) ? 3 : 3; - if (proc->first_rx==0) { - - // Transmit TX buffer based on timestamp from RX - // printf("trx_write -> USRP TS %llu (sf %d)\n", (ru->timestamp_rx+(3*fp->samples_per_tti)),(proc->subframe_rx+2)%10); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (ru->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance)&0xffffffff ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); - // prepare tx buffer pointers - - for (i=0; i<fp->nb_antennas_tx; i++) - txp[i] = (void*)&eNB->common_vars.txdata[0][i][((proc->subframe_rx+tx_sfoffset)%10)*fp->samples_per_tti]; - - txs = eNB->rfdevice.trx_write_func(&eNB->rfdevice, - ru->timestamp_rx+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance, - txp, - fp->samples_per_tti, - fp->nb_antennas_tx, - 1); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - - - - if (txs != fp->samples_per_tti) { - LOG_E(PHY,"TX : Timeout (sent %d/%d)\n",txs, fp->samples_per_tti); - exit_fun( "problem transmitting samples" ); - } - } - - for (i=0; i<fp->nb_antennas_rx; i++) - rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][*subframe*fp->samples_per_tti]; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); - - rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, - &(ru->timestamp_rx), - rxp, - fp->samples_per_tti, - fp->nb_antennas_rx); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - - if (proc->first_rx == 1) - eNB->ts_offset = ru->timestamp_rx; - - proc->frame_rx = ((ru->timestamp_rx-eNB->ts_offset) / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = ((ru->timestamp_rx-eNB->ts_offset) / fp->samples_per_tti)%10; - // synchronize first reception to frame 0 subframe 0 - - ru->timestamp_tx = ru->timestamp_rx+(4*fp->samples_per_tti); - //printf("trx_read <- USRP TS %llu (sf %d, f %d, first_rx %d)\n", ru->timestamp_rx,proc->subframe_rx,proc->frame_rx,proc->first_rx); - - if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",ru->timestamp_rx,proc->subframe_rx,*subframe); - exit_fun("Exiting"); - } - - if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",ru->timestamp_rx,proc->frame_rx,*frame); - exit_fun("Exiting"); - } - } else { - proc->first_rx = 0; - *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - } - - //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",ru->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe); - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, ru->timestamp_rx&0xffffffff ); - - if (rxs != fp->samples_per_tti) - exit_fun( "problem receiving samples" ); - - - -} - -void rx_fh_if5(RU_t *ru,int *frame, int *subframe) { - - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; - - recv_IF5(eNB, &ru->timestamp_rx, *subframe, IF5_RRH_GW_UL); - - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; - - if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,subframe); - exit_fun("Exiting"); - } - - if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)\n",proc->frame_rx,frame); - exit_fun("Exiting"); - } - } else { - proc->first_rx = 0; - *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - } - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); - -} - - -void rx_fh_if4p5(RU_t *ru,int *frame,int *subframe) { - - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - eNB_proc_t *proc = &eNB->proc; - - int prach_rx; - - uint16_t packet_type; - uint32_t symbol_number=0; - uint32_t symbol_mask, symbol_mask_full; - - symbol_mask = 0; - symbol_mask_full = (1<<fp->symbols_per_tti)-1; - prach_rx = 0; - - do { // Blocking, we need a timeout on this !!!!!!!!!!!!!!!!!!!!!!! - recv_IF4p5(eNB, &proc->frame_rx, &proc->subframe_rx, &packet_type, &symbol_number); - - if (packet_type == IF4p5_PULFFT) { - symbol_mask = symbol_mask | (1<<symbol_number); - prach_rx = (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>0) ? 1 : 0; - } else if (packet_type == IF4p5_PRACH) { - prach_rx = 0; - } - - } while( (symbol_mask != symbol_mask_full) || (prach_rx == 1)); - - //caculate timestamp_rx, timestamp_tx based on frame and subframe - proc->timestamp_rx = ((proc->frame_rx * 10) + proc->subframe_rx ) * fp->samples_per_tti ; - proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); - - - if (proc->first_rx == 0) { - if (proc->subframe_rx != *subframe){ - LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d,CCid %d)\n",proc->subframe_rx,*subframe,eNB->CC_id); - exit_fun("Exiting"); - } - if (proc->frame_rx != *frame) { - LOG_E(PHY,"Received Timestamp (IF4p5) doesn't correspond to the time we think it is (proc->frame_rx %d frame %d,CCid %d)\n",proc->frame_rx,*frame,eNB->CC_id); - exit_fun("Exiting"); - } - } else { - proc->first_rx = 0; - *frame = proc->frame_rx; - *subframe = proc->subframe_rx; - } - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); - -} - -void rx_fh_slave(RU_t *ru,int *frame,int *subframe) { - // This case is for synchronization to another thread - // it just waits for an external event. The actual rx_fh is handle by the asynchronous RX thread - eNB_proc_t *proc=&eNB->proc; - - if (wait_on_condition(&proc->mutex_FH,&proc->cond_FH,&proc->instance_cnt_FH,"rx_fh_slave") < 0) - return; - - release_thread(&proc->mutex_FH,&proc->instance_cnt_FH,"rx_fh_slave"); - - -} - - -int wakeup_rxtx(eNB_proc_t *proc,eNB_rxtx_proc_t *proc_rxtx,LTE_DL_FRAME_PARMS *fp) { - - int i; - struct timespec wait; - - wait.tv_sec=0; - wait.tv_nsec=5000000L; - - /* accept some delay in processing - up to 5ms */ - for (i = 0; i < 10 && proc_rxtx->instance_cnt_rxtx == 0; i++) { - LOG_W( PHY,"[eNB] Frame %d, eNB RXn-TXnp4 thread busy!! (cnt_rxtx %i)\n", proc_rxtx->frame_tx, proc_rxtx->instance_cnt_rxtx); - usleep(500); - } - if (proc_rxtx->instance_cnt_rxtx == 0) { - exit_fun( "TX thread busy" ); - return(-1); - } - - // wake up TX for subframe n+4 - // lock the TX mutex and make sure the thread is ready - if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); - exit_fun( "error locking mutex_rxtx" ); - return(-1); - } - - ++proc_rxtx->instance_cnt_rxtx; - - // We have just received and processed the common part of a subframe, say n. - // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired - // transmitted timestamp of the next TX slot (first). - // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, - // we want to generate subframe (n+4), so TS_tx = TX_rx+4*samples_per_tti, - // and proc->subframe_tx = proc->subframe_rx+4 - proc_rxtx->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); - proc_rxtx->frame_rx = proc->frame_rx; - proc_rxtx->subframe_rx = proc->subframe_rx; - proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > 5) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; - proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + 4)%10; - - // the thread can now be woken up - if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(-1); - } - - pthread_mutex_unlock( &proc_rxtx->mutex_rxtx ); - - return(0); -} - -void wakeup_slaves(ru_proc_t *proc) { - - int i; - struct timespec wait; - - wait.tv_sec=0; - wait.tv_nsec=5000000L; - - for (i=0;i<proc->num_slaves;i++) { - ru_proc_t *slave_proc = proc->slave_proc[i]; - // wake up slave FH thread - // lock the FH mutex and make sure the thread is ready - if (pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB CCid %d slave CCid %d (IC %d)\n",proc->CC_id,slave_proc->CC_id); - exit_fun( "error locking mutex_rxtx" ); - break; - } - - int cnt_slave = ++slave_proc->instance_cnt_FH; - slave_proc->frame_rx = proc->frame_rx; - slave_proc->subframe_rx = proc->subframe_rx; - slave_proc->timestamp_rx = proc->timestamp_rx; - slave_proc->timestamp_tx = proc->timestamp_tx; - - pthread_mutex_unlock( &slave_proc->mutex_FH ); - - if (cnt_slave == 0) { - // the thread was presumably waiting where it should and can now be woken up - if (pthread_cond_signal(&slave_proc->cond_FH) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB CCid %d, slave CCid %d\n",proc->CC_id,slave_proc->CC_id); - exit_fun( "ERROR pthread_cond_signal" ); - break; - } - } else { - LOG_W( PHY,"[RU] Frame %d, slave CC_id %d thread busy!! (cnt_FH %i)\n",slave_proc->frame_rx,slave_proc->CC_id, cnt_slave); - exit_fun( "FH thread busy" ); - break; - } - } -} - -/*! - * \brief The Fronthaul thread of RRU/RAU/RCC/eNB - * In the case of RRU/eNB, handles interface with external RF - * In the case of RAU/RCC, handles fronthaul interface with RRU/RAU - * \param param is a \ref eNB_proc_t structure which contains the info what to process. - * \returns a pointer to an int. The storage is not on the heap and must not be freed. - */ - -/*! - * \brief The prach receive thread of eNB. - * \param param is a \ref eNB_proc_t structure which contains the info what to process. - * \returns a pointer to an int. The storage is not on the heap and must not be freed. - */ -static void* eNB_thread_prach( void* param ) { - static int eNB_thread_prach_status; - - eNB_proc_t *proc = (eNB_proc_t*)param; - PHY_VARS_eNB *eNB= PHY_vars_eNB_g[0][proc->CC_id]; - - // set default return value - eNB_thread_prach_status = 0; - - thread_top_init("eNB_thread_prach",1,500000L,1000000L,20000000L); - - while (!oai_exit) { - - if (oai_exit) break; - - if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; - - prach_procedures(eNB); - - if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; - } - - printf( "Exiting eNB thread PRACH\n"); - - eNB_thread_prach_status = 0; - return &eNB_thread_prach_status; -} - -static void* ru_thread( void* param ) { - - static int ru_thread_status; - - RU_t *ru=(RU_t*)param; - ru_proc_t *proc=ru->proc; - int subframe=0, frame=0; - - // set default return value - ru_thread_status = 0; - - thread_top_init("ru_thread",0,870000,1000000,1000000); - - wait_sync("ru_thread"); - - /* -#if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - if (eNB->node_function < NGFI_RRU_IF5) - wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB); -#endif - */ - - // wakeup asnych_rxtx thread because the devices are ready at this point - pthread_mutex_lock(&proc->mutex_asynch_rxtx); - proc->instance_cnt_asynch_rxtx=0; - pthread_mutex_unlock(&proc->mutex_asynch_rxtx); - pthread_cond_signal(&proc->cond_asynch_rxtx); - - // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices - while (!oai_exit) { - - // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. - // They are set on the first rx/tx in the underly FH routines. - if (subframe==9) { - subframe=0; - frame++; - frame&=1023; - } else { - subframe++; - } - - LOG_D(PHY,"RU thread %p (proc %p), frame %d (%p), subframe %d (%p)\n", - pthread_self(), proc, frame,&frame,subframe,&subframe); - - // synchronization on FH interface, acquire signals/data and block - if (ru->rx_fh) ru->rx_fh(ru,&frame,&subframe); - else AssertFatal(1==0, "No fronthaul interface : eNB->node_function %d",eNB->node_function); - - T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); - /* - // wakeup correct eNB processes - proc_rxtx->subframe_rx = proc->subframe_rx; - proc_rxtx->frame_rx = proc->frame_rx; - proc_rxtx->subframe_tx = (proc->subframe_rx+4)%10; - proc_rxtx->frame_tx = (proc->subframe_rx < 6) ? proc->frame_rx : (proc->frame_rx+1)&1023; - proc_rxtx->timestamp_tx = proc->timestamp_tx; - */ - // At this point, all information for subframe has been received on FH interface - // If this proc is to provide synchronization, do so - wakeup_slaves(proc); - - // wait until eNBs are finished subframe RX n and TX n+4 - - // if (rxtx(eNB,proc_rxtx,"eNB_thread_single") < 0) break; - } - - - printf( "Exiting ru_thread \n"); - - ru_thread_status = 0; - return &ru_thread_status; - -} - -extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *);_ -extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); - -void init_eNB_proc(int inst) { - - int i; - int CC_id; - PHY_VARS_eNB *eNB; - eNB_proc_t *proc; - eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_single=NULL,*attr_fep=NULL,*attr_td=NULL,*attr_te; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - eNB = PHY_vars_eNB_g[inst][CC_id]; - LOG_I(PHY,"Initializing eNB %d CC_id %d (%s,%s),\n",inst,CC_id,eNB_functions[eNB->node_function],eNB_timing[eNB->node_timing]); - proc = &eNB->proc; - - proc_rxtx = proc->proc_rxtx; - proc_rxtx[0].instance_cnt_rxtx = -1; - proc_rxtx[1].instance_cnt_rxtx = -1; - proc->instance_cnt_prach = -1; - proc->instance_cnt_asynch_rxtx = -1; - proc->CC_id = CC_id; - - proc->first_rx=1; - proc->first_tx=1; - - pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL); - pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL); - pthread_cond_init( &proc_rxtx[0].cond_rxtx, NULL); - pthread_cond_init( &proc_rxtx[1].cond_rxtx, NULL); - - pthread_mutex_init( &proc->mutex_prach, NULL); - pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); - - pthread_cond_init( &proc->cond_prach, NULL); - pthread_cond_init( &proc->cond_asynch_rxtx, NULL); - - pthread_attr_init( &proc->attr_prach); - pthread_attr_init( &proc->attr_asynch_rxtx); - pthread_attr_init( &proc->attr_single); - pthread_attr_init( &proc->attr_fep); - pthread_attr_init( &proc->attr_td); - pthread_attr_init( &proc->attr_te); - pthread_attr_init( &proc_rxtx[0].attr_rxtx); - pthread_attr_init( &proc_rxtx[1].attr_rxtx); -#ifndef DEADLINE_SCHEDULER - attr0 = &proc_rxtx[0].attr_rxtx; - attr1 = &proc_rxtx[1].attr_rxtx; - attr_prach = &proc->attr_prach; - attr_asynch = &proc->attr_asynch_rxtx; - attr_single = &proc->attr_single; - attr_fep = &proc->attr_fep; - attr_td = &proc->attr_td; - attr_te = &proc->attr_te; -#endif - - if (eNB->single_thread_flag==0) { - pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] ); - pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); - } - else { - pthread_create(&proc->pthread_single, attr_single, eNB_thread_single, &eNB->proc); - init_fep_thread(eNB,attr_fep); - init_td_thread(eNB,attr_td); - init_te_thread(eNB,attr_te); - } - pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, &eNB->proc ); - if ((eNB->node_timing == synch_to_other) || - (eNB->node_function == NGFI_RRU_IF5) || - (eNB->node_function == NGFI_RRU_IF4p5)) - pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, eNB_thread_asynch_rxtx, &eNB->proc ); - - char name[16]; - if (eNB->single_thread_flag == 0) { - snprintf( name, sizeof(name), "RXTX0 %d", i ); - pthread_setname_np( proc_rxtx[0].pthread_rxtx, name ); - snprintf( name, sizeof(name), "RXTX1 %d", i ); - pthread_setname_np( proc_rxtx[1].pthread_rxtx, name ); - } - else { - snprintf( name, sizeof(name), " %d", i ); - pthread_setname_np( proc->pthread_single, name ); - } - } - - //for multiple CCs: setup master and slaves - /* - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - eNB = PHY_vars_eNB_g[inst][CC_id]; - - if (eNB->node_timing == synch_to_ext_device) { //master - eNB->proc.num_slaves = MAX_NUM_CCs-1; - eNB->proc.slave_proc = (eNB_proc_t**)malloc(eNB->proc.num_slaves*sizeof(eNB_proc_t*)); - - for (i=0; i< eNB->proc.num_slaves; i++) { - if (i < CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i]->proc); - if (i >= CC_id) eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i+1]->proc); - } - } - }*/ - - - /* setup PHY proc TX sync mechanism */ - pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); - pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); - sync_phy_proc.phy_proc_CC_id = 0; -} - - - -/*! - * \brief Terminate eNB TX and RX threads. - */ -void kill_eNB_proc(int inst) { - - int *status; - PHY_VARS_eNB *eNB; - eNB_proc_t *proc; - eNB_rxtx_proc_t *proc_rxtx; - for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - eNB=PHY_vars_eNB_g[inst][CC_id]; - - proc = &eNB->proc; - proc_rxtx = &proc->proc_rxtx[0]; - -#ifdef DEBUG_THREADS - printf( "Killing TX CC_id %d thread %d\n", CC_id, i ); -#endif - - proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race! - proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race! - proc->instance_cnt_prach = 0; - pthread_cond_signal( &proc_rxtx[0].cond_rxtx ); - pthread_cond_signal( &proc_rxtx[1].cond_rxtx ); - pthread_cond_signal( &proc->cond_prach ); - pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); - - pthread_join( proc->pthread_FH, (void**)&status ); - pthread_mutex_destroy( &proc->mutex_FH ); - pthread_cond_destroy( &proc->cond_FH ); - - pthread_join( proc->pthread_prach, (void**)&status ); - pthread_mutex_destroy( &proc->mutex_prach ); - pthread_cond_destroy( &proc->cond_prach ); - - int i; - for (i=0;i<2;i++) { - pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); - pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); - pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); - } - } -} - - -/* this function maps the phy_vars_eNB tx and rx buffers to the available rf chains. - Each rf chain is is addressed by the card number and the chain on the card. The - rf_map specifies for each CC, on which rf chain the mapping should start. Multiple - antennas are mapped to successive RF chains on the same card. */ -int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg) { - - int i, CC_id; - int j; - - uint16_t N_TA_offset = 0; - - LTE_DL_FRAME_PARMS *frame_parms; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - if (phy_vars_eNB[CC_id]) { - frame_parms = &(phy_vars_eNB[CC_id]->frame_parms); - printf("setup_eNB_buffers: frame_parms = %p\n",frame_parms); - } else { - printf("phy_vars_eNB[%d] not initialized\n", CC_id); - return(-1); - } - - if (frame_parms->frame_type == TDD) { - if (frame_parms->N_RB_DL == 100) - N_TA_offset = 624; - else if (frame_parms->N_RB_DL == 50) - N_TA_offset = 624/2; - else if (frame_parms->N_RB_DL == 25) - N_TA_offset = 624/4; - } - - - - if (openair0_cfg[CC_id].mmapped_dma == 1) { - // replace RX signal buffers with mmaped HW versions - - for (i=0; i<frame_parms->nb_antennas_rx; i++) { - printf("Mapping eNB CC_id %d, rx_ant %d\n",CC_id,i); - free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); - phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = openair0_cfg[CC_id].rxbase[i]; - - - - printf("rxdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); - - for (j=0; j<16; j++) { - printf("rxbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j]); - phy_vars_eNB[CC_id]->common_vars.rxdata[0][i][j] = 16-j; - } - } - - for (i=0; i<frame_parms->nb_antennas_tx; i++) { - printf("Mapping eNB CC_id %d, tx_ant %d\n",CC_id,i); - free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = openair0_cfg[CC_id].txbase[i];//(int32_t*) openair0_exmimo_pci[rf_map[CC_id].card].dac_head[rf_map[CC_id].chain+i]; - - printf("txdata[%d] @ %p\n",i,phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - - for (j=0; j<16; j++) { - printf("txbuffer %d: %x\n",j,phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j]); - phy_vars_eNB[CC_id]->common_vars.txdata[0][i][j] = 16-j; - } - } - } - else { // not memory-mapped DMA - - - 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; i<frame_parms->nb_antennas_rx; i++) { - free(phy_vars_eNB[CC_id]->common_vars.rxdata[0][i]); - rxdata[i] = (int32_t*)(32 + malloc16(32+frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation - phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = rxdata[i]-N_TA_offset; // N_TA offset for TDD FIXME! N_TA_offset > 16 => access of unallocated memory - memset(rxdata[i], 0, frame_parms->samples_per_tti*10*sizeof(int32_t)); - printf("rxdata[%d] @ %p (%p) (N_TA_OFFSET %d)\n", i, phy_vars_eNB[CC_id]->common_vars.rxdata[0][i],rxdata[i],N_TA_offset); - } - - for (i=0; i<frame_parms->nb_antennas_tx; i++) { - free(phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - txdata[i] = (int32_t*)(32 + malloc16(32 + frame_parms->samples_per_tti*10*sizeof(int32_t))); // FIXME broken memory allocation - phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = txdata[i]; - memset(txdata[i],0, frame_parms->samples_per_tti*10*sizeof(int32_t)); - printf("txdata[%d] @ %p\n", i, phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - } - } - } - - return(0); -} - - -void reset_opp_meas(void) { - - int sfn; - reset_meas(&softmodem_stats_mt); - reset_meas(&softmodem_stats_hw); - - for (sfn=0; sfn < 10; sfn++) { - reset_meas(&softmodem_stats_rxtx_sf); - reset_meas(&softmodem_stats_rx_sf); - } -} - - -void print_opp_meas(void) { - - int sfn=0; - print_meas(&softmodem_stats_mt, "Main ENB Thread", NULL, NULL); - print_meas(&softmodem_stats_hw, "HW Acquisation", NULL, NULL); - - for (sfn=0; sfn < 10; sfn++) { - print_meas(&softmodem_stats_rxtx_sf,"[eNB][total_phy_proc_rxtx]",NULL, NULL); - print_meas(&softmodem_stats_rx_sf,"[eNB][total_phy_proc_rx]",NULL,NULL); - } -} - -int start_if(PHY_VARS_eNB *eNB) { - return(eNB->ifdevice.trx_start_func(&eNB->ifdevice)); -} - -int start_rf(PHY_VARS_eNB *eNB) { - return(eNB->rfdevice.trx_start_func(&eNB->rfdevice)); -} - -extern void eNB_fep_rru_if5(PHY_VARS_eNB *eNB); -extern void eNB_fep_full(PHY_VARS_eNB *eNB); -extern void eNB_fep_full_2thread(PHY_VARS_eNB *eNB); -extern void do_prach(PHY_VARS_eNB *eNB); - -void init_RU(RAN_CONTEXT *rc, eNB_func_t node_function, RU_if_in_t ru_if_in[], RU_if_timing_t ru_if_timing[], eth_params_t *eth_params) { - - int ru_id; - - for (ru_id=0;ru_id<rc->nb_RU;ru_id++) { - ru = &rc.ru_desc[ru_id]; - ru->RU_if_in[ru_id] = ru_if_in[ru_id]; - ru->RU_if_timing = ru_if_timing[ru_id]; - LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s)\n",ru_id,ru_if_types[ru_if_in[ru_id]],eNB_timing[ru_timing[ru_id]]); - - switch (ru->RU_if_in[ru_id]) { - case LOCAL_RF: // this is an RRU or eNB with integrated RF - if (node_function == NGFI_RRU_IF5) { - ru->do_prach = NULL; // no prach processing - ru->fep_rx = eNB_fep_rru_if5; // need only to do send_IF5 - ru->fep_tx = NULL; // nothing (this is a time-domain signal) - ru->fh_asynch = fh_if5_asynch_DL; // TX packets come asynchronously - ru->start_if = start_if; // need to start the if interface for if5 - ru->ifdevice.host_type = RRH_HOST; - ru->rfdevice.host_type = RRH_HOST; - } - else if (node_function == NGFI_RRU_IF4p5) { - ru->do_prach = do_prach; // IF4p5 needs to do part of prach processing in RRU - ru->fep_rx = ru_fep_full; // this is DFTs + send_IF4p5 - ru->fep_tx = ru_fep_idft; // this is fep with idft only (no precoding in RRU) - ru->fh_asynch = fh_if4p5_asynch_DL; // TX packets come asynchronously - ru->start_if = start_if; // need to start the if interface for if4p5 - ru->ifdevice.host_type = RRH_HOST; - ru->rfdevice.host_type = RRH_HOST; - } - else if (node_function == eNodeB_3GPP) { - ru->do_prach = NULL; // prach is done completely in eNB processing - ru->fep_rx = eNB_fep_full; // this is DFTs only - ru->fep_tx = pc_fep_idft_prec; // this is fep with idft and precoding - ru->fh_asynch = NULL; // no incoming fronthaul - ru->start_if = NULL; // no if interface - ru->rfdevice.host_type = BBU_HOST; - } - ru->rx_fh = rx_rf; // local synchronous RF RX - ru->tx_fh = NULL; // nothing connected directly to radio - ru->start_rf = start_rf; // need to start the local RF interface - - ret = openair0_device_load(&ru->rfdevice, &openair0_cfg[ru_id]); - if (setup_RU_buffers(rc,ru_id,&openair0_cfg[ru_id])!=0) { - printf("Exiting, cannot initialize eNodeB Buffers\n"); - exit(-1); - } - break; - - case REMOTE_IF5: // the remote unit is IF5 RRU - ru->do_prach = NULL; // no prach processing in RU - ru->fep_rx = eNB_fep_full; // this is DFTs - ru->fep_tx = pc_fep_tx_rru_if5; // need to do transmit Precoding + FEP + IF5 fronthaul - if (ru->RU_if_timing == synch_to_other) { - ru->rx_fh = rx_fh_slave; // synchronize to master - ru->tx_fh = tx_fh_if5_mobipass; // use send_IF5 for mobipass - ru->fh_asynch = fh_if5_asynch_UL; // UL is asynchronous - } - else { - ru->tx_fh = tx_fh_if5; // synchronous IF5 transmission - ru->rx_fh = rx_fh_if5; // synchronous IF5 reception - ru->fh_asynch = NULL; // no asynchronous UL - } - ru->start_rf = NULL; // no local RF - ru->start_if = start_if; // need to start if interface for IF5 - ru->fh_asynch = fh_if5_asynch_DL; - ru->ifdevice.host_type = BBU_HOST; - - ret = openair0_transport_load(&ru->ifdevice, &openair0_cfg[ru_id], (eth_params+ru_id)); - printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - break; - - case REMOTE_IF4p5: - ru->do_prach = NULL; // no prach processing in RU - ru->fep_rx = eNB_fep_full; // this is DFTs - ru->fep_tx = proc_tx_high; // need to do transmit Precoding + IF4p5 fronthaul (no IDFTs) - ru->tx_fh = tx_fh_if4p5; // synchronous IF5 transmission - ru->rx_fh = rx_fh_if4p5; // synchronous IF5 reception - ru->fh_asynch = (ru->RU_if_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL; // asynchronous UL if synch_to_other - - ru->start_rf = NULL; // no local RF - ru->start_if = start_if; // need to start if interface for IF4p5 - ru->fh_asynch = fh_if5_asynch_DL; - ru->ifdevice.host_type = BBU_HOST; - - ret = openair0_transport_load(&ru->ifdevice, &openair0_cfg[ru_id], (eth_params+ru_id)); - printf("openair0_transport_init returns %d for ru_id %d\n",ret,ru_id); - if (ret<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); - } - - malloc_IF4p5_buffer(eNB); - - break; - - case REMOTE_IF1pp: - LOG_E(PHY,"RU with IF1pp not supported yet\n"); - break; - - } // switch on interface type - - } // for ru_id - - sleep(1); - LOG_D(HW,"[lte-softmodem.c] eNB threads created\n"); - - -} - -void init_RAN(RAN_CONTEXT *rc,eNB_func_t node_function[], eNB_timing_t node_timing[],eth_params_t *eth_params,int single_thread_flag) { - - int CC_id; - int inst; - PHY_VARS_eNB *eNB; - int ret; - - for (inst=0;inst<rc->nb_inst;inst++) { - for (CC_id=0;CC_id<rc->nb_CC;CC_id++) { - eNB = rc->eNB[inst][CC_id]; - if (eNB) { - eNB->node_function = node_function[CC_id]; - eNB->node_timing = node_timing[CC_id]; - eNB->abstraction_flag = 0; - eNB->single_thread_flag = single_thread_flag; - eNB->ts_offset = 0; - LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); - - switch (node_function[CC_id]) { - case NGFI_RRU_IF5: - eNB->td = NULL; - eNB->te = NULL; - eNB->proc_uespec_rx = NULL; - eNB->proc_tx = NULL; - break; - case NGFI_RRU_IF4p5: - eNB->td = NULL; - eNB->te = NULL; - eNB->proc_uespec_rx = NULL; - eNB->proc_tx = NULL;//proc_tx_rru_if4p5; - break; - case eNodeB_3GPP: - eNB->do_prach = do_prach; - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; - eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_full; - break; - case eNodeB_3GPP_BBU: - eNB->do_prach = do_prach; - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; - eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_full; - break; - case NGFI_RCC_IF4p5: - eNB->do_prach = do_prach; - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; - eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_high; - break; - case NGFI_RAU_IF4p5: - eNB->do_prach = do_prach; - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; - eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX; - eNB->proc_tx = proc_tx_high; - break; - } - // initialize eNB procedure threads if needed - init_eNB_proc(rc,inst); - } - } - } - sleep(1); - LOG_D(HW,"[lte-softmodem.c] eNB threads created\n"); - - -} - - -void stop_eNB(int nb_inst) { - - for (int inst=0;inst<nb_inst;inst++) { - printf("Killing eNB %d processing threads\n",inst); - kill_eNB_proc(inst); - } -} diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index b9cd7a57131724058c287fb0f0b412d9ee23f0ad..1ff4cb2b2178aed6383b364565e710830fd7f634 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -60,7 +60,7 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_common.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all @@ -70,22 +70,19 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" -#include "PHY/extern.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/extern.h" +#include "PHY/phy_extern.h" +#include "LAYER2/MAC/mac_extern.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "SCHED/sched_eNB.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "PHY/INIT/phy_init.h" -#include "../../SIMU/USER/init_lte.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" - -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" @@ -117,7 +114,11 @@ static int DEFENBS[] = {0}; #include "T.h" + extern volatile int oai_exit; +extern int emulate_rf; +extern int numerology; +extern int fepw; extern void phy_init_RU(RU_t*); @@ -523,7 +524,7 @@ void fh_if4p5_south_asynch_in(RU_t *ru,int *frame,int *subframe) { } if (packet_type == IF4p5_PULFFT) symbol_mask &= (~(1<<symbol_number)); else if (packet_type == IF4p5_PRACH) prach_rx &= (~0x1); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) else if (packet_type == IF4p5_PRACH_BR_CE0) prach_rx &= (~0x2); else if (packet_type == IF4p5_PRACH_BR_CE1) prach_rx &= (~0x4); else if (packet_type == IF4p5_PRACH_BR_CE2) prach_rx &= (~0x8); @@ -679,6 +680,34 @@ void fh_if4p5_north_out(RU_t *ru) { } +static void* emulatedRF_thread(void* param) { + RU_proc_t *proc = (RU_proc_t *) param; + int microsec = 500; // length of time to sleep, in miliseconds + struct timespec req = {0}; + req.tv_sec = 0; + req.tv_nsec = (numerology>0)? ((microsec * 1000L)/numerology):(microsec * 1000L)*2; + cpu_set_t cpuset; + CPU_SET(1,&cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + int policy; + struct sched_param sparam; + memset(&sparam, 0, sizeof(sparam)); + sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); + policy = SCHED_FIFO ; + pthread_setschedparam(pthread_self(), policy, &sparam); + + wait_sync("emulatedRF_thread"); + while(!oai_exit){ + nanosleep(&req, (struct timespec *)NULL); + pthread_mutex_lock(&proc->mutex_emulateRF); + ++proc->instance_cnt_emulateRF; + pthread_mutex_unlock(&proc->mutex_emulateRF); + pthread_cond_signal(&proc->cond_emulateRF); + } + return 0; +} + void rx_rf(RU_t *ru,int *frame,int *subframe) { RU_proc_t *proc = &ru->proc; @@ -686,7 +715,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { void *rxp[ru->nb_rx]; unsigned int rxs; int i; - openair0_timestamp ts,old_ts; + openair0_timestamp ts=0,old_ts=0; for (i=0; i<ru->nb_rx; i++) rxp[i] = (void*)&ru->common.rxdata[i][*subframe*fp->samples_per_tti]; @@ -694,12 +723,18 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); old_ts = proc->timestamp_rx; - - rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, + if(emulate_rf){ + wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); + release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); + rxs = fp->samples_per_tti; + } + else{ + rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, &ts, rxp, fp->samples_per_tti, ru->nb_rx); + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); @@ -715,7 +750,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { } else { if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { - LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset); + //LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset); ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); proc->timestamp_rx = ts-ru->ts_offset; } @@ -725,9 +760,9 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; // synchronize first reception to frame 0 subframe 0 - proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti); - proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10; - proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx; + //proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti); + //proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10; + //proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx; LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, subframe %d\n", ru->idx, @@ -739,8 +774,6 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { if (ru == RC.ru[0]) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, proc->frame_rx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_RU, proc->subframe_rx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx ); } if (proc->first_rx == 0) { @@ -815,6 +848,8 @@ void tx_rf(RU_t *ru) { for (i=0; i<ru->nb_tx; i++) txp[i] = (void*)&ru->common.txdata[i][(proc->subframe_tx*fp->samples_per_tti)-sf_extension]; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); @@ -855,7 +890,7 @@ static void* ru_thread_asynch_rxtx( void* param ) { int subframe=0, frame=0; - thread_top_init("ru_thread_asynch_rxtx",1,870000L,1000000L,1000000L); + thread_top_init("ru_thread_asynch_rxtx",1,870000,1000000,1000000); // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe @@ -881,7 +916,7 @@ static void* ru_thread_asynch_rxtx( void* param ) { subframe++; } LOG_D(PHY,"ru_thread_asynch_rxtx: Waiting on incoming fronthaul\n"); - // asynchronous receive from south (Mobipass) + // asynchronous receive from south (Mobipass) if (ru->fh_south_asynch_in) ru->fh_south_asynch_in(ru,&frame,&subframe); // asynchronous receive from north (RRU IF4/IF5) else if (ru->fh_north_asynch_in) { @@ -907,6 +942,7 @@ void wakeup_slaves(RU_proc_t *proc) { wait.tv_nsec=5000000L; for (i=0;i<proc->num_slaves;i++) { + //printf("////////////////////calling for slave thrads\n");////////////////////////******** RU_proc_t *slave_proc = proc->slave_proc[i]; // wake up slave FH thread // lock the FH mutex and make sure the thread is ready @@ -954,7 +990,8 @@ static void* ru_thread_prach( void* param ) { // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach",1,500000L,1000000L,20000000L); + thread_top_init("ru_thread_prach",1,500000,1000000,20000000); + //wait_sync("ru_thread_prach"); while (RC.ru_mask>0) { usleep(1e6); @@ -970,7 +1007,7 @@ static void* ru_thread_prach( void* param ) { if (ru->eNB_list[0]){ prach_procedures( ru->eNB_list[0] -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,0 #endif ); @@ -983,7 +1020,7 @@ static void* ru_thread_prach( void* param ) { NULL, proc->frame_prach, 0 -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,0 #endif ); @@ -998,7 +1035,7 @@ static void* ru_thread_prach( void* param ) { return &ru_thread_prach_status; } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) static void* ru_thread_prach_br( void* param ) { static int ru_thread_prach_status; @@ -1009,7 +1046,8 @@ static void* ru_thread_prach_br( void* param ) { // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach_br",1,500000L,1000000L,20000000L); + thread_top_init("ru_thread_prach_br",1,500000,1000000,20000000); + //wait_sync("ru_thread_prach_br"); while (!oai_exit) { @@ -1139,13 +1177,14 @@ void wakeup_eNBs(RU_t *ru) { LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top); - if (ru->num_eNB==1 && ru->eNB_top!=0) { - // call eNB function directly + if (ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() <= 4) { + // call eNB function directly + char string[20]; sprintf(string,"Incoming RU %d",ru->idx); LOG_D(PHY,"RU %d Call eNB_top\n",ru->idx); - ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string); + ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string,ru); } else { @@ -1154,7 +1193,7 @@ void wakeup_eNBs(RU_t *ru) { for (i=0;i<ru->num_eNB;i++) { LOG_D(PHY,"ru->wakeup_rxtx:%p\n", ru->wakeup_rxtx); - + eNB_list[i]->proc.ru_proc = &ru->proc; if (ru->wakeup_rxtx!=0 && ru->wakeup_rxtx(eNB_list[i],ru) < 0) { LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); @@ -1185,7 +1224,7 @@ static inline int wakeup_prach_ru(RU_t *ru) { ru->eNB_list[0]->proc.frame_prach = ru->proc.frame_rx; ru->eNB_list[0]->proc.subframe_prach = ru->proc.subframe_rx; } - LOG_I(PHY,"RU %d: waking up PRACH thread\n",ru->idx); + LOG_D(PHY,"RU %d: waking up PRACH thread\n",ru->idx); // the thread can now be woken up AssertFatal(pthread_cond_signal(&ru->proc.cond_prach) == 0, "ERROR pthread_cond_signal for RU prach thread\n"); } @@ -1195,7 +1234,7 @@ static inline int wakeup_prach_ru(RU_t *ru) { return(0); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) static inline int wakeup_prach_ru_br(RU_t *ru) { struct timespec wait; @@ -1231,20 +1270,39 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; openair0_config_t *cfg = &ru->openair0_cfg; + //printf("////////////////numerology in config = %d\n",numerology); if(fp->N_RB_DL == 100) { - if (fp->threequarter_fs) { - cfg->sample_rate=23.04e6; - cfg->samples_per_frame = 230400; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } - else { - cfg->sample_rate=30.72e6; + if(numerology == 0){ + if (fp->threequarter_fs) { + cfg->sample_rate=23.04e6; + cfg->samples_per_frame = 230400; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + else { + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + }else if(numerology == 1){ + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 20e6; + cfg->rx_bw = 20e6; + }else if(numerology == 2){ + cfg->sample_rate=122.88e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; + }else{ + printf("Wrong input for numerology %d\n setting to 20MHz normal CP configuration",numerology); + cfg->sample_rate=30.72e6; cfg->samples_per_frame = 307200; cfg->tx_bw = 10e6; cfg->rx_bw = 10e6; - } + } } else if(fp->N_RB_DL == 50) { cfg->sample_rate=15.36e6; cfg->samples_per_frame = 153600; @@ -1363,7 +1421,7 @@ static void* ru_stats_thread(void* param) { while (!oai_exit) { sleep(1); - if (opp_enabled == 1) { + if (opp_enabled == 1 && fepw) { if (ru->feprx) print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL); if (ru->feptx_ofdm) print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL); if (ru->fh_north_asynch_in) print_meas(&ru->rx_fhaul,"rx_fhaul",NULL,NULL); @@ -1377,6 +1435,59 @@ static void* ru_stats_thread(void* param) { return(NULL); } +static void* ru_thread_tx( void* param ) { + RU_t *ru = (RU_t*)param; + RU_proc_t *proc = &ru->proc; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + + thread_top_init("ru_thread_tx",1,400000,500000,500000); + + //CPU_SET(5, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //wait_sync("ru_thread_tx"); + + wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); + + printf( "ru_thread_tx ready\n"); + while (!oai_exit) { + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD_TX,sched_getcpu()); + if (oai_exit) break; + + + LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); + // wait until eNBs are finished subframe RX n and TX n+4 + wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); + if (oai_exit) break; + + // do TX front-end processing if needed (precoding and/or IDFTs) + if (ru->feptx_prec) ru->feptx_prec(ru); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + if(!emulate_rf){ + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + + if (ru->fh_north_out) ru->fh_north_out(ru); + } + release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); + + pthread_mutex_lock( &proc->mutex_eNBs ); + proc->ru_tx_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_eNBs) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_eNBs ); + } + release_thread(&proc->mutex_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); + return 0; +} + static void* ru_thread( void* param ) { static int ru_thread_status; @@ -1387,35 +1498,54 @@ static void* ru_thread( void* param ) { int ret; int subframe =9; int frame =1023; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + // set default return value ru_thread_status = 0; // set default return value - thread_top_init("ru_thread",0,870000,1000000,1000000); + thread_top_init("ru_thread",1,400000,500000,500000); - LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); + //CPU_SET(1, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + pthread_setname_np( pthread_self(),"ru thread"); + LOG_I(PHY,"thread ru created id=%ld\n", syscall(__NR_gettid)); + LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); - // Start IF device if any - if (ru->start_if) { - LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); - AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n"); - if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); - else ret = attach_rru(ru); - AssertFatal(ret==0,"Cannot connect to radio\n"); - } - if (ru->if_south == LOCAL_RF) { // configure RF parameters only - fill_rf_config(ru,ru->rf_config_file); - init_frame_parms(&ru->frame_parms,1); - phy_init_RU(ru); - - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + if(emulate_rf){ + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } } - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); + else{ + // Start IF device if any + if (ru->start_if) { + LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); + AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n"); + if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); + else ret = attach_rru(ru); + AssertFatal(ret==0,"Cannot connect to radio\n"); + } + if (ru->if_south == LOCAL_RF) { // configure RF parameters only + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + + + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + } + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } } LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); @@ -1424,38 +1554,46 @@ static void* ru_thread( void* param ) { pthread_cond_signal(&RC.ru_cond); pthread_mutex_unlock(&RC.ru_mutex); - wait_sync("ru_thread"); + pthread_mutex_lock(&proc->mutex_FH1); + proc->instance_cnt_FH1 = 0; + pthread_mutex_unlock(&proc->mutex_FH1); + pthread_cond_signal(&proc->cond_FH1); + wait_sync("ru_thread"); - - // Start RF device if any - if (ru->start_rf) { - if (ru->start_rf(ru) != 0) - LOG_E(HW,"Could not start the RF device\n"); - else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + if(!emulate_rf){ + // Start RF device if any + if (ru->start_rf) { + if (ru->start_rf(ru) != 0) + LOG_E(HW,"Could not start the RF device\n"); + else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + } + else LOG_I(PHY,"RU %d no rf device\n",ru->idx); + + // if an asnych_rxtx thread exists + // wakeup the thread because the devices are ready at this point + + if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { + pthread_mutex_lock(&proc->mutex_asynch_rxtx); + proc->instance_cnt_asynch_rxtx=0; + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); + pthread_cond_signal(&proc->cond_asynch_rxtx); + } + else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); + + // if this is a slave RRU, try to synchronize on the DL frequency + if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); } - else LOG_I(PHY,"RU %d no rf device\n",ru->idx); - // if an asnych_rxtx thread exists - // wakeup the thread because the devices are ready at this point - - if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { - pthread_mutex_lock(&proc->mutex_asynch_rxtx); - proc->instance_cnt_asynch_rxtx=0; - pthread_mutex_unlock(&proc->mutex_asynch_rxtx); - pthread_cond_signal(&proc->cond_asynch_rxtx); - } - else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); - - // if this is a slave RRU, try to synchronize on the DL frequency - if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (!oai_exit) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD,sched_getcpu()); + // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. // They are set on the first rx/tx in the underly FH routines. if (subframe==9) { @@ -1486,7 +1624,7 @@ static void* ru_thread( void* param ) { if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { wakeup_prach_ru(ru); } -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) else if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>1)) { wakeup_prach_ru_br(ru); } @@ -1505,20 +1643,21 @@ static void* ru_thread( void* param ) { // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_eNBs(ru); + + if(get_nprocs() <= 4){ + // do TX front-end processing if needed (precoding and/or IDFTs) + if (ru->feptx_prec) ru->feptx_prec(ru); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + if(!emulate_rf){ + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + + if (ru->fh_north_out) ru->fh_north_out(ru); + } + } - // wait until eNBs are finished subframe RX n and TX n+sf_ahead - wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); - - - // do TX front-end processing if needed (precoding and/or IDFTs) - if (ru->feptx_prec) ru->feptx_prec(ru); - - // do OFDM if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - // do outgoing fronthaul (south) if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - - if (ru->fh_north_out) ru->fh_north_out(ru); } @@ -1641,9 +1780,9 @@ void init_RU_proc(RU_t *ru) { int i=0; RU_proc_t *proc; - pthread_attr_t *attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL; + pthread_attr_t *attr_FH=NULL,*attr_FH1=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL,*attr_emulateRF=NULL; //pthread_attr_t *attr_fep=NULL; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_attr_t *attr_prach_br=NULL; #endif char name[100]; @@ -1656,14 +1795,19 @@ void init_RU_proc(RU_t *ru) { proc->ru = ru; proc->instance_cnt_prach = -1; - proc->instance_cnt_synch = -1; ; + proc->instance_cnt_synch = -1; proc->instance_cnt_FH = -1; + proc->instance_cnt_FH1 = -1; + proc->instance_cnt_emulateRF = -1; proc->instance_cnt_asynch_rxtx = -1; + proc->instance_cnt_eNBs = -1; proc->first_rx = 1; proc->first_tx = 1; proc->frame_offset = 0; proc->num_slaves = 0; proc->frame_tx_unwrap = 0; + proc->ru_rx_ready = 0; + proc->ru_tx_ready = 0; for (i=0;i<10;i++) proc->symbol_mask[i]=0; @@ -1671,21 +1815,27 @@ void init_RU_proc(RU_t *ru) { pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_synch,NULL); pthread_mutex_init( &proc->mutex_FH,NULL); + pthread_mutex_init( &proc->mutex_FH1,NULL); + pthread_mutex_init( &proc->mutex_emulateRF,NULL); pthread_mutex_init( &proc->mutex_eNBs, NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); + pthread_cond_init( &proc->cond_FH1, NULL); + pthread_cond_init( &proc->cond_emulateRF, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); pthread_cond_init( &proc->cond_synch,NULL); pthread_cond_init( &proc->cond_eNBs, NULL); pthread_attr_init( &proc->attr_FH); + pthread_attr_init( &proc->attr_FH1); + pthread_attr_init( &proc->attr_emulateRF); pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_synch); pthread_attr_init( &proc->attr_asynch_rxtx); pthread_attr_init( &proc->attr_fep); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) proc->instance_cnt_prach_br = -1; pthread_mutex_init( &proc->mutex_prach_br, NULL); pthread_cond_init( &proc->cond_prach_br, NULL); @@ -1694,19 +1844,26 @@ void init_RU_proc(RU_t *ru) { #ifndef DEADLINE_SCHEDULER attr_FH = &proc->attr_FH; + attr_FH1 = &proc->attr_FH1; attr_prach = &proc->attr_prach; attr_synch = &proc->attr_synch; attr_asynch = &proc->attr_asynch_rxtx; -#ifdef Rel14 + attr_emulateRF = &proc->attr_emulateRF; +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) attr_prach_br = &proc->attr_prach_br; #endif #endif pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru ); + if(emulate_rf) + pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); + + if (get_nprocs() > 4) + pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); if (ru->function == NGFI_RRU_IF4p5) { pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_create( &proc->pthread_prach_br, attr_prach_br, ru_thread_prach_br, (void*)ru ); #endif if (ru->is_slave == 1) pthread_create( &proc->pthread_synch, attr_synch, ru_thread_synch, (void*)ru); @@ -1714,7 +1871,10 @@ void init_RU_proc(RU_t *ru) { if ((ru->if_timing == synch_to_other) || (ru->function == NGFI_RRU_IF5) || - (ru->function == NGFI_RRU_IF4p5)) pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, ru_thread_asynch_rxtx, (void*)ru ); + (ru->function == NGFI_RRU_IF4p5)) + { + pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, ru_thread_asynch_rxtx, (void*)ru ); + } snprintf( name, sizeof(name), "ru_thread_FH %d", ru->idx ); pthread_setname_np( proc->pthread_FH, name ); @@ -1725,7 +1885,7 @@ void init_RU_proc(RU_t *ru) { pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); } - if (get_nprocs()>=2) { + if (get_nprocs()> 2 && fepw) { if (ru->feprx) init_fep_thread(ru,NULL); if (ru->feptx_ofdm) init_feptx_thread(ru,NULL); } @@ -1740,42 +1900,50 @@ void kill_RU_proc(int inst) pthread_mutex_lock(&proc->mutex_FH); proc->instance_cnt_FH = 0; - pthread_mutex_unlock(&proc->mutex_FH); pthread_cond_signal(&proc->cond_FH); + pthread_mutex_unlock(&proc->mutex_FH); + + pthread_mutex_lock(&proc->mutex_FH1); + proc->instance_cnt_FH1 = 0; + pthread_cond_signal(&proc->cond_FH1); + pthread_mutex_unlock(&proc->mutex_FH1); pthread_mutex_lock(&proc->mutex_prach); proc->instance_cnt_prach = 0; - pthread_mutex_unlock(&proc->mutex_prach); pthread_cond_signal(&proc->cond_prach); + pthread_mutex_unlock(&proc->mutex_prach); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_mutex_lock(&proc->mutex_prach_br); proc->instance_cnt_prach_br = 0; - pthread_mutex_unlock(&proc->mutex_prach_br); pthread_cond_signal(&proc->cond_prach_br); + pthread_mutex_unlock(&proc->mutex_prach_br); #endif pthread_mutex_lock(&proc->mutex_synch); proc->instance_cnt_synch = 0; - pthread_mutex_unlock(&proc->mutex_synch); pthread_cond_signal(&proc->cond_synch); + pthread_mutex_unlock(&proc->mutex_synch); pthread_mutex_lock(&proc->mutex_eNBs); + proc->ru_tx_ready = 0; proc->instance_cnt_eNBs = 0; - pthread_mutex_unlock(&proc->mutex_eNBs); pthread_cond_signal(&proc->cond_eNBs); + pthread_mutex_unlock(&proc->mutex_eNBs); pthread_mutex_lock(&proc->mutex_asynch_rxtx); proc->instance_cnt_asynch_rxtx = 0; - pthread_mutex_unlock(&proc->mutex_asynch_rxtx); pthread_cond_signal(&proc->cond_asynch_rxtx); + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); LOG_D(PHY, "Joining pthread_FH\n"); pthread_join(proc->pthread_FH, NULL); + LOG_D(PHY, "Joining pthread_FHTX\n"); + pthread_join(proc->pthread_FH1, NULL); if (ru->function == NGFI_RRU_IF4p5) { LOG_D(PHY, "Joining pthread_prach\n"); pthread_join(proc->pthread_prach, NULL); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) LOG_D(PHY, "Joining pthread_prach_br\n"); pthread_join(proc->pthread_prach_br, NULL); #endif @@ -1791,7 +1959,7 @@ void kill_RU_proc(int inst) pthread_join(proc->pthread_asynch_rxtx, NULL); } } - if (get_nprocs() >= 2) { + if (get_nprocs() > 2 && fepw) { if (ru->feprx) { pthread_mutex_lock(&proc->mutex_fep); proc->instance_cnt_fep = 0; @@ -1822,21 +1990,24 @@ void kill_RU_proc(int inst) pthread_mutex_destroy(&proc->mutex_asynch_rxtx); pthread_mutex_destroy(&proc->mutex_synch); pthread_mutex_destroy(&proc->mutex_FH); + pthread_mutex_destroy(&proc->mutex_FH1); pthread_mutex_destroy(&proc->mutex_eNBs); pthread_cond_destroy(&proc->cond_prach); pthread_cond_destroy(&proc->cond_FH); + pthread_cond_destroy(&proc->cond_FH1); pthread_cond_destroy(&proc->cond_asynch_rxtx); pthread_cond_destroy(&proc->cond_synch); pthread_cond_destroy(&proc->cond_eNBs); pthread_attr_destroy(&proc->attr_FH); + pthread_attr_destroy(&proc->attr_FH1); pthread_attr_destroy(&proc->attr_prach); pthread_attr_destroy(&proc->attr_synch); pthread_attr_destroy(&proc->attr_asynch_rxtx); pthread_attr_destroy(&proc->attr_fep); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_mutex_destroy(&proc->mutex_prach_br); pthread_cond_destroy(&proc->cond_prach_br); pthread_attr_destroy(&proc->attr_prach_br); @@ -1932,7 +2103,7 @@ void configure_ru(int idx, LOG_I(PHY,"REMOTE_IF4p5: prach_FrequOffset %d, prach_ConfigIndex %d\n", config->prach_FreqOffset[0],config->prach_ConfigIndex[0]); -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int i; for (i=0;i<4;i++) { config->emtc_prach_CElevel_enable[0][i] = ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i]; @@ -1976,7 +2147,7 @@ void configure_rru(int idx, config->prach_FreqOffset[0],config->prach_ConfigIndex[0],ru->att_tx,ru->att_rx); ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = config->prach_FreqOffset[0]; ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = config->prach_ConfigIndex[0]; -#ifdef Rel14 +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) for (int i=0;i<4;i++) { ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] = config->emtc_prach_CElevel_enable[0][i]; ru->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[i] = config->emtc_prach_FreqOffset[0][i]; @@ -2061,8 +2232,8 @@ void set_function_spec_param(RU_t *ru) ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception ru->fh_south_out = tx_rf; // send output to RF ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously - ru->feprx = (get_nprocs()<=2) ? fep_full :ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) + ru->feprx = (get_nprocs()<=2 || !fepw) ? fep_full :ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=2 || !fepw) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) ru->feptx_prec = NULL; ru->start_if = start_if; // need to start the if interface for if4p5 ru->ifdevice.host_type = RRU_HOST; @@ -2083,8 +2254,8 @@ void set_function_spec_param(RU_t *ru) } else if (ru->function == eNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_nprocs()<=2) ? fep_full : ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding + ru->feprx = (get_nprocs()<=2 || !fepw) ? fep_full : ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=2 || !fepw) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding ru->feptx_prec = feptx_prec; // this is fep with idft and precoding ru->fh_north_in = NULL; // no incoming fronthaul from north ru->fh_north_out = NULL; // no outgoing fronthaul to north @@ -2112,9 +2283,9 @@ void set_function_spec_param(RU_t *ru) case REMOTE_IF5: // the remote unit is IF5 RRU ru->do_prach = 0; - ru->feprx = (get_nprocs()<=2) ? fep_full : fep_full; // this is frequency-shift + DFTs + ru->feprx = (get_nprocs()<=2 || !fepw) ? fep_full : fep_full; // this is frequency-shift + DFTs ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs + ru->feptx_ofdm = (get_nprocs()<=2 || !fepw) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs if (ru->if_timing == synch_to_other) { ru->fh_south_in = fh_slave_south_in; // synchronize to master ru->fh_south_out = fh_if5_mobipass_south_out; // use send_IF5 for mobipass @@ -2245,7 +2416,7 @@ void init_RU(char *rf_config_file) { } } } - // LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); + LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); set_function_spec_param(ru); LOG_I(PHY,"Starting ru_thread %d\n",ru_id); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 676ea8988482048fc2f0480306f37b0b437b77b0..7163d8bd7dc1ab8a9bdb6b5ac0d17de484c20683 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -47,7 +47,7 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" #include "common/ran_context.h" #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" @@ -59,17 +59,14 @@ //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "PHY/vars.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" +#include "PHY/phy_vars.h" +#include "SCHED/sched_common_vars.h" +#include "LAYER2/MAC/mac_vars.h" -#include "../../SIMU/USER/init_lte.h" - -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/vars.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/vars.h" -#include "PHY_INTERFACE/vars.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_vars.h" +#include "PHY_INTERFACE/phy_interface_vars.h" #ifdef SMBV #include "PHY/TOOLS/smbv.h" @@ -93,6 +90,8 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "create_tasks.h" #endif +#include "PHY/INIT/phy_init.h" + #include "system.h" #ifdef XFORMS @@ -118,6 +117,8 @@ int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex uint8_t nfapi_mode = 0; // Default to monolithic mode +uint16_t sf_ahead=4; + pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. @@ -143,7 +144,8 @@ static int8_t threequarter_fs=0; uint32_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; - +// This is a dummy declaration (dlsch_demodulation.c is no longer compiled for eNodeB) +int16_t dlsch_demod_shift = 0; #if defined(ENABLE_ITTI) static char *itti_dump_file = NULL; @@ -217,6 +219,10 @@ extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, extern void init_eNB_afterRU(void); int transmission_mode=1; +int emulate_rf = 0; +int numerology = 0; +int codingw = 0; +int fepw = 0; @@ -632,6 +638,7 @@ void init_openair0(void) { int card; int i; + for (card=0; card<MAX_CARDS; card++) { @@ -639,6 +646,8 @@ void init_openair0(void) { openair0_cfg[card].configFilename = NULL; if(frame_parms[0]->N_RB_DL == 100) { + if(numerology == 0) + { if (frame_parms[0]->threequarter_fs) { openair0_cfg[card].sample_rate=23.04e6; openair0_cfg[card].samples_per_frame = 230400; @@ -650,6 +659,22 @@ void init_openair0(void) { openair0_cfg[card].tx_bw = 10e6; openair0_cfg[card].rx_bw = 10e6; } + }else if(numerology == 1) + { + openair0_cfg[card].sample_rate=61.44e6; + openair0_cfg[card].samples_per_frame = 307200; + openair0_cfg[card].tx_bw = 20e6; + openair0_cfg[card].rx_bw = 20e6; + }else if(numerology == 2) + { + openair0_cfg[card].sample_rate=122.88e6; + openair0_cfg[card].samples_per_frame = 307200; + openair0_cfg[card].tx_bw = 20e6; + openair0_cfg[card].rx_bw = 20e6; + }else + { + printf("Un supported numerology\n"); + } } else if(frame_parms[0]->N_RB_DL == 50) { openair0_cfg[card].sample_rate=15.36e6; openair0_cfg[card].samples_per_frame = 153600; @@ -1071,7 +1096,7 @@ int main( int argc, char **argv ) // init UE_PF_PO and mutex lock pthread_mutex_init(&ue_pf_po_mutex, NULL); - memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); + memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs); mlockall(MCL_CURRENT | MCL_FUTURE); @@ -1126,6 +1151,13 @@ int main( int argc, char **argv ) pthread_mutex_init(&sync_mutex, NULL); } + if (nfapi_mode) + { + printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); + pthread_cond_init(&sync_cond,NULL); + pthread_mutex_init(&sync_mutex, NULL); + } + const char *nfapi_mode_str = "<UNKNOWN>"; switch(nfapi_mode) { diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index e8b9d9249023d13a4d2047668b2de8eb12b28d0c..c375d28106cdf04de3d65d37644d3a7dd5cc3a58 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -28,7 +28,8 @@ #include "assertions.h" #include "msc.h" #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "flexran_agent.h" @@ -74,6 +75,8 @@ #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_PRB "Set the PRB, valid values: 6, 25, 50, 100 \n" +#define CONFIG_HLP_EMULIFACE "Set the interface name for the multicast transport for emulation mode (e.g. eth0, lo, etc.) \n" +//#define CONFIG_HLP_NUMUES "Set the number of UEs for the emulation" #define CONFIG_HLP_MSLOTS "Skip the missed slots/subframes \n" #define CONFIG_HLP_ULMCS "Set the maximum uplink MCS\n" #define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n" @@ -85,6 +88,12 @@ #define CONFIG_HLP_TPORT "tracer port\n" #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" + +#define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n" +#define CONFIG_HLP_CODINGW "coding worker thread enable(disable by defult)\n" +#define CONFIG_HLP_FEPW "FEP worker thread enabled(disable by defult)\n" +#define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n" + #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" /***************************************************************************************************************************************/ @@ -129,46 +138,54 @@ {"ue-nb-ant-tx", CONFIG_HLP_UENANTT, 0, u8ptr:&nb_antenna_tx, defuintval:1, TYPE_UINT8, 0}, \ {"ue-scan-carrier", CONFIG_HLP_UESCAN, PARAMFLAG_BOOL, iptr:&UE_scan_carrier, defintval:0, TYPE_INT, 0}, \ {"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \ +{"emul-iface", CONFIG_HLP_EMULIFACE, 0, strptr:&emul_iface, defstrval:"lo", TYPE_STRING, 100}, \ +{"L2-emul", NULL, 0, u8ptr:&nfapi_mode, defuintval:3, TYPE_UINT8, 0}, \ +{"num-ues", NULL, 0, u8ptr:&(NB_UE_INST), defuintval:1, TYPE_UINT8, 0}, \ {"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \ +{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ } #define DEFAULT_DLF 2680000000 -extern int16_t dlsch_demod_shift; + /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters common to eNodeB and UE */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_PARAMS_DESC { \ -{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ -{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ -{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ -{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ -{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ -{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ -{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ -{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ -{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ -{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ -{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ -{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ -{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ -{"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:DEFAULT_DLF, TYPE_UINT, 0}, \ -{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ -{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ -{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ -{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \ -{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ -{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ -{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \ -{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \ -{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \ -{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ -{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ -{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ -{"nbiot-disable", CONFIG_HLP_DISABLNBIOT,PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \ +{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ +{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ +{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ +{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ +{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ +{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ +{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ +{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ +{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ +{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ +{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ +{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ +{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ +{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ +{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ +{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ +{"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ +{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ +{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ +{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ +{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \ +{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ +{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ +{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \ +{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \ +{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \ +{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ +{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ +{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ +{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0}, \ +{"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \ +{"codingw" , CONFIG_HLP_CODINGW, PARAMFLAG_BOOL, iptr:&codingw, defintval:0, TYPE_INT, 0}, \ +{"fepw" , CONFIG_HLP_FEPW, PARAMFLAG_BOOL, iptr:&fepw, defintval:0, TYPE_INT, 0}, \ +{"nbiot-disable", CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \ } #define CONFIG_HLP_FLOG "Enable online log \n" @@ -262,8 +279,10 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); +extern void init_td_thread(PHY_VARS_eNB *); +extern void init_te_thread(PHY_VARS_eNB *); +extern void kill_td_thread(PHY_VARS_eNB *); +extern void kill_te_thread(PHY_VARS_eNB *); PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 2c83ea9a04e22671ba45fd6ced7b1ddbbc0656fe..a0174ea3327ef245f5f1008633adb3f1ef1f462c 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -33,19 +33,24 @@ #include "rt_wrapper.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "RRC/LITE/extern.h" -#endif -#include "PHY_INTERFACE/extern.h" +#include "LAYER2/MAC/mac.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_stub_UE.h" +#include "PHY_INTERFACE/phy_interface_extern.h" +#include "PHY/INIT/phy_init.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "PHY/extern.h" -#include "SCHED/extern.h" -#include "LAYER2/MAC/extern.h" -#include "LAYER2/MAC/proto.h" +#include "PHY/phy_extern_ue.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" +#include "SCHED_UE/sched_UE.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" + +#include <inttypes.h> #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" @@ -54,76 +59,100 @@ #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" + #include "T.h" extern double cpuf; +extern uint8_t nfapi_mode; #define FRAME_PERIOD 100000000ULL #define DAQ_PERIOD 66667ULL #define FIFO_PRIORITY 40 typedef enum { - pss=0, - pbch=1, - si=2 + pss=0, + pbch=1, + si=2 } sync_mode_t; void init_UE_threads(int); +void init_UE_threads_stub(int); +void init_UE_single_thread_stub(int); void *UE_thread(void *arg); void init_UE(int nb_inst,int,int,int); +void init_UE_stub(int nb_inst,int,int,char*); +void init_UE_stub_single_thread(int nb_inst,int,int,char*); +int init_timer_thread(void); +extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); +extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), + unsigned char _multicast_group, char *multicast_ifname); +extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); +extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); +extern int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind); +extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); +extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); +extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); + +//extern int tx_req_UE_MAC1(); + +void ue_stub_rx_handler(unsigned int, char *); int32_t **rxdata; int32_t **txdata; +int timer_subframe; +int timer_frame; +SF_ticking *phy_stub_ticking; + #define KHz (1000UL) #define MHz (1000*KHz) typedef struct eutra_band_s { - int16_t band; - uint32_t ul_min; - uint32_t ul_max; - uint32_t dl_min; - uint32_t dl_max; - lte_frame_type_t frame_type; + int16_t band; + uint32_t ul_min; + uint32_t ul_max; + uint32_t dl_min; + uint32_t dl_max; + lte_frame_type_t frame_type; } eutra_band_t; typedef struct band_info_s { - int nbands; - eutra_band_t band_info[100]; + int nbands; + eutra_band_t band_info[100]; } band_info_t; band_info_t bands_to_scan; static const eutra_band_t eutra_bands[] = { - { 1, 1920 * MHz, 1980 * MHz, 2110 * MHz, 2170 * MHz, FDD}, - { 2, 1850 * MHz, 1910 * MHz, 1930 * MHz, 1990 * MHz, FDD}, - { 3, 1710 * MHz, 1785 * MHz, 1805 * MHz, 1880 * MHz, FDD}, - { 4, 1710 * MHz, 1755 * MHz, 2110 * MHz, 2155 * MHz, FDD}, - { 5, 824 * MHz, 849 * MHz, 869 * MHz, 894 * MHz, FDD}, - { 6, 830 * MHz, 840 * MHz, 875 * MHz, 885 * MHz, FDD}, - { 7, 2500 * MHz, 2570 * MHz, 2620 * MHz, 2690 * MHz, FDD}, - { 8, 880 * MHz, 915 * MHz, 925 * MHz, 960 * MHz, FDD}, - { 9, 1749900 * KHz, 1784900 * KHz, 1844900 * KHz, 1879900 * KHz, FDD}, - {10, 1710 * MHz, 1770 * MHz, 2110 * MHz, 2170 * MHz, FDD}, - {11, 1427900 * KHz, 1452900 * KHz, 1475900 * KHz, 1500900 * KHz, FDD}, - {12, 698 * MHz, 716 * MHz, 728 * MHz, 746 * MHz, FDD}, - {13, 777 * MHz, 787 * MHz, 746 * MHz, 756 * MHz, FDD}, - {14, 788 * MHz, 798 * MHz, 758 * MHz, 768 * MHz, FDD}, - {17, 704 * MHz, 716 * MHz, 734 * MHz, 746 * MHz, FDD}, - {20, 832 * MHz, 862 * MHz, 791 * MHz, 821 * MHz, FDD}, - {22, 3510 * MHz, 3590 * MHz, 3410 * MHz, 3490 * MHz, FDD}, - {33, 1900 * MHz, 1920 * MHz, 1900 * MHz, 1920 * MHz, TDD}, - {34, 2010 * MHz, 2025 * MHz, 2010 * MHz, 2025 * MHz, TDD}, - {35, 1850 * MHz, 1910 * MHz, 1850 * MHz, 1910 * MHz, TDD}, - {36, 1930 * MHz, 1990 * MHz, 1930 * MHz, 1990 * MHz, TDD}, - {37, 1910 * MHz, 1930 * MHz, 1910 * MHz, 1930 * MHz, TDD}, - {38, 2570 * MHz, 2620 * MHz, 2570 * MHz, 2630 * MHz, TDD}, - {39, 1880 * MHz, 1920 * MHz, 1880 * MHz, 1920 * MHz, TDD}, - {40, 2300 * MHz, 2400 * MHz, 2300 * MHz, 2400 * MHz, TDD}, - {41, 2496 * MHz, 2690 * MHz, 2496 * MHz, 2690 * MHz, TDD}, - {42, 3400 * MHz, 3600 * MHz, 3400 * MHz, 3600 * MHz, TDD}, - {43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD}, - {44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD}, + { 1, 1920 * MHz, 1980 * MHz, 2110 * MHz, 2170 * MHz, FDD}, + { 2, 1850 * MHz, 1910 * MHz, 1930 * MHz, 1990 * MHz, FDD}, + { 3, 1710 * MHz, 1785 * MHz, 1805 * MHz, 1880 * MHz, FDD}, + { 4, 1710 * MHz, 1755 * MHz, 2110 * MHz, 2155 * MHz, FDD}, + { 5, 824 * MHz, 849 * MHz, 869 * MHz, 894 * MHz, FDD}, + { 6, 830 * MHz, 840 * MHz, 875 * MHz, 885 * MHz, FDD}, + { 7, 2500 * MHz, 2570 * MHz, 2620 * MHz, 2690 * MHz, FDD}, + { 8, 880 * MHz, 915 * MHz, 925 * MHz, 960 * MHz, FDD}, + { 9, 1749900 * KHz, 1784900 * KHz, 1844900 * KHz, 1879900 * KHz, FDD}, + {10, 1710 * MHz, 1770 * MHz, 2110 * MHz, 2170 * MHz, FDD}, + {11, 1427900 * KHz, 1452900 * KHz, 1475900 * KHz, 1500900 * KHz, FDD}, + {12, 698 * MHz, 716 * MHz, 728 * MHz, 746 * MHz, FDD}, + {13, 777 * MHz, 787 * MHz, 746 * MHz, 756 * MHz, FDD}, + {14, 788 * MHz, 798 * MHz, 758 * MHz, 768 * MHz, FDD}, + {17, 704 * MHz, 716 * MHz, 734 * MHz, 746 * MHz, FDD}, + {20, 832 * MHz, 862 * MHz, 791 * MHz, 821 * MHz, FDD}, + {22, 3510 * MHz, 3590 * MHz, 3410 * MHz, 3490 * MHz, FDD}, + {33, 1900 * MHz, 1920 * MHz, 1900 * MHz, 1920 * MHz, TDD}, + {34, 2010 * MHz, 2025 * MHz, 2010 * MHz, 2025 * MHz, TDD}, + {35, 1850 * MHz, 1910 * MHz, 1850 * MHz, 1910 * MHz, TDD}, + {36, 1930 * MHz, 1990 * MHz, 1930 * MHz, 1990 * MHz, TDD}, + {37, 1910 * MHz, 1930 * MHz, 1910 * MHz, 1930 * MHz, TDD}, + {38, 2570 * MHz, 2620 * MHz, 2570 * MHz, 2630 * MHz, TDD}, + {39, 1880 * MHz, 1920 * MHz, 1880 * MHz, 1920 * MHz, TDD}, + {40, 2300 * MHz, 2400 * MHz, 2300 * MHz, 2400 * MHz, TDD}, + {41, 2496 * MHz, 2690 * MHz, 2496 * MHz, 2690 * MHz, TDD}, + {42, 3400 * MHz, 3600 * MHz, 3400 * MHz, 3600 * MHz, TDD}, + {43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD}, + {44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD}, }; @@ -147,16 +176,21 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, ue = (PHY_VARS_UE *)malloc(sizeof(PHY_VARS_UE)); memset(ue,0,sizeof(PHY_VARS_UE)); memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS)); - } + } else ue = PHY_vars_UE_g[UE_id][0]; ue->Mod_id = UE_id; ue->mac_enabled = 1; - // initialize all signal buffers - init_lte_ue_signal(ue,1,abstraction_flag); - // intialize transport - init_lte_ue_transport(ue,abstraction_flag); + + // Panos: In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct? + if (nfapi_mode!=3) + { + // initialize all signal buffers + init_lte_ue_signal(ue,1,abstraction_flag); + // intialize transport + init_lte_ue_transport(ue,abstraction_flag); + } return(ue); } @@ -169,35 +203,35 @@ char uecap_xer[1024]; void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name) { #ifdef DEADLINE_SCHEDULER - if (sched_runtime!=0) { - struct sched_attr attr= {0}; - attr.size = sizeof(attr); - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = sched_runtime; - attr.sched_deadline = sched_deadline; - attr.sched_period = 0; - AssertFatal(sched_setattr(0, &attr, 0) == 0, - "[SCHED] %s thread: sched_setattr failed %s \n", name, strerror(errno)); - LOG_I(HW,"[SCHED][eNB] %s deadline thread %lu started on CPU %d\n", - name, (unsigned long)gettid(), sched_getcpu()); - } + if (sched_runtime!=0) { + struct sched_attr attr= {0}; + attr.size = sizeof(attr); + attr.sched_policy = SCHED_DEADLINE; + attr.sched_runtime = sched_runtime; + attr.sched_deadline = sched_deadline; + attr.sched_period = 0; + AssertFatal(sched_setattr(0, &attr, 0) == 0, + "[SCHED] %s thread: sched_setattr failed %s \n", name, strerror(errno)); + LOG_I(HW,"[SCHED][eNB] %s deadline thread %lu started on CPU %d\n", + name, (unsigned long)gettid(), sched_getcpu()); + } #else - if (CPU_COUNT(cpuset) > 0) - AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), ""); - struct sched_param sp; - sp.sched_priority = sched_fifo; - AssertFatal(pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp)==0, - "Can't set thread priority, Are you root?\n"); - /* Check the actual affinity mask assigned to the thread */ - cpu_set_t *cset=CPU_ALLOC(CPU_SETSIZE); - if (0 == pthread_getaffinity_np(pthread_self(), CPU_ALLOC_SIZE(CPU_SETSIZE), cset)) { - char txt[512]={0}; - for (int j = 0; j < CPU_SETSIZE; j++) - if (CPU_ISSET(j, cset)) - sprintf(txt+strlen(txt), " %d ", j); - printf("CPU Affinity of thread %s is %s\n", name, txt); - } - CPU_FREE(cset); + if (CPU_COUNT(cpuset) > 0) + AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), ""); + struct sched_param sp; + sp.sched_priority = sched_fifo; + AssertFatal(pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp)==0, + "Can't set thread priority, Are you root?\n"); + /* Check the actual affinity mask assigned to the thread */ + cpu_set_t *cset=CPU_ALLOC(CPU_SETSIZE); + if (0 == pthread_getaffinity_np(pthread_self(), CPU_ALLOC_SIZE(CPU_SETSIZE), cset)) { + char txt[512]={0}; + for (int j = 0; j < CPU_SETSIZE; j++) + if (CPU_ISSET(j, cset)) + sprintf(txt+strlen(txt), " %d ", j); + printf("CPU Affinity of thread %s is %s\n", name, txt); + } + CPU_FREE(cset); #endif } @@ -209,11 +243,11 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti int ret; LOG_I(PHY,"UE : Calling Layer 2 for initialization\n"); - + l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, 0,// cba_group_active 0); // HO flag - + for (inst=0;inst<nb_inst;inst++) { LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]); @@ -251,6 +285,76 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti #endif } +// Panos: Initiating all UEs within a single set of threads for PHY_STUB. Future extensions -> multiple +// set of threads for multiple UEs. +void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, 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, + 0,// cba_group_active + 0); // HO flag + + for (inst=0;inst<nb_inst;inst++) { + + LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]); + PHY_vars_UE_g[inst][0] = init_ue_vars(NULL,inst,0); + } + init_timer_thread(); + init_UE_single_thread_stub(nb_inst); + + + printf("UE threads created \n"); + + LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); + if(nfapi_mode!=3) + multicast_link_start(ue_stub_rx_handler,0,emul_iface); + + +} + + + + + +void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in, 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, + 0,// cba_group_active + 0); // HO flag + + for (inst=0;inst<nb_inst;inst++) { + + LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]); + PHY_vars_UE_g[inst][0] = init_ue_vars(NULL,inst,0); + } + init_timer_thread(); + + for (inst=0;inst<nb_inst;inst++) { + + 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_stub(inst); + } + + printf("UE threads created \n"); + + LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); + if(nfapi_mode !=3) + multicast_link_start(ue_stub_rx_handler,0,emul_iface); + + + +} + + + + /*! * \brief This is the UE synchronize thread. * It performs band scanning and synchonization. @@ -275,14 +379,14 @@ static void *UE_thread_synch(void *arg) UE->is_synchronized = 0; printf("UE_thread_sync in with PHY_vars_UE %p\n",arg); - cpu_set_t cpuset; + cpu_set_t cpuset; CPU_ZERO(&cpuset); if ( threads.iq != -1 ) CPU_SET(threads.iq, &cpuset); // this thread priority must be lower that the main acquisition thread sprintf(threadname, "sync UE %d\n", UE->Mod_id); init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname); - + printf("starting UE synch thread (IC %d)\n",UE->proc.instance_cnt_synch); ind = 0; found = 0; @@ -303,7 +407,7 @@ static void *UE_thread_synch(void *arg) ind++; } while (ind < sizeof(eutra_bands) / sizeof(eutra_bands[0])); - + if (found == 0) { LOG_E(PHY,"Can't find EUTRA band for frequency %d",UE->frame_parms.dl_CarrierFreq); exit_fun("Can't find EUTRA band for frequency"); @@ -317,7 +421,7 @@ static void *UE_thread_synch(void *arg) openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq; openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq; openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; - if (uplink_frequency_offset[CC_id][i] != 0) // + if (uplink_frequency_offset[CC_id][i] != 0) // openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_FDD; else //FDD openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_TDD; @@ -339,15 +443,15 @@ static void *UE_thread_synch(void *arg) } } - while (sync_var<0) - pthread_cond_wait(&sync_cond, &sync_mutex); - pthread_mutex_unlock(&sync_mutex); + while (sync_var<0) + pthread_cond_wait(&sync_cond, &sync_mutex); + pthread_mutex_unlock(&sync_mutex); - printf("Started device, unlocked sync_mutex (UE_sync_thread)\n"); + printf("Started device, unlocked sync_mutex (UE_sync_thread)\n"); - if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { - LOG_E(HW,"Could not start the device\n"); - oai_exit=1; + if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { + LOG_E(HW,"Could not start the device\n"); + oai_exit=1; } while (oai_exit==0) { @@ -356,202 +460,202 @@ static void *UE_thread_synch(void *arg) // the thread waits here most of the time pthread_cond_wait( &UE->proc.cond_synch, &UE->proc.mutex_synch ); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - + switch (sync_mode) { case pss: LOG_I(PHY,"[SCHED][UE] Scanning band %d (%d), freq %u\n",bands_to_scan.band_info[current_band].band, current_band,bands_to_scan.band_info[current_band].dl_min+current_offset); lte_sync_timefreq(UE,current_band,bands_to_scan.band_info[current_band].dl_min+current_offset); current_offset += 20000000; // increase by 20 MHz - + if (current_offset > bands_to_scan.band_info[current_band].dl_max-bands_to_scan.band_info[current_band].dl_min) { current_band++; - current_offset=0; - } - - if (current_band==bands_to_scan.nbands) { - current_band=0; - oai_exit=1; - } - - for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { - downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].dl_min+current_offset; - uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].ul_min-bands_to_scan.band_info[0].dl_min + current_offset; - - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]; - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]; - openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB; - if (UE->UE_scan_carrier) { - openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; - } - } + current_offset=0; + } + + if (current_band==bands_to_scan.nbands) { + current_band=0; + oai_exit=1; + } + + for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { + downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].dl_min+current_offset; + uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].ul_min-bands_to_scan.band_info[0].dl_min + current_offset; + + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]; + openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]; + openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB; + if (UE->UE_scan_carrier) { + openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; + } + } + + break; - break; - case pbch: #if DISABLE_LOG_X - printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); + printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); #else - LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); + LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); #endif - if (initial_sync( UE, UE->mode ) == 0) { - - hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_tti; - LOG_I( HW, "Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n", - hw_slot_offset, - freq_offset, - UE->rx_total_gain_dB, - downlink_frequency[0][0]+freq_offset, - downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset, - UE->UE_scan_carrier ); - - - // rerun with new cell parameters and frequency-offset - for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { - openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; - if (UE->UE_scan_carrier == 1) { - if (freq_offset >= 0) - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] += abs(UE->common_vars.freq_offset); - else - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(UE->common_vars.freq_offset); - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+uplink_frequency_offset[CC_id][i]; - downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i]; - freq_offset=0; - } + if (initial_sync( UE, UE->mode ) == 0) { + + hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_tti; + LOG_I( HW, "Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n", + hw_slot_offset, + freq_offset, + UE->rx_total_gain_dB, + downlink_frequency[0][0]+freq_offset, + downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset, + UE->UE_scan_carrier ); + + + // rerun with new cell parameters and frequency-offset + for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { + openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; + if (UE->UE_scan_carrier == 1) { + if (freq_offset >= 0) + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] += abs(UE->common_vars.freq_offset); + else + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(UE->common_vars.freq_offset); + openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+uplink_frequency_offset[CC_id][i]; + downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i]; + freq_offset=0; } + } + + // reconfigure for potentially different bandwidth + switch(UE->frame_parms.N_RB_DL) { + case 6: + openair0_cfg[UE->rf_map.card].sample_rate =1.92e6; + openair0_cfg[UE->rf_map.card].rx_bw =.96e6; + openair0_cfg[UE->rf_map.card].tx_bw =.96e6; + // openair0_cfg[0].rx_gain[0] -= 12; + break; + case 25: + openair0_cfg[UE->rf_map.card].sample_rate =7.68e6; + openair0_cfg[UE->rf_map.card].rx_bw =2.5e6; + openair0_cfg[UE->rf_map.card].tx_bw =2.5e6; + // openair0_cfg[0].rx_gain[0] -= 6; + break; + case 50: + openair0_cfg[UE->rf_map.card].sample_rate =15.36e6; + openair0_cfg[UE->rf_map.card].rx_bw =5.0e6; + openair0_cfg[UE->rf_map.card].tx_bw =5.0e6; + // openair0_cfg[0].rx_gain[0] -= 3; + break; + case 100: + openair0_cfg[UE->rf_map.card].sample_rate=30.72e6; + openair0_cfg[UE->rf_map.card].rx_bw=10.0e6; + openair0_cfg[UE->rf_map.card].tx_bw=10.0e6; + // openair0_cfg[0].rx_gain[0] -= 0; + break; + } + + 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); + init_frame_parms(&UE->frame_parms,1); + /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { + LOG_E(HW,"Could not start the device\n"); + oai_exit=1; + }*/ + + if (UE->UE_scan_carrier == 1) { + + UE->UE_scan_carrier = 0; + } else { + AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); + UE->is_synchronized = 1; + AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); + + if( UE->mode == rx_dump_frame ) { + FILE *fd; + if ((UE->proc.proc_rxtx[0].frame_rx&1) == 0) { // this guarantees SIB1 is present + if ((fd = fopen("rxsig_frame0.dat","w")) != NULL) { + fwrite((void*)&UE->common_vars.rxdata[0][0], + sizeof(int32_t), + 10*UE->frame_parms.samples_per_tti, + fd); + LOG_I(PHY,"Dummping Frame ... bye bye \n"); + fclose(fd); + exit(0); + } else { + LOG_E(PHY,"Cannot open file for writing\n"); + exit(0); + } + } else { + AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); + UE->is_synchronized = 0; + AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - // reconfigure for potentially different bandwidth - switch(UE->frame_parms.N_RB_DL) { - case 6: - openair0_cfg[UE->rf_map.card].sample_rate =1.92e6; - openair0_cfg[UE->rf_map.card].rx_bw =.96e6; - openair0_cfg[UE->rf_map.card].tx_bw =.96e6; - // openair0_cfg[0].rx_gain[0] -= 12; - break; - case 25: - openair0_cfg[UE->rf_map.card].sample_rate =7.68e6; - openair0_cfg[UE->rf_map.card].rx_bw =2.5e6; - openair0_cfg[UE->rf_map.card].tx_bw =2.5e6; - // openair0_cfg[0].rx_gain[0] -= 6; - break; - case 50: - openair0_cfg[UE->rf_map.card].sample_rate =15.36e6; - openair0_cfg[UE->rf_map.card].rx_bw =5.0e6; - openair0_cfg[UE->rf_map.card].tx_bw =5.0e6; - // openair0_cfg[0].rx_gain[0] -= 3; - break; - case 100: - openair0_cfg[UE->rf_map.card].sample_rate=30.72e6; - openair0_cfg[UE->rf_map.card].rx_bw=10.0e6; - openair0_cfg[UE->rf_map.card].tx_bw=10.0e6; - // openair0_cfg[0].rx_gain[0] -= 0; - break; - } - - 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); - init_frame_parms(&UE->frame_parms,1); - /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) { - LOG_E(HW,"Could not start the device\n"); - oai_exit=1; - }*/ - - if (UE->UE_scan_carrier == 1) { - - UE->UE_scan_carrier = 0; - } else { - AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); - UE->is_synchronized = 1; - AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - - if( UE->mode == rx_dump_frame ) { - FILE *fd; - if ((UE->proc.proc_rxtx[0].frame_rx&1) == 0) { // this guarantees SIB1 is present - if ((fd = fopen("rxsig_frame0.dat","w")) != NULL) { - fwrite((void*)&UE->common_vars.rxdata[0][0], - sizeof(int32_t), - 10*UE->frame_parms.samples_per_tti, - fd); - LOG_I(PHY,"Dummping Frame ... bye bye \n"); - fclose(fd); - exit(0); - } else { - LOG_E(PHY,"Cannot open file for writing\n"); - exit(0); - } - } else { - AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); - UE->is_synchronized = 0; - AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - - } - } - } - } else { - // initial sync failed - // calculate new offset and try again - if (UE->UE_scan_carrier == 1) { - if (freq_offset >= 0) - freq_offset += 100; - freq_offset *= -1; - - if (abs(freq_offset) > 7500) { - LOG_I( PHY, "[initial_sync] No cell synchronization found, abandoning\n" ); - FILE *fd; - if ((fd = fopen("rxsig_frame0.dat","w"))!=NULL) { - fwrite((void*)&UE->common_vars.rxdata[0][0], - sizeof(int32_t), - 10*UE->frame_parms.samples_per_tti, - fd); - LOG_I(PHY,"Dummping Frame ... bye bye \n"); - fclose(fd); - exit(0); - } - AssertFatal(1==0,"No cell synchronization found, abandoning"); - return &UE_thread_synch_retval; // not reached - } - } + } + } + } + } else { + // initial sync failed + // calculate new offset and try again + if (UE->UE_scan_carrier == 1) { + if (freq_offset >= 0) + freq_offset += 100; + freq_offset *= -1; + + if (abs(freq_offset) > 7500) { + LOG_I( PHY, "[initial_sync] No cell synchronization found, abandoning\n" ); + FILE *fd; + if ((fd = fopen("rxsig_frame0.dat","w"))!=NULL) { + fwrite((void*)&UE->common_vars.rxdata[0][0], + sizeof(int32_t), + 10*UE->frame_parms.samples_per_tti, + fd); + LOG_I(PHY,"Dummping Frame ... bye bye \n"); + fclose(fd); + exit(0); + } + AssertFatal(1==0,"No cell synchronization found, abandoning"); + return &UE_thread_synch_retval; // not reached + } + } #if DISABLE_LOG_X - printf("[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", - freq_offset, - UE->rx_total_gain_dB, - downlink_frequency[0][0]+freq_offset, - downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset ); + printf("[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", + freq_offset, + UE->rx_total_gain_dB, + downlink_frequency[0][0]+freq_offset, + downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset ); #else - LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", - freq_offset, - UE->rx_total_gain_dB, - downlink_frequency[0][0]+freq_offset, - downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset ); + LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", + freq_offset, + UE->rx_total_gain_dB, + downlink_frequency[0][0]+freq_offset, + downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset ); #endif - for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { - openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+freq_offset; - openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]+freq_offset; - openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; - if (UE->UE_scan_carrier==1) - openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; - } - UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); - }// initial_sync=0 - break; - case si: - default: - break; - } - - AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); - // indicate readiness - UE->proc.instance_cnt_synch--; - AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_THREAD_SYNCH, 0 ); - } // while !oai_exit - - return &UE_thread_synch_retval; + for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { + openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+freq_offset; + openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]+freq_offset; + openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; + if (UE->UE_scan_carrier==1) + openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1; + } + UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); + }// initial_sync=0 + break; + case si: + default: + break; + } + + AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); + // indicate readiness + UE->proc.instance_cnt_synch--; + AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_THREAD_SYNCH, 0 ); + } // while !oai_exit + + return &UE_thread_synch_retval; } /*! @@ -563,146 +667,733 @@ static void *UE_thread_synch(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; - PHY_VARS_UE *UE = rtd->UE; - int ret; - - proc->instance_cnt_rxtx=-1; - proc->subframe_rx=proc->sub_frame_start; - - char threadname[256]; - sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start); - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - - if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 ) - CPU_SET(threads.one, &cpuset); - if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 ) - CPU_SET(threads.two, &cpuset); - if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 ) - CPU_SET(threads.three, &cpuset); - //CPU_SET(threads.three, &cpuset); - init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, - threadname); - - while (!oai_exit) { - if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); - exit_fun("nothing to add"); - } - while (proc->instance_cnt_rxtx < 0) { - // most of the time, the thread is waiting here - pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx ); - } - if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" ); - exit_fun("nothing to add"); - } - - initRefTimes(t2); - initRefTimes(t3); - pickTime(current); - updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)"); - - // Process Rx data for one sub-frame - lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx); - if ((sf_type == SF_DL) || - (UE->frame_parms.frame_type == FDD) || - (sf_type == SF_S)) { - - if (UE->frame_parms.frame_type == TDD) { - LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n", - threadname, - UE->frame_parms.tdd_config, - (sf_type==SF_DL? "SF_DL" : - (sf_type==SF_UL? "SF_UL" : - (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); - } else { - LOG_D(PHY, "%s,%s,%s: calling UE_RX\n", - threadname, - (UE->frame_parms.frame_type==FDD? "FDD": - (UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")), - (sf_type==SF_DL? "SF_DL" : - (sf_type==SF_UL? "SF_UL" : - (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); - } + static __thread int UE_thread_rxtx_retval; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + PHY_VARS_UE *UE = rtd->UE; + int ret; + + proc->instance_cnt_rxtx=-1; + proc->subframe_rx=proc->sub_frame_start; + + char threadname[256]; + sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start); + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 ) + CPU_SET(threads.one, &cpuset); + if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 ) + CPU_SET(threads.two, &cpuset); + if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 ) + CPU_SET(threads.three, &cpuset); + //CPU_SET(threads.three, &cpuset); + init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, + threadname); + + while (!oai_exit) { + if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("nothing to add"); + } + while (proc->instance_cnt_rxtx < 0) { + // most of the time, the thread is waiting here + pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx ); + } + if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" ); + exit_fun("nothing to add"); + } + + initRefTimes(t2); + initRefTimes(t3); + pickTime(current); + updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)"); + + // Process Rx data for one sub-frame + lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx); + if ((sf_type == SF_DL) || + (UE->frame_parms.frame_type == FDD) || + (sf_type == SF_S)) { + + if (UE->frame_parms.frame_type == TDD) { + LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n", + threadname, + UE->frame_parms.tdd_config, + (sf_type==SF_DL? "SF_DL" : + (sf_type==SF_UL? "SF_UL" : + (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); + } else { + LOG_D(PHY, "%s,%s,%s: calling UE_RX\n", + threadname, + (UE->frame_parms.frame_type==FDD? "FDD": + (UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")), + (sf_type==SF_DL? "SF_DL" : + (sf_type==SF_UL? "SF_UL" : + (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); + } #ifdef UE_SLOT_PARALLELISATION - phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); + phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else - phy_procedures_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); + phy_procedures_UE_RX(UE, proc, 0, 0, 1, UE->mode); +#endif + } + +#if UE_TIMING_TRACE + start_meas(&UE->generic_stat); +#endif + if (UE->mac_enabled==1) { + + ret = ue_scheduler(UE->Mod_id, + proc->frame_rx, + proc->subframe_rx, + proc->frame_tx, + proc->subframe_tx, + subframe_select(&UE->frame_parms,proc->subframe_tx), + 0, + 0/*FIXME CC_id*/); + if ( ret != CONNECTION_OK) { + char *txt; + switch (ret) { + case CONNECTION_LOST: + txt="RRC Connection lost, returning to PRACH"; + break; + case PHY_RESYNCH: + txt="RRC Connection lost, trying to resynch"; + break; + case RESYNCH: + txt="return to PRACH and perform a contention-free access"; + break; + default: + txt="UNKNOWN RETURN CODE"; + }; + LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n", + UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt ); + } + } +#if UE_TIMING_TRACE + stop_meas(&UE->generic_stat); #endif - } + + + // Prepare the future Tx data + + 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); + + + + 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); + updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)"); + + if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("noting to add"); + } + proc->instance_cnt_rxtx--; +#if BASIC_SIMULATOR + if (pthread_cond_signal(&proc->cond_rxtx) != 0) abort(); +#endif + if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" ); + exit_fun("noting to add"); + } + } + + // thread finished + free(arg); + return &UE_thread_rxtx_retval; +} + + + +unsigned int emulator_absSF; + +void ue_stub_rx_handler(unsigned int num_bytes, char *rx_buffer) { + + PHY_VARS_UE *UE; + UE = PHY_vars_UE_g[0][0]; + + UE_tport_t *pdu = (UE_tport_t*)rx_buffer; + SLSCH_t *slsch = (SLSCH_t*)&pdu->slsch; + SLDCH_t *sldch = (SLDCH_t*)&pdu->sldch; + + switch (((UE_tport_header_t*)rx_buffer)->packet_type) { + case TTI_SYNC: + emulator_absSF = ((UE_tport_header_t*)rx_buffer)->absSF; + wakeup_thread(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread"); + break; + case SLSCH: + + + LOG_I(PHY,"Emulator SFN.SF %d.%d, Got SLSCH packet\n",emulator_absSF/10,emulator_absSF%10); + LOG_I(PHY,"Received %d bytes on UE-UE link for SFN.SF %d.%d, sending SLSCH payload (%d bytes) to MAC\n",num_bytes, + pdu->header.absSF/10,pdu->header.absSF%10, + slsch->payload_length); + printf("SLSCH:"); + for (int i=0;i<sizeof(SLSCH_t);i++) printf("%x ",((uint8_t*)slsch)[i]); + printf("\n"); + + ue_send_sl_sdu(0, + 0, + pdu->header.absSF/10, + pdu->header.absSF%10, + pdu->payload, + slsch->payload_length, + 0, + SL_DISCOVERY_FLAG_NO); + break; + + case SLDCH: + + + LOG_I(PHY,"Emulator SFN.SF %d.%d, Got SLDCH packet\n",emulator_absSF/10,emulator_absSF%10); + LOG_I(PHY,"Received %d bytes on UE-UE link for SFN.SF %d.%d, sending SLDCH payload (%d bytes) to MAC\n",num_bytes, + pdu->header.absSF/10,pdu->header.absSF%10, + sldch->payload_length); + printf("SLDCH:"); + for (int i=0;i<sizeof(SLDCH_t);i++) printf("%x ",((uint8_t*)sldch)[i]); + printf("\n"); + + ue_send_sl_sdu(0, + 0, + pdu->header.absSF/10, + pdu->header.absSF%10, + sldch->payload, + sldch->payload_length, + 0, + SL_DISCOVERY_FLAG_YES); + break; + + } +} + + +/*! + * \brief This is the UE thread for RX subframe n and TX subframe n+4. + * This thread performs the phy_procedures_UE_RX() on every received slot. + * then, if TX is enabled it performs TX for n+4. + * \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. + */ + +static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) { + + thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); + + 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 + static __thread int UE_thread_rxtx_retval; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + + // Initializations for nfapi-L2-emulator mode + dl_config_req = NULL; + ul_config_req = NULL; + hi_dci0_req = NULL; + tx_request_pdu_list = NULL; + + PHY_VARS_UE *UE; //= rtd->UE; + int ret; + // double t_diff; + + char threadname[256]; + //sprintf(threadname,"UE_%d_proc", UE->Mod_id); + + //proc->instance_cnt_rxtx=-1; + + phy_stub_ticking->ticking_var = -1; + proc->subframe_rx=proc->sub_frame_start; + + + //PANOS: CAREFUL HERE! + wait_sync("UE_phy_stub_single_thread_rxn_txnp4"); + + while (!oai_exit) { + + if (pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) != 0) { + LOG_E( MAC, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("nothing to add"); + } + while (phy_stub_ticking->ticking_var < 0) { + // most of the time, the thread is waiting here + //pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx ) + LOG_D(MAC,"Waiting for ticking_var\n"); + pthread_cond_wait( &phy_stub_ticking->cond_ticking, &phy_stub_ticking->mutex_ticking); + } + phy_stub_ticking->ticking_var--; + if (pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) != 0) { + LOG_E( MAC, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" ); + exit_fun("nothing to add"); + } + LOG_D(MAC," Panos-D [UE_phy_stub_thread_rxn_txnp4 1] Frame: %d, Subframe: %d \n" "\n" "\n", timer_frame, timer_subframe); + + + proc->subframe_rx=timer_subframe; + proc->frame_rx = timer_frame; + proc->subframe_tx=(timer_subframe+4)%10; + proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); + //oai_subframe_ind(proc->frame_rx, proc->subframe_rx); + + + oai_subframe_ind(timer_frame, timer_subframe); + + // Panos: Guessing that the next 4 lines are not needed for the phy_stub mode. + /*initRefTimes(t2); + initRefTimes(t3); + pickTime(current); + updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");*/ + + + //Panos: Not sure whether we should put the memory allocation here and not sure how much memory + //we should allocate for each subframe cycle. + UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t)); + + UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t*)malloc(NB_UE_INST*sizeof(nfapi_rx_indication_pdu_t)); + UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; + + + UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = (nfapi_crc_indication_pdu_t*)malloc(NB_UE_INST*sizeof(nfapi_crc_indication_pdu_t)); + UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0; + + UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = (nfapi_harq_indication_pdu_t*)malloc(NB_UE_INST*sizeof(nfapi_harq_indication_pdu_t)); + UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0; + + UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = (nfapi_sr_indication_pdu_t*)malloc(NB_UE_INST*sizeof(nfapi_sr_indication_pdu_t)); + UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; + + + + + for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) { + //LOG_D(MAC, "UE_phy_stub_single_thread_rxn_txnp4, NB_UE_INST:%d, Mod_id:%d \n", NB_UE_INST, Mod_id); + UE = PHY_vars_UE_g[Mod_id][0]; + lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx); + if ((sf_type == SF_DL) || + (UE->frame_parms.frame_type == FDD) || + (sf_type == SF_S)) { + + if (UE->frame_parms.frame_type == TDD) { + LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n", + threadname, + UE->frame_parms.tdd_config, + (sf_type==SF_DL? "SF_DL" : + (sf_type==SF_UL? "SF_UL" : + (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); + } else { + LOG_D(PHY, "%s,%s,%s: calling UE_RX\n", + threadname, + (UE->frame_parms.frame_type==FDD? "FDD": + (UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")), + (sf_type==SF_DL? "SF_DL" : + (sf_type==SF_UL? "SF_UL" : + (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); + } + + + phy_procedures_UE_SL_RX(UE,proc); + + if (dl_config_req!=NULL && tx_request_pdu_list!=NULL){ + //if(dl_config_req!= NULL) { + dl_config_req_UE_MAC(dl_config_req, Mod_id); + + } + + if (hi_dci0_req!=NULL && hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){ + hi_dci0_req_UE_MAC(hi_dci0_req, Mod_id); + } + + if(nfapi_mode!=3) + phy_procedures_UE_SL_TX(UE,proc); + + } #if UE_TIMING_TRACE - start_meas(&UE->generic_stat); + start_meas(&UE->generic_stat); #endif - if (UE->mac_enabled==1) { - - ret = ue_scheduler(UE->Mod_id, - proc->frame_rx, - proc->subframe_rx, - proc->frame_tx, - proc->subframe_tx, - subframe_select(&UE->frame_parms,proc->subframe_tx), - 0, - 0/*FIXME CC_id*/); - if ( ret != CONNECTION_OK) { - char *txt; - switch (ret) { - case CONNECTION_LOST: - txt="RRC Connection lost, returning to PRACH"; - break; - case PHY_RESYNCH: - txt="RRC Connection lost, trying to resynch"; - break; - case RESYNCH: - txt="return to PRACH and perform a contention-free access"; - break; - default: - txt="UNKNOWN RETURN CODE"; - }; - LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n", - UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt ); - } - } + + if (UE->mac_enabled==1) { + + ret = ue_scheduler(UE->Mod_id, + proc->frame_rx, + proc->subframe_rx, + proc->frame_tx, + proc->subframe_tx, + subframe_select(&UE->frame_parms,proc->subframe_tx), + 0, + 0/*FIXME CC_id*/); + if ( ret != CONNECTION_OK) { + char *txt; + switch (ret) { + case CONNECTION_LOST: + txt="RRC Connection lost, returning to PRACH"; + break; + case PHY_RESYNCH: + txt="RRC Connection lost, trying to resynch"; + break; + case RESYNCH: + txt="return to PRACH and perform a contention-free access"; + break; + default: + txt="UNKNOWN RETURN CODE"; + }; + LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n", + UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt ); + } + } #if UE_TIMING_TRACE - stop_meas(&UE->generic_stat); + stop_meas(&UE->generic_stat); #endif - // Prepare the future Tx data + // Prepare the future Tx data + + 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[Mod_id].UE_mode[0] == PRACH && Mod_id == next_Mod_id && proc->frame_rx >= next_ra_frame) { + + // check if we have PRACH opportunity + + if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx) && UE_mac_inst[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(Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx); + if(prach_resources!=NULL ) { + UE_mac_inst[Mod_id].ra_frame = proc->frame_rx; + LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d \n", Mod_id ); + 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; + next_Mod_id = Mod_id + 1; + next_ra_frame = (proc->frame_rx + 20)%1000; + } + + //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); + } + } // mode is PRACH + // Panos: 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, Mod_id); + } + } + + phy_procedures_UE_SL_RX(UE,proc); + + + } //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) + + + if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs>0) + { + //LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf)); + //LOG_I(MAC, "ul_config_req_UE_MAC 2.2, SFN/SF of PNF counter:%d.%d, number_of_crcs: %d \n", timer_frame, timer_subframe, UL_INFO->crc_ind.crc_indication_body.number_of_crcs); + oai_nfapi_crc_indication(&UL_INFO->crc_ind); + //LOG_I(MAC, "ul_config_req_UE_MAC 2.21 \n"); + UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0; + } + if (UL_INFO->rx_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); + oai_nfapi_rx_ind(&UL_INFO->rx_ind); + //LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n"); + UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; + } + 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); + oai_nfapi_harq_indication(&UL_INFO->harq_ind); + //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); + oai_nfapi_sr_indication(&UL_INFO->sr_ind); + //LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n"); + UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0; + } + + // Free UL_INFO messages + //if(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list != NULL){ + free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list); + UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL; + //} + //if(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list != NULL){ + free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list); + UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL; + //} + //if(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list !=NULL){ + free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list); + UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL; + //} + //if(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list!=NULL){ + free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list); + UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL; + //} + + free(UL_INFO); + UL_INFO = NULL; + + // De-allocate memory of nfapi requests copies before next subframe round + if(dl_config_req!=NULL){ + if(dl_config_req->vendor_extension) + free(dl_config_req->vendor_extension); + if(dl_config_req->dl_config_request_body.dl_config_pdu_list!=NULL){ + free(dl_config_req->dl_config_request_body.dl_config_pdu_list); + dl_config_req->dl_config_request_body.dl_config_pdu_list = NULL; + } + free(dl_config_req); + dl_config_req = NULL; + } + if(tx_request_pdu_list!=NULL){ + free(tx_request_pdu_list); + tx_request_pdu_list = NULL; + } + if(ul_config_req!=NULL){ + 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; + } + free(ul_config_req); + ul_config_req = NULL; + } + + if(hi_dci0_req!=NULL){ + if(hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){ + free(hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list); + hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = NULL; + } + free(hi_dci0_req); + hi_dci0_req = NULL; + } + + + + } + // thread finished + free(arg); + return &UE_thread_rxtx_retval; +} + + + + +/*! + * \brief This is the UE thread for RX subframe n and TX subframe n+4. + * This thread performs the phy_procedures_UE_RX() on every received slot. + * then, if TX is enabled it performs TX for n+4. + * \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. + */ + +static void *UE_phy_stub_thread_rxn_txnp4(void *arg) { + + thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); - 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,no_relay); + module_id_t Mod_id = 0; + static __thread int UE_thread_rxtx_retval; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + PHY_VARS_UE *UE = rtd->UE; + int ret; + // double t_diff; + char threadname[256]; + sprintf(threadname,"UE_%d_proc", UE->Mod_id); - 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,no_relay); - updateTimes(current, &t3, 10000, "Delay to process sub-frame (case 3)"); + //proc->instance_cnt_rxtx=-1; - if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); - exit_fun("noting to add"); - } - proc->instance_cnt_rxtx--; - if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" ); - exit_fun("noting to add"); - } + phy_stub_ticking->ticking_var = -1; + proc->subframe_rx=proc->sub_frame_start; + + //PANOS: CAREFUL HERE! + wait_sync("UE_phy_stub_thread_rxn_txnp4"); + + while (!oai_exit) { + + if (pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) != 0) { + LOG_E( MAC, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("nothing to add"); + } + while (phy_stub_ticking->ticking_var < 0) { + // most of the time, the thread is waiting here + //pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx ) + LOG_D(MAC,"Waiting for ticking_var\n"); + pthread_cond_wait( &phy_stub_ticking->cond_ticking, &phy_stub_ticking->mutex_ticking); } + phy_stub_ticking->ticking_var--; + if (pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) != 0) { + LOG_E( MAC, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" ); + exit_fun("nothing to add"); + } + LOG_D(MAC," Panos-D [UE_phy_stub_thread_rxn_txnp4 1] Frame: %d, Subframe: %d \n" "\n" "\n", timer_frame, timer_subframe); + + + proc->subframe_rx=timer_subframe; + proc->frame_rx = timer_frame; + proc->subframe_tx=(timer_subframe+4)%10; + proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); + + + // Process Rx data for one sub-frame + lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx); + if ((sf_type == SF_DL) || + (UE->frame_parms.frame_type == FDD) || + (sf_type == SF_S)) { + + if (UE->frame_parms.frame_type == TDD) { + LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n", + threadname, + UE->frame_parms.tdd_config, + (sf_type==SF_DL? "SF_DL" : + (sf_type==SF_UL? "SF_UL" : + (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); + } else { + LOG_D(PHY, "%s,%s,%s: calling UE_RX\n", + threadname, + (UE->frame_parms.frame_type==FDD? "FDD": + (UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")), + (sf_type==SF_DL? "SF_DL" : + (sf_type==SF_UL? "SF_UL" : + (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); + } + + + phy_procedures_UE_SL_RX(UE,proc); + + oai_subframe_ind(timer_frame, timer_subframe); + + if(dl_config_req!= NULL) { + + dl_config_req_UE_MAC(dl_config_req, Mod_id); + + } + //if(UE_mac_inst[Mod_id].hi_dci0_req!= NULL){ + if (hi_dci0_req!=NULL && hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){ + LOG_I( MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 after oai_subframe_ind 4 \n"); + hi_dci0_req_UE_MAC(hi_dci0_req, Mod_id); + //if(UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){ + free(hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list); + hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = NULL; + //} + free(hi_dci0_req); + hi_dci0_req = NULL; + } + + else if(hi_dci0_req!=NULL){ + free(hi_dci0_req); + hi_dci0_req = NULL; + } + + if (nfapi_mode != 3) + phy_procedures_UE_SL_TX(UE,proc); -// thread finished - free(arg); - return &UE_thread_rxtx_retval; + } + +#if UE_TIMING_TRACE + start_meas(&UE->generic_stat); +#endif + if (UE->mac_enabled==1) { + + ret = ue_scheduler(UE->Mod_id, + proc->frame_rx, + proc->subframe_rx, + proc->frame_tx, + proc->subframe_tx, + subframe_select(&UE->frame_parms,proc->subframe_tx), + 0, + 0); + if ( ret != CONNECTION_OK) { + char *txt; + switch (ret) { + case CONNECTION_LOST: + txt="RRC Connection lost, returning to PRACH"; + break; + case PHY_RESYNCH: + txt="RRC Connection lost, trying to resynch"; + break; + case RESYNCH: + txt="return to PRACH and perform a contention-free access"; + break; + default: + txt="UNKNOWN RETURN CODE"; + }; + LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n", + UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt ); + } + } +#if UE_TIMING_TRACE + stop_meas(&UE->generic_stat); +#endif + + + // Prepare the future Tx data + + 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) ) { + //LOG_D(MAC, "Panos-D: UE_phy_stub_thread_rxn_txnp4 before RACH \n"); + + // 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 + // Panos: 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; + } + free(ul_config_req); + ul_config_req = NULL; + } + else if(ul_config_req!=NULL){ + free(ul_config_req); + ul_config_req = NULL; + } + } + + phy_procedures_UE_SL_RX(UE,proc); + + } + // thread finished + free(arg); + return &UE_thread_rxtx_retval; } + + /*! * \brief This is the main UE thread. * This thread controls the other three UE threads: @@ -716,81 +1407,87 @@ static void *UE_thread_rxn_txnp4(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))); - openair0_timestamp timestamp,timestamp1; - void* rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX]; - int start_rx_stream = 0; - int i; - int th_id; + 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))); + openair0_timestamp timestamp,timestamp1; + void* rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX]; + int start_rx_stream = 0; + int i; + int th_id; - static uint8_t thread_idx = 0; + static uint8_t thread_idx = 0; - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - if ( threads.iq != -1 ) - CPU_SET(threads.iq, &cpuset); - init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, - "UHD Threads"); + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + if ( threads.iq != -1 ) + CPU_SET(threads.iq, &cpuset); + init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, + "UHD Threads"); #ifdef NAS_UE - MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); - itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p); + MessageDef *message_p; + message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); + itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p); #endif - int sub_frame=-1; - //int cumulated_shift=0; + int sub_frame=-1; + //int cumulated_shift=0; - - while (!oai_exit) { - 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 - // grab 10 ms of signal and wakeup synch thread - for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) - rxp[i] = (void*)&UE->common_vars.rxdata[i][0]; + while (!oai_exit) { + 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 (UE->mode != loop_through_memory) - 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; - if (instance_cnt_synch == 0) { - AssertFatal( 0 == pthread_cond_signal(&UE->proc.cond_synch), ""); - } else { - LOG_E( PHY, "[SCHED][UE] UE sync thread busy!!\n" ); - exit_fun("nothing to add"); - } - AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); - } else { + if (is_synchronized == 0) { +#if BASIC_SIMULATOR + while (!((instance_cnt_synch = UE->proc.instance_cnt_synch) < 0)) { + printf("ue sync not ready\n"); + usleep(500*1000); + } +#endif + if (instance_cnt_synch < 0) { // we can invoke the synch + // grab 10 ms of signal and wakeup synch thread + for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) + rxp[i] = (void*)&UE->common_vars.rxdata[i][0]; + + if (UE->mode != loop_through_memory) + 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; + if (instance_cnt_synch == 0) { + AssertFatal( 0 == pthread_cond_signal(&UE->proc.cond_synch), ""); + } else { + LOG_E( PHY, "[SCHED][UE] UE sync thread busy!!\n" ); + exit_fun("nothing to add"); + } + AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); + } else { #if OAISIM - (void)dummy_rx; /* avoid gcc warnings */ - usleep(500); + (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; i<UE->frame_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); - } + // grab 10 ms of signal into dummy buffer + if (UE->mode != loop_through_memory) { + for (int i=0; i<UE->frame_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); + } #endif - } + } } // UE->is_synchronized==0 else { @@ -833,6 +1530,17 @@ void *UE_thread(void *arg) { // update thread index for received subframe UE->current_thread_id[sub_frame] = thread_idx; +#if BASIC_SIMULATOR + { + int t; + for (t = 0; t < 2; t++) { + UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[t]; + pthread_mutex_lock(&proc->mutex_rxtx); + while (proc->instance_cnt_rxtx >= 0) pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx ); + pthread_mutex_unlock(&proc->mutex_rxtx); + } + } +#endif LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); thread_idx++; @@ -959,6 +1667,7 @@ void *UE_thread(void *arg) { return NULL; } + /*! * \brief Initialize the UE theads. * Creates the UE threads: @@ -972,117 +1681,688 @@ void *UE_thread(void *arg) { * and the locking between them. */ void init_UE_threads(int inst) { - struct rx_tx_thread_data *rtd; - PHY_VARS_UE *UE; + struct rx_tx_thread_data *rtd; + PHY_VARS_UE *UE; - AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); - AssertFatal(PHY_vars_UE_g[inst]!=NULL,"PHY_vars_UE_g[inst] is NULL\n"); - AssertFatal(PHY_vars_UE_g[inst][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n"); - UE = PHY_vars_UE_g[inst][0]; + AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); + AssertFatal(PHY_vars_UE_g[inst]!=NULL,"PHY_vars_UE_g[inst] is NULL\n"); + AssertFatal(PHY_vars_UE_g[inst][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n"); + UE = PHY_vars_UE_g[inst][0]; - pthread_attr_init (&UE->proc.attr_ue); - pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); + pthread_attr_init (&UE->proc.attr_ue); + pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); - pthread_mutex_init(&UE->proc.mutex_synch,NULL); - pthread_cond_init(&UE->proc.cond_synch,NULL); + pthread_mutex_init(&UE->proc.mutex_synch,NULL); + pthread_cond_init(&UE->proc.cond_synch,NULL); - // the threads are not yet active, therefore access is allowed without locking - int nb_threads=RX_NB_TH; - for (int i=0; i<nb_threads; i++) { - rtd = calloc(1, sizeof(struct rx_tx_thread_data)); - if (rtd == NULL) abort(); - rtd->UE = UE; - rtd->proc = &UE->proc.proc_rxtx[i]; + // the threads are not yet active, therefore access is allowed without locking + int nb_threads=RX_NB_TH; + for (int i=0; i<nb_threads; i++) { + rtd = calloc(1, sizeof(struct rx_tx_thread_data)); + if (rtd == NULL) abort(); + rtd->UE = UE; + rtd->proc = &UE->proc.proc_rxtx[i]; - pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL); - pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL); - UE->proc.proc_rxtx[i].sub_frame_start=i; - UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; - printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i); - pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd); + pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL); + pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL); + UE->proc.proc_rxtx[i].sub_frame_start=i; + UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; + printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i); + pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd); #ifdef UE_SLOT_PARALLELISATION - //pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL); - //pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL); - //pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd); + //pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL); + //pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL); + //pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd); - pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL); - pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL); - pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd); + pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL); + pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL); + pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd); #endif - } - pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); + } + pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); } + +/*! + * \brief Initialize the UE theads. + * Creates the UE threads: + * - UE_thread_rxtx0 + * - UE_thread_synch + * - UE_thread_fep_slot0 + * - UE_thread_fep_slot1 + * - UE_thread_dlsch_proc_slot0 + * - UE_thread_dlsch_proc_slot1 + * and the locking between them. + */ +void init_UE_single_thread_stub(int nb_inst) { + struct rx_tx_thread_data *rtd; + PHY_VARS_UE *UE; + + for (int i=0; i<nb_inst; i++){ + AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); + AssertFatal(PHY_vars_UE_g[i]!=NULL,"PHY_vars_UE_g[inst] is NULL\n"); + AssertFatal(PHY_vars_UE_g[i][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n"); + } + UE = PHY_vars_UE_g[0][0]; + + pthread_attr_init (&UE->proc.attr_ue); + pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); + + // Panos: Don't need synch for phy_stub mode + //pthread_mutex_init(&UE->proc.mutex_synch,NULL); + //pthread_cond_init(&UE->proc.cond_synch,NULL); + + // the threads are not yet active, therefore access is allowed without locking + // Panos: 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; + for (int i=0; i<nb_threads; i++) { + rtd = calloc(1, sizeof(struct rx_tx_thread_data)); + if (rtd == NULL) abort(); + rtd->UE = UE; + rtd->proc = &UE->proc.proc_rxtx[i]; + + pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL); + pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL); + UE->proc.proc_rxtx[i].sub_frame_start=i; + UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; + printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i); + pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_phy_stub_single_thread_rxn_txnp4, rtd); + + } + // Panos: Remove thread for UE_sync in phy_stub_UE mode. + //pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); +} + + + + +/*! + * \brief Initialize the UE theads. + * Creates the UE threads: + * - UE_thread_rxtx0 + * - UE_thread_synch + * - UE_thread_fep_slot0 + * - UE_thread_fep_slot1 + * - UE_thread_dlsch_proc_slot0 + * - UE_thread_dlsch_proc_slot1 + * and the locking between them. + */ +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"); + AssertFatal(PHY_vars_UE_g[inst]!=NULL,"PHY_vars_UE_g[inst] is NULL\n"); + AssertFatal(PHY_vars_UE_g[inst][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n"); + UE = PHY_vars_UE_g[inst][0]; + + pthread_attr_init (&UE->proc.attr_ue); + pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); + + // Panos: Don't need synch for phy_stub mode + //pthread_mutex_init(&UE->proc.mutex_synch,NULL); + //pthread_cond_init(&UE->proc.cond_synch,NULL); + + // the threads are not yet active, therefore access is allowed without locking + // Panos: 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; + for (int i=0; i<nb_threads; i++) { + rtd = calloc(1, sizeof(struct rx_tx_thread_data)); + if (rtd == NULL) abort(); + rtd->UE = UE; + rtd->proc = &UE->proc.proc_rxtx[i]; + + pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL); + pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL); + UE->proc.proc_rxtx[i].sub_frame_start=i; + UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; + printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i); + pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_phy_stub_thread_rxn_txnp4, rtd); + + + } + // Panos: Remove thread for UE_sync in phy_stub_UE mode. + //pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); +} + + + + #ifdef OPENAIR2 void fill_ue_band_info(void) { - 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; - - for (i=0; i<bands_to_scan.nbands; i++) { - - for (j=0; j<sizeof (eutra_bands) / sizeof (eutra_bands[0]); j++) - if (eutra_bands[j].band == UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA) { - memcpy(&bands_to_scan.band_info[i], - &eutra_bands[j], - sizeof(eutra_band_t)); - - printf("Band %d (%lu) : DL %u..%u Hz, UL %u..%u Hz, Duplex %s \n", - bands_to_scan.band_info[i].band, - UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA, - bands_to_scan.band_info[i].dl_min, - bands_to_scan.band_info[i].dl_max, - bands_to_scan.band_info[i].ul_min, - bands_to_scan.band_info[i].ul_max, - (bands_to_scan.band_info[i].frame_type==FDD) ? "FDD" : "TDD"); - break; - } - } + 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; + + for (i=0; i<bands_to_scan.nbands; i++) { + + for (j=0; j<sizeof (eutra_bands) / sizeof (eutra_bands[0]); j++) + if (eutra_bands[j].band == UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA) { + memcpy(&bands_to_scan.band_info[i], + &eutra_bands[j], + sizeof(eutra_band_t)); + + printf("Band %d (%lu) : DL %u..%u Hz, UL %u..%u Hz, Duplex %s \n", + bands_to_scan.band_info[i].band, + UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA, + bands_to_scan.band_info[i].dl_min, + bands_to_scan.band_info[i].dl_max, + bands_to_scan.band_info[i].ul_min, + bands_to_scan.band_info[i].ul_max, + (bands_to_scan.band_info[i].frame_type==FDD) ? "FDD" : "TDD"); + break; + } + } } #endif int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg) { - int i, CC_id; - LTE_DL_FRAME_PARMS *frame_parms; - openair0_rf_map *rf_map; - - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - rf_map = &phy_vars_ue[CC_id]->rf_map; - - 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; i<frame_parms->nb_antennas_rx; i++) { - LOG_I(PHY, "Mapping UE CC_id %d, rx_ant %d, freq %u on card %d, chain %d\n", - CC_id, i, downlink_frequency[CC_id][i], rf_map->card, 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 + int i, CC_id; + LTE_DL_FRAME_PARMS *frame_parms; + openair0_rf_map *rf_map; + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + rf_map = &phy_vars_ue[CC_id]->rf_map; + + 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; i<frame_parms->nb_antennas_rx; i++) { + LOG_I(PHY, "Mapping UE CC_id %d, rx_ant %d, freq %u on card %d, chain %d\n", + CC_id, i, downlink_frequency[CC_id][i], rf_map->card, 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 + } + + for (i=0; i<frame_parms->nb_antennas_tx; i++) { + LOG_I(PHY, "Mapping UE CC_id %d, tx_ant %d, freq %u on card %d, chain %d\n", + CC_id, i, downlink_frequency[CC_id][i], rf_map->card, 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]; + } + + // rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x] + // txdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.txdata[x] + // be careful when releasing memory! + // because no "release_ue_buffers"-function is available, at least rxdata and txdata memory will leak (only some bytes) + } + return 0; +} + + + + +/*static void* timer_thread( void* param ) { + thread_top_init("timer_thread",1,870000L,1000000L,1000000L); + timer_subframe =9; + timer_frame =1023; + //phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking)); + phy_stub_ticking->ticking_var = -1; + PHY_VARS_UE *UE; + UE = PHY_vars_UE_g[0][0]; + double t_diff; + int external_timer = 0; + + + //struct timespec pselect_start; + + + //struct timespec sf_duration; + //sf_duration.tv_sec = 0; + //sf_duration.tv_nsec = 1e6; + + + wait_sync("timer_thread"); + + //pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL); + //pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL); + + // struct timespec start = {0}; + // struct timespec end = {0}; + //sleepValue.tv_nsec = 1000000; + opp_enabled = 1; + + // first check if we are receiving timing indications + if(nfapi_mode==4) { + usleep(10000); + if (UE->instance_cnt_timer > 0) { + external_timer = 1; + int absSFm1 = ((emulator_absSF+10239)%10240); + timer_frame = absSFm1/10; + timer_subframe = absSFm1%10; + pthread_mutex_lock(&UE->timer_mutex); + UE->instance_cnt_timer = -1; + pthread_mutex_unlock(&UE->timer_mutex); + LOG_I(PHY,"Running with external timer\n"); + } + else LOG_I(PHY,"Running with internal timer\n"); + } + + struct timespec t_start; + struct timespec t_now; + struct timespec t_sleep; + uint64_t T_0; + uint64_t T_now; + uint64_t T_next_SF; + uint64_t T_sleep; + uint64_t sf_cnt = 0; //Total Subframe counter + + clock_gettime(CLOCK_MONOTONIC, &t_start); + T_0 = (uint64_t) t_start.tv_sec*1000000000 + t_start.tv_nsec; + LOG_I(MAC, "Panos-D: timer_thread(), T_0 value: %" PRId64 "\n", T_0); + //printf("%" PRId64 "\n", t); + + while (!oai_exit) { + + // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. + // They are set on the first rx/tx in the underly FH routines. + if (timer_subframe==9) { + timer_subframe=0; + timer_frame++; + timer_frame&=1023; + } else { + timer_subframe++; + } + //printf("[timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe); + //LOG_I(MAC," Panos-D [timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe); + //AssertFatal( 0 == pthread_cond_signal(&phy_stub_ticking->cond_ticking), ""); + AssertFatal(pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) ==0,""); + phy_stub_ticking->ticking_var++; + // This should probably be a call to pthread_cond_broadcast when we introduce support for multiple UEs (threads) + if(phy_stub_ticking->ticking_var == 0){ + //AssertFatal(phy_stub_ticking->ticking_var == 0,"phy_stub_ticking->ticking_var = %d", + //phy_stub_ticking->ticking_var); + if (pthread_cond_signal(&phy_stub_ticking->cond_ticking) != 0) { + //LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id); + LOG_E( PHY, "timer_thread ERROR pthread_cond_signal for UE_thread\n"); + exit_fun("nothing to add"); } - - for (i=0; i<frame_parms->nb_antennas_tx; i++) { - LOG_I(PHY, "Mapping UE CC_id %d, tx_ant %d, freq %u on card %d, chain %d\n", - CC_id, i, downlink_frequency[CC_id][i], rf_map->card, 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]; + } + else + LOG_I(MAC, "Panos-D: timer_thread() Timing problem! \n"); + + AssertFatal(pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) ==0,""); + start_meas(&UE->timer_stats); + + + //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); // get initial time-stamp + if (external_timer == 0) { + sf_cnt++; + T_next_SF = T_0 + sf_cnt*1000000; + do{ + clock_gettime(CLOCK_MONOTONIC, &t_now); + T_now =(uint64_t) t_now.tv_sec*1000000000 + t_now.tv_nsec; + }while(T_now < T_next_SF); + //usleep(1000); + UE_tport_t pdu; + pdu.header.packet_type = TTI_SYNC; + pdu.header.absSF = (timer_frame*10)+timer_subframe; + if (nfapi_mode!=3){ + multicast_link_write_sock(0, + &pdu, + sizeof(UE_tport_header_t)); + } + + } + else { + wait_on_condition(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread"); + release_thread(&UE->timer_mutex,&UE->instance_cnt_timer,"timer_thread"); + } + //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); // get final time-stamp + + //double t_ns = (double)(end.tv_sec - start.tv_sec) * 1.0e9 + + // (double)(end.tv_nsec - start.tv_nsec); + //printf("Panos-D: [timer_thread] REAL TIME difference: %f", t_ns); + + + stop_meas(&UE->timer_stats); + t_diff = get_time_meas_us(&UE->timer_stats); + + //printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now); + //LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); + //if (t_diff > 1100) + + + // LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff); + //LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff); + + //printf("Panos-D: Absolute time: %f", t_diff); + + + stop_meas(&UE->timer_stats); + t_diff = get_time_meas_us(&UE->timer_stats); + //printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now); + //LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); + //if (t_diff > 1100) LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff); + //printf("Panos-D: Absolute time: %f", t_diff); + + //UE->proc.ticking_var++; + // pthread_cond_signal() //Send signal to ue_thread()? + // We also need to somehow pass the information of SFN/SF + } + free(phy_stub_ticking); + pthread_cond_destroy(&phy_stub_ticking->cond_ticking); + pthread_mutex_destroy(&phy_stub_ticking->mutex_ticking); + return 0; + +}*/ + + + + + + + + + +// Panos: This timer thread is used only in the phy_stub mode as an independent timer +// which will be ticking and provide the SFN/SF values that will be used from the UE threads +// playing the role of nfapi-pnf. + +//02/02/2018 +static void* timer_thread( void* param ) { + thread_top_init("timer_thread",1,870000L,1000000L,1000000L); + timer_subframe =9; + timer_frame =1023; + //phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking)); + phy_stub_ticking->ticking_var = -1; + PHY_VARS_UE *UE; + UE = PHY_vars_UE_g[0][0]; + //double t_diff; + int external_timer = 0; + + + wait_sync("timer_thread"); + + opp_enabled = 1; + + // first check if we are receiving timing indications + if(nfapi_mode==4) { + usleep(10000); + if (UE->instance_cnt_timer > 0) { + external_timer = 1; + int absSFm1 = ((emulator_absSF+10239)%10240); + timer_frame = absSFm1/10; + timer_subframe = absSFm1%10; + pthread_mutex_lock(&UE->timer_mutex); + UE->instance_cnt_timer = -1; + pthread_mutex_unlock(&UE->timer_mutex); + LOG_I(PHY,"Running with external timer\n"); + } + else LOG_I(PHY,"Running with internal timer\n"); + } + + struct timespec t_start; + struct timespec t_now; + struct timespec t_sleep; + uint64_t T_0; + uint64_t T_now; + uint64_t T_next_SF; + uint64_t T_sleep; + uint64_t sf_cnt = 0; //Total Subframe counter + + clock_gettime(CLOCK_MONOTONIC, &t_start); + T_0 = (uint64_t) t_start.tv_sec*1000000000 + t_start.tv_nsec; + LOG_D(MAC, "timer_thread(), T_0 value: %" PRId64 "\n", T_0); + + while (!oai_exit) { + + // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. + // They are set on the first rx/tx in the underly FH routines. + if (timer_subframe==9) { + timer_subframe=0; + timer_frame++; + timer_frame&=1023; + } else { + timer_subframe++; + } + + //AssertFatal( 0 == pthread_cond_signal(&phy_stub_ticking->cond_ticking), ""); + AssertFatal(pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) ==0,""); + phy_stub_ticking->ticking_var++; + // This should probably be a call to pthread_cond_broadcast when we introduce support for multiple UEs (threads) + if(phy_stub_ticking->ticking_var == 0){ + //AssertFatal(phy_stub_ticking->ticking_var == 0,"phy_stub_ticking->ticking_var = %d", + //phy_stub_ticking->ticking_var); + if (pthread_cond_signal(&phy_stub_ticking->cond_ticking) != 0) { + //LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id); + LOG_E( PHY, "timer_thread ERROR pthread_cond_signal for UE_thread\n"); + exit_fun("nothing to add"); } - - // rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x] - // txdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.txdata[x] - // be careful when releasing memory! - // because no "release_ue_buffers"-function is available, at least rxdata and txdata memory will leak (only some bytes) } - return 0; + else + LOG_D(MAC, "timer_thread() Timing problem! ticking_var value:%d \n \n \n", phy_stub_ticking->ticking_var); + + AssertFatal(pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) ==0,""); + start_meas(&UE->timer_stats); + + + //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); // get initial time-stamp + if (external_timer == 0) { + clock_gettime(CLOCK_MONOTONIC, &t_now); + sf_cnt++; + T_next_SF = T_0 + sf_cnt*1000000; + T_now =(uint64_t) t_now.tv_sec*1000000000 + t_now.tv_nsec; + if(T_now > T_next_SF){ + t_sleep.tv_sec =0; + t_sleep.tv_nsec =0; + } + else{ + T_sleep = T_next_SF - T_now; + t_sleep.tv_sec =0; + t_sleep.tv_nsec = (__syscall_slong_t) T_sleep; + } + nanosleep(&t_sleep, (struct timespec *)NULL); + UE_tport_t pdu; + pdu.header.packet_type = TTI_SYNC; + pdu.header.absSF = (timer_frame*10)+timer_subframe; + if (nfapi_mode!=3){ + multicast_link_write_sock(0, + (char *)&pdu, + sizeof(UE_tport_header_t)); + } + + } + else { + wait_on_condition(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread"); + release_thread(&UE->timer_mutex,&UE->instance_cnt_timer,"timer_thread"); + } + + + /*stop_meas(&UE->timer_stats); + t_diff = get_time_meas_us(&UE->timer_stats); + + stop_meas(&UE->timer_stats); + t_diff = get_time_meas_us(&UE->timer_stats);*/ + } + free(phy_stub_ticking); + pthread_cond_destroy(&phy_stub_ticking->cond_ticking); + pthread_mutex_destroy(&phy_stub_ticking->mutex_ticking); + return 0; + +} + + + + + + + + + + + + + + + + + + + +/*static void* timer_thread( void* param ) { + thread_top_init("timer_thread",1,870000L,1000000L,1000000L); + timer_subframe =9; + timer_frame =1023; + //phy_stub_ticking = (SF_ticking*)malloc(sizeof(SF_ticking)); + phy_stub_ticking->ticking_var = -1; + PHY_VARS_UE *UE; + UE = PHY_vars_UE_g[0][0]; + double t_diff; + int external_timer = 0; + + wait_sync("timer_thread"); + + //pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL); + //pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL); + + // struct timespec start = {0}; + // struct timespec end = {0}; + //sleepValue.tv_nsec = 1000000; + opp_enabled = 1; + + // first check if we are receiving timing indications + if(nfapi_mode==4) { + usleep(10000); + if (UE->instance_cnt_timer > 0) { + external_timer = 1; + int absSFm1 = ((emulator_absSF+10239)%10240); + timer_frame = absSFm1/10; + timer_subframe = absSFm1%10; + pthread_mutex_lock(&UE->timer_mutex); + UE->instance_cnt_timer = -1; + pthread_mutex_unlock(&UE->timer_mutex); + LOG_I(PHY,"Running with external timer\n"); + } + else LOG_I(PHY,"Running with internal timer\n"); + } + + while (!oai_exit) { + + // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. + // They are set on the first rx/tx in the underly FH routines. + if (timer_subframe==9) { + timer_subframe=0; + timer_frame++; + timer_frame&=1023; + } else { + timer_subframe++; + } + //printf("[timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe); + //LOG_I(MAC," Panos-D [timer_thread] Frame: %d, Subframe: %d \n", timer_frame, timer_subframe); + //AssertFatal( 0 == pthread_cond_signal(&phy_stub_ticking->cond_ticking), ""); + AssertFatal(pthread_mutex_lock(&phy_stub_ticking->mutex_ticking) ==0,""); + phy_stub_ticking->ticking_var++; + // This should probably be a call to pthread_cond_broadcast when we introduce support for multiple UEs (threads) + if(phy_stub_ticking->ticking_var == 0){ + //AssertFatal(phy_stub_ticking->ticking_var == 0,"phy_stub_ticking->ticking_var = %d", + // phy_stub_ticking->ticking_var); + if (pthread_cond_signal(&phy_stub_ticking->cond_ticking) != 0) { + //LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id); + LOG_E( PHY, "timer_thread ERROR pthread_cond_signal for UE_thread\n"); + exit_fun("nothing to add"); + } + } + + AssertFatal(pthread_mutex_unlock(&phy_stub_ticking->mutex_ticking) ==0,""); + start_meas(&UE->timer_stats); + + + //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); // get initial time-stamp + if (external_timer == 0) { + usleep(1000); + UE_tport_t pdu; + pdu.header.packet_type = TTI_SYNC; + pdu.header.absSF = (timer_frame*10)+timer_subframe; + multicast_link_write_sock(0, + &pdu, + sizeof(UE_tport_header_t)); + + } + else { + wait_on_condition(&UE->timer_mutex,&UE->timer_cond,&UE->instance_cnt_timer,"timer_thread"); + release_thread(&UE->timer_mutex,&UE->instance_cnt_timer,"timer_thread"); + } + //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); // get final time-stamp + + //double t_ns = (double)(end.tv_sec - start.tv_sec) * 1.0e9 + + // (double)(end.tv_nsec - start.tv_nsec); + //printf("Panos-D: [timer_thread] REAL TIME difference: %f", t_ns); + + + stop_meas(&UE->timer_stats); + t_diff = get_time_meas_us(&UE->timer_stats); + + //printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now); + //LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); + //if (t_diff > 1100) + + + // LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff); + //LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff); + + //printf("Panos-D: Absolute time: %f", t_diff); + + + stop_meas(&UE->timer_stats); + t_diff = get_time_meas_us(&UE->timer_stats); + //printf("Panos-D: Absolute time: %lld, diff: %lld, diff_now: %lld \n",UE->timer_stats.p_time, UE->timer_stats.diff, UE->timer_stats.diff_now); + //LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); + //if (t_diff > 1100) LOG_E(MAC," Panos-D Absolute time: %f\n", t_diff); + //printf("Panos-D: Absolute time: %f", t_diff); + + //UE->proc.ticking_var++; + // pthread_cond_signal() //Send signal to ue_thread()? + // We also need to somehow pass the information of SFN/SF + } + free(phy_stub_ticking); + pthread_cond_destroy(&phy_stub_ticking->cond_ticking); + pthread_mutex_destroy(&phy_stub_ticking->mutex_ticking); + return 0; + +}*/ + + + + + + + + +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)); + pthread_mutex_init(&UE->timer_mutex,NULL); + pthread_cond_init(&UE->timer_cond,NULL); + UE->instance_cnt_timer = -1; + pthread_mutex_init(&phy_stub_ticking->mutex_ticking,NULL); + pthread_cond_init(&phy_stub_ticking->cond_ticking,NULL); + pthread_create(&phy_stub_ticking->pthread_timer, NULL, &timer_thread, NULL); + return 0; +} + + +/* HACK: this function is needed to compile the UE + * fix it somehow + */ +int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,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 ae4798f399231040178b47a6b11f5b1a0aec8ae5..40075429182531d06d61b1654ec9cd9ad7765d9a 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -47,7 +47,7 @@ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_UE.h" #include "common/ran_context.h" #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" @@ -59,22 +59,18 @@ //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all -#include "PHY/vars.h" -#include "SCHED/vars.h" -#include "LAYER2/MAC/vars.h" - +#include "PHY/phy_vars_ue.h" +#include "PHY/LTE_TRANSPORT/transport_vars.h" +#include "SCHED/sched_common_vars.h" +#include "PHY/MODULATION/modulation_vars.h" #include "../../SIMU/USER/init_lte.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/vars.h" -#include "LAYER2/MAC/proto.h" -#include "RRC/LITE/vars.h" -#include "PHY_INTERFACE/vars.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_vars.h" +#include "LAYER2/MAC/mac_proto.h" +#include "RRC/LTE/rrc_vars.h" +#include "PHY_INTERFACE/phy_interface_vars.h" -#ifdef SMBV -#include "PHY/TOOLS/smbv.h" -unsigned short config_frames[4] = {2,9,11,13}; -#endif #include "UTIL/LOG/log_extern.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" @@ -101,6 +97,8 @@ unsigned short config_frames[4] = {2,9,11,13}; #endif #include "lte-softmodem.h" +RAN_CONTEXT_t RC; + /* temporary compilation wokaround (UE/eNB split */ uint16_t sf_ahead; #ifdef XFORMS @@ -114,6 +112,17 @@ unsigned char scope_enb_num_ue = 2; static pthread_t forms_thread; //xforms #endif //XFORMS +pthread_cond_t nfapi_sync_cond; +pthread_mutex_t nfapi_sync_mutex; +int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex + +uint8_t nfapi_mode = 0; + +uint16_t sf_ahead=2; + +char *emul_iface; + + pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. @@ -205,6 +214,7 @@ uint64_t num_missed_slots=0; // counter for the number of missed slots extern void reset_opp_meas(void); extern void print_opp_meas(void); +extern void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface); extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, @@ -213,7 +223,10 @@ extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, int transmission_mode=1; - +int emulate_rf = 0; +int numerology = 0; +int codingw = 0; +int fepw = 0; /* struct for ethernet specific parameters given in eNB conf file */ eth_params_t *eth_params; @@ -383,7 +396,7 @@ static void *scope_thread(void *arg) { #endif while (!oai_exit) { - dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm); + // dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm); //fl_set_object_label(form_stats->stats_text, stats_buffer); fl_clear_browser(form_stats->stats_text); fl_add_browser_line(form_stats->stats_text, stats_buffer); @@ -455,6 +468,7 @@ void *l2l1_task(void *arg) { } #endif +extern int16_t dlsch_demod_shift; static void get_options(void) { int CC_id; @@ -573,7 +587,8 @@ static void get_options(void) { // Read it in and store in asn1c data structures sprintf(uecap_xer,"%stargets/PROJECTS/GENERIC-LTE-EPC/CONF/UE_config.xml",getenv("OPENAIR_HOME")); printf("%s\n",uecap_xer); - uecap_xer_in=1; + if(nfapi_mode!=3) + uecap_xer_in=1; } /* UE with config file */ } @@ -739,6 +754,32 @@ void terminate_task(task_id_t task_id, module_id_t mod_id) #endif + + +static inline void wait_nfapi_init(char *thread_name) { + + printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); + pthread_mutex_lock( &nfapi_sync_mutex ); + + while (nfapi_sync_var<0) + pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); + + pthread_mutex_unlock(&nfapi_sync_mutex); + + printf( "NFAPI: got sync (%s)\n", thread_name); +} + +int stop_L1L2(module_id_t enb_id) +{ + return 0; +} + + +int restart_L1L2(module_id_t enb_id) +{ + return 0; +} + int main( int argc, char **argv ) { int i; @@ -750,6 +791,10 @@ int main( int argc, char **argv ) uint8_t abstraction_flag=0; uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; + // Default value for the number of UEs. It will hold, + // if not changed from the command line option --num-ues + NB_UE_INST=1; + #if defined (XFORMS) int ret; #endif @@ -777,7 +822,21 @@ int main( int argc, char **argv ) printf("Reading in command-line options\n"); - get_options (); + get_options (); + + printf("NFAPI_MODE value: %d \n", nfapi_mode); + + // Panos: Not sure if the following is needed here + /*if (CONFIG_ISFLAGSET(CONFIG_ABORT)) { + if (UE_flag == 0) { + fprintf(stderr,"Getting configuration failed\n"); + exit(-1); + } + else { + printf("Setting nfapi mode to UE_STUB_OFFNET\n"); + nfapi_mode = 4; + } + }*/ #if T_TRACER @@ -843,6 +902,14 @@ int main( int argc, char **argv ) #endif #endif +//TTN for D2D +#ifdef Rel14 + printf ("RRC control socket\n"); + rrc_control_socket_init(); + printf ("PDCP PC5S socket\n"); + pdcp_pc5_socket_init(); +#endif + #if !defined(ENABLE_ITTI) // to make a graceful exit when ctrl-c is pressed signal(SIGSEGV, signal_handler); @@ -869,20 +936,66 @@ int main( int argc, char **argv ) printf("Before CC \n"); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - NB_UE_INST=1; - NB_INST=1; - PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)); - PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); + + + // Panos: From old version + /*if (UE_flag==1) { + PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)*NB_UE_INST); + for (int i=0; i<NB_UE_INST; i++) { + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + + PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); + PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag); + + UE[CC_id] = PHY_vars_UE_g[i][CC_id]; + printf("PHY_vars_UE_g[inst][%d] = %p\n",CC_id,UE[CC_id]); + + if (phy_test==1) + UE[CC_id]->mac_enabled = 0; + else + UE[CC_id]->mac_enabled = 1; + } + } + }*/ + + + + //NB_UE_INST=1; + NB_INST=1; + if(nfapi_mode == 3){ + PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)*NB_UE_INST); + for (int i=0; i<NB_UE_INST; i++) { + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); + PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag); + + UE[CC_id] = PHY_vars_UE_g[i][CC_id]; + printf("PHY_vars_UE_g[inst][%d] = %p\n",CC_id,UE[CC_id]); + + if (phy_test==1) + UE[CC_id]->mac_enabled = 0; + else + UE[CC_id]->mac_enabled = 1; + } + } + } + else{ + + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + //NB_UE_INST=1; + NB_INST=1; + PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)); + PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); PHY_vars_UE_g[0][CC_id] = init_ue_vars(frame_parms[CC_id], 0,abstraction_flag); UE[CC_id] = PHY_vars_UE_g[0][CC_id]; printf("PHY_vars_UE_g[0][%d] = %p\n",CC_id,UE[CC_id]); - + if (phy_test==1) UE[CC_id]->mac_enabled = 0; - else + else UE[CC_id]->mac_enabled = 1; - + if (UE[CC_id]->mac_enabled == 0) { //set default UL parameters for testing mode for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { UE[CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK; @@ -894,13 +1007,13 @@ int main( int argc, char **argv ) UE[CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4; } } - + UE[CC_id]->UE_scan = UE_scan; UE[CC_id]->UE_scan_carrier = UE_scan_carrier; UE[CC_id]->mode = mode; printf("UE[%d]->mode = %d\n",CC_id,mode); - - if (UE[CC_id]->mac_enabled == 1) { + + if (UE[CC_id]->mac_enabled == 1) { UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1234; UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1234; }else { @@ -909,7 +1022,7 @@ int main( int argc, char **argv ) } UE[CC_id]->rx_total_gain_dB = (int)rx_gain[CC_id][0] + rx_gain_off; UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id]; - + if (frame_parms[CC_id]->frame_type==FDD) { UE[CC_id]->N_TA_offset = 0; } @@ -920,14 +1033,16 @@ int main( int argc, char **argv ) UE[CC_id]->N_TA_offset = 624/2; else if (frame_parms[CC_id]->N_RB_DL == 25) UE[CC_id]->N_TA_offset = 624/4; - + } - init_openair0(); + init_openair0(); } + printf("Runtime table\n"); fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); cpuf=get_cpu_freq_GHz(); + } @@ -977,6 +1092,9 @@ int main( int argc, char **argv ) printf("cannot create ITTI tasks\n"); exit(-1); // need a softer mode } + if(nfapi_mode==3){ //Panos: Here we should add another nfapi_mode for the case of Supervised LTE-D2D + UE_config_stub_pnf(); + } printf("ITTI tasks created\n"); #endif @@ -1026,9 +1144,46 @@ int main( int argc, char **argv ) rt_sleep_ns(10*100000000ULL); + const char *nfapi_mode_str = "<UNKNOWN>"; + + switch(nfapi_mode) + { + case 0: + nfapi_mode_str = "MONOLITHIC"; + break; + case 1: + nfapi_mode_str = "PNF"; + break; + case 2: + nfapi_mode_str = "VNF"; + break; + case 3: + nfapi_mode_str = "UE_STUB_PNF"; + break; + case 4: + nfapi_mode_str = "UE_STUB_OFFNET"; + break; + default: + nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; + break; + } + printf("NFAPI MODE:%s\n", nfapi_mode_str); + + // start the main threads int eMBMS_active = 0; - init_UE(1,eMBMS_active,uecap_xer_in,0); + + if (nfapi_mode==3) // UE-STUB-PNF + { + config_sync_var=0; + wait_nfapi_init("main?"); + //Panos: Temporarily we will be using single set of threads for multiple UEs. + //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); + init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); + } + else { + init_UE(1,eMBMS_active,uecap_xer_in,0); + } if (phy_test==0) { printf("Filling UE band info\n"); @@ -1036,10 +1191,12 @@ int main( int argc, char **argv ) dl_phy_sync_success (0, 0, 0, 1); } - number_of_cards = 1; - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id]->rf_map.card=0; - PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; + if (nfapi_mode!=3){ + number_of_cards = 1; + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[0][CC_id]->rf_map.card=0; + PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; + } } @@ -1055,13 +1212,16 @@ int main( int argc, char **argv ) UE[CC_id]->hw_timing_advance = 160; #endif } - if (setup_ue_buffers(UE,&openair0_cfg[0])!=0) { - printf("Error setting up eNB buffer\n"); - exit(-1); + if(nfapi_mode!=3) { + if (setup_ue_buffers(UE,&openair0_cfg[0])!=0) { + printf("Error setting up eNB buffer\n"); + exit(-1); + } } + if (input_fd) { printf("Reading in from file to antenna buffer %d\n",0); if (fread(UE[0]->common_vars.rxdata[0], diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index c1e5996d44375f4d40f3eeb433ebced1279810f9..443d183068e634ab97e751d7ed5f448edd820732 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -43,8 +43,9 @@ #include <getopt.h> #include <sys/sysinfo.h> #include "rt_wrapper.h" +#include <errno.h> -#include "openair1/PHY/defs.h" +#include "openair1/PHY/defs_common.h" static int latency_target_fd = -1; static int32_t latency_target_value = 0; @@ -283,6 +284,7 @@ void thread_top_init(char *thread_name, if (sched_setattr(0, &attr, flags) < 0 ) { perror("[SCHED] eNB tx thread: sched_setattr failed\n"); + fprintf(stderr,"sched_setattr Error = %s",strerror(errno)); exit(1); } diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index 94bd1bbe43d2f3ee8bb02dc1ab18a246dfad9710..3018dbe1fb10e7565303323d9e599daf072b38c5 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -26,32 +26,24 @@ #include <stdio.h> #include <time.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" +#include "PHY/phy_extern_ue.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log_if.h" #include "UTIL/LOG/log_extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OPT/opt.h" // to test OPT -#endif #include "UTIL/FIFO/types.h" -#ifdef IFFT_FPGA -#include "PHY/LTE_REFSIG/mod_table.h" -#endif - -#include "SCHED/defs.h" -#include "SCHED/extern.h" - #ifdef XFORMS #include "forms.h" #include "phy_procedures_sim_form.h" @@ -60,7 +52,11 @@ #include "oaisim.h" #define RF -//#define DEBUG_SIM +#define DEBUG_SIM +/* +#undef LOG_D +#define LOG_D(A,B,C...) printf(B,C) +*/ int number_rb_ul; int first_rbUL ; @@ -232,7 +228,6 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM pthread_mutex_lock(&RU_output_mutex[UE_id]); if (RU_output_mask[UE_id] == 0) { // This is the first eNodeB for this UE, clear the buffer - for (aa=0; aa<nb_antennas_rx; aa++) { memset((void*)r_re_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double)); memset((void*)r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double)); @@ -375,7 +370,8 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM UE_id,ru_id, 10*log10(rx_pwr),subframe); #endif - + + pthread_mutex_lock(&RU_output_mutex[UE_id]); for (i=0; i<frame_parms->samples_per_tti; i++) { for (aa=0; aa<nb_antennas_rx; aa++) { @@ -389,14 +385,14 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM - double *r_re_p[2] = {r_re_DL[ru_id][0],r_re_DL[ru_id][1]}; - double *r_im_p[2] = {r_im_DL[ru_id][0],r_im_DL[ru_id][1]}; + double *r_re_p[2] = {r_re_DL[UE_id][0],r_re_DL[UE_id][1]}; + double *r_im_p[2] = {r_im_DL[UE_id][0],r_im_DL[UE_id][1]}; #ifdef DEBUG_SIM rx_pwr = signal_energy_fp(r_re_p,r_im_p,nb_antennas_rx,length<length_meas?length:length_meas,0)/(12.0*frame_parms->N_RB_DL); LOG_D(OCM,"[SIM][DL] UE %d : ADC in %f dBm/RE for subframe %d\n",UE_id,10*log10(rx_pwr),subframe); #endif - + rxdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.rxdata; sf_offset = (subframe*frame_parms->samples_per_tti)+offset; diff --git a/targets/SIMU/USER/init_lte.c b/targets/SIMU/USER/init_lte.c index 0818629727c7e4e2fc6b2c74e7dd0971c4bb4de9..13b9026640786664904fc326bf4bef6968bd3ece 100644 --- a/targets/SIMU/USER/init_lte.c +++ b/targets/SIMU/USER/init_lte.c @@ -29,12 +29,12 @@ #include "init_lte.h" -#include "PHY/extern.h" +#include "PHY/phy_extern.h" -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log_if.h" -#include "PHY_INTERFACE/extern.h" +#include "PHY_INTERFACE/phy_interface.h" /* diff --git a/targets/SIMU/USER/init_lte.h b/targets/SIMU/USER/init_lte.h index 6f0aa0a6eb5ea8840a6b587bd7f18d6563d251b3..fee6c974b84d0e7c2c5761eaae24e7c7a51e1d2d 100644 --- a/targets/SIMU/USER/init_lte.h +++ b/targets/SIMU/USER/init_lte.h @@ -20,7 +20,7 @@ */ #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, @@ -32,10 +32,6 @@ PHY_VARS_UE* init_lte_UE(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); -PHY_VARS_RN* init_lte_RN(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t RN_id, - uint8_t eMBMS_active_state); - void init_lte_vars(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs], uint8_t frame_type, uint8_t tdd_config, diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 0008ba3bbde128740f20be36289ad2b419d018e9..1847db1d7185627b15ca36e9d80385fb5e5961c4 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -41,24 +41,23 @@ #include <execinfo.h> #include "event_handler.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/LTE_TRANSPORT/proto.h" -#include "PHY/vars.h" - -#include "SIMULATION/ETH_TRANSPORT/proto.h" - -//#ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/proto.h" -#include "LAYER2/MAC/vars.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" +#include "PHY/phy_vars.h" +#include "PHY/phy_vars_ue.h" +#include "SCHED/sched_common_vars.h" + +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_vars.h" #include "pdcp.h" -#include "RRC/LITE/vars.h" +#include "RRC/LTE/rrc_vars.h" #include "RRC/NAS/nas_config.h" -#include "SCHED/defs.h" -#include "SCHED/vars.h" #include "system.h" @@ -101,6 +100,7 @@ char smbv_ip[16]; #if defined(ENABLE_ITTI) # include "intertask_interface.h" # include "create_tasks.h" +# include "intertask_interface_init.h" #endif #include "T.h" @@ -195,6 +195,11 @@ time_stats_t oaisim_stats_f; time_stats_t dl_chan_stats; time_stats_t ul_chan_stats; +int emulate_rf = 0; +int numerology = 0; +int codingw = 0; +int fepw = 0; + // this should reflect the channel models in openair1/SIMULATION/TOOLS/defs.h mapping small_scale_names[] = { { "custom", custom }, { "SCM_A", SCM_A }, @@ -622,12 +627,8 @@ l2l1_task (void *args_p) } #endif - module_id_t UE_id; + - if (abstraction_flag == 1) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) - dl_phy_sync_success (UE_id, 0, 0,1); //UE_id%NB_eNB_INST); - } start_meas (&oaisim_stats); @@ -696,8 +697,8 @@ l2l1_task (void *args_p) //oai_emulation.info.time_ms += 1; oai_emulation.info.time_s += 0.01; // emu time in s, each frame lasts for 10 ms // JNote: TODO check the coherency of the time and frame (I corrected it to 10 (instead of 0.01) - update_omg (frame); // frequency is defined in the omg_global params configurable by the user - update_omg_ocm (); + //update_omg (frame); // frequency is defined in the omg_global params configurable by the user + //update_omg_ocm (); #ifdef OPENAIR2 @@ -737,19 +738,16 @@ l2l1_task (void *args_p) CC_id=0; int all_done=0; - while (all_done==0) { pthread_mutex_lock(&subframe_mutex); - int subframe_ru_mask_local = subframe_ru_mask; - int subframe_UE_mask_local = subframe_UE_mask; + int subframe_ru_mask_local = (subframe_select(&RC.ru[0]->frame_parms,(sf+4)%10)!=SF_UL) ? subframe_ru_mask : ((1<<NB_RU)-1); + int subframe_UE_mask_local = (RC.ru[0]->frame_parms.frame_type == FDD || subframe_select(&RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? subframe_UE_mask : ((1<<NB_UE_INST)-1); pthread_mutex_unlock(&subframe_mutex); LOG_D(EMU,"Frame %d, Subframe %d, NB_RU %d, NB_UE %d: Checking masks %x,%x\n",frame,sf,NB_RU,NB_UE_INST,subframe_ru_mask_local,subframe_UE_mask_local); if ((subframe_ru_mask_local == ((1<<NB_RU)-1)) && - (subframe_UE_mask_local == ((1<<NB_UE_INST)-1))) - all_done=1; - else - usleep(1500); + (subframe_UE_mask_local == ((1<<NB_UE_INST)-1))) all_done=1; + else usleep(1500); } @@ -794,15 +792,6 @@ l2l1_task (void *args_p) PHY_vars_eNB_g[eNB_inst][0]->frame_parms.Nid_cell); */ -#ifdef OPENAIR2 - //Application: traffic gen - update_otg_eNB (eNB_inst, oai_emulation.info.time_ms); - - //IP/OTG to PDCP and PDCP to IP operation - // pdcp_run (frame, 1, 0, eNB_inst); //PHY_vars_eNB_g[eNB_id]->Mod_id -#endif - - #ifdef PRINT_STATS if((sf==9) && frame%10==0) @@ -816,18 +805,16 @@ l2l1_task (void *args_p) fwrite (stats_buffer, 1, len, eNB_stats[eNB_inst]); fflush(eNB_stats[eNB_inst]); } - */ #ifdef OPENAIR2 -/* if (eNB_l2_stats) { len = dump_eNB_l2_stats (stats_buffer, 0); rewind (eNB_l2_stats); fwrite (stats_buffer, 1, len, eNB_l2_stats); fflush(eNB_l2_stats); } -*/ #endif +*/ #endif } }// eNB_inst loop @@ -874,7 +861,7 @@ l2l1_task (void *args_p) } - update_ocm (); + //update_ocm (); /* if ((frame >= 10) && (frame <= 11) && (abstraction_flag == 0) #ifdef PROC @@ -1070,6 +1057,7 @@ void set_UE_defaults(int nb_ue) { PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[i][0]->agregationLevel = 0xFF; } PHY_vars_UE_g[UE_id][CC_id]->current_dlsch_cqi[0] = 10; + PHY_vars_UE_g[UE_id][CC_id]->tx_power_max_dBm = 23; } } } @@ -1109,6 +1097,7 @@ int main (int argc, char **argv) oai_emulation.info.n_frames = MAX_FRAME_NUMBER; //1024; //10; oai_emulation.info.n_frames_flag = 0; //fixme snr_dB = 30; + NB_UE_INST = 1; //Default values if not changed by the user in get_simulation_options(); pdcp_period = 1; @@ -1125,7 +1114,7 @@ int main (int argc, char **argv) // start thread for log gen log_thread_init (); - init_oai_emulation (); // to initialize everything !!! + //init_oai_emulation (); // to initialize everything !!! // get command-line options get_simulation_options (argc, argv); //Command-line options @@ -1162,7 +1151,37 @@ int main (int argc, char **argv) #endif // configure oaisim with OCG - oaisim_config (); // config OMG and OCG, OPT, OTG, OLG + //oaisim_config (); // config OMG and OCG, OPT, OTG, OLG + logInit(); + +#if defined(ENABLE_ITTI) + itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, oai_emulation.info.itti_dump_file); + MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); +#endif + + set_glog(LOG_INFO, 0x15); + + + //set_log(OCG, LOG_DEBUG, 1); + //set_log(EMU, LOG_INFO, 20); + set_log(MAC, LOG_DEBUG, 1); + set_log(RLC, LOG_TRACE, 1); + //set_log(PHY, LOG_DEBUG, 1); + set_log(PDCP, LOG_TRACE, 1); + set_log(RRC, LOG_DEBUG, 1); + //set_log(OCM, LOG_INFO, 20); + //set_log(OTG, LOG_INFO, 1); + set_comp_log(OCG, LOG_ERR, 0x15,1); + set_comp_log(EMU, LOG_DEBUG, 0x15,20); + set_comp_log(MAC, LOG_TRACE, 0x15,1); + set_comp_log(RLC, LOG_TRACE, 0x15,1); + set_comp_log(PHY, LOG_TRACE, 0x15, 1); + set_comp_log(PDCP, LOG_DEBUG, 0x15,1); + set_comp_log(RRC, LOG_DEBUG, 0x15,1); + set_comp_log(OCM, LOG_DEBUG, 0x15,20); + set_comp_log(OTG, LOG_DEBUG, 0x15,1); + set_comp_log(OMG, LOG_NOTICE, 0x15,1); + set_comp_log(OPT, LOG_ERR, 0x15,1); if (ue_connection_test == 1) { snr_direction = -snr_step; @@ -1174,15 +1193,11 @@ int main (int argc, char **argv) pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&subframe_mutex, NULL); -#ifdef OPENAIR2 - init_omv (); -#endif //Before this call, NB_UE_INST and NB_eNB_INST are not set correctly check_and_adjust_params (); set_seed = oai_emulation.emulation_config.seed.value; - init_otg_pdcp_buffer (); init_seed (set_seed); @@ -1197,7 +1212,7 @@ int main (int argc, char **argv) - if (create_tasks_ue(oai_emulation.info.nb_ue_local) < 0) + if (create_tasks_ue(NB_UE_INST) < 0) exit(-1); // need a softer mode @@ -1210,6 +1225,7 @@ int main (int argc, char **argv) init_ocm (); + printf("Sending sync to all threads\n"); @@ -1218,12 +1234,6 @@ int main (int argc, char **argv) pthread_cond_broadcast(&sync_cond); pthread_mutex_unlock(&sync_mutex); -#ifdef SMBV - // Rohde&Schwarz SMBV100A vector signal generator - smbv_init_config(smbv_fname, smbv_nframes); - smbv_write_config_from_frame_parms(smbv_fname, &PHY_vars_eNB_g[0][0]->frame_parms); -#endif - /* #if defined (FLEXRAN_AGENT_SB_IF) flexran_agent_start(); #endif */ @@ -1732,11 +1742,6 @@ oai_shutdown (void) #endif - //Perform KPI measurements - if (oai_emulation.info.otg_enabled == 1){ - LOG_N(EMU,"calling OTG kpi gen .... \n"); - kpi_gen (); - } if (oai_emulation.info.opp_enabled == 1) print_opp_meas_oaisim (); @@ -1792,15 +1797,6 @@ oai_shutdown (void) } //End of PHY abstraction changes - // stop OMG - stop_mobility_generator (omg_param_list); //omg_param_list.mobility_type -#ifdef OPENAIR2 - - if (oai_emulation.info.omv_enabled == 1) - omv_end (pfd[1], omv_data); - -#endif - if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0) && (ShaF != NULL)) { destroyMat (ShaF, map1, map2); @@ -1810,9 +1806,6 @@ oai_shutdown (void) if (opt_enabled == 1) terminate_opt (); - if (oai_emulation.info.cli_enabled) - cli_server_cleanup (); - for (int i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++) if (oai_emulation.info.oai_ifup[i] == 1) { char interfaceName[8]; diff --git a/targets/SIMU/USER/oaisim.h b/targets/SIMU/USER/oaisim.h index 0fdc4002e47cd053fd8ffe56a4b4d7d5f2bd94d8..1ddc09398322cbb2cd91463e818a5d12ae4efc0f 100644 --- a/targets/SIMU/USER/oaisim.h +++ b/targets/SIMU/USER/oaisim.h @@ -26,15 +26,16 @@ #include <stdio.h> #include <time.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" #include "oaisim_config.h" #include "init_lte.h" #ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/mac.h" #include "UTIL/OMV/structures.h" #endif diff --git a/targets/SIMU/USER/oaisim_config.h b/targets/SIMU/USER/oaisim_config.h index fe1309b7a48531033474e6bf7413bd54a9b0642c..a403252d06430f214ba3c30e521f1e4652e8f000 100644 --- a/targets/SIMU/USER/oaisim_config.h +++ b/targets/SIMU/USER/oaisim_config.h @@ -49,10 +49,8 @@ The current sturcture of oaisim is shown by the figure. #include "UTIL/OPT/opt.h" // to test OPT #include "UTIL/OMG/omg.h" #include "UTIL/CLI/cli_if.h" -#include "PHY/defs.h" -#include "PHY/extern.h" -#include "SIMULATION/ETH_TRANSPORT/defs.h" -#include "PHY/defs.h" +#include "PHY/defs_eNB.h" +#include "PHY/phy_extern.h" /** @defgroup _init_oai Initial oaisim * @ingroup _fn diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index ceaae1958b9c08df2b57028dd7f54c4fa7fe79b5..a302c12ff327e3bef62371db9da1f88b1632e6db 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -43,29 +43,22 @@ #include "assertions.h" #include "oaisim_functions.h" -#include "PHY/extern.h" -#include "LAYER2/MAC/extern.h" -#ifdef OPENAIR2 -#include "LAYER2/MAC/proto.h" -#endif +#include "PHY/phy_extern.h" +#include "PHY/phy_extern_ue.h" +#include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" #include "LAYER2/PDCP_v10.1.0/pdcp.h" #include "LAYER2/PDCP_v10.1.0/pdcp_primitives.h" -#include "RRC/LITE/extern.h" +#include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "PHY_INTERFACE/extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" //#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h" -#include "SCHED/extern.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "UTIL/OCG/OCG_extern.h" #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "UTIL/OTG/otg_config.h" #include "UTIL/OTG/otg_tx.h" -#if ENABLE_RAL -#include "lteRALenb.h" -#include "lteRALue.h" -#endif - #include "cor_SF_sim.h" #include "enb_config.h" @@ -83,11 +76,6 @@ #include "ENB_APP/enb_paramdef.h" #include "common/config/config_userapi.h" -#ifdef SMBV -extern uint8_t config_smbv; -extern char smbv_ip[16]; -#endif - //constant for OAISIM soft realtime calibration #define SF_DEVIATION_OFFSET_NS 100000 //= 0.1ms : should be as a number of UE #define SLEEP_STEP_US 100 // = 0.01ms could be adaptive, should be as a number of UE @@ -137,34 +125,14 @@ int sleep_time_us = 0; int phy_test = 0; -#ifdef OPENAIR2 -// omv related info -//pid_t omv_pid; -char full_name[200]; -extern int pfd[2]; // fd for omv : fixme: this could be a local var -char fdstr[10]; -char frames[10]; -char num_enb[10]; -char num_ue[10]; -//area_x, area_y and area_z for omv -char x_area[20]; -char y_area[20]; -char z_area[20]; -char nb_antenna[20]; -char frame_type[10]; -char tdd_config[10]; -#endif - -Packet_OTG_List_t *otg_pdcp_buffer = NULL; - extern node_desc_t *enb_data[NUMBER_OF_RU_MAX]; -extern node_desc_t *ue_data[NUMBER_OF_UE_MAX]; -extern channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; -extern channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; +extern node_desc_t *ue_data[MAX_MOBILES_PER_ENB]; +extern channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; +extern channel_desc_t *UE2RU[MAX_MOBILES_PER_ENB][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; extern mapping small_scale_names[]; -#if defined(Rel10) || defined(Rel14) -extern pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][maxServiceCount][maxSessionPerPMCH]; +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) +extern pdcp_mbms_t pdcp_mbms_array_ue[MAX_MOBILES_PER_ENB][maxServiceCount][maxSessionPerPMCH]; extern pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][maxServiceCount][maxSessionPerPMCH]; #endif @@ -701,7 +669,7 @@ void get_simulation_options(int argc, char *argv[]) break; case 'u': - oai_emulation.info.nb_ue_local = atoi (optarg); + NB_UE_INST = atoi (optarg); break; case 'U': @@ -870,13 +838,13 @@ void check_and_adjust_params(void) int32_t ret; //int i,j; - if (oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local > NUMBER_OF_UE_MAX) { - LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_UE_MAX); + if (oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local > MAX_MOBILES_PER_ENB) { + LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the MAX_MOBILES_PER_ENB\n", MAX_MOBILES_PER_ENB); exit(EXIT_FAILURE); } if (oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local > NUMBER_OF_eNB_MAX) { - LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX); + LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the MAX_MOBILES_PER_ENB\n", NUMBER_OF_eNB_MAX); exit(EXIT_FAILURE); } @@ -931,80 +899,15 @@ void check_and_adjust_params(void) } // ethernet flag */ // - NB_UE_INST = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_ue_remote; - NB_eNB_INST = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_enb_remote; - NB_RN_INST = oai_emulation.info.nb_rn_local + oai_emulation.info.nb_rn_remote; - NB_RU = oai_emulation.info.nb_ru_local + oai_emulation.info.nb_ru_remote; + + NB_RU = RC.nb_RU; #if defined(PDCP_USE_NETLINK_QUEUES) && defined(OPENAIR2) pdcp_netlink_init(); #endif - if (NB_RN_INST > 0 ) { - LOG_N(EMU,"Total number of RN %d (local %d, remote %d) mobility (the same as eNB) %s \n", NB_RN_INST,oai_emulation.info.nb_rn_local,oai_emulation.info.nb_rn_remote, - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); - - LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ", - NB_eNB_INST, NB_eNB_INST+NB_RN_INST, - NB_UE_INST, NB_UE_INST+NB_RN_INST); - NB_eNB_INST+=NB_RN_INST; - NB_UE_INST+=NB_RN_INST; - } - - LOG_I(EMU,"Total number of UE %d (first local %d , num local %d, remote %d, relay %d) mobility %s \n", - NB_UE_INST,oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local,oai_emulation.info.nb_ue_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option); - - LOG_I(EMU,"Total number of eNB %d (local %d, remote %d, relay %d) mobility %s \n", - NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); - } -#ifdef OPENAIR2 -void init_omv(void) -{ - if (oai_emulation.info.omv_enabled == 1) { - - if(pipe(pfd) == -1) - perror("pipe error \n"); - - snprintf( full_name, sizeof(full_name), "%s/UTIL/OMV/OMV",getenv("OPENAIR2_DIR") ); - LOG_I(EMU,"Stating the OMV path %s pfd[0] %d pfd[1] %d \n", full_name, pfd[0],pfd[1]); - - switch(fork()) { - case -1 : - perror("fork failed \n"); - break; - - case 0 : // child is going to be the omv, it is the reader - if(close(pfd[1]) == -1 ) // we close the write desc. - perror("close on write\n" ); - - sprintf(fdstr, "%d", pfd[0] ); - sprintf(num_enb, "%d", NB_eNB_INST); - sprintf(num_ue, "%d", NB_UE_INST); - sprintf(x_area, "%f", oai_emulation.topology_config.area.x_m ); - sprintf(y_area, "%f", oai_emulation.topology_config.area.y_m ); - sprintf(z_area, "%f", 200.0 ); - sprintf(frames, "%d", oai_emulation.info.n_frames); - sprintf(nb_antenna, "%d", 4); - sprintf(frame_type, "%s", (oai_emulation.info.frame_type[0] == 0) ? "FDD" : "TDD"); - sprintf(tdd_config, "%d", oai_emulation.info.tdd_config[0]); - // execl is used to launch the visualisor - execl(full_name,"OMV", fdstr, frames, num_enb, num_ue, x_area, y_area, z_area, nb_antenna, frame_type, tdd_config,NULL ); - perror( "error in execl the OMV" ); - } - - //parent - if(close( pfd[0] ) == -1 ) // we close the write desc. - perror("close on read\n" ); - } -} -#endif - void init_seed(uint8_t set_seed) { @@ -1020,9 +923,9 @@ void init_seed(uint8_t set_seed) } openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -openair0_timestamp current_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; +openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; -openair0_timestamp last_UE_rx_timestamp[NUMBER_OF_UE_MAX][MAX_NUM_CCs]; +openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; int ru_trx_start(openair0_device *device) { return(0); @@ -1087,20 +990,21 @@ int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** subframe = (last_ru_rx_timestamp[ru_id][CC_id]/RC.ru[ru_id]->frame_parms.samples_per_tti)%10; - LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id]); - - do_UL_sig(UE2RU, - enb_data, - ue_data, - subframe, - 0, // abstraction_flag - &RC.ru[ru_id]->frame_parms, - 0, // frame is only used for abstraction - ru_id, - CC_id); - + if (subframe_select(&RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms.frame_type == FDD) { + LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", + subframe,(unsigned long long)*ptimestamp, + (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id]); + + do_UL_sig(UE2RU, + enb_data, + ue_data, + subframe, + 0, // abstraction_flag + &RC.ru[ru_id]->frame_parms, + 0, // frame is only used for abstraction + ru_id, + CC_id); + } last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms.samples_per_tti; sample_count += RC.ru[ru_id]->frame_parms.samples_per_tti; } @@ -1352,9 +1256,6 @@ void init_devices(void){ PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_freq_func = UE_trx_set_freq; PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_gains_func = UE_trx_set_gains; last_UE_rx_timestamp[UE_id][CC_id] = 0; - - - } } } @@ -1371,63 +1272,16 @@ void init_ocm(void) //char* frame_type = "unknown"; LTE_DL_FRAME_PARMS *fp = &RC.ru[0]->frame_parms; -#if 0 - switch (fp->frame_type) { - case FDD: - frame_type = "FDD"; - break; - - case TDD: - frame_type = "TDD"; - break; - } -#endif - - if (abstraction_flag) { - - get_beta_map(); - get_MIESM_param(); - - //load_pbch_desc(); - } - - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - enb_data[ru_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_enb(enb_data[ru_id],oai_emulation.environment_system_config.antenna.eNB_antenna); - } - - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - ue_data[UE_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_ue(ue_data[UE_id],oai_emulation.environment_system_config.antenna.UE_antenna); - } - - if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 ) && - (oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m>0) && - (oai_emulation.environment_system_config.fading.shadowing.variance_dB>0)) { - - // init SF map here!!! - map1 =(int)oai_emulation.topology_config.area.x_m; - map2 =(int)oai_emulation.topology_config.area.y_m; - ShaF = init_SF(map1,map2,oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m,oai_emulation.environment_system_config.fading.shadowing.variance_dB); - - // size of area to generate shadow fading map - LOG_D(EMU,"Simulation area x=%f, y=%f\n", - oai_emulation.topology_config.area.x_m, - oai_emulation.topology_config.area.y_m); - } - - if (abstraction_flag == 0) - init_channel_vars (fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); + init_channel_vars (fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); // initialize channel descriptors + LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST); for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - LOG_I(OCM,"Initializing channel (%s, %d) from RU %d to UE %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, - map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), ru_id, UE_id); - + LOG_I(PHY,"Initializing channel descriptors (RU %d, UE %d) for N_RB_DL %d\n",ru_id,UE_id, + RC.ru[ru_id]->frame_parms.N_RB_DL); RU2UE[ru_id][UE_id][CC_id] = new_channel_desc_scm(RC.ru[ru_id]->nb_tx, PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, @@ -1456,22 +1310,29 @@ void init_ocm(void) // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id]; - } - } - } -} -void init_otg_pdcp_buffer(void) -{ - module_id_t i; - otg_pdcp_buffer = malloc((NB_UE_INST + NB_eNB_INST) * sizeof(Packet_OTG_List_t)); + AssertFatal(RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); + AssertFatal(UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); + //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE + if (ru_id == (UE_id % RC.nb_RU)) { + RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; + UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; + } else { + RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; + UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower; + } + + LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, + RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, + RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower,snr_dB); + - for (i = 0; i < NB_UE_INST + NB_eNB_INST; i++) { - pkt_list_init(&(otg_pdcp_buffer[i])); - //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", i, pkt_list_get_head(&(otg_pdcp_buffer[i]))); + } + } } } +/* void update_omg (frame_t frameP) { module_id_t UE_id, eNB_id; @@ -1517,7 +1378,7 @@ void update_ocm() - /* check if the openair channel model is activated used for PHY abstraction : path loss*/ + // check if the openair channel model is activated used for PHY abstraction : path loss if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 )) { for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) @@ -1529,15 +1390,12 @@ void update_ocm() //LOG_D(OMG," extracting position of eNb...\n"); //display_node_list(enb_node_list); // display_node_list(ue_node_list); - extract_position(enb_node_list, enb_data, RC.nb_RU); + //extract_position(enb_node_list, enb_data, RC.nb_RU); //extract_position_fixed_enb(enb_data, NB_eNB_INST,frame); //LOG_D(OMG," extracting position of UE...\n"); // if (oai_emulation.info.omg_model_ue == TRACE) - extract_position(ue_node_list, ue_data, NB_UE_INST); + //extract_position(ue_node_list, ue_data, NB_UE_INST); - /* if (frame % 50 == 0) - LOG_N(OCM,"Path loss for TTI %d : \n", frame); - */ for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { @@ -1552,10 +1410,10 @@ void update_ocm() //dx = enb_data[ru_id]->x - ue_data[UE_id]->x; //dy = enb_data[ru_id]->y - ue_data[UE_id]->y; //distance = sqrt(dx * dx + dy * dy); - /*LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n", - ru_id, enb_data[ru_id]->x,enb_data[ru_id]->y, - UE_id, ue_data[UE_id]->x,ue_data[UE_id]->y, - distance);*/ + ///LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n", + // ru_id, enb_data[ru_id]->x,enb_data[ru_id]->y, + // UE_id, ue_data[UE_id]->x,ue_data[UE_id]->y, + // distance); } } } @@ -1587,6 +1445,7 @@ void update_ocm() } } + #ifdef OPENAIR2 void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) { @@ -1594,13 +1453,12 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) #if defined(USER_MODE) && defined(OAI_EMU) //int rrc_state=0; -/* if (oai_emulation.info.otg_enabled ==1 ) { int dst_id, app_id; Packet_otg_elt_t *otg_pkt; - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { + for (dst_id = 0; dst_id < MAX_MOBILES_PER_ENB; dst_id++) { for_times += 1; // generate traffic if the ue is rrc reconfigured state @@ -1633,7 +1491,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) } } -#if defined(Rel10) || defined(Rel14) +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) mbms_service_id_t service_id; mbms_session_id_t session_id; rb_id_t rb_id; @@ -1665,10 +1523,10 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) otg_pkt=NULL; } -*/ + // old version - /* // MBSM multicast traffic - #if defined(Rel10) || defined(Rel14) + // MBSM multicast traffic + #if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (frame >= 46) {// only generate when UE can receive MTCH (need to control this value) for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH @@ -1690,15 +1548,15 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) } } // end multicast traffic #endif - */ -/* + + } } } } // end multicast traffic -*/ + #endif } @@ -1708,7 +1566,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) if (otg_enabled==1) { ctime = frame * 100; - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { + for (dst_id = 0; dst_id < MAX_MOBILES_PER_ENB; dst_id++) { if (mac_get_rrc_status(eNB_index, eNB_flag, dst_id ) > 2) { otg_pkt = malloc (sizeof(Packet_otg_elt_t)); (otg_pkt->otg_pkt).sdu_buffer = packet_gen(module_instP, dst_id, ctime, &pkt_size); @@ -1737,6 +1595,7 @@ void update_otg_UE(module_id_t ue_mod_idP, unsigned int ctime) { } #endif +*/ int init_slot_isr(void) { diff --git a/targets/SIMU/USER/sinr_sim.c b/targets/SIMU/USER/sinr_sim.c index 7c752ce432f2b268cc7d11b2efd1f770a2c2482b..2dc86b844301977c9983430ac51e7f89b2725072 100644 --- a/targets/SIMU/USER/sinr_sim.c +++ b/targets/SIMU/USER/sinr_sim.c @@ -27,27 +27,26 @@ #include <time.h> #include <cblas.h> -#include "SIMULATION/TOOLS/defs.h" -#include "SIMULATION/RF/defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/RF/rf.h" #include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" +#include "PHY/defs_eNB.h" +#include "PHY/defs_UE.h" +#include "PHY/phy_extern.h" #include "oaisim_config.h" #ifdef OPENAIR2 -#include "LAYER2/MAC/defs.h" -#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log_if.h" #include "UTIL/LOG/log_extern.h" -#include "RRC/LITE/extern.h" -#include "PHY_INTERFACE/extern.h" +#include "RRC/LTE/rrc_extern.h" +#include "PHY_INTERFACE/phy_interface_extern.h" #include "UTIL/OCG/OCG.h" #include "UTIL/OMG/omg.h" #include "UTIL/OPT/opt.h" // to test OPT #endif -#include "SCHED/defs.h" -#include "SCHED/extern.h" #include "oaisim.h"