diff --git a/README.txt b/README.txt
index aec938c0d3..33c0df9d8d 100644
--- a/README.txt
+++ b/README.txt
@@ -61,3 +61,4 @@ v1.0.0 -> January 2019. This version first implements the architectural split de
S1-flex has been introduced.
New tools: config library, telnet server, ...
A lot of bugfixes and a proper automated Continuous Integration process validates contributions.
+v1.0.1 -> February 2019: Bug fix for the UE L1 simulator.
diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab
index fc0290fc44..f59208ed8b 100644
--- a/ci-scripts/Jenkinsfile-gitlab
+++ b/ci-scripts/Jenkinsfile-gitlab
@@ -104,6 +104,7 @@ pipeline {
} else {
echo "Git Branch is ${GIT_BRANCH}"
echo "Git Commit is ${GIT_COMMIT}"
+ sh "git log -n1 --pretty=format:\"%s\" > .git/CI_COMMIT_MSG"
sh "zip -r -qq localZip.zip ."
// Running astyle options on all C/H files in the repository
@@ -260,7 +261,7 @@ pipeline {
expression {doRedHatBuild}
}
steps {
- gitlabCommitStatus(name: "Build eNb-USRP-CentOS") {
+ gitlabCommitStatus(name: "Build eNb-USRP-RHE") {
script {
try {
withCredentials([
@@ -572,6 +573,10 @@ OAI CI Team''',
replyTo: 'no-reply@openairinterface.org',
subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!',
to: env.gitlabUserEmail
+
+ if (fileExists('.git/CI_COMMIT_MSG')) {
+ sh "rm -f .git/CI_COMMIT_MSG"
+ }
}
}
success {
diff --git a/ci-scripts/cppcheck_suppressions.list b/ci-scripts/cppcheck_suppressions.list
new file mode 100644
index 0000000000..d5aea7ae9d
--- /dev/null
+++ b/ci-scripts/cppcheck_suppressions.list
@@ -0,0 +1,92 @@
+// *INDENT-OFF* cppcheck doesn't like "astyling" this file!!!!
+// /*
+// * 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
+// */
+//*****************************************************************************
+//*****************************************************************************
+// section for "valid" memory leaks: the related functions are allocators and
+// the caller is responsible of freeing the memory. cppcheck has a mechanism
+// to check more accuretaly this, by defining callers responsible of freeing
+// but tools like valgring might be more suitable
+//
+//-----------------------------------------------------------------------------
+// suppress error about keysP memory leak, free must be done by calling func
+memleak:common/utils/hashtable/obj_hashtable.c
+//-----------------------------------------------------------------------------
+// suppress error about keys memory leak, free must be done by calling func
+memleak:openair2/UTIL/OMG/omg_hashtable.c
+//-----------------------------------------------------------------------------
+// suppress error about data memory leak. This is the buffer where
+// _emm_as_encode function creates the encoded buffer
+//
+memleak:openair3/NAS/UE/EMM/SAP/emm_as.c
+//-----------------------------------------------------------------------------
+//*****************************************************************************
+// section for files not used in oai exec's included in CI.
+// Possibly candidates for removal otherwise should be documented and updated
+// for project rules enforcement
+// ----------------------------------------------------------------------------
+// likely sources for test programs, maintained?
+invalidPrintfArgType_sint:openair1/PHY/CODING/TESTBENCH/ltetest.c
+memleak:openair1/PHY/CODING/TESTBENCH/ltetest.c
+invalidPrintfArgType_sint:openair1/PHY/CODING/TESTBENCH/pdcch_test.c
+//
+//-----------------------------------------------------------------------------
+// oaisim deprecated, remove?
+doubleFree:openair3/TEST/oaisim_mme_list_benchmark.c
+//
+//-----------------------------------------------------------------------------
+// is itti analyzer deprecated
+nullPointer:common/utils/itti_analyzer/itti_analyzer.c
+nullPointerRedundantCheck:common/utils/itti_analyzer/libbuffers/buffers.c
+doubleFree:common/utils/itti_analyzer/libbuffers/socket.c
+memleak:common/utils/itti_analyzer/libbuffers/socket.c
+memleak:common/utils/itti_analyzer/libparser/array_type.c
+memleak:common/utils/itti_analyzer/libui/ui_callbacks.c
+//-----------------------------------------------------------------------------
+// obviously never even compiled!!!
+syntaxError:openair1/SIMULATION/LTE_PHY/dlsim_tm4.c
+//-----------------------------------------------------------------------------
+// omg, otg commented out in cmakelist to be cleaned up definitely?
+arrayIndexOutOfBounds:openair2/UTIL/OMG/omg.c
+uninitvar:openair2/UTIL/OTG/otg_rx_socket.c
+//
+//*****************************************************************************
+//
+// True problems we don't know how to fix, Suppression is commented out,
+// as these kind of problem need either to be fixed or can be suppressed
+// when fully uderstood
+//-----------------------------------------------------------------------------
+// the function [nv]fapi_pnf_p7_config_create should return
+// _this. _this points to a structure and a dynamically allocated field is
+// returned. cppcheck suspects _this will never be released, so do i
+// memleak:nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c
+// memleak:nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c
+//-----------------------------------------------------------------------------
+// may be security_data->kenb.value is released from calling functions. But even
+// when, for test, freeing it before returning from emm_proc_security_mode_command
+// which does the allocation, cppcheck complains. So something might be wrong...
+// memleak:openair3/NAS/UE/EMM/SecurityModeControl.c
+//-----------------------------------------------------------------------------
+// when used, nobody but the original developer can guess if sn_data_cnf is set or not
+// cppcheck found that in some cases it is not, code needs cleanup before fixing that...
+// uninitvar:openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c
+//*****************************************************************************
+// *INDENT-ON*
diff --git a/ci-scripts/doGitLabMerge.sh b/ci-scripts/doGitLabMerge.sh
index 852b6407ea..6c9ee12b4e 100755
--- a/ci-scripts/doGitLabMerge.sh
+++ b/ci-scripts/doGitLabMerge.sh
@@ -121,6 +121,7 @@ git config user.email "jenkins@openairinterface.org"
git config user.name "OAI Jenkins"
git checkout -f $SOURCE_COMMIT_ID
+git log -n1 --pretty=format:\"%s\" > .git/CI_COMMIT_MSG
git merge --ff $TARGET_COMMIT_ID -m "Temporary merge for CI"
diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool
index 6e0a83e07d..c28f51415e 100755
--- a/ci-scripts/oai-ci-vm-tool
+++ b/ci-scripts/oai-ci-vm-tool
@@ -264,7 +264,7 @@ case $key in
ARCHIVES_LOC=cppcheck
LOG_PATTERN=cppcheck.xml
NB_PATTERN_FILES=1
- BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2"
+ BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list"
NBARGS=$[$NBARGS+256]
shift
;;
@@ -340,11 +340,11 @@ case $key in
;;
cppcheck)
VM_NAME=ci-cppcheck
- VM_MEMORY=8192
+ VM_MEMORY=4096
ARCHIVES_LOC=cppcheck
LOG_PATTERN=cppcheck.xml
NB_PATTERN_FILES=1
- BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2"
+ BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list"
NBARGS=$[$NBARGS+256]
;;
enb-ethernet)
diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh
index bfce7acd8f..08d2f78443 100755
--- a/ci-scripts/reportBuildLocally.sh
+++ b/ci-scripts/reportBuildLocally.sh
@@ -363,6 +363,14 @@ function report_build {
echo "
Commit ID | " >> ./build_results.html
echo " $SOURCE_COMMIT_ID | " >> ./build_results.html
echo " " >> ./build_results.html
+ if [ -e .git/CI_COMMIT_MSG ]
+ then
+ echo " " >> ./build_results.html
+ echo " | Commit Message | " >> ./build_results.html
+ MSG=`cat .git/CI_COMMIT_MSG`
+ echo " $MSG | " >> ./build_results.html
+ echo "
" >> ./build_results.html
+ fi
fi
if [ $MR_TRIG -eq 1 ]
then
@@ -374,6 +382,14 @@ function report_build {
echo " Source Commit ID | " >> ./build_results.html
echo " $SOURCE_COMMIT_ID | " >> ./build_results.html
echo " " >> ./build_results.html
+ if [ -e .git/CI_COMMIT_MSG ]
+ then
+ echo " " >> ./build_results.html
+ echo " | Source Commit Message | " >> ./build_results.html
+ MSG=`cat .git/CI_COMMIT_MSG`
+ echo " $MSG | " >> ./build_results.html
+ echo "
" >> ./build_results.html
+ fi
echo " " >> ./build_results.html
echo " | Target Branch | " >> ./build_results.html
echo " $TARGET_BRANCH | " >> ./build_results.html
@@ -492,7 +508,7 @@ function report_build {
if [ -e ./archives/red_hat ]
then
- echo " Red Hat (CentOS Linux release 7.4.1708) -- Summary
" >> ./build_results.html
+ echo " Red Hat Enterprise Linux Server release 7.6) -- Summary
" >> ./build_results.html
summary_table_header "Red Hat -- OAI Build eNB -- USRP option" ./archives/red_hat
summary_table_row "LTE SoftModem - Release 14" ./archives/red_hat/lte-softmodem.Rel14.txt "Built target lte-softmodem" ./enb_usrp_rh_row1.html
diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh
index 004e021de1..63dc724b84 100755
--- a/ci-scripts/reportTestLocally.sh
+++ b/ci-scripts/reportTestLocally.sh
@@ -139,6 +139,14 @@ function report_test {
echo " Commit ID | " >> ./test_simulator_results.html
echo " $SOURCE_COMMIT_ID | " >> ./test_simulator_results.html
echo "
" >> ./test_simulator_results.html
+ if [ -e .git/CI_COMMIT_MSG ]
+ then
+ echo " " >> ./test_simulator_results.html
+ echo " | Commit Message | " >> ./test_simulator_results.html
+ MSG=`cat .git/CI_COMMIT_MSG`
+ echo " $MSG | " >> ./test_simulator_results.html
+ echo "
" >> ./test_simulator_results.html
+ fi
fi
if [ $MR_TRIG -eq 1 ]
then
@@ -150,6 +158,14 @@ function report_test {
echo " Source Commit ID | " >> ./test_simulator_results.html
echo " $SOURCE_COMMIT_ID | " >> ./test_simulator_results.html
echo " " >> ./test_simulator_results.html
+ if [ -e .git/CI_COMMIT_MSG ]
+ then
+ echo " " >> ./test_simulator_results.html
+ echo " | Commit Message | " >> ./test_simulator_results.html
+ MSG=`cat .git/CI_COMMIT_MSG`
+ echo " $MSG | " >> ./test_simulator_results.html
+ echo "
" >> ./test_simulator_results.html
+ fi
echo " " >> ./test_simulator_results.html
echo " | Target Branch | " >> ./test_simulator_results.html
echo " $TARGET_BRANCH | " >> ./test_simulator_results.html
diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh
index 7ff04e23f8..9aa6606eea 100755
--- a/ci-scripts/runTestOnVM.sh
+++ b/ci-scripts/runTestOnVM.sh
@@ -569,6 +569,7 @@ function start_l2_sim_enb {
ENB_SYNC=1
echo "L2-SIM eNB is sync'ed: waiting for UE(s) to connect"
fi
+ sleep 10
}
function start_l2_sim_ue {
@@ -604,10 +605,34 @@ function start_l2_sim_ue {
if [ $i -lt 50 ]
then
UE_SYNC=0
- echo "L2-SIM UE is NOT sync'ed w/eNB"
+ echo "L2-SIM UE is NOT sync'ed w/ eNB"
+ return
else
UE_SYNC=1
- echo "L2-SIM UE is sync'ed w/eNB"
+ echo "L2-SIM UE is sync'ed w/ eNB"
+ fi
+ # Checking oip1 interface has now an IP address
+ i="0"
+ echo "ifconfig oip1 | egrep -c \"inet addr\"" > $1
+ while [ $i -lt 10 ]
+ do
+ sleep 5
+ CONNECTED=`ssh -o StrictHostKeyChecking=no ubuntu@$LOC_VM_IP_ADDR < $1`
+ if [ $CONNECTED -eq 1 ]
+ then
+ i="100"
+ else
+ i=$[$i+1]
+ fi
+ done
+ rm $1
+ if [ $i -lt 50 ]
+ then
+ UE_SYNC=0
+ echo "L2-SIM UE oip1 is NOT sync'ed w/ EPC"
+ else
+ UE_SYNC=1
+ echo "L2-SIM UE oip1 is sync'ed w/ EPC"
fi
sleep 10
}
diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper
index acfb75b1a8..048ba300e7 100755
--- a/cmake_targets/tools/build_helper
+++ b/cmake_targets/tools/build_helper
@@ -102,6 +102,7 @@ check_supported_distribution() {
"ubuntu14.04") return 0 ;;
"fedora24") return 0 ;;
"rhel7") return 0 ;;
+ "rhel7.6") return 0 ;;
"centos7") return 0 ;;
esac
return 1
@@ -310,10 +311,20 @@ install_usrp_uhd_driver() {
# On newer kernels, it fails to install
$SUDO apt-get -y install uhd-host
fi
+ # quick workaround for RHE7.6
+ local distribution=$(get_distribution_release)
if [ -z $1 ]; then
- $SUDO uhd_images_downloader
+ if [[ "$distribution" == "rhel7.6" ]]; then
+ $SUDO /usr/local/bin/uhd_images_downloader
+ else
+ $SUDO uhd_images_downloader
+ fi
else
- $SUDO uhd_images_downloader -i $1
+ if [[ "$distribution" == "rhel7.6" ]]; then
+ $SUDO /usr/local/bin/uhd_images_downloader -i $1
+ else
+ $SUDO uhd_images_downloader -i $1
+ fi
fi
}
diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c
index 4d32e9726f..0083c2e66b 100644
--- a/common/config/config_cmdline.c
+++ b/common/config/config_cmdline.c
@@ -166,13 +166,14 @@ int config_check_unknown_cmdlineopt(char *prefix) {
int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH];
int finalcheck = 0;
+ memset(testprefix,0,sizeof(testprefix));
memset(testprefix,0,sizeof(testprefix));
if (prefix != NULL) {
if (strcmp(prefix,CONFIG_CHECKALLSECTIONS) == 0)
finalcheck = 1;
else if (strlen(prefix) > 0) {
- sprintf(testprefix,"--%.*s.",CONFIG_MAXOPTLENGTH-1,prefix);
+ sprintf(testprefix,"--%.*s.",CONFIG_MAXOPTLENGTH-4,prefix);
}
}
diff --git a/common/utils/T/local_tracer.c b/common/utils/T/local_tracer.c
index f8e92881a9..4be0b35d16 100644
--- a/common/utils/T/local_tracer.c
+++ b/common/utils/T/local_tracer.c
@@ -31,7 +31,7 @@ typedef struct {
int remote_port;
pthread_mutex_t lock;
pthread_cond_t cond;
- databuf * volatile head, *tail;
+ databuf *volatile head, *tail;
uint64_t memusage;
uint64_t last_warning_memusage;
} forward_data;
@@ -40,80 +40,115 @@ typedef struct {
/* utility functions */
/****************************************************************************/
-static void new_thread(void *(*f)(void *), void *data)
-{
+static void new_thread(void *(*f)(void *), void *data) {
pthread_t t;
pthread_attr_t att;
- if (pthread_attr_init(&att))
- { fprintf(stderr, "pthread_attr_init err\n"); exit(1); }
- if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED))
- { fprintf(stderr, "pthread_attr_setdetachstate err\n"); exit(1); }
- if (pthread_attr_setstacksize(&att, 10000000))
- { fprintf(stderr, "pthread_attr_setstacksize err\n"); exit(1); }
- if (pthread_create(&t, &att, f, data))
- { fprintf(stderr, "pthread_create err\n"); exit(1); }
- if (pthread_attr_destroy(&att))
- { fprintf(stderr, "pthread_attr_destroy err\n"); exit(1); }
+ if (pthread_attr_init(&att)) {
+ fprintf(stderr, "pthread_attr_init err\n");
+ exit(1);
+ }
+
+ if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
+ fprintf(stderr, "pthread_attr_setdetachstate err\n");
+ exit(1);
+ }
+
+ if (pthread_attr_setstacksize(&att, 10000000)) {
+ fprintf(stderr, "pthread_attr_setstacksize err\n");
+ exit(1);
+ }
+
+ if (pthread_create(&t, &att, f, data)) {
+ fprintf(stderr, "pthread_create err\n");
+ exit(1);
+ }
+
+ if (pthread_attr_destroy(&att)) {
+ fprintf(stderr, "pthread_attr_destroy err\n");
+ exit(1);
+ }
}
-static int get_connection(char *addr, int port)
-{
+static int get_connection(char *addr, int port) {
struct sockaddr_in a;
socklen_t alen;
int s, t;
-
printf("T tracer: waiting for connection on %s:%d\n", addr, port);
-
s = socket(AF_INET, SOCK_STREAM, 0);
- if (s == -1) { perror("socket"); exit(1); }
+
+ if (s == -1) {
+ perror("socket");
+ exit(1);
+ }
+
t = 1;
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(int)))
- { perror("setsockopt"); exit(1); }
+
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(int))) {
+ perror("setsockopt");
+ exit(1);
+ }
a.sin_family = AF_INET;
a.sin_port = htons(port);
a.sin_addr.s_addr = inet_addr(addr);
- if (bind(s, (struct sockaddr *)&a, sizeof(a))) { perror("bind"); exit(1); }
- if (listen(s, 5)) { perror("bind"); exit(1); }
+ if (bind(s, (struct sockaddr *)&a, sizeof(a))) {
+ perror("bind");
+ exit(1);
+ }
+
+ if (listen(s, 5)) {
+ perror("bind");
+ exit(1);
+ }
+
alen = sizeof(a);
t = accept(s, (struct sockaddr *)&a, &alen);
- if (t == -1) { perror("accept"); exit(1); }
+
+ if (t == -1) {
+ perror("accept");
+ exit(1);
+ }
+
close(s);
-
printf("T tracer: connected\n");
-
return t;
}
static void forward(void *_forwarder, char *buf, int size);
-void send_T_messages_txt(void *forwarder)
-{
+void send_T_messages_txt(void *forwarder) {
char buf[T_BUFFER_MAX];
char *T_LOCAL_buf = buf;
int T_LOCAL_size;
unsigned char *src;
int src_len;
-
/* trace T_message.txt
* Send several messages -1 with content followed by message -2.
*/
src = T_messages_txt;
src_len = T_messages_txt_len;
+
while (src_len) {
int send_size = src_len;
+
if (send_size > T_PAYLOAD_MAXSIZE - sizeof(int))
send_size = T_PAYLOAD_MAXSIZE - sizeof(int);
+
/* TODO: be careful, we use internal T stuff, to rewrite? */
T_LOCAL_size = 0;
T_HEADER(T_ID(-1));
- T_PUT_buffer(1, ((T_buffer){addr:(src), length:(send_size)}));
+ T_PUT_buffer(1, ((T_buffer) {
+addr:
+(src), length:
+ (send_size)
+ }));
forward(forwarder, buf, T_LOCAL_size);
src += send_size;
src_len -= send_size;
}
+
T_LOCAL_size = 0;
T_HEADER(T_ID(-2));
forward(forwarder, buf, T_LOCAL_size);
@@ -123,49 +158,54 @@ void send_T_messages_txt(void *forwarder)
/* forward functions */
/****************************************************************************/
-static void *data_sender(void *_f)
-{
+static void *data_sender(void *_f) {
forward_data *f = _f;
databuf *cur;
char *buf, *b;
int size;
-
wait:
+
if (pthread_mutex_lock(&f->lock)) abort();
+
while (f->head == NULL)
if (pthread_cond_wait(&f->cond, &f->lock)) abort();
+
cur = f->head;
buf = cur->d;
size = cur->l;
f->head = cur->next;
f->memusage -= size;
+
if (f->head == NULL) f->tail = NULL;
+
if (pthread_mutex_unlock(&f->lock)) abort();
+
free(cur);
goto process;
-
process:
b = buf;
+
if (f->socket_remote != -1)
- while (size) {
- int l = write(f->socket_remote, b, size);
- if (l <= 0) {
- printf("T tracer: forward error\n");
- close(f->socket_remote);
- f->socket_remote = -1;
- break;
+ while (size) {
+ int l = write(f->socket_remote, b, size);
+
+ if (l <= 0) {
+ printf("T tracer: forward error\n");
+ close(f->socket_remote);
+ f->socket_remote = -1;
+ break;
+ }
+
+ size -= l;
+ b += l;
}
- size -= l;
- b += l;
- }
free(buf);
-
goto wait;
}
-static void *forward_remote_messages(void *_f)
-{
+
+static void *forward_remote_messages(void *_f) {
#define PUT(x) do { \
if (bufsize == bufmaxsize) { \
bufmaxsize += 4096; \
@@ -180,7 +220,6 @@ static void *forward_remote_messages(void *_f)
int len = l; \
while (len) { PUT(*zz); zz++; len--; } \
} while (0)
-
forward_data *f = _f;
int from;
int to;
@@ -190,43 +229,53 @@ static void *forward_remote_messages(void *_f)
int bufsize = 0;
int bufmaxsize = 0;
char t;
-
again:
while (1) {
from = f->socket_remote;
to = f->socket_local;
-
bufsize = 0;
-
/* let's read and process messages */
- len = read(from, &t, 1); if (len <= 0) goto dead;
+ len = read(from, &t, 1);
+
+ if (len <= 0) goto dead;
+
PUT(t);
switch (t) {
- case 0:
- case 1:
- /* message 0 and 1: get a length and then 'length' numbers */
- if (read(from, &len, sizeof(int)) != sizeof(int)) goto dead;
- PUT_BUF(&len, 4);
- while (len) {
- if (read(from, &l, sizeof(int)) != sizeof(int)) goto dead;
- PUT_BUF(&l, 4);
- len--;
- }
- break;
+ case 0:
+ case 1:
- case 2: break;
- default:
- printf("%s:%d:%s: unhandled message type %d\n",
- __FILE__, __LINE__, __FUNCTION__, t);
- abort();
+ /* message 0 and 1: get a length and then 'length' numbers */
+ if (read(from, &len, sizeof(int)) != sizeof(int)) goto dead;
+
+ PUT_BUF(&len, 4);
+
+ while (len) {
+ if (read(from, &l, sizeof(int)) != sizeof(int)) goto dead;
+
+ PUT_BUF(&l, 4);
+ len--;
+ }
+
+ break;
+
+ case 2:
+ break;
+
+ default:
+ printf("%s:%d:%s: unhandled message type %d\n",
+ __FILE__, __LINE__, __FUNCTION__, t);
+ abort();
}
b = buf;
+
while (bufsize) {
l = write(to, b, bufsize);
+
if (l <= 0) abort();
+
bufsize -= l;
b += l;
}
@@ -236,71 +285,80 @@ dead:
/* socket died, let's stop all traces and wait for another tracer */
/* TODO: be careful with those write, they might write less than wanted */
buf[0] = 1;
+
if (write(to, buf, 1) != 1) abort();
+
len = T_NUMBER_OF_IDS;
+
if (write(to, &len, sizeof(int)) != sizeof(int)) abort();
+
l = 0;
+
while (len) {
if (write(to, &l, sizeof(int)) != sizeof(int)) abort();
+
len--;
};
close(f->socket_remote);
+
f->socket_remote = get_connection("0.0.0.0", f->remote_port);
+
send_T_messages_txt(f);
+
goto again;
return NULL;
}
-static void *forwarder(int port, int s)
-{
+static void *forwarder(int port, int s) {
forward_data *f;
+ f = malloc(sizeof(*f));
- f = malloc(sizeof(*f)); if (f == NULL) abort();
+ if (f == NULL) abort();
pthread_mutex_init(&f->lock, NULL);
pthread_cond_init(&f->cond, NULL);
-
f->socket_local = s;
f->head = f->tail = NULL;
-
f->memusage = 0;
f->last_warning_memusage = 0;
-
printf("T tracer: waiting for remote tracer on port %d\n", port);
-
f->remote_port = port;
f->socket_remote = get_connection("0.0.0.0", port);
send_T_messages_txt(f);
-
new_thread(data_sender, f);
new_thread(forward_remote_messages, f);
-
return f;
}
-static void forward(void *_forwarder, char *buf, int size)
-{
+static void forward(void *_forwarder, char *buf, int size) {
forward_data *f = _forwarder;
int32_t ssize = size;
databuf *new;
+ new = malloc(sizeof(*new));
- new = malloc(sizeof(*new)); if (new == NULL) abort();
+ if (new == NULL) abort();
if (pthread_mutex_lock(&f->lock)) abort();
- new->d = malloc(size + 4); if (new->d == NULL) abort();
+ new->d = malloc(size + 4);
+
+ if (new->d == NULL) abort();
+
/* put the size of the message at the head */
memcpy(new->d, &ssize, 4);
memcpy(new->d+4, buf, size);
new->l = size+4;
new->next = NULL;
- if (f->head == NULL) f->head = new;
- if (f->tail != NULL) f->tail->next = new;
- f->tail = new;
+ if (f->head == NULL) f->head = new;
+
+ 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
@@ -308,26 +366,30 @@ static void forward(void *_forwarder, char *buf, int size)
*/
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 */
+#endif /* BASIC_SIMULATOR */
f->memusage += size+4;
+
/* warn every 100MB */
if (f->memusage > f->last_warning_memusage &&
f->memusage - f->last_warning_memusage > 100000000) {
f->last_warning_memusage += 100000000;
printf("T tracer: WARNING: memory usage is over %"PRIu64"MB\n",
f->last_warning_memusage / 1000000);
- } else
- if (f->memusage < f->last_warning_memusage &&
- f->last_warning_memusage - f->memusage > 100000000) {
+ } else if (f->memusage < f->last_warning_memusage &&
+ f->last_warning_memusage - f->memusage > 100000000) {
f->last_warning_memusage = (f->memusage/100000000) * 100000000;
}
if (pthread_cond_signal(&f->cond)) abort();
+
if (pthread_mutex_unlock(&f->lock)) abort();
}
@@ -335,14 +397,12 @@ static void forward(void *_forwarder, char *buf, int size)
/* local functions */
/****************************************************************************/
-static void wait_message(void)
-{
+static void wait_message(void) {
while ((T_local_cache[T_busylist_head].busy & 0x02) == 0) usleep(1000);
}
void T_local_tracer_main(int remote_port, int wait_for_tracer,
- int local_socket, void *shm_array)
-{
+ int local_socket, void *shm_array) {
int s;
int port = remote_port;
int dont_wait = wait_for_tracer ? 0 : 1;
@@ -350,16 +410,16 @@ 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) {
- printf("local tracer received SIGPIPE\n");
- abort();
+ printf("local tracer received SIGPIPE\n");
+ abort();
}
T_local_cache = shm_array;
-
s = local_socket;
if (dont_wait) {
char t = 2;
+
if (write(s, &t, 1) != 1) abort();
}
diff --git a/common/utils/T/tracer/gui/notify.c b/common/utils/T/tracer/gui/notify.c
index 7ff4006941..84fb161b6e 100644
--- a/common/utils/T/tracer/gui/notify.c
+++ b/common/utils/T/tracer/gui/notify.c
@@ -5,46 +5,41 @@
#include
unsigned long register_notifier(gui *_g, char *notification, widget *w,
- notifier handler, void *private)
-{
+ notifier handler, void *private) {
struct gui *g = _g;
unsigned long ret;
-
glock(g);
if (g->next_notifier_id == 2UL * 1024 * 1024 * 1024)
ERR("%s:%d: report a bug\n", __FILE__, __LINE__);
g->notifiers = realloc(g->notifiers,
- (g->notifiers_count+1) * sizeof(struct notifier));
+ (g->notifiers_count+1) * sizeof(struct notifier));
+
if (g->notifiers == NULL) abort();
ret = g->next_notifier_id;
-
g->notifiers[g->notifiers_count].handler = handler;
g->notifiers[g->notifiers_count].id = g->next_notifier_id;
g->next_notifier_id++;
g->notifiers[g->notifiers_count].notification = strdup(notification);
+
if (g->notifiers[g->notifiers_count].notification == NULL) abort();
+
g->notifiers[g->notifiers_count].w = w;
g->notifiers[g->notifiers_count].private = private;
/* initialize done to 1 so as not to call the handler if it's created
* by the call of another one that is in progress
*/
g->notifiers[g->notifiers_count].done = 1;
-
g->notifiers_count++;
-
gunlock(g);
-
return ret;
}
-void unregister_notifier(gui *_g, unsigned long notifier_id)
-{
+void unregister_notifier(gui *_g, unsigned long notifier_id) {
struct gui *g = _g;
int i;
-
glock(g);
for (i = 0; i < g->notifiers_count; i++)
@@ -54,13 +49,12 @@ void unregister_notifier(gui *_g, unsigned long notifier_id)
ERR("%s:%d: notifier_id %ld not found\n", __FILE__,__LINE__,notifier_id);
free(g->notifiers[i].notification);
-
memmove(g->notifiers + i, g->notifiers + i + 1,
- (g->notifiers_count-1 - i) * sizeof(struct notifier));
-
+ (g->notifiers_count-1 - i) * sizeof(struct notifier));
g->notifiers_count--;
g->notifiers = realloc(g->notifiers,
- g->notifiers_count * sizeof(struct notifier));
+ g->notifiers_count * sizeof(struct notifier));
+
if (g->notifiers == NULL) abort();
gunlock(g);
@@ -68,19 +62,19 @@ void unregister_notifier(gui *_g, unsigned long notifier_id)
/* called with lock ON */
void gui_notify(struct gui *g, char *notification, widget *w,
- void *notification_data)
-{
+ void *notification_data) {
void *private;
notifier handler;
int i;
-
/* this function is not re-entrant, for the moment keep as is
* and if the need is there, we'll make a new thread to handle
* notifications (or something)
* for now let's crash in case of recursive call
*/
static int inside = 0;
+
if (inside) ERR("%s:%d: BUG! contact the authors\n", __FILE__, __LINE__);
+
inside = 1;
/* clear all handlers */
@@ -91,26 +85,25 @@ void gui_notify(struct gui *g, char *notification, widget *w,
* need to be careful here
*/
loop:
+
for (i = 0; i < g->notifiers_count; i++) {
if (g->notifiers[i].done == 1 ||
g->notifiers[i].w != w ||
strcmp(g->notifiers[i].notification, notification) != 0)
continue;
+
break;
}
+
if (i == g->notifiers_count) goto done;
g->notifiers[i].done = 1;
-
handler = g->notifiers[i].handler;
private = g->notifiers[i].private;
-
gunlock(g);
handler(private, g, notification, w, notification_data);
glock(g);
-
goto loop;
-
done:
inside = 0;
}
diff --git a/common/utils/T/tracer/hacks/dump_nack_signal.c b/common/utils/T/tracer/hacks/dump_nack_signal.c
index bb8f1a9477..02825202fb 100644
--- a/common/utils/T/tracer/hacks/dump_nack_signal.c
+++ b/common/utils/T/tracer/hacks/dump_nack_signal.c
@@ -7,21 +7,19 @@
#include "config.h"
#include "../T_defs.h"
-void usage(void)
-{
+void usage(void) {
printf(
-"options:\n"
-" -d this option is mandatory\n"
-" -ip connect to given IP address (default %s)\n"
-" -p connect to given port (default %d)\n",
- DEFAULT_REMOTE_IP,
- DEFAULT_REMOTE_PORT
+ "options:\n"
+ " -d this option is mandatory\n"
+ " -ip connect to given IP address (default %s)\n"
+ " -p connect to given port (default %d)\n",
+ DEFAULT_REMOTE_IP,
+ DEFAULT_REMOTE_PORT
);
exit(1);
}
-int main(int n, char **v)
-{
+int main(int n, char **v) {
char *database_filename = NULL;
void *database;
char *ip = DEFAULT_REMOTE_IP;
@@ -36,11 +34,28 @@ int main(int n, char **v)
for (i = 1; i < n; i++) {
if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
- if (!strcmp(v[i], "-d"))
- { if (i > n-2) usage(); database_filename = v[++i]; continue; }
- if (!strcmp(v[i], "-ip")) { if (i > n-2) usage(); ip = v[++i]; continue; }
- if (!strcmp(v[i], "-p"))
- { if (i > n-2) usage(); port = atoi(v[++i]); continue; }
+
+ if (!strcmp(v[i], "-d")) {
+ if (i > n-2) usage();
+
+ database_filename = v[++i];
+ continue;
+ }
+
+ if (!strcmp(v[i], "-ip")) {
+ if (i > n-2) usage();
+
+ ip = v[++i];
+ continue;
+ }
+
+ if (!strcmp(v[i], "-p")) {
+ if (i > n-2) usage();
+
+ port = atoi(v[++i]);
+ continue;
+ }
+
usage();
}
@@ -50,71 +65,92 @@ int main(int n, char **v)
}
database = parse_database(database_filename);
-
load_config_file(database_filename);
-
number_of_events = number_of_ids(database);
is_on = calloc(number_of_events, sizeof(int));
+
if (is_on == NULL) abort();
on_off(database, "ENB_PHY_INPUT_SIGNAL", is_on, 1);
on_off(database, "ENB_PHY_ULSCH_UE_NACK", is_on, 1);
on_off(database, "ENB_PHY_ULSCH_UE_ACK", is_on, 1);
-
ev_input = event_id_from_name(database, "ENB_PHY_INPUT_SIGNAL");
ev_nack = event_id_from_name(database, "ENB_PHY_ULSCH_UE_NACK");
ev_ack = event_id_from_name(database, "ENB_PHY_ULSCH_UE_ACK");
-
socket = connect_to(ip, port);
-
t = 1;
+
if (socket_send(socket, &t, 1) == -1 ||
socket_send(socket, &number_of_events, sizeof(int)) == -1 ||
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();
+ FILE *z = fopen("/tmp/dd", "w");
+
+ if (z == NULL) abort();
+
while (1) {
char *v;
event e;
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;
- if (ebuf.osize > T_BUFFER_MAX)
- { printf("event size too big\n"); exit(1); }
+
+ 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();
-fflush(z);
+
+ if (fwrite(dump_ev[sf].e[4].b, dump_ev[sf].e[4].bsize, 1, z) != 1) abort();
+
+ fflush(z);
}
+
if (e.type == ev_nack) {
int sf = e.e[2].i;
printf("nack %d/%d\n", e.e[1].i, sf);
- FILE *f = fopen("/tmp/dump.raw", "w"); if (f == NULL) abort();
+ FILE *f = fopen("/tmp/dump.raw", "w");
+
+ if (f == NULL) abort();
+
if (fwrite(dump[sf] + ((char *)dump_ev[sf].e[4].b - v),
- dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
+ dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
+
if (fclose(f)) abort();
+
printf("dumped... press enter (delta %d)\n", (int)((char *)dump_ev[sf].e[4].b - v));
-// getchar();
+ // getchar();
}
+
if (e.type == ev_ack) {
int sf = e.e[2].i;
printf("ack %d/%d\n", e.e[1].i, sf);
- FILE *f = fopen("/tmp/dump.raw", "w"); if (f == NULL) abort();
+ FILE *f = fopen("/tmp/dump.raw", "w");
+
+ if (f == NULL) abort();
+
if (fwrite(dump[sf] + ((char *)dump_ev[sf].e[4].b - v),
- dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
+ dump_ev[sf].e[4].bsize, 1, f) != 1) abort();
+
if (fclose(f)) abort();
+
printf("dumped... press enter (delta %d)\n", (int)((char *)dump_ev[sf].e[4].b - v));
-// getchar();
+ // getchar();
}
}
+ if (z)
+ fclose(z);
return 0;
}
diff --git a/common/utils/T/tracer/macpdu2wireshark.c b/common/utils/T/tracer/macpdu2wireshark.c
index d9bcb8b7f5..7ea3b70bb4 100644
--- a/common/utils/T/tracer/macpdu2wireshark.c
+++ b/common/utils/T/tracer/macpdu2wireshark.c
@@ -58,14 +58,11 @@ typedef struct {
} ev_data;
void trace(ev_data *d, int direction, int rnti_type, int rnti,
- int frame, int subframe, void *buf, int bufsize, int preamble)
-{
+ int frame, int subframe, void *buf, int bufsize, int preamble) {
ssize_t ret;
int fsf;
int i;
-
d->buf.osize = 0;
-
PUTS(&d->buf, MAC_LTE_START_STRING);
PUTC(&d->buf, FDD_RADIO);
PUTC(&d->buf, direction);
@@ -92,16 +89,17 @@ void trace(ev_data *d, int direction, int rnti_type, int rnti,
}
PUTC(&d->buf, MAC_LTE_PAYLOAD_TAG);
+
for (i = 0; i < bufsize; i++)
- PUTC(&d->buf, ((char*)buf)[i]);
+ PUTC(&d->buf, ((char *)buf)[i]);
ret = sendto(d->socket, d->buf.obuf, d->buf.osize, 0,
- (struct sockaddr *)&d->to, sizeof(struct sockaddr_in));
+ (struct sockaddr *)&d->to, sizeof(struct sockaddr_in));
+
if (ret != d->buf.osize) abort();
}
-void ul(void *_d, event e)
-{
+void ul(void *_d, event e) {
ev_data *d = _d;
trace(d, DIRECTION_UPLINK, C_RNTI, e.e[d->ul_rnti].i,
e.e[d->ul_frame].i, e.e[d->ul_subframe].i,
@@ -109,13 +107,14 @@ void ul(void *_d, event e)
NO_PREAMBLE);
}
-void dl(void *_d, event e)
-{
+void dl(void *_d, event e) {
ev_data *d = _d;
if (e.e[d->dl_rnti].i == 0xffff) {
if (d->no_sib) return;
+
if (d->max_sib && d->cur_sib == d->max_sib) return;
+
d->cur_sib++;
}
@@ -126,22 +125,21 @@ void dl(void *_d, event e)
NO_PREAMBLE);
}
-void mib(void *_d, event e)
-{
+void mib(void *_d, event e) {
ev_data *d = _d;
if (d->no_mib) return;
- if (d->max_mib && d->cur_mib == d->max_mib) return;
- d->cur_mib++;
+ if (d->max_mib && d->cur_mib == d->max_mib) return;
+
+ d->cur_mib++;
trace(d, DIRECTION_DOWNLINK, NO_RNTI, 0,
e.e[d->mib_frame].i, e.e[d->mib_subframe].i,
e.e[d->mib_data].b, e.e[d->mib_data].bsize,
NO_PREAMBLE);
}
-void preamble(void *_d, event e)
-{
+void preamble(void *_d, event e) {
ev_data *d = _d;
trace(d, DIRECTION_UPLINK, NO_RNTI, 0,
e.e[d->preamble_frame].i, e.e[d->preamble_subframe].i,
@@ -149,8 +147,7 @@ void preamble(void *_d, event e)
e.e[d->preamble_preamble].i);
}
-void rar(void *_d, event e)
-{
+void rar(void *_d, event e) {
ev_data *d = _d;
trace(d, DIRECTION_DOWNLINK, RA_RNTI, e.e[d->rar_rnti].i,
e.e[d->rar_frame].i, e.e[d->rar_subframe].i,
@@ -159,114 +156,118 @@ void rar(void *_d, event e)
}
void setup_data(ev_data *d, void *database, int ul_id, int dl_id, int mib_id,
- int preamble_id, int rar_id)
-{
+ int preamble_id, int rar_id) {
database_event_format f;
int i;
-
d->ul_rnti = -1;
d->ul_frame = -1;
d->ul_subframe = -1;
d->ul_data = -1;
-
d->dl_rnti = -1;
d->dl_frame = -1;
d->dl_subframe = -1;
d->dl_data = -1;
-
d->mib_frame = -1;
d->mib_subframe = -1;
d->mib_data = -1;
-
d->preamble_frame = -1;
d->preamble_subframe = -1;
d->preamble_preamble = -1;
-
d->rar_rnti = -1;
d->rar_frame = -1;
d->rar_subframe = -1;
d->rar_data = -1;
-
#define G(var_name, var_type, var) \
if (!strcmp(f.name[i], var_name)) { \
if (strcmp(f.type[i], var_type)) goto error; \
var = i; \
continue; \
}
-
/* ul: rnti, frame, subframe, data */
f = get_format(database, ul_id);
+
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->ul_rnti);
G("frame", "int", d->ul_frame);
G("subframe", "int", d->ul_subframe);
G("data", "buffer", d->ul_data);
}
+
if (d->ul_rnti == -1 || d->ul_frame == -1 || d->ul_subframe == -1 ||
d->ul_data == -1) goto error;
/* dl: rnti, frame, subframe, data */
f = get_format(database, dl_id);
+
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->dl_rnti);
G("frame", "int", d->dl_frame);
G("subframe", "int", d->dl_subframe);
G("data", "buffer", d->dl_data);
}
+
if (d->dl_rnti == -1 || d->dl_frame == -1 || d->dl_subframe == -1 ||
d->dl_data == -1) goto error;
/* MIB: frame, subframe, data */
f = get_format(database, mib_id);
+
for (i = 0; i < f.count; i++) {
G("frame", "int", d->mib_frame);
G("subframe", "int", d->mib_subframe);
G("data", "buffer", d->mib_data);
}
+
if (d->mib_frame == -1 || d->mib_subframe == -1 || d->mib_data == -1)
goto error;
/* preamble: frame, subframe, preamble */
f = get_format(database, preamble_id);
+
for (i = 0; i < f.count; i++) {
G("frame", "int", d->preamble_frame);
G("subframe", "int", d->preamble_subframe);
G("preamble", "int", d->preamble_preamble);
}
+
if (d->preamble_frame == -1 || d->preamble_subframe == -1 ||
d->preamble_preamble == -1) goto error;
/* rar: rnti, frame, subframe, data */
f = get_format(database, rar_id);
+
for (i = 0; i < f.count; i++) {
G("rnti", "int", d->rar_rnti);
G("frame", "int", d->rar_frame);
G("subframe", "int", d->rar_subframe);
G("data", "buffer", d->rar_data);
}
+
if (d->rar_rnti == -1 || d->rar_frame == -1 || d->rar_subframe == -1 ||
d->rar_data == -1) goto error;
#undef G
-
return;
-
error:
printf("bad T_messages.txt\n");
abort();
}
-void *receiver(void *_d)
-{
+void *receiver(void *_d) {
ev_data *d = _d;
int s;
char buf[100000];
-
s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s == -1) { perror("socket"); abort(); }
- if (bind(s, (struct sockaddr *)&d->to, sizeof(struct sockaddr_in)) == -1)
- { perror("bind"); abort(); }
+ if (s == -1) {
+ perror("socket");
+ abort();
+ }
+
+ if (bind(s, (struct sockaddr *)&d->to, sizeof(struct sockaddr_in)) == -1) {
+ perror("bind");
+ abort();
+ }
while (1) {
if (recv(s, buf, 100000, 0) <= 0) abort();
@@ -275,33 +276,31 @@ void *receiver(void *_d)
return 0;
}
-void usage(void)
-{
+void usage(void) {
printf(
-"options:\n"
-" -d this option is mandatory\n"
-" -i read events from this dump file\n"
-" -ip send packets to this IP address (default %s)\n"
-" -p send packets to this port (default %d)\n"
-" -no-mib do not report MIB\n"
-" -no-sib do not report SIBs\n"
-" -max-mib report at maximum n MIB\n"
-" -max-sib report at maximum n SIBs\n"
-" -live run live\n"
-" -live-ip tracee's IP address (default %p)\n"
-" -live-port tracee's port (default %d)\n"
-"-i and -live are mutually exclusive options. One of them must be provided\n"
-"but not both.\n",
- DEFAULT_IP,
- DEFAULT_PORT,
- DEFAULT_LIVE_IP,
- DEFAULT_LIVE_PORT
+ "options:\n"
+ " -d this option is mandatory\n"
+ " -i read events from this dump file\n"
+ " -ip send packets to this IP address (default %s)\n"
+ " -p send packets to this port (default %d)\n"
+ " -no-mib do not report MIB\n"
+ " -no-sib do not report SIBs\n"
+ " -max-mib report at maximum n MIB\n"
+ " -max-sib report at maximum n SIBs\n"
+ " -live run live\n"
+ " -live-ip tracee's IP address (default %s)\n"
+ " -live-port tracee's port (default %d)\n"
+ "-i and -live are mutually exclusive options. One of them must be provided\n"
+ "but not both.\n",
+ DEFAULT_IP,
+ DEFAULT_PORT,
+ DEFAULT_LIVE_IP,
+ DEFAULT_LIVE_PORT
);
exit(1);
}
-int main(int n, char **v)
-{
+int main(int n, char **v) {
char *database_filename = NULL;
char *input_filename = NULL;
void *database;
@@ -315,28 +314,82 @@ int main(int n, char **v)
char *live_ip = DEFAULT_LIVE_IP;
int live_port = DEFAULT_LIVE_PORT;
int live = 0;
-
memset(&d, 0, sizeof(ev_data));
for (i = 1; i < n; i++) {
if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
- if (!strcmp(v[i], "-d"))
- { if (i > n-2) usage(); database_filename = v[++i]; continue; }
- if (!strcmp(v[i], "-i"))
- { if (i > n-2) usage(); input_filename = v[++i]; continue; }
- if (!strcmp(v[i], "-ip")) { if (i > n-2) usage(); ip = v[++i]; continue; }
- if (!strcmp(v[i], "-p")) {if(i>n-2)usage(); port=atoi(v[++i]); continue; }
- if (!strcmp(v[i], "-no-mib")) { d.no_mib = 1; continue; }
- if (!strcmp(v[i], "-no-sib")) { d.no_sib = 1; continue; }
- if (!strcmp(v[i], "-max-mib"))
- { if (i > n-2) usage(); d.max_mib = atoi(v[++i]); continue; }
- if (!strcmp(v[i], "-max-sib"))
- { if (i > n-2) usage(); d.max_sib = atoi(v[++i]); continue; }
- if (!strcmp(v[i], "-live")) { live = 1; continue; }
- if (!strcmp(v[i], "-live-ip"))
- { if (i > n-2) usage(); live_ip = v[++i]; continue; }
- if (!strcmp(v[i], "-live-port"))
- { if (i > n-2) usage(); live_port = atoi(v[++i]); continue; }
+
+ if (!strcmp(v[i], "-d")) {
+ if (i > n-2) usage();
+
+ database_filename = v[++i];
+ continue;
+ }
+
+ if (!strcmp(v[i], "-i")) {
+ if (i > n-2) usage();
+
+ input_filename = v[++i];
+ continue;
+ }
+
+ if (!strcmp(v[i], "-ip")) {
+ if (i > n-2) usage();
+
+ ip = v[++i];
+ continue;
+ }
+
+ if (!strcmp(v[i], "-p")) {
+ if(i>n-2)usage();
+
+ port=atoi(v[++i]);
+ continue;
+ }
+
+ if (!strcmp(v[i], "-no-mib")) {
+ d.no_mib = 1;
+ continue;
+ }
+
+ if (!strcmp(v[i], "-no-sib")) {
+ d.no_sib = 1;
+ continue;
+ }
+
+ if (!strcmp(v[i], "-max-mib")) {
+ if (i > n-2) usage();
+
+ d.max_mib = atoi(v[++i]);
+ continue;
+ }
+
+ if (!strcmp(v[i], "-max-sib")) {
+ if (i > n-2) usage();
+
+ d.max_sib = atoi(v[++i]);
+ continue;
+ }
+
+ if (!strcmp(v[i], "-live")) {
+ live = 1;
+ continue;
+ }
+
+ if (!strcmp(v[i], "-live-ip")) {
+ if (i > n-2) usage();
+
+ live_ip = v[++i];
+ continue;
+ }
+
+ if (!strcmp(v[i], "-live-port")) {
+ if (i > n-2) usage();
+
+ live_port = atoi(v[++i]);
+ continue;
+ }
+
usage();
}
@@ -357,25 +410,34 @@ int main(int n, char **v)
if (live == 0) {
in = open(input_filename, O_RDONLY);
- if (in == -1) { perror(input_filename); return 1; }
+
+ if (in == -1) {
+ perror(input_filename);
+ return 1;
+ }
} else
in = connect_to(live_ip, live_port);
database = parse_database(database_filename);
load_config_file(database_filename);
-
h = new_handler(database);
if (live) {
char mt = 1;
int number_of_events = number_of_ids(database);
int *is_on = calloc(number_of_events, sizeof(int));
- if (is_on == NULL) { printf("ERROR: out of memory\n"); exit(1); }
+
+ if (is_on == NULL) {
+ printf("ERROR: out of memory\n");
+ exit(1);
+ }
+
on_off(database, "ENB_MAC_UE_UL_PDU_WITH_DATA", is_on, 1);
on_off(database, "ENB_MAC_UE_DL_PDU_WITH_DATA", is_on, 1);
on_off(database, "ENB_PHY_MIB", is_on, 1);
on_off(database, "ENB_PHY_INITIATE_RA_PROCEDURE", is_on, 1);
on_off(database, "ENB_MAC_UE_DL_RAR_PDU_WITH_DATA", is_on, 1);
+
/* activate selected traces */
if (socket_send(in, &mt, 1) == -1 ||
socket_send(in, &number_of_events, sizeof(int)) == -1 ||
@@ -383,6 +445,7 @@ int main(int n, char **v)
printf("ERROR: socket_send failed\n");
exit(1);
}
+
free(is_on);
}
@@ -392,31 +455,34 @@ int main(int n, char **v)
preamble_id = event_id_from_name(database, "ENB_PHY_INITIATE_RA_PROCEDURE");
rar_id = event_id_from_name(database, "ENB_MAC_UE_DL_RAR_PDU_WITH_DATA");
setup_data(&d, database, ul_id, dl_id, mib_id, preamble_id, rar_id);
-
register_handler_function(h, ul_id, ul, &d);
register_handler_function(h, dl_id, dl, &d);
register_handler_function(h, mib_id, mib, &d);
register_handler_function(h, preamble_id, preamble, &d);
register_handler_function(h, rar_id, rar, &d);
-
d.socket = socket(AF_INET, SOCK_DGRAM, 0);
- if (d.socket == -1) { perror("socket"); exit(1); }
+
+ if (d.socket == -1) {
+ perror("socket");
+ exit(1);
+ }
d.to.sin_family = AF_INET;
d.to.sin_port = htons(port);
d.to.sin_addr.s_addr = inet_addr(ip);
-
new_thread(receiver, &d);
-
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
/* read messages */
while (1) {
event e;
e = get_event(in, &ebuf, database);
+
if (e.type == -1) break;
+
if (!(e.type == ul_id || e.type == dl_id || e.type == mib_id ||
e.type == preamble_id || e.type == rar_id)) continue;
+
handle_event(h, e);
}
diff --git a/common/utils/T/tracer/utils.c b/common/utils/T/tracer/utils.c
index 7f58b6f5aa..2452254cf9 100644
--- a/common/utils/T/tracer/utils.c
+++ b/common/utils/T/tracer/utils.c
@@ -9,27 +9,38 @@
#include
#include
-void new_thread(void *(*f)(void *), void *data)
-{
+void new_thread(void *(*f)(void *), void *data) {
pthread_t t;
pthread_attr_t att;
- if (pthread_attr_init(&att))
- { fprintf(stderr, "pthread_attr_init err\n"); exit(1); }
- if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED))
- { fprintf(stderr, "pthread_attr_setdetachstate err\n"); exit(1); }
- if (pthread_attr_setstacksize(&att, 10000000))
- { fprintf(stderr, "pthread_attr_setstacksize err\n"); exit(1); }
- if (pthread_create(&t, &att, f, data))
- { fprintf(stderr, "pthread_create err\n"); exit(1); }
- if (pthread_attr_destroy(&att))
- { fprintf(stderr, "pthread_attr_destroy err\n"); exit(1); }
+ if (pthread_attr_init(&att)) {
+ fprintf(stderr, "pthread_attr_init err\n");
+ exit(1);
+ }
+
+ if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
+ fprintf(stderr, "pthread_attr_setdetachstate err\n");
+ exit(1);
+ }
+
+ if (pthread_attr_setstacksize(&att, 10000000)) {
+ fprintf(stderr, "pthread_attr_setstacksize err\n");
+ exit(1);
+ }
+
+ if (pthread_create(&t, &att, f, data)) {
+ fprintf(stderr, "pthread_create err\n");
+ exit(1);
+ }
+
+ if (pthread_attr_destroy(&att)) {
+ fprintf(stderr, "pthread_attr_destroy err\n");
+ exit(1);
+ }
}
-void sleepms(int ms)
-{
+void sleepms(int ms) {
struct timespec t;
-
t.tv_sec = ms / 1000;
t.tv_nsec = (ms % 1000) * 1000000L;
@@ -37,12 +48,15 @@ void sleepms(int ms)
if (nanosleep(&t, NULL)) abort();
}
-void bps(char *out, float v, char *suffix)
-{
+void bps(char *out, float v, char *suffix) {
static char *bps_unit[4] = { "", "k", "M", "G" };
int flog;
- if (v < 1000) flog = 0; else flog = floor(floor(log10(v)) / 3);
+
+ if (v < 1000) flog = 0;
+ else flog = floor(floor(log10(v)) / 3);
+
if (flog > 3) flog = 3;
+
v /= pow(10, flog*3);
sprintf(out, "%g%s%s", round(v*100)/100, bps_unit[flog], suffix);
}
@@ -51,25 +65,31 @@ void bps(char *out, float v, char *suffix)
/* list */
/****************************************************************************/
-list *list_remove_head(list *l)
-{
+list *list_remove_head(list *l) {
list *ret;
+
if (l == NULL) return NULL;
+
ret = l->next;
+
if (ret != NULL) ret->last = l->last;
+
free(l);
return ret;
}
-list *list_append(list *l, void *data)
-{
+list *list_append(list *l, void *data) {
list *new = calloc(1, sizeof(list));
+
if (new == NULL) abort();
+
new->data = data;
+
if (l == NULL) {
new->last = new;
return new;
}
+
l->last->next = new;
l->last = new;
return l;
@@ -79,88 +99,107 @@ list *list_append(list *l, void *data)
/* socket */
/****************************************************************************/
-int create_listen_socket(char *addr, int port)
-{
+int create_listen_socket(char *addr, int port) {
struct sockaddr_in a;
int s;
int v;
-
s = socket(AF_INET, SOCK_STREAM, 0);
- if (s == -1) { perror("socket"); exit(1); }
+
+ if (s == -1) {
+ perror("socket");
+ exit(1);
+ }
+
v = 1;
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(int)))
- { perror("setsockopt"); exit(1); }
+
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(int))) {
+ perror("setsockopt");
+ exit(1);
+ }
a.sin_family = AF_INET;
a.sin_port = htons(port);
a.sin_addr.s_addr = inet_addr(addr);
- if (bind(s, (struct sockaddr *)&a, sizeof(a))) { perror("bind"); exit(1); }
- if (listen(s, 5)) { perror("listen"); exit(1); }
+ if (bind(s, (struct sockaddr *)&a, sizeof(a))) {
+ perror("bind");
+ exit(1);
+ }
+
+ if (listen(s, 5)) {
+ perror("listen");
+ exit(1);
+ }
return s;
}
-int socket_accept(int s)
-{
+int socket_accept(int s) {
struct sockaddr_in a;
socklen_t alen;
alen = sizeof(a);
return accept(s, (struct sockaddr *)&a, &alen);
}
-int socket_send(int socket, void *buffer, int size)
-{
+int socket_send(int socket, void *buffer, int size) {
char *x = buffer;
int ret;
+
while (size) {
ret = write(socket, x, size);
+
if (ret <= 0) return -1;
+
size -= ret;
x += ret;
}
+
return 0;
}
-int get_connection(char *addr, int port)
-{
+int get_connection(char *addr, int port) {
int s, t;
-
printf("waiting for connection on %s:%d\n", addr, port);
-
s = create_listen_socket(addr, port);
-
t = socket_accept(s);
- if (t == -1) { perror("accept"); exit(1); }
+
+ if (t == -1) {
+ perror("accept");
+ exit(1);
+ }
+
close(s);
-
printf("connected\n");
-
return t;
}
-int fullread(int fd, void *_buf, int count)
-{
+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 try_connect_to(char *addr, int port)
-{
+int try_connect_to(char *addr, int port) {
int s;
struct sockaddr_in a;
-
s = socket(AF_INET, SOCK_STREAM, 0);
- if (s == -1) { perror("socket"); exit(1); }
+
+ if (s == -1) {
+ perror("socket");
+ exit(1);
+ }
a.sin_family = AF_INET;
a.sin_port = htons(port);
@@ -175,14 +214,12 @@ int try_connect_to(char *addr, int port)
return s;
}
-int connect_to(char *addr, int port)
-{
+int connect_to(char *addr, int port) {
int s;
-
printf("connecting to %s:%d\n", addr, port);
-
again:
s = try_connect_to(addr, port);
+
if (s == -1) {
printf("trying again in 1s\n");
sleep(1);
@@ -196,49 +233,45 @@ again:
/* buffer */
/****************************************************************************/
-void PUTC(OBUF *o, char c)
-{
+void PUTC(OBUF *o, char c) {
if (o->osize == o->omaxsize) {
o->omaxsize += 512;
o->obuf = realloc(o->obuf, o->omaxsize);
+
if (o->obuf == NULL) abort();
}
+
o->obuf[o->osize] = c;
o->osize++;
}
-void PUTS(OBUF *o, char *s)
-{
+void PUTS(OBUF *o, char *s) {
while (*s) PUTC(o, *s++);
}
-static int clean(char c)
-{
+static int clean(char c) {
if (!isprint(c)) c = ' ';
+
return c;
}
-void PUTS_CLEAN(OBUF *o, char *s)
-{
+void PUTS_CLEAN(OBUF *o, char *s) {
while (*s) PUTC(o, clean(*s++));
}
-void PUTI(OBUF *o, int i)
-{
+void PUTI(OBUF *o, int i) {
char s[64];
sprintf(s, "%d", i);
PUTS(o, s);
}
-void PUTX2(OBUF *o, int i)
-{
+void PUTX2(OBUF *o, int i) {
char s[64];
sprintf(s, "%2.2x", i);
PUTS(o, s);
}
-void PUTUL(OBUF *o, unsigned long l)
-{
+void PUTUL(OBUF *o, unsigned long l) {
char s[128];
sprintf(s, "%ld", l);
PUTS(o, s);
diff --git a/common/utils/backtrace.c b/common/utils/backtrace.c
index 889e0d84d1..f6de74f156 100644
--- a/common/utils/backtrace.c
+++ b/common/utils/backtrace.c
@@ -31,18 +31,18 @@
#include "backtrace.h"
/* Obtain a backtrace and print it to stdout. */
-void display_backtrace(void)
-{
+void display_backtrace(void) {
void *array[10];
size_t size;
char **strings;
size_t i;
- char* test=getenv("NO_BACKTRACE");
- if (test!=0) *((int*)0)=0;
+ char *test=getenv("NO_BACKTRACE");
+
+ if (test!=0) *((int *)0)=0;
+
size = backtrace(array, 10);
strings = backtrace_symbols(array, size);
-
- printf("Obtained %zd stack frames.\n", size);
+ printf("Obtained %u stack frames.\n", (unsigned int)size);
for (i = 0; i < size; i++)
printf("%s\n", strings[i]);
@@ -50,8 +50,7 @@ void display_backtrace(void)
free(strings);
}
-void backtrace_handle_signal(siginfo_t *info)
-{
+void backtrace_handle_signal(siginfo_t *info) {
display_backtrace();
//exit(EXIT_FAILURE);
}
diff --git a/common/utils/hashtable/hashtable.c b/common/utils/hashtable/hashtable.c
index 2c7b35744c..7b0fc42213 100644
--- a/common/utils/hashtable/hashtable.c
+++ b/common/utils/hashtable/hashtable.c
@@ -2,9 +2,9 @@
* 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 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.
+ * except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
@@ -28,17 +28,33 @@
//-------------------------------------------------------------------------------------------------------------------------------
-char* hashtable_rc_code2string(hashtable_rc_t rcP)
+char *hashtable_rc_code2string(hashtable_rc_t rcP)
//-------------------------------------------------------------------------------------------------------------------------------
{
- switch (rcP) {
- case HASH_TABLE_OK: return "HASH_TABLE_OK";break;
- case HASH_TABLE_INSERT_OVERWRITTEN_DATA: return "HASH_TABLE_INSERT_OVERWRITTEN_DATA";break;
- case HASH_TABLE_KEY_NOT_EXISTS: return "HASH_TABLE_KEY_NOT_EXISTS";break;
- case HASH_TABLE_KEY_ALREADY_EXISTS: return "HASH_TABLE_KEY_ALREADY_EXISTS";break;
- case HASH_TABLE_BAD_PARAMETER_HASHTABLE: return "HASH_TABLE_BAD_PARAMETER_HASHTABLE";break;
- default: return "UNKNOWN hashtable_rc_t";
- }
+ switch (rcP) {
+ case HASH_TABLE_OK:
+ return "HASH_TABLE_OK";
+ break;
+
+ case HASH_TABLE_INSERT_OVERWRITTEN_DATA:
+ return "HASH_TABLE_INSERT_OVERWRITTEN_DATA";
+ break;
+
+ case HASH_TABLE_KEY_NOT_EXISTS:
+ return "HASH_TABLE_KEY_NOT_EXISTS";
+ break;
+
+ case HASH_TABLE_KEY_ALREADY_EXISTS:
+ return "HASH_TABLE_KEY_ALREADY_EXISTS";
+ break;
+
+ case HASH_TABLE_BAD_PARAMETER_HASHTABLE:
+ return "HASH_TABLE_BAD_PARAMETER_HASHTABLE";
+ break;
+
+ default:
+ return "UNKNOWN hashtable_rc_t";
+ }
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
@@ -46,7 +62,7 @@ char* hashtable_rc_code2string(hashtable_rc_t rcP)
* hash_free_int_func() is used when this hashtable is used to store int values as data (pointer = value).
*/
-void hash_free_int_func(void* memoryP){}
+void hash_free_int_func(void *memoryP) {}
//-------------------------------------------------------------------------------------------------------------------------------
/*
@@ -55,9 +71,8 @@ void hash_free_int_func(void* memoryP){}
* This is a simple/naive hash function which adds the key's ASCII char values. It will probably generate lots of collisions on large hash tables.
*/
-static hash_size_t def_hashfunc(const uint64_t keyP)
-{
- return (hash_size_t)keyP;
+static hash_size_t def_hashfunc(const uint64_t keyP) {
+ return (hash_size_t)keyP;
}
//-------------------------------------------------------------------------------------------------------------------------------
@@ -67,132 +82,147 @@ static hash_size_t def_hashfunc(const uint64_t keyP)
* The user can also specify a hash function. If the hashfunc argument is NULL, a default hash function is used.
* If an error occurred, NULL is returned. All other values in the returned hash_table_t pointer should be released with hashtable_destroy().
*/
-hash_table_t *hashtable_create(const hash_size_t sizeP, hash_size_t (*hashfuncP)(const hash_key_t ), void (*freefuncP)(void*))
-{
- hash_table_t *hashtbl = NULL;
+hash_table_t *hashtable_create(const hash_size_t sizeP, hash_size_t (*hashfuncP)(const hash_key_t ), void (*freefuncP)(void *)) {
+ hash_table_t *hashtbl = NULL;
- if(!(hashtbl=malloc(sizeof(hash_table_t)))) {
- return NULL;
- }
+ if(!(hashtbl=malloc(sizeof(hash_table_t)))) {
+ return NULL;
+ }
- if(!(hashtbl->nodes=calloc(sizeP, sizeof(hash_node_t*)))) {
- free(hashtbl);
- return NULL;
- }
+ if(!(hashtbl->nodes=calloc(sizeP, sizeof(hash_node_t *)))) {
+ free(hashtbl);
+ return NULL;
+ }
- hashtbl->size=sizeP;
+ hashtbl->size=sizeP;
- if(hashfuncP) hashtbl->hashfunc=hashfuncP;
- else hashtbl->hashfunc=def_hashfunc;
+ if(hashfuncP) hashtbl->hashfunc=hashfuncP;
+ else hashtbl->hashfunc=def_hashfunc;
- if(freefuncP) hashtbl->freefunc=freefuncP;
- else hashtbl->freefunc=free;
+ if(freefuncP) hashtbl->freefunc=freefuncP;
+ else hashtbl->freefunc=free;
- return hashtbl;
+ return hashtbl;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* Cleanup
* The hashtable_destroy() walks through the linked lists for each possible hash value, and releases the elements. It also releases the nodes array and the hash_table_t.
*/
-hashtable_rc_t hashtable_destroy(hash_table_t * hashtblP)
-{
- hash_size_t n;
- hash_node_t *node, *oldnode;
+hashtable_rc_t hashtable_destroy(hash_table_t **hashtblP) {
+ hash_size_t n;
+ hash_node_t *node, *oldnode;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
- }
+ if (*hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
- for(n=0; nsize; ++n) {
- node=hashtblP->nodes[n];
- while(node) {
- oldnode=node;
- node=node->next;
- if (oldnode->data) {
- hashtblP->freefunc(oldnode->data);
- }
- free(oldnode);
- }
- }
- free(hashtblP->nodes);
- free(hashtblP);
- hashtblP=NULL;
- return HASH_TABLE_OK;
-}
-//-------------------------------------------------------------------------------------------------------------------------------
-hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtblP, const hash_key_t keyP)
-//-------------------------------------------------------------------------------------------------------------------------------
-{
- hash_node_t *node = NULL;
- hash_size_t hash = 0;
+ for(n=0; n<(*hashtblP)->size; ++n) {
+ node=(*hashtblP)->nodes[n];
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
- }
-
- hash=hashtblP->hashfunc(keyP)%hashtblP->size;
- node=hashtblP->nodes[hash];
while(node) {
- if(node->key == keyP) {
- return HASH_TABLE_OK;
- }
+ oldnode=node;
+ node=node->next;
+
+ if (oldnode->data) {
+ (*hashtblP)->freefunc(oldnode->data);
+ }
+
+ free(oldnode);
+ }
+ }
+
+ free((*hashtblP)->nodes);
+ free((*hashtblP));
+ *hashtblP=NULL;
+ return HASH_TABLE_OK;
+}
+//-------------------------------------------------------------------------------------------------------------------------------
+hashtable_rc_t hashtable_is_key_exists (const hash_table_t *const hashtblP, const hash_key_t keyP)
+//-------------------------------------------------------------------------------------------------------------------------------
+{
+ hash_node_t *node = NULL;
+ hash_size_t hash = 0;
+
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP)%hashtblP->size;
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if(node->key == keyP) {
+ return HASH_TABLE_OK;
+ }
+
+ node=node->next;
+ }
+
+ return HASH_TABLE_KEY_NOT_EXISTS;
+}
+//-------------------------------------------------------------------------------------------------------------------------------
+hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void functP(hash_key_t keyP, void *dataP, void *parameterP), void *parameterP)
+//-------------------------------------------------------------------------------------------------------------------------------
+{
+ hash_node_t *node = NULL;
+ unsigned int i = 0;
+ unsigned int num_elements = 0;
+
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ while ((num_elements < hashtblP->num_elements) && (i < hashtblP->size)) {
+ if (hashtblP->nodes[i] != NULL) {
+ node=hashtblP->nodes[i];
+
+ while(node) {
+ num_elements += 1;
+ functP(node->key, node->data, parameterP);
node=node->next;
+ }
}
- return HASH_TABLE_KEY_NOT_EXISTS;
+
+ i += 1;
+ }
+
+ return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
-hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void functP(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP)
+hashtable_rc_t hashtable_dump_content (const hash_table_t *const hashtblP, char *const buffer_pP, int *const remaining_bytes_in_buffer_pP )
//-------------------------------------------------------------------------------------------------------------------------------
{
- hash_node_t *node = NULL;
- unsigned int i = 0;
- unsigned int num_elements = 0;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
- }
- while ((num_elements < hashtblP->num_elements) && (i < hashtblP->size)) {
- if (hashtblP->nodes[i] != NULL) {
- node=hashtblP->nodes[i];
- while(node) {
- num_elements += 1;
- functP(node->key, node->data, parameterP);
- node=node->next;
- }
- }
- i += 1;
- }
- return HASH_TABLE_OK;
-}
-//-------------------------------------------------------------------------------------------------------------------------------
-hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char * const buffer_pP, int * const remaining_bytes_in_buffer_pP )
-//-------------------------------------------------------------------------------------------------------------------------------
-{
- hash_node_t *node = NULL;
- unsigned int i = 0;
- if (hashtblP == NULL) {
+ hash_node_t *node = NULL;
+ unsigned int i = 0;
+
+ if (hashtblP == NULL) {
+ *remaining_bytes_in_buffer_pP = snprintf(
+ buffer_pP,
+ *remaining_bytes_in_buffer_pP,
+ "HASH_TABLE_BAD_PARAMETER_HASHTABLE");
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ while ((i < hashtblP->size) && (*remaining_bytes_in_buffer_pP > 0)) {
+ if (hashtblP->nodes[i] != NULL) {
+ node=hashtblP->nodes[i];
+
+ while(node) {
*remaining_bytes_in_buffer_pP = snprintf(
- buffer_pP,
- *remaining_bytes_in_buffer_pP,
- "HASH_TABLE_BAD_PARAMETER_HASHTABLE");
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ buffer_pP,
+ *remaining_bytes_in_buffer_pP,
+ "Key 0x%"PRIx64" Element %p\n",
+ node->key,
+ node->data);
+ node=node->next;
+ }
}
- while ((i < hashtblP->size) && (*remaining_bytes_in_buffer_pP > 0)) {
- if (hashtblP->nodes[i] != NULL) {
- node=hashtblP->nodes[i];
- while(node) {
- *remaining_bytes_in_buffer_pP = snprintf(
- buffer_pP,
- *remaining_bytes_in_buffer_pP,
- "Key 0x%"PRIx64" Element %p\n",
- node->key,
- node->data);
- node=node->next;
- }
- }
- i += 1;
- }
- return HASH_TABLE_OK;
+
+ i += 1;
+ }
+
+ return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
@@ -200,97 +230,110 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char
* Adding a new element
* To make sure the hash value is not bigger than size, the result of the user provided hash function is used modulo size.
*/
-hashtable_rc_t hashtable_insert(hash_table_t * const hashtblP, const hash_key_t keyP, void *dataP)
-{
- hash_node_t *node = NULL;
- hash_size_t hash = 0;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
- }
- hash=hashtblP->hashfunc(keyP)%hashtblP->size;
+hashtable_rc_t hashtable_insert(hash_table_t *const hashtblP, const hash_key_t keyP, void *dataP) {
+ hash_node_t *node = NULL;
+ hash_size_t hash = 0;
- node=hashtblP->nodes[hash];
- while(node) {
- if(node->key == keyP) {
- if (node->data) {
- hashtblP->freefunc(node->data);
- }
- node->data=dataP;
- return HASH_TABLE_INSERT_OVERWRITTEN_DATA;
- }
- node=node->next;
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP)%hashtblP->size;
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if(node->key == keyP) {
+ if (node->data) {
+ hashtblP->freefunc(node->data);
+ }
+
+ node->data=dataP;
+ return HASH_TABLE_INSERT_OVERWRITTEN_DATA;
}
- if(!(node=malloc(sizeof(hash_node_t)))) return -1;
- node->key=keyP;
- node->data=dataP;
- if (hashtblP->nodes[hash]) {
- node->next=hashtblP->nodes[hash];
- } else {
- node->next = NULL;
- }
- hashtblP->nodes[hash]=node;
- hashtblP->num_elements += 1;
- return HASH_TABLE_OK;
+
+ node=node->next;
+ }
+
+ if(!(node=malloc(sizeof(hash_node_t)))) return -1;
+
+ node->key=keyP;
+ node->data=dataP;
+
+ if (hashtblP->nodes[hash]) {
+ node->next=hashtblP->nodes[hash];
+ } else {
+ node->next = NULL;
+ }
+
+ hashtblP->nodes[hash]=node;
+ hashtblP->num_elements += 1;
+ return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* To remove an element from the hash table, we just search for it in the linked list for that hash value,
* and remove it if it is found. If it was not found, it is an error and -1 is returned.
*/
-hashtable_rc_t hashtable_remove(hash_table_t * const hashtblP, const hash_key_t keyP)
-{
- hash_node_t *node, *prevnode=NULL;
- hash_size_t hash = 0;
+hashtable_rc_t hashtable_remove(hash_table_t *const hashtblP, const hash_key_t keyP) {
+ hash_node_t *node, *prevnode=NULL;
+ hash_size_t hash = 0;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP)%hashtblP->size;
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if(node->key == keyP) {
+ if(prevnode) prevnode->next=node->next;
+ else hashtblP->nodes[hash]=node->next;
+
+ if (node->data) {
+ hashtblP->freefunc(node->data);
+ }
+
+ free(node);
+ hashtblP->num_elements -= 1;
+ return HASH_TABLE_OK;
}
- hash=hashtblP->hashfunc(keyP)%hashtblP->size;
- node=hashtblP->nodes[hash];
- while(node) {
- if(node->key == keyP) {
- if(prevnode) prevnode->next=node->next;
- else hashtblP->nodes[hash]=node->next;
- if (node->data) {
- hashtblP->freefunc(node->data);
- }
- free(node);
- hashtblP->num_elements -= 1;
- return HASH_TABLE_OK;
- }
- prevnode=node;
- node=node->next;
- }
- return HASH_TABLE_KEY_NOT_EXISTS;
+
+ prevnode=node;
+ node=node->next;
+ }
+
+ return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* Searching for an element is easy. We just search through the linked list for the corresponding hash value.
* NULL is returned if we didn't find it.
*/
-hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key_t keyP, void** dataP)
-{
- hash_node_t *node = NULL;
- hash_size_t hash = 0;
+hashtable_rc_t hashtable_get(const hash_table_t *const hashtblP, const hash_key_t keyP, void **dataP) {
+ hash_node_t *node = NULL;
+ hash_size_t hash = 0;
- if (hashtblP == NULL) {
- *dataP = NULL;
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
- }
- hash=hashtblP->hashfunc(keyP)%hashtblP->size;
-/* fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
-
- node=hashtblP->nodes[hash];
-
- while(node) {
- if(node->key == keyP) {
- *dataP = node->data;
- return HASH_TABLE_OK;
- }
- node=node->next;
- }
+ if (hashtblP == NULL) {
*dataP = NULL;
- return HASH_TABLE_KEY_NOT_EXISTS;
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP)%hashtblP->size;
+ /* fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if(node->key == keyP) {
+ *dataP = node->data;
+ return HASH_TABLE_OK;
+ }
+
+ node=node->next;
+ }
+
+ *dataP = NULL;
+ return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
@@ -304,36 +347,33 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key
* After that, we can just free the old table and copy the elements from newtbl to hashtbl.
*/
-hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t sizeP)
-{
- hash_table_t newtbl;
- hash_size_t n;
- hash_node_t *node,*next;
+hashtable_rc_t hashtable_resize(hash_table_t *const hashtblP, const hash_size_t sizeP) {
+ hash_table_t newtbl;
+ hash_size_t n;
+ hash_node_t *node,*next;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ newtbl.size = sizeP;
+ newtbl.hashfunc = hashtblP->hashfunc;
+
+ if(!(newtbl.nodes=calloc(sizeP, sizeof(hash_node_t *)))) return -1;
+
+ for(n=0; nsize; ++n) {
+ for(node=hashtblP->nodes[n]; node; node=next) {
+ next = node->next;
+ hashtable_insert(&newtbl, node->key, node->data);
+ // Lionel GAUTHIER: BAD CODE TO BE REWRITTEN
+ hashtable_remove(hashtblP, node->key);
}
+ }
- newtbl.size = sizeP;
- newtbl.hashfunc = hashtblP->hashfunc;
-
- if(!(newtbl.nodes=calloc(sizeP, sizeof(hash_node_t*)))) return -1;
-
- for(n=0; nsize; ++n) {
- for(node=hashtblP->nodes[n]; node; node=next) {
- next = node->next;
- hashtable_insert(&newtbl, node->key, node->data);
- // Lionel GAUTHIER: BAD CODE TO BE REWRITTEN
- hashtable_remove(hashtblP, node->key);
-
- }
- }
-
- free(hashtblP->nodes);
- hashtblP->size=newtbl.size;
- hashtblP->nodes=newtbl.nodes;
-
- return HASH_TABLE_OK;
+ free(hashtblP->nodes);
+ hashtblP->size=newtbl.size;
+ hashtblP->nodes=newtbl.nodes;
+ return HASH_TABLE_OK;
}
diff --git a/common/utils/hashtable/hashtable.h b/common/utils/hashtable/hashtable.h
index 62002fb60f..3f770684fa 100644
--- a/common/utils/hashtable/hashtable.h
+++ b/common/utils/hashtable/hashtable.h
@@ -2,9 +2,9 @@
* 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 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.
+ * except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
@@ -31,41 +31,41 @@ typedef uint64_t hash_key_t;
#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1)
typedef enum hashtable_return_code_e {
- HASH_TABLE_OK = 0,
- HASH_TABLE_INSERT_OVERWRITTEN_DATA = 1,
- HASH_TABLE_KEY_NOT_EXISTS = 2,
- HASH_TABLE_KEY_ALREADY_EXISTS = 3,
- HASH_TABLE_BAD_PARAMETER_HASHTABLE = 4,
- HASH_TABLE_SYSTEM_ERROR = 5,
- HASH_TABLE_CODE_MAX
+ HASH_TABLE_OK = 0,
+ HASH_TABLE_INSERT_OVERWRITTEN_DATA = 1,
+ HASH_TABLE_KEY_NOT_EXISTS = 2,
+ HASH_TABLE_KEY_ALREADY_EXISTS = 3,
+ HASH_TABLE_BAD_PARAMETER_HASHTABLE = 4,
+ HASH_TABLE_SYSTEM_ERROR = 5,
+ HASH_TABLE_CODE_MAX
} hashtable_rc_t;
typedef struct hash_node_s {
- hash_key_t key;
- void *data;
- struct hash_node_s *next;
+ hash_key_t key;
+ void *data;
+ struct hash_node_s *next;
} hash_node_t;
typedef struct hash_table_s {
- hash_size_t size;
- hash_size_t num_elements;
- struct hash_node_s **nodes;
- hash_size_t (*hashfunc)(const hash_key_t);
- void (*freefunc)(void*);
+ hash_size_t size;
+ hash_size_t num_elements;
+ struct hash_node_s **nodes;
+ hash_size_t (*hashfunc)(const hash_key_t);
+ void (*freefunc)(void *);
} hash_table_t;
-char* hashtable_rc_code2string(hashtable_rc_t rcP);
-void hash_free_int_func(void* memoryP);
-hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void*));
-hashtable_rc_t hashtable_destroy(hash_table_t * const hashtbl);
-hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtbl, const uint64_t key);
-hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t * const hashtblP, void funct(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP);
-hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char * const buffer_pP, int * const remaining_bytes_in_buffer_pP );
-hashtable_rc_t hashtable_insert (hash_table_t * const hashtbl, const hash_key_t key, void *data);
-hashtable_rc_t hashtable_remove (hash_table_t * const hashtbl, const hash_key_t key);
-hashtable_rc_t hashtable_get (const hash_table_t * const hashtbl, const hash_key_t key, void **dataP);
-hashtable_rc_t hashtable_resize (hash_table_t * const hashtbl, const hash_size_t size);
+char *hashtable_rc_code2string(hashtable_rc_t rcP);
+void hash_free_int_func(void *memoryP);
+hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void *));
+hashtable_rc_t hashtable_destroy(hash_table_t **hashtbl);
+hashtable_rc_t hashtable_is_key_exists (const hash_table_t *const hashtbl, const uint64_t key);
+hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void funct(hash_key_t keyP, void *dataP, void *parameterP), void *parameterP);
+hashtable_rc_t hashtable_dump_content (const hash_table_t *const hashtblP, char *const buffer_pP, int *const remaining_bytes_in_buffer_pP );
+hashtable_rc_t hashtable_insert (hash_table_t *const hashtbl, const hash_key_t key, void *data);
+hashtable_rc_t hashtable_remove (hash_table_t *const hashtbl, const hash_key_t key);
+hashtable_rc_t hashtable_get (const hash_table_t *const hashtbl, const hash_key_t key, void **dataP);
+hashtable_rc_t hashtable_resize (hash_table_t *const hashtbl, const hash_size_t size);
diff --git a/common/utils/hashtable/obj_hashtable.c b/common/utils/hashtable/obj_hashtable.c
index 7fb68d1681..643dcce552 100644
--- a/common/utils/hashtable/obj_hashtable.c
+++ b/common/utils/hashtable/obj_hashtable.c
@@ -2,9 +2,9 @@
* 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 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.
+ * except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
@@ -30,13 +30,12 @@
* This is a simple/naive hash function which adds the key's ASCII char values. It will probably generate lots of collisions on large hash tables.
*/
-static hash_size_t def_hashfunc(const void *keyP, int key_sizeP)
-{
- hash_size_t hash=0;
+static hash_size_t def_hashfunc(const void *keyP, int key_sizeP) {
+ hash_size_t hash=0;
- while(key_sizeP) hash^=((unsigned char*)keyP)[key_sizeP --];
+ while(key_sizeP) hash^=((unsigned char *)keyP)[key_sizeP --];
- return hash;
+ return hash;
}
//-------------------------------------------------------------------------------------------------------------------------------
@@ -46,201 +45,221 @@ static hash_size_t def_hashfunc(const void *keyP, int key_sizeP)
* The user can also specify a hash function. If the hashfunc argument is NULL, a default hash function is used.
* If an error occurred, NULL is returned. All other values in the returned obj_hash_table_t pointer should be released with hashtable_destroy().
*/
-obj_hash_table_t *obj_hashtable_create(hash_size_t sizeP, hash_size_t (*hashfuncP)(const void*, int ), void (*freekeyfuncP)(void*), void (*freedatafuncP)(void*))
-{
- obj_hash_table_t *hashtbl;
+obj_hash_table_t *obj_hashtable_create(hash_size_t sizeP, hash_size_t (*hashfuncP)(const void *, int ), void (*freekeyfuncP)(void *), void (*freedatafuncP)(void *)) {
+ obj_hash_table_t *hashtbl;
- if(!(hashtbl=malloc(sizeof(obj_hash_table_t)))) return NULL;
+ if(!(hashtbl=malloc(sizeof(obj_hash_table_t)))) return NULL;
- if(!(hashtbl->nodes=calloc(sizeP, sizeof(obj_hash_node_t*)))) {
- free(hashtbl);
- return NULL;
- }
+ if(!(hashtbl->nodes=calloc(sizeP, sizeof(obj_hash_node_t *)))) {
+ free(hashtbl);
+ return NULL;
+ }
- hashtbl->size=sizeP;
+ hashtbl->size=sizeP;
- if(hashfuncP) hashtbl->hashfunc=hashfuncP;
- else hashtbl->hashfunc=def_hashfunc;
+ if(hashfuncP) hashtbl->hashfunc=hashfuncP;
+ else hashtbl->hashfunc=def_hashfunc;
- if(freekeyfuncP) hashtbl->freekeyfunc=freekeyfuncP;
- else hashtbl->freekeyfunc=free;
+ if(freekeyfuncP) hashtbl->freekeyfunc=freekeyfuncP;
+ else hashtbl->freekeyfunc=free;
- if(freedatafuncP) hashtbl->freedatafunc=freedatafuncP;
- else hashtbl->freedatafunc=free;
+ if(freedatafuncP) hashtbl->freedatafunc=freedatafuncP;
+ else hashtbl->freedatafunc=free;
- return hashtbl;
+ return hashtbl;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* Cleanup
* The hashtable_destroy() walks through the linked lists for each possible hash value, and releases the elements. It also releases the nodes array and the obj_hash_table_t.
*/
-hashtable_rc_t obj_hashtable_destroy(obj_hash_table_t *hashtblP)
-{
- hash_size_t n;
- obj_hash_node_t *node, *oldnode;
+hashtable_rc_t obj_hashtable_destroy(obj_hash_table_t *hashtblP) {
+ hash_size_t n;
+ obj_hash_node_t *node, *oldnode;
- for(n=0; nsize; ++n) {
- node=hashtblP->nodes[n];
- while(node) {
- oldnode=node;
- node=node->next;
- hashtblP->freekeyfunc(oldnode->key);
- hashtblP->freedatafunc(oldnode->data);
- free(oldnode);
- }
+ for(n=0; nsize; ++n) {
+ node=hashtblP->nodes[n];
+
+ while(node) {
+ oldnode=node;
+ node=node->next;
+ hashtblP->freekeyfunc(oldnode->key);
+ hashtblP->freedatafunc(oldnode->data);
+ free(oldnode);
}
- free(hashtblP->nodes);
- free(hashtblP);
- return HASH_TABLE_OK;
+ }
+
+ free(hashtblP->nodes);
+ free(hashtblP);
+ return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
-hashtable_rc_t obj_hashtable_is_key_exists (obj_hash_table_t *hashtblP, void* keyP, int key_sizeP)
+hashtable_rc_t obj_hashtable_is_key_exists (obj_hash_table_t *hashtblP, void *keyP, int key_sizeP)
//-------------------------------------------------------------------------------------------------------------------------------
{
- obj_hash_node_t *node;
- hash_size_t hash;
+ obj_hash_node_t *node;
+ hash_size_t hash;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if(node->key == keyP) {
+ return HASH_TABLE_OK;
+ } else if (node->key_size == key_sizeP) {
+ if (memcmp(node->key, keyP, key_sizeP) == 0) {
+ return HASH_TABLE_OK;
+ }
}
- hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
- node=hashtblP->nodes[hash];
- while(node) {
- if(node->key == keyP) {
- return HASH_TABLE_OK;
- } else if (node->key_size == key_sizeP) {
- if (memcmp(node->key, keyP, key_sizeP) == 0) {
- return HASH_TABLE_OK;
- }
- }
- node=node->next;
- }
- return HASH_TABLE_KEY_NOT_EXISTS;
+
+ node=node->next;
+ }
+
+ return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* Adding a new element
* To make sure the hash value is not bigger than size, the result of the user provided hash function is used modulo size.
*/
-hashtable_rc_t obj_hashtable_insert(obj_hash_table_t *hashtblP, void* keyP, int key_sizeP, void *dataP)
-{
- obj_hash_node_t *node;
- hash_size_t hash;
+hashtable_rc_t obj_hashtable_insert(obj_hash_table_t *hashtblP, void *keyP, int key_sizeP, void *dataP) {
+ obj_hash_node_t *node;
+ hash_size_t hash;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if(node->key == keyP) {
+ if (node->data) {
+ hashtblP->freedatafunc(node->data);
+ }
+
+ node->data=dataP;
+ // waste of memory here (keyP is lost) we should free it now
+ return HASH_TABLE_INSERT_OVERWRITTEN_DATA;
}
- hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
- node=hashtblP->nodes[hash];
- while(node) {
- if(node->key == keyP) {
- if (node->data) {
- hashtblP->freedatafunc(node->data);
- }
- node->data=dataP;
- // waste of memory here (keyP is lost) we should free it now
- return HASH_TABLE_INSERT_OVERWRITTEN_DATA;
- }
- node=node->next;
- }
- if(!(node=malloc(sizeof(obj_hash_node_t)))) return -1;
- node->key=keyP;
- node->data=dataP;
- if (hashtblP->nodes[hash]) {
- node->next=hashtblP->nodes[hash];
- } else {
- node->next = NULL;
- }
- hashtblP->nodes[hash]=node;
- return HASH_TABLE_OK;
+
+ node=node->next;
+ }
+
+ if(!(node=malloc(sizeof(obj_hash_node_t)))) return -1;
+
+ node->key=keyP;
+ node->data=dataP;
+
+ if (hashtblP->nodes[hash]) {
+ node->next=hashtblP->nodes[hash];
+ } else {
+ node->next = NULL;
+ }
+
+ hashtblP->nodes[hash]=node;
+ return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* To remove an element from the hash table, we just search for it in the linked list for that hash value,
* and remove it if it is found. If it was not found, it is an error and -1 is returned.
*/
-hashtable_rc_t obj_hashtable_remove(obj_hash_table_t *hashtblP, const void* keyP, int key_sizeP)
-{
- obj_hash_node_t *node, *prevnode=NULL;
- hash_size_t hash;
+hashtable_rc_t obj_hashtable_remove(obj_hash_table_t *hashtblP, const void *keyP, int key_sizeP) {
+ obj_hash_node_t *node, *prevnode=NULL;
+ hash_size_t hash;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if ((node->key == keyP) || ((node->key_size == key_sizeP) && (memcmp(node->key, keyP, key_sizeP) == 0))) {
+ if(prevnode) {
+ prevnode->next=node->next;
+ } else {
+ hashtblP->nodes[hash]=node->next;
+ }
+
+ hashtblP->freekeyfunc(node->key);
+ hashtblP->freedatafunc(node->data);
+ free(node);
+ return HASH_TABLE_OK;
}
- hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
- node=hashtblP->nodes[hash];
- while(node) {
- if ((node->key == keyP) || ((node->key_size == key_sizeP) && (memcmp(node->key, keyP, key_sizeP) == 0))){
- if(prevnode) {
- prevnode->next=node->next;
- } else {
- hashtblP->nodes[hash]=node->next;
- }
- hashtblP->freekeyfunc(node->key);
- hashtblP->freedatafunc(node->data);
- free(node);
- return HASH_TABLE_OK;
- }
- prevnode=node;
- node=node->next;
- }
- return HASH_TABLE_KEY_NOT_EXISTS;
+ prevnode=node;
+ node=node->next;
+ }
+
+ return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* Searching for an element is easy. We just search through the linked list for the corresponding hash value.
* NULL is returned if we didn't find it.
*/
-hashtable_rc_t obj_hashtable_get(obj_hash_table_t *hashtblP, const void* keyP, int key_sizeP, void** dataP)
-{
- obj_hash_node_t *node;
- hash_size_t hash;
+hashtable_rc_t obj_hashtable_get(obj_hash_table_t *hashtblP, const void *keyP, int key_sizeP, void **dataP) {
+ obj_hash_node_t *node;
+ hash_size_t hash;
- if (hashtblP == NULL) {
- *dataP = NULL;
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
- }
- hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
- node=hashtblP->nodes[hash];
- while(node) {
- if(node->key == keyP) {
- *dataP = node->data;
- return HASH_TABLE_OK;
- } else if (node->key_size == key_sizeP) {
- if (memcmp(node->key, keyP, key_sizeP) == 0) {
- *dataP = node->data;
- return HASH_TABLE_OK;
- }
- }
- node=node->next;
- }
+ if (hashtblP == NULL) {
*dataP = NULL;
- return HASH_TABLE_KEY_NOT_EXISTS;
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ hash=hashtblP->hashfunc(keyP, key_sizeP)%hashtblP->size;
+ node=hashtblP->nodes[hash];
+
+ while(node) {
+ if(node->key == keyP) {
+ *dataP = node->data;
+ return HASH_TABLE_OK;
+ } else if (node->key_size == key_sizeP) {
+ if (memcmp(node->key, keyP, key_sizeP) == 0) {
+ *dataP = node->data;
+ return HASH_TABLE_OK;
+ }
+ }
+
+ node=node->next;
+ }
+
+ *dataP = NULL;
+ return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* Function to return all keys of an object hash table
*/
-hashtable_rc_t obj_hashtable_get_keys(obj_hash_table_t *hashtblP, void ** keysP, unsigned int *sizeP)
-{
- size_t n = 0;
- obj_hash_node_t *node = NULL;
- obj_hash_node_t *next = NULL;
- *sizeP = 0;
- keysP = calloc(hashtblP->num_elements, sizeof(void *));
- if (keysP) {
- for(n=0; nsize; ++n) {
- for(node=hashtblP->nodes[n]; node; node=next) {
- keysP[*sizeP++] = node->key;
- next = node->next;
- }
- }
- return HASH_TABLE_OK;
+hashtable_rc_t obj_hashtable_get_keys(obj_hash_table_t *hashtblP, void **keysP, unsigned int *sizeP) {
+ size_t n = 0;
+ obj_hash_node_t *node = NULL;
+ obj_hash_node_t *next = NULL;
+ *sizeP = 0;
+ keysP = calloc(hashtblP->num_elements, sizeof(void *));
+
+ if (keysP) {
+ for(n=0; nsize; ++n) {
+ for(node=hashtblP->nodes[n]; node; node=next) {
+ keysP[*sizeP++] = node->key;
+ next = node->next;
+ }
}
- return HASH_TABLE_SYSTEM_ERROR;
+
+ // cppcheck-suppress memleak
+ return HASH_TABLE_OK;
+ }
+
+ return HASH_TABLE_SYSTEM_ERROR;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
@@ -253,34 +272,32 @@ hashtable_rc_t obj_hashtable_get_keys(obj_hash_table_t *hashtblP, void ** keysP,
* This allows us to reuse hashtable_insert() and hashtable_remove(), when moving the elements to the new table.
* After that, we can just free the old table and copy the elements from newtbl to hashtbl.
*/
-hashtable_rc_t obj_hashtable_resize(obj_hash_table_t *hashtblP, hash_size_t sizeP)
-{
- obj_hash_table_t newtbl;
- hash_size_t n;
- obj_hash_node_t *node,*next;
+hashtable_rc_t obj_hashtable_resize(obj_hash_table_t *hashtblP, hash_size_t sizeP) {
+ obj_hash_table_t newtbl;
+ hash_size_t n;
+ obj_hash_node_t *node,*next;
- if (hashtblP == NULL) {
- return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ if (hashtblP == NULL) {
+ return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
+ }
+
+ newtbl.size = sizeP;
+ newtbl.hashfunc = hashtblP->hashfunc;
+
+ if(!(newtbl.nodes=calloc(sizeP, sizeof(obj_hash_node_t *)))) return HASH_TABLE_SYSTEM_ERROR;
+
+ for(n=0; nsize; ++n) {
+ for(node=hashtblP->nodes[n]; node; node=next) {
+ next = node->next;
+ obj_hashtable_insert(&newtbl, node->key, node->key_size, node->data);
+ obj_hashtable_remove(hashtblP, node->key, node->key_size);
}
+ }
- newtbl.size = sizeP;
- newtbl.hashfunc = hashtblP->hashfunc;
-
- if(!(newtbl.nodes=calloc(sizeP, sizeof(obj_hash_node_t*)))) return HASH_TABLE_SYSTEM_ERROR;
-
- for(n=0; nsize; ++n) {
- for(node=hashtblP->nodes[n]; node; node=next) {
- next = node->next;
- obj_hashtable_insert(&newtbl, node->key, node->key_size, node->data);
- obj_hashtable_remove(hashtblP, node->key, node->key_size);
- }
- }
-
- free(hashtblP->nodes);
- hashtblP->size=newtbl.size;
- hashtblP->nodes=newtbl.nodes;
-
- return HASH_TABLE_OK;
+ free(hashtblP->nodes);
+ hashtblP->size=newtbl.size;
+ hashtblP->nodes=newtbl.nodes;
+ return HASH_TABLE_OK;
}
diff --git a/common/utils/memory_pools.c b/common/utils/memory_pools.c
index 78b6923dc8..9f37e47080 100644
--- a/common/utils/memory_pools.c
+++ b/common/utils/memory_pools.c
@@ -23,19 +23,19 @@
#include "memory_pools.h"
#if T_TRACER
-#include
-#include "T.h"
+ #include
+ #include "T.h"
#endif
/*------------------------------------------------------------------------------*/
const static int mp_debug = 0;
# define MP_DEBUG(x, args...) do { if (mp_debug) fprintf(stdout, "[MP][D]"x, ##args); fflush (stdout); } \
- while(0)
+ while(0)
/*------------------------------------------------------------------------------*/
#ifndef CHARS_TO_UINT32
-#define CHARS_TO_UINT32(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4))
+ #define CHARS_TO_UINT32(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4))
#endif
#define MEMORY_POOL_ITEM_INFO_NUMBER 2
@@ -129,33 +129,25 @@ static const pool_start_mark_t POOL_START_MARK = CHARS_TO_UINT32 ('P'
static const pools_start_mark_t POOLS_START_MARK = CHARS_TO_UINT32 ('P', 'S', 's', 't');
/*------------------------------------------------------------------------------*/
-static inline uint32_t items_group_number_items (items_group_t *items_group)
-{
+static inline uint32_t items_group_number_items (items_group_t *items_group) {
return items_group->number_plus_one - 1;
}
-static inline uint32_t items_group_free_items (items_group_t *items_group)
-{
+static inline uint32_t items_group_free_items (items_group_t *items_group) {
items_group_positions_t positions;
uint32_t free_items;
-
positions.all = items_group->positions.all;
-
free_items = items_group->number_plus_one + positions.ind.put - positions.ind.get;
free_items %= items_group->number_plus_one;
-
return free_items;
}
-static inline items_group_index_t items_group_get_free_item (items_group_t *items_group)
-{
+static inline items_group_index_t items_group_get_free_item (items_group_t *items_group) {
items_group_position_t get_raw;
items_group_position_t put;
items_group_position_t get;
items_group_position_t free_items;
-
items_group_index_t index = ITEMS_GROUP_INDEX_INVALID;
-
/* Get current put position */
put = items_group->positions.ind.put % items_group->number_plus_one;
/* Get current get position and increase it */
@@ -193,11 +185,9 @@ static inline items_group_index_t items_group_get_free_item (items_group_t *item
return (index);
}
-static inline int items_group_put_free_item (items_group_t *items_group, items_group_index_t index)
-{
+static inline int items_group_put_free_item (items_group_t *items_group, items_group_index_t index) {
items_group_position_t put_raw;
items_group_position_t put;
-
/* Get current put position and increase it */
put_raw = __sync_fetch_and_add (&items_group->positions.ind.put, 1);
put = put_raw % items_group->number_plus_one;
@@ -209,70 +199,54 @@ static inline int items_group_put_free_item (items_group_t *items_group, items_g
AssertError (items_group->indexes[put] <= ITEMS_GROUP_INDEX_INVALID, return (EXIT_FAILURE),
"Index at current put position (%d) is not marked as free (%d)!\n", put, items_group->number_plus_one);
-
/* Save freed item index at current put position */
items_group->indexes[put] = index;
return (EXIT_SUCCESS);
}
/*------------------------------------------------------------------------------*/
-static inline memory_pools_t *memory_pools_from_handler (memory_pools_handle_t memory_pools_handle)
-{
+static inline memory_pools_t *memory_pools_from_handler (memory_pools_handle_t memory_pools_handle) {
memory_pools_t *memory_pools;
-
/* Recover memory_pools */
memory_pools = (memory_pools_t *) memory_pools_handle;
/* Sanity check on passed handle */
AssertError (memory_pools->start_mark == POOLS_START_MARK, memory_pools = NULL,
"Handle %p is not a valid memory pools handle, start mark is missing!\n", memory_pools_handle);
-
return (memory_pools);
}
-static inline memory_pool_item_t *memory_pool_item_from_handler (memory_pool_item_handle_t memory_pool_item_handle)
-{
+static inline memory_pool_item_t *memory_pool_item_from_handler (memory_pool_item_handle_t memory_pool_item_handle) {
void *address;
memory_pool_item_t *memory_pool_item;
-
/* Recover memory_pools */
address = memory_pool_item_handle - sizeof(memory_pool_item_start_t);
memory_pool_item = (memory_pool_item_t *) address;
-
/* Sanity check on passed handle */
AssertError (memory_pool_item->start.start_mark == POOL_ITEM_START_MARK, memory_pool_item = NULL,
"Handle %p is not a valid memory pool item handle, start mark is missing!\n", memory_pool_item);
-
return (memory_pool_item);
}
-static inline memory_pool_item_t *memory_pool_item_from_index (memory_pool_t *memory_pool, items_group_index_t index)
-{
+static inline memory_pool_item_t *memory_pool_item_from_index (memory_pool_t *memory_pool, items_group_index_t index) {
void *address;
-
address = (void *) memory_pool->items;
address += index * memory_pool->pool_item_size;
-
return (address);
}
/*------------------------------------------------------------------------------*/
-memory_pools_handle_t memory_pools_create (uint32_t pools_number)
-{
+memory_pools_handle_t memory_pools_create (uint32_t pools_number) {
memory_pools_t *memory_pools;
pool_id_t pool;
-
AssertFatal (pools_number <= MAX_POOLS_NUMBER, "Too many memory pools requested (%d/%d)!\n", pools_number, MAX_POOLS_NUMBER); /* Limit to a reasonable number of pools */
-
/* Allocate memory_pools */
memory_pools = malloc (sizeof(memory_pools_t));
AssertFatal (memory_pools != NULL, "Memory pools structure allocation failed!\n");
-
/* Initialize memory_pools */
{
memory_pools->start_mark = POOLS_START_MARK;
memory_pools->pools_number = pools_number;
memory_pools->pools_defined = 0;
-
/* Allocate pools */
memory_pools->pools = calloc (pools_number, sizeof(memory_pool_t));
AssertFatal (memory_pools->pools != NULL, "Memory pools allocation failed!\n");
@@ -282,12 +256,10 @@ memory_pools_handle_t memory_pools_create (uint32_t pools_number)
memory_pools->pools[pool].start_mark = POOL_START_MARK;
}
}
-
return ((memory_pools_handle_t) memory_pools);
}
-char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle)
-{
+char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle) {
memory_pools_t *memory_pools;
pool_id_t pool;
char *statistics;
@@ -296,13 +268,10 @@ char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle)
uint32_t allocated_pools_memory = 0;
items_group_t *items_group;
uint32_t pool_items_size;
-
/* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
-
statistics = malloc(memory_pools->pools_defined * 200);
-
printed_chars = sprintf (&statistics[0], "Pool: size, number, minimum, free, address space and memory used in Kbytes\n");
for (pool = 0; pool < memory_pools->pools_defined; pool++) {
@@ -321,32 +290,25 @@ char *memory_pools_statistics(memory_pools_handle_t memory_pools_handle)
}
printed_chars = sprintf (&statistics[printed_chars], "Pools memory %u Kbytes\n", allocated_pools_memory / (1024));
-
return (statistics);
}
-int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t pool_items_number, uint32_t pool_item_size)
-{
+int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t pool_items_number, uint32_t pool_item_size) {
memory_pools_t *memory_pools;
memory_pool_t *memory_pool;
pool_id_t pool;
items_group_index_t item_index;
memory_pool_item_t *memory_pool_item;
-
AssertFatal (pool_items_number <= MAX_POOL_ITEMS_NUMBER, "Too many items for a memory pool (%u/%d)!\n", pool_items_number, MAX_POOL_ITEMS_NUMBER); /* Limit to a reasonable number of items */
AssertFatal (pool_item_size <= MAX_POOL_ITEM_SIZE, "Item size is too big for memory pool items (%u/%d)!\n", pool_item_size, MAX_POOL_ITEM_SIZE); /* Limit to a reasonable item size */
-
/* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
-
/* Check number of already created pools */
AssertFatal (memory_pools->pools_defined < memory_pools->pools_number, "Can not allocate more memory pool (%d)!\n", memory_pools->pools_number);
-
/* Select pool */
pool = memory_pools->pools_defined;
memory_pool = &memory_pools->pools[pool];
-
/* Initialize pool */
{
memory_pool->pool_id = pool;
@@ -357,7 +319,6 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p
memory_pool->items_group_free.minimum = pool_items_number;
memory_pool->items_group_free.positions.ind.put = pool_items_number;
memory_pool->items_group_free.positions.ind.get = 0;
-
/* Allocate free indexes */
memory_pool->items_group_free.indexes = malloc(memory_pool->items_group_free.number_plus_one * sizeof(items_group_index_t));
AssertFatal (memory_pool->items_group_free.indexes != NULL, "Memory pool indexes allocation failed!\n");
@@ -369,7 +330,6 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p
/* Last index is not allocated */
memory_pool->items_group_free.indexes[item_index] = ITEMS_GROUP_INDEX_INVALID;
-
/* Allocate items */
memory_pool->items = calloc (pool_items_number, memory_pool->pool_item_size);
AssertFatal (memory_pool->items != NULL, "Memory pool items allocation failed!\n");
@@ -383,20 +343,16 @@ int memory_pools_add_pool (memory_pools_handle_t memory_pools_handle, uint32_t p
memory_pool_item->data[memory_pool->item_data_number] = POOL_ITEM_END_MARK;
}
}
-
memory_pools->pools_defined ++;
-
return (0);
}
-memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_pools_handle, uint32_t item_size, uint16_t info_0, uint16_t info_1)
-{
+memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_pools_handle, uint32_t item_size, uint16_t info_0, uint16_t info_1) {
memory_pools_t *memory_pools;
memory_pool_item_t *memory_pool_item;
memory_pool_item_handle_t memory_pool_item_handle = NULL;
pool_id_t pool;
items_group_index_t item_index = ITEMS_GROUP_INDEX_INVALID;
-
/* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertError (memory_pools != NULL, {}, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
@@ -424,12 +380,10 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po
/* Sanity check on item status, must be free */
AssertFatal (memory_pool_item->start.item_status == ITEM_STATUS_FREE, "Item status is not set to free (%d) in pool %u, item %d!\n",
memory_pool_item->start.item_status, pool, item_index);
-
memory_pool_item->start.item_status = ITEM_STATUS_ALLOCATED;
memory_pool_item->start.info[0] = info_0;
memory_pool_item->start.info[1] = info_1;
memory_pool_item_handle = memory_pool_item->data;
-
MP_DEBUG(" Alloc [%2u][%6d]{%6d}, %3u %3u, %6u, %p, %p, %p\n",
pool, item_index,
items_group_free_items (&memory_pools->pools[pool].items_group_free),
@@ -445,8 +399,7 @@ memory_pool_item_handle_t memory_pools_allocate (memory_pools_handle_t memory_po
return memory_pool_item_handle;
}
-int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, uint16_t info_0)
-{
+int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, uint16_t info_0) {
memory_pools_t *memory_pools;
memory_pool_item_t *memory_pool_item;
pool_id_t pool;
@@ -455,36 +408,29 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it
uint32_t pool_item_size;
uint16_t info_1;
int result;
-
/* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertError (memory_pools != NULL, return (EXIT_FAILURE), "Failed to retrieve memory pools for handle %p!\n", memory_pools_handle);
-
/* Recover memory pool item */
memory_pool_item = memory_pool_item_from_handler (memory_pool_item_handle);
AssertError (memory_pool_item != NULL, return (EXIT_FAILURE), "Failed to retrieve memory pool item for handle %p!\n", memory_pool_item_handle);
-
info_1 = memory_pool_item->start.info[1];
-
/* Recover pool index */
pool = memory_pool_item->start.pool_id;
AssertFatal (pool < memory_pools->pools_defined, "Pool index is invalid (%u/%u)!\n", pool, memory_pools->pools_defined);
-
item_size = memory_pools->pools[pool].item_data_number;
pool_item_size = memory_pools->pools[pool].pool_item_size;
item_index = (((void *) memory_pool_item) - ((void *) memory_pools->pools[pool].items)) / pool_item_size;
-
MP_DEBUG(" Free [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n",
pool, item_index,
items_group_free_items (&memory_pools->pools[pool].items_group_free),
memory_pool_item->start.info[0], info_1,
memory_pool_item_handle, memory_pool_item,
memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t))));
-
/* Sanity check on calculated item index */
AssertFatal (memory_pool_item == memory_pool_item_from_index(&memory_pools->pools[pool], item_index),
"Incorrect memory pool item address (%p, %p) for pool %u, item %d!\n",
- memory_pool_item, memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index);
+ memory_pool_item,(void *)memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index);
/* Sanity check on end marker, must still be present (no write overflow) */
AssertFatal (memory_pool_item->data[item_size] == POOL_ITEM_END_MARK,
"Memory pool item is corrupted, end mark is not present for pool %u, item %d!\n", pool, item_index);
@@ -492,31 +438,23 @@ int memory_pools_free (memory_pools_handle_t memory_pools_handle, memory_pool_it
AssertFatal (memory_pool_item->start.item_status == ITEM_STATUS_ALLOCATED,
"Trying to free a non allocated (%x) memory pool item (pool %u, item %d)!\n",
memory_pool_item->start.item_status, pool, item_index);
-
memory_pool_item->start.item_status = ITEM_STATUS_FREE;
-
result = items_group_put_free_item(&memory_pools->pools[pool].items_group_free, item_index);
-
AssertError (result == EXIT_SUCCESS, {}, "Failed to free memory pool item (pool %u, item %d)!\n", pool, item_index);
-
return (result);
}
-void memory_pools_set_info (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, int index, uint16_t info)
-{
+void memory_pools_set_info (memory_pools_handle_t memory_pools_handle, memory_pool_item_handle_t memory_pool_item_handle, int index, uint16_t info) {
memory_pools_t *memory_pools;
memory_pool_item_t *memory_pool_item;
pool_id_t pool;
items_group_index_t item_index;
uint32_t item_size;
uint32_t pool_item_size;
-
AssertFatal (index < MEMORY_POOL_ITEM_INFO_NUMBER, "Incorrect info index (%d/%d)!\n", index, MEMORY_POOL_ITEM_INFO_NUMBER);
-
/* Recover memory pool item */
memory_pool_item = memory_pool_item_from_handler (memory_pool_item_handle);
AssertFatal (memory_pool_item != NULL, "Failed to retrieve memory pool item for handle %p!\n", memory_pool_item_handle);
-
/* Set info[1] */
memory_pool_item->start.info[index] = info;
@@ -525,26 +463,22 @@ void memory_pools_set_info (memory_pools_handle_t memory_pools_handle, memory_po
/* Recover memory_pools */
memory_pools = memory_pools_from_handler (memory_pools_handle);
AssertFatal (memory_pools != NULL, "Failed to retrieve memory pool for handle %p!\n", memory_pools_handle);
-
/* Recover pool index */
pool = memory_pool_item->start.pool_id;
AssertFatal (pool < memory_pools->pools_defined, "Pool index is invalid (%u/%u)!\n", pool, memory_pools->pools_defined);
-
item_size = memory_pools->pools[pool].item_data_number;
pool_item_size = memory_pools->pools[pool].pool_item_size;
item_index = (((void *) memory_pool_item) - ((void *) memory_pools->pools[pool].items)) / pool_item_size;
-
MP_DEBUG(" Info [%2u][%6d]{%6d}, %3u %3u, %p, %p, %p, %u\n",
pool, item_index,
items_group_free_items (&memory_pools->pools[pool].items_group_free),
memory_pool_item->start.info[0], memory_pool_item->start.info[1],
memory_pool_item_handle, memory_pool_item,
memory_pools->pools[pool].items, ((uint32_t) (item_size * sizeof(memory_pool_data_t))));
-
/* Sanity check on calculated item index */
AssertFatal (memory_pool_item == memory_pool_item_from_index(&memory_pools->pools[pool], item_index),
"Incorrect memory pool item address (%p, %p) for pool %u, item %d!\n",
- memory_pool_item, memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index);
+ memory_pool_item, (void *)memory_pool_item_from_index(&memory_pools->pools[pool], item_index), pool, item_index);
/* Sanity check on end marker, must still be present (no write overflow) */
AssertFatal (memory_pool_item->data[item_size] == POOL_ITEM_END_MARK,
"Memory pool item is corrupted, end mark is not present for pool %u, item %d!\n", pool, item_index);
diff --git a/common/utils/msc/msc.h b/common/utils/msc/msc.h
index 4a71d52ffa..60c483a168 100644
--- a/common/utils/msc/msc.h
+++ b/common/utils/msc/msc.h
@@ -62,9 +62,9 @@ typedef enum {
MSC_S11_MME,
MSC_S6A_MME,
MSC_HSS,
- MAX_MSC_PROTOS,
MSC_X2AP_SRC_ENB,
MSC_X2AP_TARGET_ENB,
+ MAX_MSC_PROTOS,
} msc_proto_t;
diff --git a/common/utils/telnetsrv/telnetsrv.c b/common/utils/telnetsrv/telnetsrv.c
index 4e8e2c7c7f..b6803ead6b 100644
--- a/common/utils/telnetsrv/telnetsrv.c
+++ b/common/utils/telnetsrv/telnetsrv.c
@@ -58,7 +58,7 @@
#include "telnetsrv_phycmd.h"
#include "telnetsrv_proccmd.h"
-static char *telnet_defstatmod[] = {"softmodem","phy","loader"};
+static char *telnet_defstatmod[] = {"softmodem","phy","loader","measur"};
static telnetsrv_params_t telnetparams;
#define TELNETSRV_LISTENADDR 0
#define TELNETSRV_LISTENPORT 1
@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = {
/* configuration parameters for telnet utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- {"listenaddr", "\n", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
- {"listenport", "\n", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
- {"priority", "\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
- {"loopcount", "\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
- {"loopdelay", "\n", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
- {"histfile", "\n", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
- {"histsize", "\n", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
- {"phypbsize", "\n",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
- {"staticmod", "\n", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
- {"shrmod", "\n", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 }
+ {"listenaddr", "", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
+ {"listenport", "", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
+ {"priority", "", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
+ {"loopcount", "", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
+ {"loopdelay", "", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
+ {"histfile", "", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
+ {"histsize", "", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
+ {"phypbsize", "",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
+ {"staticmod", "", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
+ {"shrmod", "", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 }
};
int get_phybsize(void) {
@@ -355,7 +355,7 @@ int setgetvar(int moduleindex,char getorset,char *params) {
char varname[TELNET_CMD_MAXSIZE];
char *varval=NULL;
memset(varname,0,sizeof(varname));
- n = sscanf(params,"%s %ms",varname,&varval);
+ n = sscanf(params,"%19s %ms",varname,&varval);
for ( i=0 ; telnetparams.CmdParsers[moduleindex].var[i].varvalptr != NULL ; i++) {
if ( strncasecmp(telnetparams.CmdParsers[moduleindex].var[i].varname,varname,strlen(telnetparams.CmdParsers[moduleindex].var[i].varname)) == 0) {
@@ -475,7 +475,7 @@ int process_command(char *buf) {
memset(cmdb,0,sizeof(cmdb));
bufbck=strdup(buf);
rt=CMDSTATUS_NOTFOUND;
- j = sscanf(buf,"%9s %9s %[^\t\n]",modulename,cmd,cmdb);
+ j = sscanf(buf,"%9s %9s %2000[^\t\n]",modulename,cmd,cmdb);
if (telnetparams.telnetdbg > 0)
printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb);
@@ -500,23 +500,32 @@ int process_command(char *buf) {
}/* else */
}/* strncmp: module name test */
else if (strncasecmp(modulename,"loop",4) == 0 ) {
- int lc;
int f = fcntl(telnetparams.new_socket,F_GETFL);
- fcntl (telnetparams.new_socket, F_SETFL, O_NONBLOCK | f);
+ int f1=fcntl (telnetparams.new_socket, F_SETFL, O_NONBLOCK | f);
- for(lc=0; lc 0 ) {
+ if (telnetparams.telnetdbg > 0)
+ client_printf("Received \"%s\" status %d, errno %s while running loop\n",dummybuff,rs,strerror(errno));
+
+ if ( errno != EAGAIN && errno != EWOULDBLOCK) {
+ client_printf( STDFMT " Loop canceled, iteration %i/%i\n",lc,telnetparams.loopcount );
+ lc=telnetparams.loopcount;
break;
}
+
+ usleep(telnetparams.loopdelay * 1000);
}
fcntl (telnetparams.new_socket, F_SETFL, f);
diff --git a/common/utils/telnetsrv/telnetsrv.h b/common/utils/telnetsrv/telnetsrv.h
index 2d3ef531ae..89f6a8dda1 100644
--- a/common/utils/telnetsrv/telnetsrv.h
+++ b/common/utils/telnetsrv/telnetsrv.h
@@ -69,7 +69,8 @@ typedef struct cmddef {
#define TELNET_VARTYPE_INT64 3
#define TELNET_VARTYPE_STRING 4
#define TELNET_VARTYPE_DOUBLE 5
-//#define TELNET_VARTYPE_PTR 6
+#define TELNET_VARTYPE_INT8 6
+#define TELNET_VARTYPE_UINT 7
typedef struct variabledef {
char varname[TELNET_CMD_MAXSIZE];
char vartype;
diff --git a/common/utils/telnetsrv/telnetsrv_CMakeLists.txt b/common/utils/telnetsrv/telnetsrv_CMakeLists.txt
index 5dee7db4c4..3a07632bfe 100644
--- a/common/utils/telnetsrv/telnetsrv_CMakeLists.txt
+++ b/common/utils/telnetsrv/telnetsrv_CMakeLists.txt
@@ -9,6 +9,7 @@ set(TELNETSRV_SOURCE
${TELNETROOT}/telnetsrv_phycmd.c
${TELNETROOT}/telnetsrv_proccmd.c
${TELNETROOT}/telnetsrv_loader.c
+ ${TELNETROOT}/telnetsrv_measurements.c
)
#set(TELNETSRV_ETHDEVCMD_SOURCE
diff --git a/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h
new file mode 100644
index 0000000000..0b91ef1d4f
--- /dev/null
+++ b/common/utils/telnetsrv/telnetsrv_cpumeasur_def.h
@@ -0,0 +1,99 @@
+/*
+ * 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 common/utils/telnetsrv/telnetsrv_cpumeasur_def.h
+ * \brief: definitions of macro used to initialize the telnet_ltemeasurdef_t
+ * \ strucures arrays which are then used by the display functions
+ * \ in telnetsrv_measurements.c.
+ * \author Francois TABURET
+ * \date 2019
+ * \version 0.1
+ * \company NOKIA BellLabs France
+ * \email: francois.taburet@nokia-bell-labs.com
+ * \note
+ * \warning
+ */
+
+
+#define CPU_PHYENB_MEASURE \
+{ \
+ {"phy_proc_tx", &(phyvars->phy_proc_tx),0},\
+ {"phy_proc_rx", &(phyvars->phy_proc_rx),0},\
+ {"rx_prach", &(phyvars->rx_prach),0},\
+ {"ofdm_mod", &(phyvars->ofdm_mod_stats),0},\
+ {"dlsch_common_and_dci", &(phyvars->dlsch_common_and_dci),0},\
+ {"dlsch_ue_specific", &(phyvars->dlsch_ue_specific),0},\
+ {"dlsch_encoding", &(phyvars->dlsch_encoding_stats),0},\
+ {"dlsch_modulation", &(phyvars->dlsch_modulation_stats),0},\
+ {"dlsch_scrambling", &(phyvars->dlsch_scrambling_stats),0},\
+ {"dlsch_rate_matching", &(phyvars->dlsch_rate_matching_stats),0},\
+ {"dlsch_turbo_encod_prep", &(phyvars->dlsch_turbo_encoding_preperation_stats),0},\
+ {"dlsch_turbo_encod_segm", &(phyvars->dlsch_turbo_encoding_segmentation_stats),0},\
+ {"dlsch_turbo_encod", &(phyvars->dlsch_turbo_encoding_stats),0},\
+ {"dlsch_turbo_encod_waiting", &(phyvars->dlsch_turbo_encoding_waiting_stats),0},\
+ {"dlsch_turbo_encod_signal", &(phyvars->dlsch_turbo_encoding_signal_stats),0},\
+ {"dlsch_turbo_encod_main", &(phyvars->dlsch_turbo_encoding_main_stats),0},\
+ {"dlsch_turbo_encod_wakeup0", &(phyvars->dlsch_turbo_encoding_wakeup_stats0),0},\
+ {"dlsch_turbo_encod_wakeup1", &(phyvars->dlsch_turbo_encoding_wakeup_stats1),0},\
+ {"dlsch_interleaving", &(phyvars->dlsch_interleaving_stats),0},\
+ {"rx_dft", &(phyvars->rx_dft_stats),0},\
+ {"ulsch_channel_estimation", &(phyvars->ulsch_channel_estimation_stats),0},\
+ {"ulsch_freq_offset_estimation", &(phyvars->ulsch_freq_offset_estimation_stats),0},\
+ {"ulsch_decoding", &(phyvars->ulsch_decoding_stats),0},\
+ {"ulsch_demodulation", &(phyvars->ulsch_demodulation_stats),0},\
+ {"ulsch_rate_unmatching", &(phyvars->ulsch_rate_unmatching_stats),0},\
+ {"ulsch_turbo_decoding", &(phyvars->ulsch_turbo_decoding_stats),0},\
+ {"ulsch_deinterleaving", &(phyvars->ulsch_deinterleaving_stats),0},\
+ {"ulsch_demultiplexing", &(phyvars->ulsch_demultiplexing_stats),0},\
+ {"ulsch_llr", &(phyvars->ulsch_llr_stats),0},\
+ {"ulsch_tc_init", &(phyvars->ulsch_tc_init_stats),0},\
+ {"ulsch_tc_alpha", &(phyvars->ulsch_tc_alpha_stats),0},\
+ {"ulsch_tc_beta", &(phyvars->ulsch_tc_beta_stats),0},\
+ {"ulsch_tc_gamma", &(phyvars->ulsch_tc_gamma_stats),0},\
+ {"ulsch_tc_ext", &(phyvars->ulsch_tc_ext_stats),0},\
+ {"ulsch_tc_intl1", &(phyvars->ulsch_tc_intl1_stats),0},\
+ {"ulsch_tc_intl2", &(phyvars->ulsch_tc_intl2_stats),0},\
+}
+
+#define CPU_MACENB_MEASURE \
+{ \
+ {"eNB_scheduler", &(macvars->eNB_scheduler),0},\
+ {"schedule_si", &(macvars->schedule_si),0},\
+ {"schedule_ra", &(macvars->schedule_ra),0},\
+ {"schedule_ulsch", &(macvars->schedule_ulsch),0},\
+ {"fill_DLSCH_dci", &(macvars->fill_DLSCH_dci),0},\
+ {"schedule_dlsch_pre", &(macvars->schedule_dlsch_preprocessor),0},\
+ {"schedule_dlsch", &(macvars->schedule_dlsch),0},\
+ {"schedule_mch", &(macvars->schedule_mch),0},\
+ {"rx_ulsch_sdu", &(macvars->rx_ulsch_sdu),0},\
+ {"schedule_pch", &(macvars->schedule_pch),0},\
+}
+
+#define CPU_PDCPENB_MEASURE \
+{ \
+ {"pdcp_run", &(pdcpvars->pdcp_run),0},\
+ {"data_req", &(pdcpvars->data_req),0},\
+ {"data_ind", &(pdcpvars->data_ind),0},\
+ {"apply_security", &(pdcpvars->apply_security),0},\
+ {"validate_security", &(pdcpvars->validate_security),0},\
+ {"pdcp_ip", &(pdcpvars->pdcp_ip),0},\
+ {"ip_pdcp", &(pdcpvars->ip_pdcp),0},\
+}
diff --git a/common/utils/telnetsrv/telnetsrv_measurements.c b/common/utils/telnetsrv/telnetsrv_measurements.c
new file mode 100644
index 0000000000..7cfc656225
--- /dev/null
+++ b/common/utils/telnetsrv/telnetsrv_measurements.c
@@ -0,0 +1,316 @@
+/*
+ * 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 common/utils/telnetsrv/telnetsrv_measurements.c
+ * \brief: implementation of telnet commands related to measurments
+ * \author Francois TABURET
+ * \date 2019
+ * \version 0.1
+ * \company NOKIA BellLabs France
+ * \email: francois.taburet@nokia-bell-labs.com
+ * \note
+ * \warning
+ */
+#define _GNU_SOURCE
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+
+
+#define TELNETSERVERCODE
+#include "telnetsrv.h"
+#define TELNETSRV_MEASURMENTS_MAIN
+#include "common/utils/LOG/log.h"
+#include "common/config/config_userapi.h"
+#include "telnetsrv_measurements.h"
+#include "telnetsrv_ltemeasur_def.h"
+#include "telnetsrv_cpumeasur_def.h"
+#include "openair2/LAYER2/MAC/mac.h"
+#include "openair1/PHY/phy_extern.h"
+
+void measurcmd_display_macstats(telnet_printfunc_t prnt);
+void measurcmd_display_macstats_ue(telnet_printfunc_t prnt);
+void measurcmd_display_rlcstats(telnet_printfunc_t prnt);
+void measurcmd_display_phycpu(telnet_printfunc_t prnt);
+void measurcmd_display_maccpu(telnet_printfunc_t prnt);
+void measurcmd_display_pdcpcpu(telnet_printfunc_t prnt);
+
+
+static telnet_measurgroupdef_t measurgroups[] = {
+ {"enb", GROUP_LTESTATS,0, measurcmd_display_macstats, {NULL}},
+ {"enbues",GROUP_LTESTATS,0, measurcmd_display_macstats_ue,{NULL}},
+ {"rlc", GROUP_LTESTATS,0, measurcmd_display_rlcstats, {NULL}},
+ {"phycpu",GROUP_CPUSTATS,0, measurcmd_display_phycpu, {NULL}},
+ {"maccpu",GROUP_CPUSTATS,0, measurcmd_display_maccpu, {NULL}},
+ {"pdcpcpu",GROUP_CPUSTATS,0, measurcmd_display_pdcpcpu, {NULL}},
+};
+#define TELNET_NUM_MEASURGROUPS (sizeof(measurgroups)/sizeof(telnet_measurgroupdef_t))
+
+static int eNB_id =0;
+static char *grouptypes[] = {"ltestats","cpustats"};
+static double cpufreq;
+#define TELNET_NUM_MEASURTYPES (sizeof(grouptypes)/sizeof(char *))
+
+#define HDR "---------------------------------"
+
+void measurcmd_display_groups(telnet_printfunc_t prnt) {
+ prnt(" %*s %10s %s\n",TELNET_MAXMEASURNAME_LEN-1,"name","type","nombre de mesures");
+
+ for(int i=0; istatname,
+ ((cpumeasure+i)->astatptr->trials!=0)?(((cpumeasure+i)->astatptr->diff)/((cpumeasure+i)->astatptr->trials))/cpufreq/1000:0,
+ (cpumeasure+i)->astatptr->trials, ((i%2)==1)?"|\n":" | " );
+ }
+
+ prnt("\n\n");
+} /* measurcmd_display_measures */
+
+#define PRINT_CPUMEAS_STATE ((cpumeas(CPUMEAS_GETSTATE))?"enabled":"disabled")
+void measurcmd_display_phycpu(telnet_printfunc_t prnt) {
+ PHY_VARS_eNB *phyvars = RC.eNB[eNB_id][0];
+ telnet_cpumeasurdef_t cpumeasur[]=CPU_PHYENB_MEASURE;
+ prnt("%s cpu (%1.1g GHz) measurements: PHY (cpustats %s) %s\n",HDR,cpufreq,
+ PRINT_CPUMEAS_STATE,HDR);
+ measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t));
+}
+
+void measurcmd_display_maccpu(telnet_printfunc_t prnt) {
+ eNB_MAC_INST *macvars = RC.mac[eNB_id];
+ telnet_cpumeasurdef_t cpumeasur[]=CPU_MACENB_MEASURE;
+ prnt("%s cpu (%1.1g GHz) measurements: MAC (cpustats %s) %s\n",HDR,cpufreq,
+ PRINT_CPUMEAS_STATE,HDR);
+ measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t));
+}
+
+void measurcmd_display_pdcpcpu(telnet_printfunc_t prnt) {
+ pdcp_stats_t *pdcpvars = &(eNB_pdcp_stats[eNB_id]);
+ telnet_cpumeasurdef_t cpumeasur[]=CPU_PDCPENB_MEASURE;
+ prnt("%s cpu (%1.1g GHz) measurements: PDCP (cpustats %s) %s \n",HDR,cpufreq,
+ PRINT_CPUMEAS_STATE,HDR);
+ measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t));
+}
+/*----------------------------------------------------------------------------------------------------*/
+/* lte measurements functions */
+uint64_t measurcmd_getstatvalue(telnet_ltemeasurdef_t *measur,telnet_printfunc_t prnt) {
+ uint64_t val;
+
+ switch(measur->vtyp) {
+ case TELNET_VARTYPE_INT64:
+ val = (uint64_t)(*((uint64_t *)(measur->vptr)));
+ break;
+
+ case TELNET_VARTYPE_INT32:
+ val = (uint64_t)(*((uint32_t *)(measur->vptr)));
+ break;
+
+ case TELNET_VARTYPE_INT16:
+ val = (uint64_t)(*((uint16_t *)(measur->vptr)));
+ break;
+
+ case TELNET_VARTYPE_INT8:
+ val = (uint64_t)(*((uint8_t *)(measur->vptr)));
+ break;
+
+ case TELNET_VARTYPE_UINT:
+ val = (uint64_t)(*((unsigned int *)(measur->vptr)));
+ break;
+
+ default:
+ prnt("%s %i: unknown type \n",measur->statname,measur->vtyp);
+ val = (uint64_t)(*((uint64_t *)(measur->vptr)));
+ break;
+ }
+
+ return val;
+} /* measurcmd_getstatvalue */
+
+void measurcmd_display_measures(telnet_printfunc_t prnt, telnet_ltemeasurdef_t *statsptr, int stats_size) {
+ for (int i=0; iUE_list);
+
+ for (int UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
+ for (int i=0; inumactiveCCs[UE_id]; i++) {
+ int CC_id = UE_list->ordered_CCids[i][UE_id];
+ prnt("%s UE %i Id %i CCid %i %s\n",HDR,i,UE_id,CC_id,HDR);
+ eNB_UE_STATS *macuestatptr = &(UE_list->eNB_UE_stats[CC_id][UE_id]);
+ telnet_ltemeasurdef_t statsptr[]=LTEMAC_UEMEASURE;
+ measurcmd_display_measures(prnt, statsptr, sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t));
+ }
+ }
+} /* measurcmd_display_macstats_ue */
+
+void measurcmd_display_macstats(telnet_printfunc_t prnt) {
+ for (int CC_id=0 ; CC_id < MAX_NUM_CCs; CC_id++) {
+ eNB_STATS *macstatptr=&(RC.mac[eNB_id]->eNB_stats[CC_id]);
+ telnet_ltemeasurdef_t statsptr[]=LTEMAC_MEASURE;
+ prnt("%s eNB %i mac stats CC %i frame %u %s\n",
+ HDR, eNB_id, CC_id, RC.mac[eNB_id]->frame,HDR);
+ measurcmd_display_measures(prnt,statsptr,sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t));
+ }
+} /* measurcmd_display_macstats */
+
+
+void measurcmd_display_one_rlcstat(telnet_printfunc_t prnt, int UE_id, telnet_ltemeasurdef_t *statsptr, int num_rlcmeasure, unsigned int *rlcstats,
+ char *rbid_str, protocol_ctxt_t *ctxt, const srb_flag_t srb_flagP, const rb_id_t rb_idP)
+
+{
+ int rlc_status = rlc_stat_req(ctxt,srb_flagP,rb_idP,
+ rlcstats, rlcstats+1, rlcstats+2, rlcstats+3, rlcstats+4, rlcstats+5,
+ rlcstats+6, rlcstats+7, rlcstats+8, rlcstats+9, rlcstats+10, rlcstats+11,
+ rlcstats+12, rlcstats+13, rlcstats+14, rlcstats+15, rlcstats+16, rlcstats+17,
+ rlcstats+18, rlcstats+19, rlcstats+20, rlcstats+21, rlcstats+22, rlcstats+23,
+ rlcstats+24, rlcstats+25, rlcstats+26, rlcstats+27);
+
+ if (rlc_status == RLC_OP_STATUS_OK) {
+ prnt("%s UE %i RLC %s mode %s %s\n",HDR,UE_id, rbid_str,
+ (rlcstats[0]==RLC_MODE_AM)? "AM": (rlcstats[0]==RLC_MODE_UM)?"UM":"NONE",HDR);
+ measurcmd_display_measures(prnt, statsptr, num_rlcmeasure);
+ }
+} /* status measurcmd_rlc_stat_req */
+
+
+void measurcmd_display_rlcstats(telnet_printfunc_t prnt) {
+ protocol_ctxt_t ctxt;
+ UE_list_t *UE_list = &(RC.mac[eNB_id]->UE_list);
+ telnet_ltemeasurdef_t statsptr[]=LTE_RLCMEASURE;
+ int num_rlcmeasure = sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t );
+ unsigned int *rlcstats = malloc(num_rlcmeasure*sizeof(unsigned int));
+ eNB_MAC_INST *eNB = RC.mac[eNB_id];
+
+ for(int i=0; i head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
+#define NB_eNB_INST 1
+ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,eNB_id, ENB_FLAG_YES,UE_list->eNB_UE_stats[0][UE_id].crnti,
+ eNB->frame,eNB->subframe,eNB_id);
+ measurcmd_display_one_rlcstat(prnt, UE_id, statsptr, num_rlcmeasure, rlcstats, "DCCH", &ctxt, SRB_FLAG_YES, DCCH);
+ measurcmd_display_one_rlcstat(prnt, UE_id, statsptr, num_rlcmeasure, rlcstats, "DTCH", &ctxt, SRB_FLAG_NO, DTCH-2);
+ }
+} /* measurcmd_display_macstats_ue */
+
+/*------------------------------------------------------------------------------------------------------------------------*/
+/* function called by the telnet server when measur command is entered */
+int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt) {
+ char *subcmd=NULL;
+ int idx1, idx2;
+ int badcmd=1;
+
+ if (debug > 0)
+ prnt(" measurcmd_show received %s\n",buf);
+
+ // char tmp[20480];
+ // dump_eNB_l2_stats(tmp, 0);
+ // prnt("%s\n",tmp);
+ int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2);
+
+ if (s>0) {
+ if ( strcmp(subcmd,"groups") == 0) {
+ measurcmd_display_groups(prnt);
+ badcmd=0;
+ } else {
+ for (int i=0; i0 */
+
+ if (badcmd) {
+ prnt("%s: unknown measur command\n",buf);
+ }
+
+ return CMDSTATUS_FOUND;
+}
+
+
+int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt) {
+ char *subcmd=NULL;
+ int idx1, idx2;
+ int badcmd=1;
+
+ if (debug > 0)
+ prnt(" measurcmd_show received %s\n",buf);
+
+ int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2);
+
+ if (s>0) {
+ if ( strcmp(subcmd,"enable") == 0) {
+ cpumeas(CPUMEAS_ENABLE);
+ badcmd=0;
+ } else if ( strcmp(subcmd,"disable") == 0) {
+ cpumeas(CPUMEAS_DISABLE);
+ badcmd=0;
+ }
+ }
+
+ if (badcmd) {
+ prnt("Cpu measurments state: %s\n",PRINT_CPUMEAS_STATE);
+ }
+
+ free(subcmd);
+ return CMDSTATUS_FOUND;
+}
+/*-------------------------------------------------------------------------------------*/
+
+/* function called at telnet server init to add the measur command */
+void add_measur_cmds(void) {
+ add_telnetcmd("measur",measur_vardef,measur_cmdarray);
+ cpufreq = get_cpu_freq_GHz();
+}
diff --git a/common/utils/telnetsrv/telnetsrv_measurements.h b/common/utils/telnetsrv/telnetsrv_measurements.h
new file mode 100644
index 0000000000..46f25da4c5
--- /dev/null
+++ b/common/utils/telnetsrv/telnetsrv_measurements.h
@@ -0,0 +1,88 @@
+/*
+ * 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 common/utils/telnetsrv/telnetsrv_measurements.h
+ * \brief: Include file defining constants, structures and function prototypes
+ * \ used to implement the measurements functionality of the telnet server
+ * \author Francois TABURET
+ * \date 2019
+ * \version 0.1
+ * \company NOKIA BellLabs France
+ * \email: francois.taburet@nokia-bell-labs.com
+ * \note
+ * \warning
+ */
+#include
+#include "telnetsrv.h"
+#include "openair1/PHY/defs_eNB.h"
+#ifdef TELNETSRV_MEASURMENTS_MAIN
+
+
+#define TELNET_MAXMEASURNAME_LEN 30
+#define TELNET_MAXMEASURGROUPS 10
+
+telnetshell_vardef_t measur_vardef[] = {
+ {"",0,NULL}
+};
+
+typedef struct cpumeasurdef {
+ char statname[TELNET_MAXMEASURNAME_LEN];
+ time_stats_t *astatptr;
+ unsigned int statemask;
+} telnet_cpumeasurdef_t;
+
+typedef struct ltemeasurdef {
+ char statname[TELNET_MAXMEASURNAME_LEN];
+ void *vptr;
+ char vtyp;
+ unsigned int statemask;
+} telnet_ltemeasurdef_t;
+
+#define GROUP_LTESTATS 0
+#define GROUP_CPUSTATS 1
+typedef void(*measur_dislayfunc_t)(telnet_printfunc_t prnt);
+typedef struct mesurgroupdef {
+ char groupname[TELNET_MAXMEASURNAME_LEN];
+ unsigned char type;
+ unsigned char size;
+ measur_dislayfunc_t displayfunc;
+ union {
+ telnet_cpumeasurdef_t *cpustats;
+ telnet_ltemeasurdef_t *ltestats;
+ };
+} telnet_measurgroupdef_t;
+
+#define MACSTATS_NAME(valptr) #valptr
+#define LTEMAC_MEASURGROUP_NAME "ltemac"
+#define PHYCPU_MEASURGROUP_NAME "phycpu"
+
+int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt);
+int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt);
+telnetshell_cmddef_t measur_cmdarray[] = {
+ {"show", "groups | " , measurcmd_show},
+ {"cpustats","[enable | disable]",measurcmd_cpustats},
+ {"","",NULL}
+};
+
+#else
+extern void add_measur_cmds(void);
+#endif /* TELNETSRV_MEASURCMD_MAIN */
diff --git a/common/utils/telnetsrv/telnetsrv_phycmd.c b/common/utils/telnetsrv/telnetsrv_phycmd.c
index c60126f1c7..35554a77a6 100644
--- a/common/utils/telnetsrv/telnetsrv_phycmd.c
+++ b/common/utils/telnetsrv/telnetsrv_phycmd.c
@@ -29,7 +29,7 @@
* \note
* \warning
*/
-#define _GNU_SOURCE
+#define _GNU_SOURCE
#include
#include
@@ -39,104 +39,88 @@
#define TELNETSRV_PHYCMD_MAIN
#include "telnetsrv_phycmd.h"
char *prnbuff;
-extern int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length);
+extern int dump_eNB_l2_stats(char *buffer, int length);
-void init_phytelnet(void)
-{
-prnbuff=malloc(get_phybsize() );
-if (prnbuff == NULL)
- {
- fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
- }
+void init_phytelnet(void) {
+ prnbuff=malloc(get_phybsize() );
+
+ if (prnbuff == NULL) {
+ fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
+ }
}
-void display_uestatshead( telnet_printfunc_t prnt)
-{
-prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
+void display_uestatshead( telnet_printfunc_t prnt) {
+ prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
}
-void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag)
-{
+void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) {
+ int p;
+ prnbuff=malloc(20480);
+ p=dump_eNB_l2_stats( prnbuff, 20480);
-int p;
-
- p=dump_eNB_l2_stats( prnbuff, 0);
- if(prntflag>=1)
- prnt("%s\n",prnbuff);
- if(debug>=1)
- prnt("%i bytes printed\n",p);
+ if(prntflag>=1)
+ prnt("%s\n",prnbuff);
+ if(debug>=1)
+ prnt("%i bytes printed\n",p);
+ free(prnbuff);
}
-void display_uestats(int debug, telnet_printfunc_t prnt, int ue)
-{
- for (int cc=0; cc<1 ; cc++)
- {
-
-
- }
+void display_uestats(int debug, telnet_printfunc_t prnt, int ue) {
+ for (int cc=0; cc<1 ; cc++) {
+ }
}
-void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt)
-{
- prnt(" DLSCH kb DLSCH kb/s\n");
-
- dump_uestats(debug, prnt,0);
-
+void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt) {
+ prnt(" DLSCH kb DLSCH kb/s\n");
+ dump_uestats(debug, prnt,0);
}
-int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt)
-{
-
-
+int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) {
+ if (debug > 0)
+ prnt("phy interface module received %s\n",buf);
- if (debug > 0)
- prnt("phy interface module received %s\n",buf);
- if (strcasestr(buf,"phycnt") != NULL)
- {
- display_phycounters(buf, debug, prnt);
- }
- if (strcasestr(buf,"uestat") != NULL)
- {
- char *cptr=strcasestr(buf+sizeof("uestat"),"UE");
- display_uestatshead(prnt);
- if (cptr != NULL)
- {
- int ueidx = strtol( cptr+sizeof("UE"), NULL, 10);
- if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0)
- {
- display_uestats(debug, prnt,ueidx);
- }
- } /* if cptr != NULL */
- else
- {
- for (int ue=0; ue= 0) {
+ display_uestats(debug, prnt,ueidx);
+ }
+ } /* if cptr != NULL */
+ else {
+ for (int ue=0; ue]", dump_phyvars},
+ {"disp","[phycnt,uedump,uestat UE]", dump_phyvars},
- {"","",NULL},
+ {"","",NULL},
};
/*-------------------------------------------------------------------------------------*/
-void add_phy_cmds(void)
-{
-
- init_phytelnet();
- add_telnetcmd("phy", phy_vardef, phy_cmdarray);
+void add_phy_cmds(void) {
+ init_phytelnet();
+ add_telnetcmd("phy", phy_vardef, phy_cmdarray);
}
diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md
index fef47d9c27..29163fd832 100644
--- a/doc/FEATURE_SET.md
+++ b/doc/FEATURE_SET.md
@@ -124,6 +124,9 @@ The X2AP layer is based on **3GPP 36.423** v14.6.0 and implements the following
- X2 Setup Request
- X2 Setup Response
+ - X2 Setup Failure
+ - Handover Request
+ - Handover Request Acknowledge
## eNB Advanced Features ##
diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c
index 3da2059ba7..2597c9e8de 100644
--- a/nfapi/oai_integration/nfapi_vnf.c
+++ b/nfapi/oai_integration/nfapi_vnf.c
@@ -61,7 +61,7 @@ typedef struct {
char local_addr[80];
int local_port;
- char* remote_addr;
+ char *remote_addr;
int remote_port;
uint8_t duplex_mode;
@@ -127,12 +127,12 @@ typedef struct mac mac_t;
typedef struct mac {
- void* user_data;
+ void *user_data;
- void (*dl_config_req)(mac_t* mac, nfapi_dl_config_request_t* req);
- void (*ul_config_req)(mac_t* mac, nfapi_ul_config_request_t* req);
- void (*hi_dci0_req)(mac_t* mac, nfapi_hi_dci0_request_t* req);
- void (*tx_req)(mac_t* mac, nfapi_tx_request_t* req);
+ void (*dl_config_req)(mac_t *mac, nfapi_dl_config_request_t *req);
+ void (*ul_config_req)(mac_t *mac, nfapi_ul_config_request_t *req);
+ void (*hi_dci0_req)(mac_t *mac, nfapi_hi_dci0_request_t *req);
+ void (*tx_req)(mac_t *mac, nfapi_tx_request_t *req);
} mac_t;
typedef struct {
@@ -145,15 +145,15 @@ typedef struct {
unsigned aperiodic_timing_enabled;
unsigned periodic_timing_period;
- // This is not really the right place if we have multiple PHY,
+ // This is not really the right place if we have multiple PHY,
// should be part of the phy struct
udp_data udp;
uint8_t thread_started;
- nfapi_vnf_p7_config_t* config;
+ nfapi_vnf_p7_config_t *config;
- mac_t* mac;
+ mac_t *mac;
} vnf_p7_info;
@@ -165,24 +165,27 @@ typedef struct {
} vnf_info;
-int vnf_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) {
+int vnf_pack_vendor_extension_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "vnf_pack_vendor_extension_tlv\n");
- nfapi_tl_t* tlv = (nfapi_tl_t*)ve;
+ nfapi_tl_t *tlv = (nfapi_tl_t *)ve;
+
switch(tlv->tag) {
- case VENDOR_EXT_TLV_2_TAG:
- {
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n");
- vendor_ext_tlv_2* ve = (vendor_ext_tlv_2*)tlv;
- if(!push32(ve->dummy, ppWritePackedMsg, end))
- return 0;
- return 1;
- }
- break;
+ case VENDOR_EXT_TLV_2_TAG: {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n");
+ vendor_ext_tlv_2 *ve = (vendor_ext_tlv_2 *)tlv;
+
+ if(!push32(ve->dummy, ppWritePackedMsg, end))
+ return 0;
+
+ return 1;
+ }
+ break;
}
+
return -1;
}
-int vnf_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* codec) {
+int vnf_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p4_p5_codec_config_t *codec) {
return -1;
}
@@ -192,17 +195,14 @@ extern void init_eNB_afterRU(void);
extern uint16_t sf_ahead;
void oai_create_enb(void) {
-
int bodge_counter=0;
PHY_VARS_eNB *eNB = RC.eNB[0][0];
-
- printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->if_inst);
-
+ printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag,
+ eNB->single_thread_flag, eNB->if_inst);
eNB->Mod_id = bodge_counter;
eNB->CC_id = bodge_counter;
eNB->abstraction_flag = 0;
eNB->single_thread_flag = 0;//single_thread_flag;
-
RC.nb_CC[bodge_counter] = 1;
if (eNB->if_inst==0) {
@@ -213,7 +213,6 @@ void oai_create_enb(void) {
// that will result in eNB->configured being set to TRUE.
// See we need to wait for that to happen otherwise the NFAPI message exchanges won't contain the right parameter values
if (RC.eNB[0][0]->if_inst==0 || RC.eNB[0][0]->if_inst->PHY_config_req==0 || RC.eNB[0][0]->if_inst->schedule_response==0) {
-
printf("RC.eNB[0][0]->if_inst->PHY_config_req is not installed - install it\n");
install_schedule_handlers(RC.eNB[0][0]->if_inst);
}
@@ -227,17 +226,13 @@ void oai_create_enb(void) {
}
void oai_enb_init(void) {
-
printf("%s() About to call init_eNB_afterRU()\n", __FUNCTION__);
init_eNB_afterRU();
}
-int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) {
-
+int pnf_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
printf("[VNF] pnf connection indication idx:%d\n", p5_idx);
-
oai_create_enb();
-
nfapi_pnf_param_request_t req;
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_PARAM_REQUEST;
@@ -245,40 +240,29 @@ int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) {
return 0;
}
-int pnf_disconnection_indication_cb(nfapi_vnf_config_t* config, int p5_idx) {
+int pnf_disconnection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
printf("[VNF] pnf disconnection indication idx:%d\n", p5_idx);
-
- vnf_info* vnf = (vnf_info*)(config->user_data);
-
+ vnf_info *vnf = (vnf_info *)(config->user_data);
pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys;
-
- vnf_p7_info* p7_vnf = vnf->p7_vnfs;
+ vnf_p7_info *p7_vnf = vnf->p7_vnfs;
nfapi_vnf_p7_del_pnf((p7_vnf->config), phy->id);
-
return 0;
}
-int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp) {
-
+int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_response_t *resp) {
printf("[VNF] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code);
-
- vnf_info* vnf = (vnf_info*)(config->user_data);
-
+ vnf_info *vnf = (vnf_info *)(config->user_data);
pnf_info *pnf = vnf->pnfs;
- for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i)
- {
+ for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) {
phy_info phy;
memset(&phy,0,sizeof(phy));
phy.index = resp->pnf_phy.phy[i].phy_config_index;
-
printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index);
-
nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id));
- for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j)
- {
+ for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) {
printf("[VNF] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index);
phy.rfs[0] = resp->pnf_phy.phy[i].rf_config[j].rf_config_index;
}
@@ -290,16 +274,13 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re
rf_info rf;
memset(&rf,0,sizeof(rf));
rf.index = resp->pnf_rf.rf[i].rf_config_index;
-
printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index);
-
pnf->rfs[0] = rf;
}
nfapi_pnf_config_request_t req;
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PNF_CONFIG_REQUEST;
-
req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG;
req.pnf_phy_rf_config.number_phy_rf_config_info = 2; // DJP pnf.phys.size();
printf("DJP:Hard coded num phy rf to 2\n");
@@ -311,25 +292,22 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re
}
nfapi_vnf_pnf_config_req(config, p5_idx, &req);
-
return 0;
}
-int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp) {
-
+int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_response_t *resp) {
printf("[VNF] pnf config response idx:%d resp[header[phy_id:%u message_id:%02x message_length:%u]]\n", p5_idx, resp->header.phy_id, resp->header.message_id, resp->header.message_length);
if(1) {
- nfapi_pnf_start_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.phy_id = resp->header.phy_id;
- req.header.message_id = NFAPI_PNF_START_REQUEST;
- nfapi_vnf_pnf_start_req(config, p5_idx, &req);
+ nfapi_pnf_start_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.phy_id = resp->header.phy_id;
+ req.header.message_id = NFAPI_PNF_START_REQUEST;
+ nfapi_vnf_pnf_start_req(config, p5_idx, &req);
} else {
// Rather than send the pnf_start_request we will demonstrate
// sending a vendor extention message. The start request will be
- // send when the vendor extension response is received
-
+ // send when the vendor extension response is received
//vnf_info* vnf = (vnf_info*)(config->user_data);
vendor_ext_p5_req req;
memset(&req, 0, sizeof(req));
@@ -338,22 +316,17 @@ int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_
req.dummy2 = 1977;
nfapi_vnf_vendor_extension(config, p5_idx, &req.header);
}
+
return 0;
}
int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
-
L1_proc_t *proc=&eNB->proc;
-
L1_rxtx_proc_t *L1_proc= (sf&1)? &proc->L1_proc : &proc->L1_proc_tx;
-
LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-
//printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf);
-
//int i;
struct timespec wait;
-
wait.tv_sec=0;
wait.tv_nsec=5000000L;
@@ -368,10 +341,8 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
{
static uint16_t old_sf = 0;
static uint16_t old_sfn = 0;
-
proc->subframe_rx = old_sf;
proc->frame_rx = old_sfn;
-
// Try to be 1 frame back
old_sf = sf;
old_sfn = sfn;
@@ -380,9 +351,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
}
++L1_proc->instance_cnt;
-
//LOG_D( PHY,"[VNF-subframe_ind] sfn/sf:%d:%d proc[frame_rx:%d subframe_rx:%d] L1_proc->instance_cnt_rxtx:%d \n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->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).
@@ -407,7 +376,6 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
//LOG_D(PHY,"%s() About to attempt pthread_mutex_unlock\n", __FUNCTION__);
pthread_mutex_unlock( &L1_proc->mutex );
//LOG_D(PHY,"%s() UNLOCKED pthread_mutex_unlock\n", __FUNCTION__);
-
return(0);
}
@@ -415,12 +383,10 @@ extern pthread_cond_t nfapi_sync_cond;
extern pthread_mutex_t nfapi_sync_mutex;
extern int nfapi_sync_var;
-int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) {
-
+int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) {
printf("[VNF] SYNC %s\n", sync==1 ? "ACHIEVED" : "LOST");
-
- if (sync==1 && nfapi_sync_var!=0) {
+ if (sync==1 && nfapi_sync_var!=0) {
printf("[VNF] Signal to OAI main code that it can go\n");
pthread_mutex_lock(&nfapi_sync_mutex);
nfapi_sync_var=0;
@@ -431,9 +397,9 @@ int phy_sync_indication(struct nfapi_vnf_p7_config* config, uint8_t sync) {
return(0);
}
-int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf) {
-
+int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn_sf) {
static uint8_t first_time = 1;
+
if (first_time) {
printf("[VNF] subframe indication %d\n", NFAPI_SFNSF2DEC(sfn_sf));
first_time = 0;
@@ -442,40 +408,33 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id,
if (RC.eNB && RC.eNB[0][0]->configured) {
uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf);
uint16_t sf = NFAPI_SFNSF2SF(sfn_sf);
-
//LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf);
-
wake_eNB_rxtx(RC.eNB[0][0], sfn, sf);
} else {
printf("[VNF] %s() RC.eNB:%p\n", __FUNCTION__, RC.eNB);
+
if (RC.eNB) printf("RC.eNB[0][0]->configured:%d\n", RC.eNB[0][0]->configured);
}
return 0;
}
-int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind) {
-
+int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indication_t *ind) {
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
-
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
-
printf("[VNF] RACH_IND eNB:%p sfn_sf:%d number_of_preambles:%d\n", eNB, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
-
pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
eNB->UL_INFO.rach_ind = *ind;
eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = eNB->preamble_list;
- for (int i=0;irach_indication_body.number_of_preambles;i++) {
+ for (int i=0; irach_indication_body.number_of_preambles; i++) {
if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) {
-
- printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
- i,
- ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti,
- ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble,
- ind->rach_indication_body.preamble_list[i].preamble_rel8.timing_advance
- );
+ printf("preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
+ i,
+ ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti,
+ ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble,
+ ind->rach_indication_body.preamble_list[i].preamble_rel8.timing_advance
+ );
}
if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) {
@@ -484,21 +443,17 @@ int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indicatio
eNB->preamble_list[i] = ind->rach_indication_body.preamble_list[i];
}
- pthread_mutex_unlock(&eNB->UL_INFO_mutex);
+ pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_rach_ind(p7_vnf->mac, ind);
return 1;
}
-int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind) {
-
+int phy_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_harq_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
-
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs);
-
pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
eNB->UL_INFO.harq_ind = *ind;
eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = eNB->harq_pdu_list;
@@ -507,51 +462,41 @@ int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indicatio
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
-
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_harq_ind(p7_vnf->mac, ind);
-
return 1;
}
-int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind) {
-
+int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
-
pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
eNB->UL_INFO.crc_ind = *ind;
-
nfapi_crc_indication_t *dest_ind = &eNB->UL_INFO.crc_ind;
nfapi_crc_indication_pdu_t *dest_pdu_list = eNB->crc_pdu_list;
-
*dest_ind = *ind;
dest_ind->crc_indication_body.crc_pdu_list = dest_pdu_list;
if (ind->crc_indication_body.number_of_crcs==0)
- LOG_D(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs);
+ LOG_D(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs,
+ eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs);
for (int i=0; icrc_indication_body.number_of_crcs; i++) {
memcpy(&dest_ind->crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0]));
-
- LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n",
- __FUNCTION__,
- NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs,
- i,
- ind->crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti,
- eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti);
+ LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n",
+ __FUNCTION__,
+ NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs,
+ i,
+ ind->crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti,
+ eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[i].rx_ue_information.rnti);
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
-
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_crc_ind(p7_vnf->mac, ind);
-
return 1;
}
-int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind) {
-
+int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
if (ind->rx_indication_body.number_of_pdus==0) {
@@ -559,198 +504,170 @@ int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t*
}
pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
nfapi_rx_indication_t *dest_ind = &eNB->UL_INFO.rx_ind;
nfapi_rx_indication_pdu_t *dest_pdu_list = eNB->rx_pdu_list;
-
*dest_ind = *ind;
dest_ind->rx_indication_body.rx_pdu_list = dest_pdu_list;
for(int i=0; irx_indication_body.number_of_pdus; i++) {
nfapi_rx_indication_pdu_t *dest_pdu = &dest_ind->rx_indication_body.rx_pdu_list[i];
nfapi_rx_indication_pdu_t *src_pdu = &ind->rx_indication_body.rx_pdu_list[i];
-
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
-
// DJP - TODO FIXME - intentional memory leak
dest_pdu->data = malloc(dest_pdu->rx_indication_rel8.length);
-
memcpy(dest_pdu->data, src_pdu->data, dest_pdu->rx_indication_rel8.length);
-
LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
- __FUNCTION__,
- NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i,
- dest_pdu->rx_ue_information.handle,
- dest_pdu->rx_ue_information.rnti,
- dest_pdu->rx_indication_rel8.length,
- dest_pdu->rx_indication_rel8.offset,
- dest_pdu->rx_indication_rel8.ul_cqi,
- dest_pdu->rx_indication_rel8.timing_advance,
- dest_pdu->data
- );
+ __FUNCTION__,
+ NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i,
+ dest_pdu->rx_ue_information.handle,
+ dest_pdu->rx_ue_information.rnti,
+ dest_pdu->rx_indication_rel8.length,
+ dest_pdu->rx_indication_rel8.offset,
+ dest_pdu->rx_indication_rel8.ul_cqi,
+ dest_pdu->rx_indication_rel8.timing_advance,
+ dest_pdu->data
+ );
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
-
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_rx_ind(p7_vnf->mac, ind);
return 1;
}
-int phy_srs_indication(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind) {
+int phy_srs_indication(struct nfapi_vnf_p7_config *config, nfapi_srs_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_srs_ind(p7_vnf->mac, ind);
return 1;
}
-int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind) {
-
+int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t *ind) {
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
-
LOG_D(MAC, "%s() NFAPI SFN/SF:%d srs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs);
-
pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
nfapi_sr_indication_t *dest_ind = &eNB->UL_INFO.sr_ind;
nfapi_sr_indication_pdu_t *dest_pdu_list = eNB->sr_pdu_list;
-
*dest_ind = *ind;
dest_ind->sr_indication_body.sr_pdu_list = dest_pdu_list;
-
LOG_D(MAC,"%s() eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs);
- for (int i=0;iUL_INFO.sr_ind.sr_indication_body.number_of_srs;i++) {
+ for (int i=0; iUL_INFO.sr_ind.sr_indication_body.number_of_srs; i++) {
nfapi_sr_indication_pdu_t *dest_pdu = &dest_ind->sr_indication_body.sr_pdu_list[i];
nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i];
-
LOG_D(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
-
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
}
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
-
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_sr_ind(p7_vnf->mac, ind);
-
return 1;
}
-int phy_cqi_indication(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind) {
-
+int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_cqi_ind(p7_vnf->mac, ind);
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
-
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis);
-
pthread_mutex_lock(&eNB->UL_INFO_mutex);
-
eNB->UL_INFO.cqi_ind = ind->cqi_indication_body;
-
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
-
return 1;
}
-int phy_lbt_dl_indication(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind) {
+int phy_lbt_dl_indication(struct nfapi_vnf_p7_config *config, nfapi_lbt_dl_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_lbt_dl_ind(p7_vnf->mac, ind);
return 1;
}
-int phy_nb_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind) {
+int phy_nb_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_nb_harq_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_nb_harq_ind(p7_vnf->mac, ind);
return 1;
}
-int phy_nrach_indication(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind) {
+int phy_nrach_indication(struct nfapi_vnf_p7_config *config, nfapi_nrach_indication_t *ind) {
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
//mac_nrach_ind(p7_vnf->mac, ind);
return 1;
}
-void* vnf_allocate(size_t size) {
+void *vnf_allocate(size_t size) {
//return (void*)memory_pool::allocate(size);
- return (void*)malloc(size);
+ return (void *)malloc(size);
}
-void vnf_deallocate(void* ptr) {
+void vnf_deallocate(void *ptr) {
//memory_pool::deallocate((uint8_t*)ptr);
free(ptr);
}
-void vnf_trace(nfapi_trace_level_t nfapi_level, const char* message, ...) {
-
+void vnf_trace(nfapi_trace_level_t nfapi_level, const char *message, ...) {
va_list args;
-
va_start(args, message);
nfapi_log("FILE>", "FUNC", 999, PHY, nfapitooai_level(nfapi_level), message, args);
va_end(args);
}
-int phy_vendor_ext(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg) {
-
- if(msg->message_id == P7_VENDOR_EXT_IND)
- {
+int phy_vendor_ext(struct nfapi_vnf_p7_config *config, nfapi_p7_message_header_t *msg) {
+ if(msg->message_id == P7_VENDOR_EXT_IND) {
//vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg;
//printf("[VNF] vendor_ext (error_code:%d)\n", ind->error_code);
- }
- else
- {
+ } else {
printf("[VNF] unknown %02x\n", msg->message_id);
}
+
return 0;
}
-nfapi_p7_message_header_t* phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t* msg_size) {
- if(message_id == P7_VENDOR_EXT_IND)
- {
+nfapi_p7_message_header_t *phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t *msg_size) {
+ if(message_id == P7_VENDOR_EXT_IND) {
*msg_size = sizeof(vendor_ext_p7_ind);
- return (nfapi_p7_message_header_t*)malloc(sizeof(vendor_ext_p7_ind));
+ return (nfapi_p7_message_header_t *)malloc(sizeof(vendor_ext_p7_ind));
}
+
return 0;
}
-void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header) {
+void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) {
free(header);
}
-int phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p7_codec_config_t* codec) {
-
+int phy_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p7_codec_config_t *codec) {
(void)tl;
(void)ppReadPackedMessage;
(void)ve;
return -1;
}
-int phy_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* codec) {
-
+int phy_pack_vendor_extension_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n");
+ nfapi_tl_t *tlv = (nfapi_tl_t *)ve;
- nfapi_tl_t* tlv = (nfapi_tl_t*)ve;
switch(tlv->tag) {
- case VENDOR_EXT_TLV_1_TAG:
- {
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n");
- vendor_ext_tlv_1* ve = (vendor_ext_tlv_1*)tlv;
- if(!push32(ve->dummy, ppWritePackedMsg, end))
- return 0;
- return 1;
- }
- break;
+ case VENDOR_EXT_TLV_1_TAG: {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n");
+ vendor_ext_tlv_1 *ve = (vendor_ext_tlv_1 *)tlv;
+
+ if(!push32(ve->dummy, ppWritePackedMsg, end))
+ return 0;
+
+ return 1;
+ }
+ break;
+
default:
return -1;
break;
}
}
-int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t* config) {
-
+int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t *config) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
if(header->message_id == P7_VENDOR_EXT_IND) {
- vendor_ext_p7_ind* req = (vendor_ext_p7_ind*)(header);
+ vendor_ext_p7_ind *req = (vendor_ext_p7_ind *)(header);
+
if(!pull16(ppReadPackedMessage, &req->error_code, end))
return 0;
}
@@ -758,54 +675,48 @@ int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t**
return 1;
}
-int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) {
+int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
if(header->message_id == P7_VENDOR_EXT_REQ) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
- vendor_ext_p7_req* req = (vendor_ext_p7_req*)(header);
+ vendor_ext_p7_req *req = (vendor_ext_p7_req *)(header);
+
if(!(push16(req->dummy1, ppWritePackedMsg, end) &&
- push16(req->dummy2, ppWritePackedMsg, end)))
+ push16(req->dummy2, ppWritePackedMsg, end)))
return 0;
}
+
return 1;
}
-int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) {
-
+int vnf_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
if(header->message_id == P5_VENDOR_EXT_REQ) {
- vendor_ext_p5_req* req = (vendor_ext_p5_req*)(header);
+ vendor_ext_p5_req *req = (vendor_ext_p5_req *)(header);
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2);
return (!(push16(req->dummy1, ppWritePackedMsg, end) &&
- push16(req->dummy2, ppWritePackedMsg, end)));
+ push16(req->dummy2, ppWritePackedMsg, end)));
}
+
return 0;
}
static pthread_t vnf_start_pthread;
static pthread_t vnf_p7_start_pthread;
-void* vnf_p7_start_thread(void *ptr) {
-
+void *vnf_p7_start_thread(void *ptr) {
printf("%s()\n", __FUNCTION__);
-
pthread_setname_np(pthread_self(), "VNF_P7");
-
- nfapi_vnf_p7_config_t* config = (nfapi_vnf_p7_config_t*)ptr;
-
+ nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr;
nfapi_vnf_p7_start(config);
-
return config;
}
void set_thread_priority(int priority);
-void* vnf_p7_thread_start(void* ptr) {
-
+void *vnf_p7_thread_start(void *ptr) {
set_thread_priority(79);
-
- vnf_p7_info* p7_vnf = (vnf_p7_info*)ptr;
-
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr;
p7_vnf->config->port = p7_vnf->local_port;
p7_vnf->config->sync_indication = &phy_sync_indication;
p7_vnf->config->subframe_indication = &phy_subframe_indication;
@@ -821,117 +732,87 @@ void* vnf_p7_thread_start(void* ptr) {
p7_vnf->config->nrach_indication = &phy_nrach_indication;
p7_vnf->config->malloc = &vnf_allocate;
p7_vnf->config->free = &vnf_deallocate;
-
p7_vnf->config->trace = &vnf_trace;
-
p7_vnf->config->vendor_ext = &phy_vendor_ext;
p7_vnf->config->user_data = p7_vnf;
-
p7_vnf->mac->user_data = p7_vnf;
-
p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension;
p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension;
p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv;
p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv;
p7_vnf->config->codec_config.allocate = &vnf_allocate;
p7_vnf->config->codec_config.deallocate = &vnf_deallocate;
-
p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext;
p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext;
-
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config);
-
return 0;
}
-int pnf_start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp) {
-
- vnf_info* vnf = (vnf_info*)(config->user_data);
+int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_response_t *resp) {
+ vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
pnf_info *pnf = vnf->pnfs;
nfapi_param_request_t req;
-
printf("[VNF] pnf start response idx:%d config:%p user_data:%p p7_vnf[config:%p thread_started:%d]\n", p5_idx, config, config->user_data, vnf->p7_vnfs[0].config, vnf->p7_vnfs[0].thread_started);
if(p7_vnf->thread_started == 0) {
-
pthread_t vnf_p7_thread;
pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, p7_vnf);
p7_vnf->thread_started = 1;
- }
- else
- {
- // P7 thread already running.
+ } else {
+ // P7 thread already running.
}
// start all the phys in the pnf.
printf("[VNF] Sending NFAPI_PARAM_REQUEST phy_id:%d\n", pnf->phys[0].id);
-
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_PARAM_REQUEST;
req.header.phy_id = pnf->phys[0].id;
-
nfapi_vnf_param_req(config, p5_idx, &req);
-
return 0;
}
extern uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq,uint32_t bw);
-int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t* resp) {
-
+int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_param_response_t *resp) {
printf("[VNF] Received NFAPI_PARAM_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
-
- vnf_info* vnf = (vnf_info*)(config->user_data);
+ vnf_info *vnf = (vnf_info *)(config->user_data);
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
-
pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys;
struct sockaddr_in pnf_p7_sockaddr;
nfapi_config_request_t *req = &RC.mac[0]->config[0];
-
phy->remote_port = resp->nfapi_config.p7_pnf_port.value;
-
memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4);
-
phy->remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr);
-
// for now just 1
-
- printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period);
-
+ printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled,
+ p7_vnf->periodic_timing_period);
req->header.message_id = NFAPI_CONFIG_REQUEST;
req->header.phy_id = phy->id;
-
printf("[VNF] Send NFAPI_CONFIG_REQUEST\n");
-
req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG;
req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port;
req->num_tlv++;
-
printf("[VNF] DJP local_port:%d\n", p7_vnf->local_port);
-
req->nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG;
struct sockaddr_in vnf_p7_sockaddr;
vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf->local_addr);
memcpy(&(req->nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4);
req->num_tlv++;
printf("[VNF] DJP local_addr:%s\n", p7_vnf->local_addr);
-
req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG;
req->nfapi_config.timing_window.value = p7_vnf->timing_window;
printf("[VNF] Timing window:%u\n", p7_vnf->timing_window);
req->num_tlv++;
if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) {
-
req->nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG;
req->nfapi_config.timing_info_mode.value = (p7_vnf->aperiodic_timing_enabled << 1) | (p7_vnf->periodic_timing_enabled);
req->num_tlv++;
if(p7_vnf->periodic_timing_enabled) {
-
req->nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG;
req->nfapi_config.timing_info_period.value = p7_vnf->periodic_timing_period;
req->num_tlv++;
@@ -943,142 +824,110 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t
ve2.tl.tag = VENDOR_EXT_TLV_2_TAG;
ve2.dummy = 2016;
req->vendor_extension = &ve2.tl;
-
nfapi_vnf_config_req(config, p5_idx, req);
printf("[VNF] Sent NFAPI_CONFIG_REQ num_tlv:%u\n",req->num_tlv);
-
return 0;
}
-int config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp) {
-
+int config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_config_response_t *resp) {
nfapi_start_request_t req;
-
printf("[VNF] Received NFAPI_CONFIG_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
-
printf("[VNF] Calling oai_enb_init()\n");
oai_enb_init();
-
memset(&req, 0, sizeof(req));
req.header.message_id = NFAPI_START_REQUEST;
req.header.phy_id = resp->header.phy_id;
nfapi_vnf_start_req(config, p5_idx, &req);
-
printf("[VNF] Send NFAPI_START_REQUEST idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
-
return 0;
}
-int start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp) {
-
+int start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_start_response_t *resp) {
printf("[VNF] Received NFAPI_START_RESP idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
-
- vnf_info* vnf = (vnf_info*)(config->user_data);
-
+ vnf_info *vnf = (vnf_info *)(config->user_data);
pnf_info *pnf = vnf->pnfs;
phy_info *phy = pnf->phys;
vnf_p7_info *p7_vnf = vnf->p7_vnfs;
nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id);
-
return 0;
}
-int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg) {
-
+int vendor_ext_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_p4_p5_message_header_t *msg) {
printf("[VNF] %s\n", __FUNCTION__);
switch(msg->message_id) {
- case P5_VENDOR_EXT_RSP:
- {
- vendor_ext_p5_rsp* rsp = (vendor_ext_p5_rsp*)msg;
- printf("[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code);
-
- // send the start request
-
- nfapi_pnf_start_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_PNF_START_REQUEST;
- nfapi_vnf_pnf_start_req(config, p5_idx, &req);
- }
- break;
+ case P5_VENDOR_EXT_RSP: {
+ vendor_ext_p5_rsp *rsp = (vendor_ext_p5_rsp *)msg;
+ printf("[VNF] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code);
+ // send the start request
+ nfapi_pnf_start_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_PNF_START_REQUEST;
+ nfapi_vnf_pnf_start_req(config, p5_idx, &req);
+ }
+ break;
}
return 0;
}
-int vnf_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t* codec) {
-
+int vnf_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
- if(header->message_id == P5_VENDOR_EXT_RSP)
- {
- vendor_ext_p5_rsp* req = (vendor_ext_p5_rsp*)(header);
+ if(header->message_id == P5_VENDOR_EXT_RSP) {
+ vendor_ext_p5_rsp *req = (vendor_ext_p5_rsp *)(header);
return(!pull16(ppReadPackedMessage, &req->error_code, end));
}
+
return 0;
}
-nfapi_p4_p5_message_header_t* vnf_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t* msg_size) {
-
+nfapi_p4_p5_message_header_t *vnf_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t *msg_size) {
if(message_id == P5_VENDOR_EXT_RSP) {
*msg_size = sizeof(vendor_ext_p5_rsp);
- return (nfapi_p4_p5_message_header_t*)malloc(sizeof(vendor_ext_p5_rsp));
+ return (nfapi_p4_p5_message_header_t *)malloc(sizeof(vendor_ext_p5_rsp));
}
+
return 0;
}
-void vnf_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t* header) {
+void vnf_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t *header) {
free(header);
}
nfapi_vnf_config_t *config = 0;
-void vnf_start_thread(void* ptr) {
-
+void vnf_start_thread(void *ptr) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] VNF NFAPI thread - nfapi_vnf_start()%s\n", __FUNCTION__);
-
pthread_setname_np(pthread_self(), "VNF");
-
- config = (nfapi_vnf_config_t*)ptr;
-
+ config = (nfapi_vnf_config_t *)ptr;
nfapi_vnf_start(config);
}
static vnf_info vnf;
extern uint8_t nfapi_mode;
/*------------------------------------------------------------------------------*/
-void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port)
-{
+void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) {
nfapi_mode = 2;
-
memset(&vnf, 0, sizeof(vnf));
-
memset(vnf.p7_vnfs, 0, sizeof(vnf.p7_vnfs));
-
vnf.p7_vnfs[0].timing_window = 32;
vnf.p7_vnfs[0].periodic_timing_enabled = 1;
vnf.p7_vnfs[0].aperiodic_timing_enabled = 0;
vnf.p7_vnfs[0].periodic_timing_period = 10;
-
vnf.p7_vnfs[0].config = nfapi_vnf_p7_config_create();
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() vnf.p7_vnfs[0].config:%p VNF ADDRESS:%s:%d\n", __FUNCTION__, vnf.p7_vnfs[0].config, vnf_addr, vnf_p5_port);
-
strcpy(vnf.p7_vnfs[0].local_addr, vnf_addr);
vnf.p7_vnfs[0].local_port = 50001;
- vnf.p7_vnfs[0].mac = (mac_t*)malloc(sizeof(mac_t));
-
- nfapi_vnf_config_t* config = nfapi_vnf_config_create();
-
+ vnf.p7_vnfs[0].mac = (mac_t *)malloc(sizeof(mac_t));
+ nfapi_vnf_config_t *config = nfapi_vnf_config_create();
config->malloc = malloc;
config->free = free;
config->trace = &vnf_trace;
-
config->vnf_p5_port = vnf_p5_port;
config->vnf_ipv4 = 1;
config->vnf_ipv6 = 0;
-
config->pnf_list = 0;
config->phy_list = 0;
-
config->pnf_connection_indication = &pnf_connection_indication_cb;
config->pnf_disconnect_indication = &pnf_disconnection_indication_cb;
config->pnf_param_resp = &pnf_param_resp_cb;
@@ -1088,33 +937,26 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port)
config->config_resp = &config_resp_cb;
config->start_resp = &start_resp_cb;
config->vendor_ext = &vendor_ext_cb;
-
config->user_data = &vnf;
-
// To allow custom vendor extentions to be added to nfapi
config->codec_config.unpack_vendor_extension_tlv = &vnf_unpack_vendor_extension_tlv;
config->codec_config.pack_vendor_extension_tlv = &vnf_pack_vendor_extension_tlv;
-
config->codec_config.unpack_p4_p5_vendor_extension = &vnf_unpack_p4_p5_vendor_extension;
config->codec_config.pack_p4_p5_vendor_extension = &vnf_pack_p4_p5_vendor_extension;
config->allocate_p4_p5_vendor_ext = &vnf_allocate_p4_p5_vendor_ext;
config->deallocate_p4_p5_vendor_ext = &vnf_deallocate_p4_p5_vendor_ext;
config->codec_config.allocate = &vnf_allocate;
config->codec_config.deallocate = &vnf_deallocate;
-
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
- pthread_create(&vnf_start_pthread, NULL, (void*)&vnf_start_thread, config);
+ pthread_create(&vnf_start_pthread, NULL, (void *)&vnf_start_thread, config);
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Created VNF NFAPI start thread %s\n", __FUNCTION__);
}
-int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req)
-{
+int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) {
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
-
dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
dl_config_req->header.message_id = NFAPI_DL_CONFIG_REQUEST;
int retval = nfapi_vnf_p7_dl_config_req(p7_config, dl_config_req);
-
dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = 1;
dl_config_req->dl_config_request_body.number_dci = 0;
dl_config_req->dl_config_request_body.number_pdu = 0;
@@ -1123,35 +965,31 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req)
if (retval!=0) {
LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval);
}
+
return retval;
}
-int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req)
-{
+int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) {
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
-
tx_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
tx_req->header.message_id = NFAPI_TX_REQUEST;
//LOG_D(PHY, "[VNF] %s() TX_REQ sfn_sf:%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(tx_req->sfn_sf), tx_req->tx_request_body.number_of_pdus);
-
int retval = nfapi_vnf_p7_tx_req(p7_config, tx_req);
-
if (retval!=0) {
LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval);
} else {
tx_req->tx_request_body.number_of_pdus = 0;
}
+
return retval;
}
int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) {
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
-
hi_dci0_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;
//LOG_D(PHY, "[VNF] %s() HI_DCI0_REQ sfn_sf:%d dci:%d hi:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_hi);
-
int retval = nfapi_vnf_p7_hi_dci0_req(p7_config, hi_dci0_req);
if (retval!=0) {
@@ -1160,19 +998,16 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) {
hi_dci0_req->hi_dci0_request_body.number_of_hi = 0;
hi_dci0_req->hi_dci0_request_body.number_of_dci = 0;
}
+
return retval;
}
int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) {
-
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
-
ul_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
ul_config_req->header.message_id = NFAPI_UL_CONFIG_REQUEST;
//LOG_D(PHY, "[VNF] %s() header message_id:%02x\n", __FUNCTION__, ul_config_req->header.message_id);
-
//LOG_D(PHY, "[VNF] %s() UL_CONFIG sfn_sf:%d PDUs:%d rach_prach_frequency_resources:%d srs_present:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ul_config_req->sfn_sf), ul_config_req->ul_config_request_body.number_of_pdus, ul_config_req->ul_config_request_body.rach_prach_frequency_resources, ul_config_req->ul_config_request_body.srs_present);
-
int retval = nfapi_vnf_p7_ul_config_req(p7_config, ul_config_req);
if (retval!=0) {
@@ -1183,5 +1018,6 @@ int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) {
ul_config_req->ul_config_request_body.rach_prach_frequency_resources = 0;
ul_config_req->ul_config_request_body.srs_present = 0;
}
+
return retval;
}
diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c
index c180b5b0f9..6fe9b47409 100644
--- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c
+++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c
@@ -1545,7 +1545,7 @@ static uint8_t pack_tx_request_body_value(void* tlv, uint8_t **ppWritePackedMsg,
// DJP - if(pusharray8(pdu->segments[j].segment_data, (uint32_t)(-1), pdu->segments[j].segment_length, ppWritePackedMsg, end) == 0)
int push_ret = pusharray8(pdu->segments[j].segment_data, 65535, pdu->segments[j].segment_length, ppWritePackedMsg, end);
- if (0 && pdu->segments[j].segment_length == 3)
+ if (pdu->segments[j].segment_length == 3)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() BCH? segment_data:%x %x %x\n", __FUNCTION__,
pdu->segments[j].segment_data[0],
@@ -4429,40 +4429,43 @@ static uint8_t unpack_tx_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *
for(i = 0; i < totalNumPdus; ++i)
{
nfapi_tx_request_pdu_t* pdu = &(pNfapiMsg->tx_request_body.tx_pdu_list[i]);
+ if (pdu) {
+ uint16_t length = 0;
+ uint16_t index = 0;
- uint16_t length = 0;
- uint16_t index = 0;
-
- if(!(pull16(ppReadPackedMsg, &length, end) &&
+ if(!(pull16(ppReadPackedMsg, &length, end) &&
pull16(ppReadPackedMsg, &index, end)))
- return 0;
+ return 0;
- pdu->pdu_length = length;
- pdu->pdu_index = index;
+ pdu->pdu_length = length;
+ pdu->pdu_index = index;
// TODO : May need to rethink this bit
- pdu->num_segments = 1;
- pdu->segments[0].segment_length = pdu->pdu_length;
- pdu->segments[0].segment_data = nfapi_p7_allocate(pdu->pdu_length, config);
+ pdu->num_segments = 1;
+ pdu->segments[0].segment_length = pdu->pdu_length;
+ pdu->segments[0].segment_data = nfapi_p7_allocate(pdu->pdu_length, config);
- if(pdu->segments[0].segment_data)
- {
- if(!pullarray8(ppReadPackedMsg, pdu->segments[0].segment_data, pdu->segments[0].segment_length, pdu->segments[0].segment_length, end))
+ if(pdu->segments[0].segment_data)
+ {
+ if(!pullarray8(ppReadPackedMsg, pdu->segments[0].segment_data, pdu->segments[0].segment_length, pdu->segments[0].segment_length, end))
return 0;
- if (0 && pdu->segments[0].segment_length == 3)
- {
+ if (pdu->segments[0].segment_length == 3)
+ {
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() BCH? segment_data:%x %x %x\n", __FUNCTION__,
pdu->segments[0].segment_data[0],
pdu->segments[0].segment_data[1],
pdu->segments[0].segment_data[2]
);
- }
- }
- else
- {
+ }
+ }
+ else
+ {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "unpack_tx_request: Failed to allocate pdu (len:%d) %d/%d %d\n", pdu->pdu_length, totalNumPdus, i, pdu->pdu_index);
- }
+ }
+ } else {
+ NFAPI_TRACE(NFAPI_TRACE_ERROR, "NULL pdu\n");
+ }
}
}
break;
diff --git a/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp
index df0ca12305..1c2f0bef80 100644
--- a/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp
+++ b/nfapi/open-nFAPI/pnf_sim/src/fapi_stub.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Cisco Systems, Inc.
- *
+ *
* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
- *
+ *
* 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.
@@ -34,609 +34,510 @@
#include
#include
-struct phy_pdu
-{
- phy_pdu() : buffer_len(1500), buffer(0), len(0)
- {
- buffer = (char*) malloc(buffer_len);
- }
-
- virtual ~phy_pdu()
- {
- free(buffer);
- }
+struct phy_pdu {
+ phy_pdu() : buffer_len(1500), buffer(0), len(0) {
+ buffer = (char *) malloc(buffer_len);
+ }
+
+ virtual ~phy_pdu() {
+ free(buffer);
+ }
- unsigned buffer_len;
- char* buffer;
- unsigned len;
+ unsigned buffer_len;
+ char *buffer;
+ unsigned len;
};
-class fapi_private
-{
- std::mutex mutex;
- std::queue rx_buffer;
+class fapi_private {
+ std::mutex mutex;
+ std::queue rx_buffer;
- std::queue free_store;
- public:
+ std::queue free_store;
+ public:
- fapi_private()
- : byte_count(0), tick(0), first_dl_config(false)
- {
- }
+ fapi_private()
+ : byte_count(0), tick(0), first_dl_config(false) {
+ }
- phy_pdu* allocate_phy_pdu()
- {
- phy_pdu* pdu = 0;
- mutex.lock();
- if(free_store.empty())
- {
- pdu = new phy_pdu();
- }
- else
- {
- pdu = free_store.front();
- free_store.pop();
- }
- mutex.unlock();
- return pdu;
- }
+ phy_pdu *allocate_phy_pdu() {
+ phy_pdu *pdu = 0;
+ mutex.lock();
- void release_phy_pdu(phy_pdu* pdu)
- {
- mutex.lock();
- free_store.push(pdu);
- mutex.unlock();
- }
+ if(free_store.empty()) {
+ pdu = new phy_pdu();
+ } else {
+ pdu = free_store.front();
+ free_store.pop();
+ }
- bool rx_buffer_empty()
- {
- bool empty;
- mutex.lock();
- empty = rx_buffer.empty();
- mutex.unlock();
+ mutex.unlock();
+ return pdu;
+ }
- return empty;
- }
-
+ void release_phy_pdu(phy_pdu *pdu) {
+ mutex.lock();
+ free_store.push(pdu);
+ mutex.unlock();
+ }
- void push_rx_buffer(phy_pdu* buff)
- {
- mutex.lock();
- rx_buffer.push(buff);
- mutex.unlock();
- }
+ bool rx_buffer_empty() {
+ bool empty;
+ mutex.lock();
+ empty = rx_buffer.empty();
+ mutex.unlock();
+ return empty;
+ }
- phy_pdu* pop_rx_buffer()
- {
- phy_pdu* buff = 0;
- mutex.lock();
- if(!rx_buffer.empty())
- {
- buff = rx_buffer.front();
- rx_buffer.pop();
- }
- mutex.unlock();
- return buff;
- }
- uint32_t byte_count;
- uint32_t tick;
- bool first_dl_config;
+ void push_rx_buffer(phy_pdu *buff) {
+ mutex.lock();
+ rx_buffer.push(buff);
+ mutex.unlock();
+ }
+
+ phy_pdu *pop_rx_buffer() {
+ phy_pdu *buff = 0;
+ mutex.lock();
+
+ if(!rx_buffer.empty()) {
+ buff = rx_buffer.front();
+ rx_buffer.pop();
+ }
+
+ mutex.unlock();
+ return buff;
+ }
+
+ uint32_t byte_count;
+ uint32_t tick;
+ bool first_dl_config;
};
extern "C"
{
- typedef struct fapi_internal
- {
- fapi_t _public;
+ typedef struct fapi_internal {
+ fapi_t _public;
- fapi_cb_t callbacks;
+ fapi_cb_t callbacks;
- uint8_t state;
- fapi_config_t config;
+ uint8_t state;
+ fapi_config_t config;
- int rx_sock;
- int tx_sock;
- struct sockaddr_in tx_addr;
+ int rx_sock;
+ int tx_sock;
+ struct sockaddr_in tx_addr;
- uint32_t tx_byte_count;
- uint32_t tick;
-
- fapi_private* fapi;
+ uint32_t tx_byte_count;
+ uint32_t tick;
- } fapi_internal_t;
+ fapi_private *fapi;
+
+ } fapi_internal_t;
}
extern void set_thread_priority(int);
/*
{
- pthread_attr_t ptAttr;
-
- struct sched_param schedParam;
- schedParam.__sched_priority = 79;
- sched_setscheduler(0, SCHED_RR, &schedParam);
+ pthread_attr_t ptAttr;
- pthread_attr_setschedpolicy(&ptAttr, SCHED_RR);
+ struct sched_param schedParam;
+ schedParam.__sched_priority = 79;
+ sched_setscheduler(0, SCHED_RR, &schedParam);
- pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED);
+ pthread_attr_setschedpolicy(&ptAttr, SCHED_RR);
- struct sched_param thread_params;
- thread_params.sched_priority = 20;
- pthread_attr_setschedparam(&ptAttr, &thread_params);
+ pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED);
+
+ struct sched_param thread_params;
+ thread_params.sched_priority = 20;
+ pthread_attr_setschedparam(&ptAttr, &thread_params);
}
*/
-void send_uplink_indications(fapi_internal_t* instance, uint16_t sfn_sf)
-{
- fapi_harq_ind_t harq_ind;
- (instance->callbacks.fapi_harq_ind)(&(instance->_public), &harq_ind);
+void send_uplink_indications(fapi_internal_t *instance, uint16_t sfn_sf) {
+ fapi_harq_ind_t harq_ind;
+ (instance->callbacks.fapi_harq_ind)(&(instance->_public), &harq_ind);
+ fapi_crc_ind_t crc_ind;
+ crc_ind.header.message_id = FAPI_CRC_INDICATION;
+ crc_ind.header.length = 0; //??;
+ crc_ind.sfn_sf = sfn_sf;
+ crc_ind.body.number_of_crcs = 1;
+ crc_ind.body.pdus[0].rx_ue_info.handle = 0; //??
+ crc_ind.body.pdus[0].rx_ue_info.rnti = 0; //??
+ crc_ind.body.pdus[0].rel8_pdu.crc_flag = 1;
+ (instance->callbacks.fapi_crc_ind)(&(instance->_public), &crc_ind);
- fapi_crc_ind_t crc_ind;
- crc_ind.header.message_id = FAPI_CRC_INDICATION;
- crc_ind.header.length = 0; //??;
- crc_ind.sfn_sf = sfn_sf;
- crc_ind.body.number_of_crcs = 1;
- crc_ind.body.pdus[0].rx_ue_info.handle = 0; //??
- crc_ind.body.pdus[0].rx_ue_info.rnti = 0; //??
- crc_ind.body.pdus[0].rel8_pdu.crc_flag = 1;
+ if(!instance->fapi->rx_buffer_empty()) {
+ fapi_rx_ulsch_ind_t rx_ind;
+ memset(&rx_ind, 0, sizeof(rx_ind));
+ rx_ind.header.message_id = FAPI_RX_ULSCH_INDICATION;
+ rx_ind.sfn_sf = sfn_sf;
+ phy_pdu *buff = 0;
+ int i = 0;
+ std::list free_list;
- (instance->callbacks.fapi_crc_ind)(&(instance->_public), &crc_ind);
+ do {
+ buff = instance->fapi->pop_rx_buffer();
- if(!instance->fapi->rx_buffer_empty())
- {
- fapi_rx_ulsch_ind_t rx_ind;
- memset(&rx_ind, 0, sizeof(rx_ind));
- rx_ind.header.message_id = FAPI_RX_ULSCH_INDICATION;
- rx_ind.sfn_sf = sfn_sf;
+ if(buff != 0) {
+ if(buff->len == 0) {
+ printf("[FAPI] Buffer length = 0\n");
+ }
+ rx_ind.body.pdus[i].rx_ue_info.handle = 0xDEADBEEF;
+ rx_ind.body.pdus[i].rx_ue_info.rnti = 0x4242;
+ rx_ind.body.pdus[i].rel8_pdu.length = buff->len;
+ //rx_ind.pdus[i].rel8_pdu.data_offset;
+ //rx_ind.pdus[i].rel8_pdu.ul_cqi;
+ //rx_ind.pdus[i].rel8_pdu.timing_advance;
+ rx_ind.body.data[i] = buff->buffer;
+ rx_ind.body.number_of_pdus++;
+ i++;
+ instance->fapi->byte_count += buff->len;
+ free_list.push_back(buff);
+ }
+ } while(buff != 0 && i < 8);
- phy_pdu* buff = 0;
- int i = 0;
- std::list free_list;
- do
- {
- buff = instance->fapi->pop_rx_buffer();
- if(buff != 0)
- {
- if(buff->len == 0)
- {
- printf("[FAPI] Buffer length = 0\n");
- }
+ (instance->callbacks.fapi_rx_ulsch_ind)(&(instance->_public), &rx_ind);
- rx_ind.body.pdus[i].rx_ue_info.handle = 0xDEADBEEF;
- rx_ind.body.pdus[i].rx_ue_info.rnti = 0x4242;
+ for(phy_pdu *pdu : free_list) {
+ instance->fapi->release_phy_pdu(pdu);
+ //free(tx_req.tx_request_body.tx_pdu_list[j].segments[0].segment_data);
+ }
+ } else {
+ fapi_rx_ulsch_ind_t rx_ind;
+ memset(&rx_ind, 0, sizeof(rx_ind));
+ rx_ind.header.message_id = FAPI_RX_ULSCH_INDICATION;
+ rx_ind.sfn_sf = sfn_sf;
+ (instance->callbacks.fapi_rx_ulsch_ind)(&(instance->_public), &rx_ind);
+ }
- rx_ind.body.pdus[i].rel8_pdu.length = buff->len;
- //rx_ind.pdus[i].rel8_pdu.data_offset;
- //rx_ind.pdus[i].rel8_pdu.ul_cqi;
- //rx_ind.pdus[i].rel8_pdu.timing_advance;
-
- rx_ind.body.data[i] = buff->buffer;
-
- rx_ind.body.number_of_pdus++;
- i++;
-
- instance->fapi->byte_count += buff->len;
-
- free_list.push_back(buff);
- }
- }while(buff != 0 && i < 8);
-
- (instance->callbacks.fapi_rx_ulsch_ind)(&(instance->_public), &rx_ind);
-
- for(phy_pdu* pdu : free_list)
- {
- instance->fapi->release_phy_pdu(pdu);
- //free(tx_req.tx_request_body.tx_pdu_list[j].segments[0].segment_data);
- }
- }
- else
- {
- fapi_rx_ulsch_ind_t rx_ind;
- memset(&rx_ind, 0, sizeof(rx_ind));
- rx_ind.header.message_id = FAPI_RX_ULSCH_INDICATION;
- rx_ind.sfn_sf = sfn_sf;
- (instance->callbacks.fapi_rx_ulsch_ind)(&(instance->_public), &rx_ind);
- }
-
-
- fapi_rx_cqi_ind_t cqi_ind;
- cqi_ind.sfn_sf = sfn_sf;
- (instance->callbacks.fapi_rx_cqi_ind)(&(instance->_public), &cqi_ind);
-
- fapi_rx_sr_ind_t sr_ind;
- sr_ind.sfn_sf = sfn_sf;
- (instance->callbacks.fapi_rx_sr_ind)(&(instance->_public), &sr_ind);
-
- fapi_rach_ind_t rach_ind;
- rach_ind.sfn_sf = sfn_sf;
- (instance->callbacks.fapi_rach_ind)(&(instance->_public), &rach_ind);
-
- fapi_srs_ind_t srs_ind;
- srs_ind.sfn_sf = sfn_sf;
- (instance->callbacks.fapi_srs_ind)(&(instance->_public), &srs_ind);
- /*
- nfapi_lbt_dl_indication_t lbt_ind;
- memset(&lbt_ind, 0, sizeof(lbt_ind));
- lbt_ind.header.message_id = NFAPI_LBT_DL_INDICATION;
- lbt_ind.header.phy_id = config->phy_id;
- lbt_ind.sfn_sf = sfn_sf;
- nfapi_pnf_p7_lbt_dl_ind(config, &lbt_ind);
-
- vendor_ext_p7_ind ve_p7_ind;
- memset(&ve_p7_ind, 0, sizeof(ve_p7_ind));
- ve_p7_ind.header.message_id = P7_VENDOR_EXT_IND;
- ve_p7_ind.header.phy_id = config->phy_id;
- ve_p7_ind.error_code = NFAPI_MSG_OK;
- nfapi_pnf_p7_vendor_extension(config, &(ve_p7_ind.header));
- */
-
- fapi_nb_harq_ind_t nb_harq_ind;
- nb_harq_ind.sfn_sf = sfn_sf;
- (instance->callbacks.fapi_nb_harq_ind)(&(instance->_public), &nb_harq_ind);
-
- fapi_nrach_ind_t nrach_ind;
- nrach_ind.sfn_sf = sfn_sf;
- (instance->callbacks.fapi_nrach_ind)(&(instance->_public), &nrach_ind);
+ fapi_rx_cqi_ind_t cqi_ind;
+ cqi_ind.sfn_sf = sfn_sf;
+ (instance->callbacks.fapi_rx_cqi_ind)(&(instance->_public), &cqi_ind);
+ fapi_rx_sr_ind_t sr_ind;
+ sr_ind.sfn_sf = sfn_sf;
+ (instance->callbacks.fapi_rx_sr_ind)(&(instance->_public), &sr_ind);
+ fapi_rach_ind_t rach_ind;
+ rach_ind.sfn_sf = sfn_sf;
+ (instance->callbacks.fapi_rach_ind)(&(instance->_public), &rach_ind);
+ fapi_srs_ind_t srs_ind;
+ srs_ind.sfn_sf = sfn_sf;
+ (instance->callbacks.fapi_srs_ind)(&(instance->_public), &srs_ind);
+ /*
+ nfapi_lbt_dl_indication_t lbt_ind;
+ memset(&lbt_ind, 0, sizeof(lbt_ind));
+ lbt_ind.header.message_id = NFAPI_LBT_DL_INDICATION;
+ lbt_ind.header.phy_id = config->phy_id;
+ lbt_ind.sfn_sf = sfn_sf;
+ nfapi_pnf_p7_lbt_dl_ind(config, &lbt_ind);
+ vendor_ext_p7_ind ve_p7_ind;
+ memset(&ve_p7_ind, 0, sizeof(ve_p7_ind));
+ ve_p7_ind.header.message_id = P7_VENDOR_EXT_IND;
+ ve_p7_ind.header.phy_id = config->phy_id;
+ ve_p7_ind.error_code = NFAPI_MSG_OK;
+ nfapi_pnf_p7_vendor_extension(config, &(ve_p7_ind.header));
+ */
+ fapi_nb_harq_ind_t nb_harq_ind;
+ nb_harq_ind.sfn_sf = sfn_sf;
+ (instance->callbacks.fapi_nb_harq_ind)(&(instance->_public), &nb_harq_ind);
+ fapi_nrach_ind_t nrach_ind;
+ nrach_ind.sfn_sf = sfn_sf;
+ (instance->callbacks.fapi_nrach_ind)(&(instance->_public), &nrach_ind);
}
-void* fapi_thread_start(void* ptr)
-{
- set_thread_priority(81);
+void *fapi_thread_start(void *ptr) {
+ set_thread_priority(81);
+ fapi_internal_t *instance = (fapi_internal_t *)ptr;
+ uint16_t sfn_sf_dec = 0;
+ uint32_t last_tv_usec = 0;
+ uint32_t last_tv_sec = 0;
+ uint32_t millisec;
+ uint32_t last_millisec = -1;
+ uint16_t catchup = 0;
- fapi_internal_t* instance = (fapi_internal_t*)ptr;
- uint16_t sfn_sf_dec = 0;
- uint32_t last_tv_usec = 0;
- uint32_t last_tv_sec = 0;
+ while(1) {
+ // get the time
+ struct timeval sf_start;
+ (void)gettimeofday(&sf_start, NULL);
+ uint16_t sfn_sf = ((((sfn_sf_dec) / 10) << 4) | (((sfn_sf_dec) - (((sfn_sf_dec) / 10) * 10)) & 0xF));
+ // increment the sfn/sf - for the next subframe
+ sfn_sf_dec++;
- uint32_t millisec;
- uint32_t last_millisec = -1;
- uint16_t catchup = 0;
+ if(sfn_sf_dec > 10239)
+ sfn_sf_dec = 0;
- while(1)
- {
- // get the time
- struct timeval sf_start;
- (void)gettimeofday(&sf_start, NULL);
-
- uint16_t sfn_sf = ((((sfn_sf_dec) / 10) << 4) | (((sfn_sf_dec) - (((sfn_sf_dec) / 10) * 10)) & 0xF));
- // increment the sfn/sf - for the next subframe
- sfn_sf_dec++;
- if(sfn_sf_dec > 10239)
- sfn_sf_dec = 0;
+ fapi_subframe_ind_t ind;
+ ind.sfn_sf = sfn_sf;
-
- fapi_subframe_ind_t ind;
- ind.sfn_sf = sfn_sf;
+ if(instance->fapi->first_dl_config)
+ send_uplink_indications(instance, sfn_sf);
- if(instance->fapi->first_dl_config)
- send_uplink_indications(instance, sfn_sf);
+ if(instance->tick == 1000) {
+ if(instance->tx_byte_count > 0) {
+ printf("[FAPI] Tx rate %d bytes/sec\n", instance->tx_byte_count);
+ instance->tx_byte_count = 0;
+ }
- if(instance->tick == 1000)
- {
- if(instance->tx_byte_count > 0)
- {
- printf("[FAPI] Tx rate %d bytes/sec\n", instance->tx_byte_count);
- instance->tx_byte_count = 0;
- }
-
- instance->tick = 0;
- }
+ instance->tick = 0;
+ }
- instance->tick++;
+ instance->tick++;
+ (instance->callbacks.fapi_subframe_ind)(&(instance->_public), &ind);
+ {
+ phy_pdu *pdu = instance->fapi->allocate_phy_pdu();
+ int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, MSG_DONTWAIT, 0, 0);
- (instance->callbacks.fapi_subframe_ind)(&(instance->_public), &ind);
+ if(len > 0) {
+ pdu->len = len;
+ instance->fapi->push_rx_buffer(pdu);
+ } else {
+ instance->fapi->release_phy_pdu(pdu);
+ }
+ }
- {
- phy_pdu* pdu = instance->fapi->allocate_phy_pdu();
- int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, MSG_DONTWAIT, 0, 0);
- if(len > 0)
- {
- pdu->len = len;
- instance->fapi->push_rx_buffer(pdu);
- }
- else
- {
- instance->fapi->release_phy_pdu(pdu);
- }
- }
-
+ if(catchup) {
+ catchup--;
+ } else {
+ struct timespec now_ts;
+ struct timespec sleep_ts;
+ struct timespec sleep_rem_ts;
+ // get the current time
+ clock_gettime(CLOCK_MONOTONIC, &now_ts);
+ // determine how long to sleep before the start of the next 1ms
+ sleep_ts.tv_sec = 0;
+ sleep_ts.tv_nsec = 1e6 - (now_ts.tv_nsec % 1000000);
+ int nanosleep_result = nanosleep(&sleep_ts, &sleep_rem_ts);
- if(catchup)
- {
- catchup--;
- }
- else
- {
- struct timespec now_ts;
- struct timespec sleep_ts;
- struct timespec sleep_rem_ts;
+ if(nanosleep_result != 0)
+ printf("*** nanosleep failed or was interrupted\n");
- // get the current time
- clock_gettime(CLOCK_MONOTONIC, &now_ts);
+ clock_gettime(CLOCK_MONOTONIC, &now_ts);
+ millisec = now_ts.tv_nsec / 1e6;
+ if(last_millisec != -1 && ((last_millisec + 1 ) % 1000) != millisec) {
+ printf("*** missing millisec %d %d\n", last_millisec, millisec);
+ catchup = millisec - last_millisec - 1;
+ }
- // determine how long to sleep before the start of the next 1ms
- sleep_ts.tv_sec = 0;
- sleep_ts.tv_nsec = 1e6 - (now_ts.tv_nsec % 1000000);
-
- int nanosleep_result = nanosleep(&sleep_ts, &sleep_rem_ts);
-
- if(nanosleep_result != 0)
- printf("*** nanosleep failed or was interrupted\n");
-
-
- clock_gettime(CLOCK_MONOTONIC, &now_ts);
- millisec = now_ts.tv_nsec / 1e6;
-
- if(last_millisec != -1 && ((last_millisec + 1 ) % 1000) != millisec)
- {
- printf("*** missing millisec %d %d\n", last_millisec, millisec);
- catchup = millisec - last_millisec - 1;
- }
-
- last_millisec = millisec;
- }
- }
+ last_millisec = millisec;
+ }
+ }
}
extern "C"
{
- fapi_t* fapi_create(fapi_cb_t* callbacks, fapi_config_t* config)
- {
- fapi_internal_t* instance = (fapi_internal*)calloc(1, sizeof(fapi_internal_t));
- instance->callbacks = *callbacks;
- instance->config = *config;
- instance->state = 0;
+ fapi_t *fapi_create(fapi_cb_t *callbacks, fapi_config_t *config) {
+ fapi_internal_t *instance = (fapi_internal *)calloc(1, sizeof(fapi_internal_t));
+ instance->callbacks = *callbacks;
+ instance->config = *config;
+ instance->state = 0;
+ instance->fapi = new fapi_private();
+ return (fapi_t *)instance;
+ }
- instance->fapi = new fapi_private();
+ void fapi_destroy(fapi_t *fapi) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ delete instance->fapi;
+ free(instance);
+ }
- return (fapi_t*)instance;
- }
-
- void fapi_destroy(fapi_t* fapi)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
-
- delete instance->fapi;
- free(instance);
- }
+ void *fapi_rx_thread_start(void *ptr) {
+ set_thread_priority(60);
+ fapi_internal_t *instance = (fapi_internal_t *)ptr;
- void* fapi_rx_thread_start(void* ptr)
- {
- set_thread_priority(60);
+ while(1) {
+ phy_pdu *pdu = instance->fapi->allocate_phy_pdu();
+ int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, 0, 0, 0);
- fapi_internal_t* instance = (fapi_internal_t*)ptr;
+ if(len > 0) {
+ pdu->len = len;
+ instance->fapi->push_rx_buffer(pdu);
+ } else {
+ instance->fapi->release_phy_pdu(pdu);
+ }
+ }
+ }
- while(1)
- {
- phy_pdu* pdu = instance->fapi->allocate_phy_pdu();
- int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, 0, 0, 0);
- if(len > 0)
- {
- pdu->len = len;
- instance->fapi->push_rx_buffer(pdu);
- }
- else
- {
- instance->fapi->release_phy_pdu(pdu);
- }
+ void fapi_start_data(fapi_t *fapi, unsigned rx_port, const char *tx_address, unsigned tx_port) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ printf("[FAPI] Rx Data from %u\n", rx_port);
+ printf("[FAPI] Tx Data to %s:%u\n", tx_address, tx_port);
+ instance->rx_sock = socket(AF_INET, SOCK_DGRAM, 0);
- }
- }
+ if(instance->rx_sock < 0) {
+ printf("[FAPI] Failed to create socket\n");
+ return;
+ }
- void fapi_start_data(fapi_t* fapi, unsigned rx_port, const char* tx_address, unsigned tx_port)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
+ struct sockaddr_in addr;
- printf("[FAPI] Rx Data from %d\n", rx_port);
- printf("[FAPI] Tx Data to %s:%d\n", tx_address, tx_port);
+ memset(&addr, 0, sizeof(addr));
- instance->rx_sock = socket(AF_INET, SOCK_DGRAM, 0);
-
- if(instance->rx_sock < 0)
- {
- printf("[FAPI] Failed to create socket\n");
- return;
- }
+ addr.sin_family = AF_INET;
- struct sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_port = htons(rx_port);
- addr.sin_addr.s_addr = INADDR_ANY;
-
- int bind_result = bind(instance->rx_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
-
- if(bind_result == -1)
- {
- printf("[FAPI] Failed to bind to port %d\n", rx_port);
- close(instance->rx_sock);
- return ;
- }
+ addr.sin_port = htons(rx_port);
- instance->tx_sock = socket(AF_INET, SOCK_DGRAM, 0);
- instance->tx_addr.sin_family = AF_INET;
- instance->tx_addr.sin_port = htons(tx_port);
- instance->tx_addr.sin_addr.s_addr = inet_addr(tx_address);
+ addr.sin_addr.s_addr = INADDR_ANY;
- }
+ int bind_result = bind(instance->rx_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
+
+ if(bind_result == -1) {
+ printf("[FAPI] Failed to bind to port %u\n", rx_port);
+ close(instance->rx_sock);
+ return ;
+ }
+
+ instance->tx_sock = socket(AF_INET, SOCK_DGRAM, 0);
+ instance->tx_addr.sin_family = AF_INET;
+ instance->tx_addr.sin_port = htons(tx_port);
+ instance->tx_addr.sin_addr.s_addr = inet_addr(tx_address);
+ }
- void fill_tlv(fapi_tlv_t tlvs[], uint8_t count, uint8_t tag, uint8_t len, uint16_t value)
- {
- tlvs[count].tag = tag;
- tlvs[count].value = value;
- tlvs[count].length = len;
-
- }
+ void fill_tlv(fapi_tlv_t tlvs[], uint8_t count, uint8_t tag, uint8_t len, uint16_t value) {
+ tlvs[count].tag = tag;
+ tlvs[count].value = value;
+ tlvs[count].length = len;
+ }
- int fapi_param_request(fapi_t* fapi, fapi_param_req_t* req)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
-
- fapi_param_resp_t resp;
- resp.header.message_id = FAPI_PARAM_RESPONSE;
+ int fapi_param_request(fapi_t *fapi, fapi_param_req_t *req) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ fapi_param_resp_t resp;
+ resp.header.message_id = FAPI_PARAM_RESPONSE;
+ resp.error_code = FAPI_MSG_OK;
+ resp.number_of_tlvs = 0;
+ fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_STATE_TAG, 2, instance->state);
- resp.error_code = FAPI_MSG_OK;
+ if(instance->state == 0) {
+ if(instance->config.duplex_mode == 0) {
+ // -- TDD
+ // Downlink Bandwidth Support
+ // Uplink Bandwidth Support
+ // Downlink Modulation Support
+ // Uplink Modulation Support
+ // PHY Antenna Capability
+ // Release Capability
+ // MBSFN Capability
+ } else if(instance->config.duplex_mode == 1) {
+ // -- FDD
+ // Downlink Bandwidth Support
+ fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG, 2, instance->config.dl_channel_bw_support);
+ // Uplink Bandwidth Support
+ fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG, 2, instance->config.ul_channel_bw_support);
+ // Downlink Modulation Support
+ // Uplink Modulation Support
+ // PHY Antenna Capability
+ // Release Capability
+ // MBSFN Capability
+ // LAA Capability
+ }
+ } else {
+ if(instance->config.duplex_mode == 0) {
+ // -- TDD
+ // Downlink Bandwidth Support
+ // Uplink Bandwidth Support
+ // Downlink Modulation Support
+ // Uplink Modulation Support
+ // PHY Antenna Capability
+ // Release Capability
+ // MBSFN Capability
+ // Duplexing Mode
+ // PCFICH Power Offset
+ // P-B
+ // DL Cyclic Prefix Type
+ // UL Cyclic Prefix Type
+ // RF Config
+ // PHICH Config
+ // SCH Config
+ // PRACH Config
+ // PUSCH Config
+ // PUCCH Config
+ // SRS Config
+ // Uplink Reference Signal Config
+ // TDD Frame Structure Config
+ // Data Report Mode
+ } else if(instance->config.duplex_mode == 1) {
+ // FDD
+ // Downlink Bandwidth Support
+ // Uplink Bandwidth Support
+ // Downlink Modulation Support
+ // Uplink Modulation Support
+ // PHY Antenna Capability
+ // Release Capability
+ // MBSFN Capability
+ // LAA Capability
+ // Duplexing Mode
+ // PCFICH Power Offset
+ // P-B
+ // DL Cyclic Prefix Type
+ // UL Cyclic Prefix Type
+ // RF Config
+ // PHICH Config
+ // SCH Config
+ // PRACH Config
+ // PUSCH Config
+ // PUCCH Config
+ // SRS Config
+ // Uplink Reference Signal Config
+ // Data Report Mode
+ }
+ }
- resp.number_of_tlvs = 0;
- fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_STATE_TAG, 2, instance->state);
+ //todo fill
+ (instance->callbacks.fapi_param_response)(fapi, &resp);
+ return 0;
+ }
+ int fapi_config_request(fapi_t *fapi, fapi_config_req_t *req) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ fapi_config_resp_t resp;
+ resp.header.message_id = FAPI_CONFIG_RESPONSE;
+ resp.error_code = FAPI_MSG_OK;
+ (instance->callbacks.fapi_config_response)(fapi, &resp);
+ return 0;
+ }
- if(instance->state == 0)
- {
- if(instance->config.duplex_mode == 0)
- {
- // -- TDD
- // Downlink Bandwidth Support
- // Uplink Bandwidth Support
- // Downlink Modulation Support
- // Uplink Modulation Support
- // PHY Antenna Capability
- // Release Capability
- // MBSFN Capability
- }
- else if(instance->config.duplex_mode == 1)
- {
- // -- FDD
- // Downlink Bandwidth Support
- fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG, 2, instance->config.dl_channel_bw_support);
- // Uplink Bandwidth Support
- fill_tlv(resp.tlvs, resp.number_of_tlvs++, FAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG, 2, instance->config.ul_channel_bw_support);
- // Downlink Modulation Support
- // Uplink Modulation Support
- // PHY Antenna Capability
- // Release Capability
- // MBSFN Capability
- // LAA Capability
- }
- }
- else
- {
- if(instance->config.duplex_mode == 0)
- {
- // -- TDD
- // Downlink Bandwidth Support
- // Uplink Bandwidth Support
- // Downlink Modulation Support
- // Uplink Modulation Support
- // PHY Antenna Capability
- // Release Capability
- // MBSFN Capability
- // Duplexing Mode
- // PCFICH Power Offset
- // P-B
- // DL Cyclic Prefix Type
- // UL Cyclic Prefix Type
- // RF Config
- // PHICH Config
- // SCH Config
- // PRACH Config
- // PUSCH Config
- // PUCCH Config
- // SRS Config
- // Uplink Reference Signal Config
- // TDD Frame Structure Config
- // Data Report Mode
- }
- else if(instance->config.duplex_mode == 1)
- {
- // FDD
- // Downlink Bandwidth Support
- // Uplink Bandwidth Support
- // Downlink Modulation Support
- // Uplink Modulation Support
- // PHY Antenna Capability
- // Release Capability
- // MBSFN Capability
- // LAA Capability
- // Duplexing Mode
- // PCFICH Power Offset
- // P-B
- // DL Cyclic Prefix Type
- // UL Cyclic Prefix Type
- // RF Config
- // PHICH Config
- // SCH Config
- // PRACH Config
- // PUSCH Config
- // PUCCH Config
- // SRS Config
- // Uplink Reference Signal Config
- // Data Report Mode
- }
- }
+ int fapi_start_request(fapi_t *fapi, fapi_start_req_t *req) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ pthread_t fapi_thread;
+ pthread_create(&fapi_thread, NULL, &fapi_thread_start, instance);
+ return 0;
+ }
+ int fapi_dl_config_request(fapi_t *fapi, fapi_dl_config_req_t *req) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ instance->fapi->first_dl_config = true;
+ return 0;
+ }
+ int fapi_ul_config_request(fapi_t *fapi, fapi_ul_config_req_t *req) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ return 0;
+ }
+ int fapi_hi_dci0_request(fapi_t *fapi, fapi_hi_dci0_req_t *req) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
+ return 0;
+ }
+ int fapi_tx_request(fapi_t *fapi, fapi_tx_req_t *req) {
+ fapi_internal_t *instance = (fapi_internal_t *)fapi;
- //todo fill
- (instance->callbacks.fapi_param_response)(fapi, &resp);
+ for(int i = 0; i < req->body.number_of_pdus; ++i) {
+ uint16_t len = req->body.pdus[i].pdu_length;
+ uint32_t *data = req->body.pdus[i].tlvs[0].value;
+ //printf("[FAPI] sfnsf:%d len:%d\n", req->sfn_sf,len);
+ //
+ instance->tx_byte_count += len;
+ int sendto_result = sendto(instance->tx_sock, data, len, 0, (struct sockaddr *)&(instance->tx_addr), sizeof(instance->tx_addr));
- return 0;
- }
+ if(sendto_result == -1) {
+ // error
+ }
+ }
- int fapi_config_request(fapi_t* fapi, fapi_config_req_t* req)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
-
- fapi_config_resp_t resp;
- resp.header.message_id = FAPI_CONFIG_RESPONSE;
- resp.error_code = FAPI_MSG_OK;
-
- (instance->callbacks.fapi_config_response)(fapi, &resp);
- return 0;
- }
-
- int fapi_start_request(fapi_t* fapi, fapi_start_req_t* req)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
-
- pthread_t fapi_thread;
- pthread_create(&fapi_thread, NULL, &fapi_thread_start, instance);
-
- return 0;
- }
-
- int fapi_dl_config_request(fapi_t* fapi, fapi_dl_config_req_t* req)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
- instance->fapi->first_dl_config = true;
- return 0;
- }
- int fapi_ul_config_request(fapi_t* fapi, fapi_ul_config_req_t* req)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
- return 0;
- }
- int fapi_hi_dci0_request(fapi_t* fapi, fapi_hi_dci0_req_t* req)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
- return 0;
- }
- int fapi_tx_request(fapi_t* fapi, fapi_tx_req_t* req)
- {
- fapi_internal_t* instance = (fapi_internal_t*)fapi;
-
- for(int i = 0; i < req->body.number_of_pdus; ++i)
- {
- uint16_t len = req->body.pdus[i].pdu_length;
- uint32_t* data = req->body.pdus[i].tlvs[0].value;
- //printf("[FAPI] sfnsf:%d len:%d\n", req->sfn_sf,len);
- //
- instance->tx_byte_count += len;
-
- int sendto_result = sendto(instance->tx_sock, data, len, 0, (struct sockaddr*)&(instance->tx_addr), sizeof(instance->tx_addr));
-
- if(sendto_result == -1)
- {
- // error
- }
- }
-
- return 0;
- }
+ return 0;
+ }
}
diff --git a/nfapi/open-nFAPI/pnf_sim/src/main.cpp b/nfapi/open-nFAPI/pnf_sim/src/main.cpp
index e2622cf3c3..251e2a48cb 100644
--- a/nfapi/open-nFAPI/pnf_sim/src/main.cpp
+++ b/nfapi/open-nFAPI/pnf_sim/src/main.cpp
@@ -101,7 +101,7 @@ class phy_info
{
index = 0;
id = 0;
-
+ udp = 0;
local_port = 0;
remote_addr = 0;
remote_port = 0;
@@ -178,6 +178,7 @@ class pnf_info
sync_mode = 0;
location_mode = 0;
+ location_coordinates = 0;
dl_config_timing = 0;
ul_config_timing = 0;
tx_timing = 0;
diff --git a/nfapi/open-nFAPI/vnf_sim/src/mac.cpp b/nfapi/open-nFAPI/vnf_sim/src/mac.cpp
index fa6f487be8..88898afc74 100644
--- a/nfapi/open-nFAPI/vnf_sim/src/mac.cpp
+++ b/nfapi/open-nFAPI/vnf_sim/src/mac.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Cisco Systems, Inc.
- *
+ *
* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
- *
+ *
* 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.
@@ -31,1297 +31,1130 @@
#include
#include
-uint32_t rand_range(uint32_t min, uint32_t max)
-{
- return ((rand() % (max + 1 - min)) + min);
+uint32_t rand_range(uint32_t min, uint32_t max) {
+ return ((rand() % (max + 1 - min)) + min);
}
-struct mac_pdu
-{
- mac_pdu() : buffer_len(1500), buffer(0), len(0)
- {
- buffer = (char*) malloc(buffer_len);
- }
-
- virtual ~mac_pdu()
- {
- free(buffer);
- }
+struct mac_pdu {
+ mac_pdu() : buffer_len(1500), buffer(0), len(0) {
+ buffer = (char *) malloc(buffer_len);
+ }
- unsigned buffer_len;
- char* buffer;
- unsigned len;
+ virtual ~mac_pdu() {
+ free(buffer);
+ }
+
+ unsigned buffer_len;
+ char *buffer;
+ unsigned len;
};
-class mac_private
-{
- std::mutex mutex;
- std::queue rx_buffer;
+class mac_private {
+ std::mutex mutex;
+ std::queue rx_buffer;
- std::queue free_store;
- public:
+ std::queue free_store;
+ public:
- mac_private(bool _wireshark_test_mode)
- : byte_count(0), tick(0), wireshark_test_mode(_wireshark_test_mode)
- {
+ mac_private(bool _wireshark_test_mode)
+ : byte_count(0), tick(0), wireshark_test_mode(_wireshark_test_mode) {
+ }
- }
+ mac_pdu *allocate_mac_pdu() {
+ mac_pdu *pdu = 0;
+ mutex.lock();
- mac_pdu* allocate_mac_pdu()
- {
- mac_pdu* pdu = 0;
- mutex.lock();
- if(free_store.empty())
- {
- pdu = new mac_pdu();
- }
- else
- {
- pdu = free_store.front();
- free_store.pop();
- }
- mutex.unlock();
- return pdu;
- }
+ if(free_store.empty()) {
+ pdu = new mac_pdu();
+ } else {
+ pdu = free_store.front();
+ free_store.pop();
+ }
- void release_mac_pdu(mac_pdu* pdu)
- {
- mutex.lock();
- free_store.push(pdu);
- mutex.unlock();
- }
+ mutex.unlock();
+ return pdu;
+ }
-
+ void release_mac_pdu(mac_pdu *pdu) {
+ mutex.lock();
+ free_store.push(pdu);
+ mutex.unlock();
+ }
- void push_rx_buffer(mac_pdu* buff)
- {
- mutex.lock();
- rx_buffer.push(buff);
- mutex.unlock();
- }
- mac_pdu* pop_rx_buffer()
- {
- mac_pdu* buff = 0;
- mutex.lock();
- if(!rx_buffer.empty())
- {
- buff = rx_buffer.front();
- rx_buffer.pop();
- }
- mutex.unlock();
- return buff;
- }
- uint32_t byte_count;
- uint32_t tick;
-
- bool wireshark_test_mode;
+ void push_rx_buffer(mac_pdu *buff) {
+ mutex.lock();
+ rx_buffer.push(buff);
+ mutex.unlock();
+ }
+
+ mac_pdu *pop_rx_buffer() {
+ mac_pdu *buff = 0;
+ mutex.lock();
+
+ if(!rx_buffer.empty()) {
+ buff = rx_buffer.front();
+ rx_buffer.pop();
+ }
+
+ mutex.unlock();
+ return buff;
+ }
+
+ uint32_t byte_count;
+ uint32_t tick;
+
+ bool wireshark_test_mode;
};
extern "C"
{
- typedef struct {
- mac_t _public;
+ typedef struct {
+ mac_t _public;
- int rx_sock;
- int tx_sock;
- struct sockaddr_in tx_addr;
+ int rx_sock;
+ int tx_sock;
+ struct sockaddr_in tx_addr;
- uint32_t tx_byte_count;
+ uint32_t tx_byte_count;
- mac_private* mac;
-
- } mac_internal_t;
+ mac_private *mac;
- mac_t* mac_create(uint8_t wireshark_test_mode)
- {
- mac_internal_t* instance = (mac_internal_t*)malloc(sizeof(mac_internal_t));
- instance->mac = new mac_private((wireshark_test_mode >= 1));
- return (mac_t*)instance;
- }
-
- void mac_destroy(mac_t* mac)
- {
- mac_internal_t* instance = (mac_internal_t*)mac;
- delete instance->mac;
- free(instance);
- }
-
- void* mac_rx_thread_start(void* ptr)
- {
- mac_internal_t* instance = (mac_internal_t*)ptr;
+ } mac_internal_t;
- while(1)
- {
- mac_pdu* pdu = instance->mac->allocate_mac_pdu();
- int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, 0, 0, 0);
- if(len > 0)
- {
- pdu->len = len;
- instance->mac->push_rx_buffer(pdu);
- }
- else
- {
- instance->mac->release_mac_pdu(pdu);
- }
- }
- return 0;
- }
+ mac_t *mac_create(uint8_t wireshark_test_mode) {
+ mac_internal_t *instance = (mac_internal_t *)malloc(sizeof(mac_internal_t));
+ instance->mac = new mac_private((wireshark_test_mode >= 1));
+ return (mac_t *)instance;
+ }
- void mac_start_data(mac_t* mac, unsigned rx_port, const char* tx_address, unsigned tx_port)
- {
- mac_internal_t* instance = (mac_internal_t*)mac;
+ void mac_destroy(mac_t *mac) {
+ mac_internal_t *instance = (mac_internal_t *)mac;
+ delete instance->mac;
+ free(instance);
+ }
- printf("[MAC] Rx Data from %d\n", rx_port);
- printf("[MAC] Tx Data to %s.%d\n", tx_address, tx_port);
+ void *mac_rx_thread_start(void *ptr) {
+ mac_internal_t *instance = (mac_internal_t *)ptr;
- instance->rx_sock = socket(AF_INET, SOCK_DGRAM, 0);
-
- if(instance->rx_sock < 0)
- {
- printf("[MAC] Failed to create socket\n");
- return;
- }
+ while(1) {
+ mac_pdu *pdu = instance->mac->allocate_mac_pdu();
+ int len = recvfrom(instance->rx_sock, pdu->buffer, pdu->buffer_len, 0, 0, 0);
- struct sockaddr_in addr;
- memset(&addr, 0, sizeof(0));
- addr.sin_family = AF_INET;
- addr.sin_port = htons(rx_port);
- addr.sin_addr.s_addr = INADDR_ANY;
-
- if(bind(instance->rx_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0)
- {
- printf("[MAC] Failed to bind to %d\n", rx_port);
- close(instance->rx_sock);
- return;
- }
+ if(len > 0) {
+ pdu->len = len;
+ instance->mac->push_rx_buffer(pdu);
+ } else {
+ instance->mac->release_mac_pdu(pdu);
+ }
+ }
- pthread_t mac_rx_thread;
- pthread_create(&mac_rx_thread, NULL, &mac_rx_thread_start, instance);
+ return 0;
+ }
- instance->tx_sock = socket(AF_INET, SOCK_DGRAM, 0);
- instance->tx_addr.sin_family = AF_INET;
- instance->tx_addr.sin_port = htons(tx_port);
- instance->tx_addr.sin_addr.s_addr = inet_addr(tx_address);
- }
+ void mac_start_data(mac_t *mac, unsigned rx_port, const char *tx_address, unsigned tx_port) {
+ mac_internal_t *instance = (mac_internal_t *)mac;
+ printf("[MAC] Rx Data from %u\n", rx_port);
+ printf("[MAC] Tx Data to %s.%u\n", tx_address, tx_port);
+ instance->rx_sock = socket(AF_INET, SOCK_DGRAM, 0);
+ if(instance->rx_sock < 0) {
+ printf("[MAC] Failed to create socket\n");
+ return;
+ }
-
- void generate_test_subframe(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf)
- {
- //mac_internal_t* instance = (mac_internal_t*)mac;
-
- uint8_t max_num_dl_pdus = 50;
- nfapi_dl_config_request_pdu_t dl_config_pdus[max_num_dl_pdus];
- memset(&dl_config_pdus, 0, sizeof(dl_config_pdus));
-
- nfapi_dl_config_request_t dl_config_req;
- memset(&dl_config_req, 0, sizeof(dl_config_req));
- dl_config_req.header.message_id = NFAPI_DL_CONFIG_REQUEST;
- dl_config_req.header.phy_id = phy_id;
- dl_config_req.sfn_sf = sfn_sf;
- dl_config_req.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
-
- dl_config_req.dl_config_request_body.number_pdu = rand_range(4, max_num_dl_pdus);
-
- uint16_t i = 0;
- for(i = 0; i < dl_config_req.dl_config_request_body.number_pdu; ++i)
- {
- dl_config_pdus[i].pdu_type = rand_range(0, 11);
-
- switch(dl_config_pdus[i].pdu_type)
- {
- case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE:
- {
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.dci_format = rand_range(0, 9);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx = rand_range(0, 255);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = rand_range(0, 32);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti = rand_range(0, (uint16_t)-1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = rand_range(0, 320000);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = rand_range(0, 31);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = rand_range(0, 3);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = rand_range(0, 31);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = rand_range(0, 31);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_2 = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.harq_process = rand_range(0, 31);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tpmi = rand_range(0, 15);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.pmi = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.precoding_information = rand_range(0, 63);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tpc = rand_range(0, 3);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = rand_range(0, 15);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.ngap = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_size_index = rand_range(0, 31);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.downlink_power_offset = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.allocate_prach_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.preamble_index = rand_range(0, 63);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.prach_mask_index = rand_range(0, 15);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = rand_range(0, 3);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = rand_range(0, 10000);
-
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.mcch_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.mcch_change_notification = rand_range(0, 255);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.scrambling_identity = rand_range(0, 1);
-
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.carrier_indicator = rand_range(0, 7);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.srs_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.srs_request = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.antenna_ports_scrambling_and_layers = rand_range(0, 15);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.n_dl_rb = rand_range(0, 100);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.harq_ack_resource_offset = rand_range(0, 3);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.pdsch_re_mapping_quasi_co_location_indicator = rand_range(0, 3);
-
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.primary_cell_type = rand_range(0, 2);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.number_ul_dl_configurations = 2;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[0] = rand_range(1, 5);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[1] = rand_range(1, 5);
-
-
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_configuration = rand_range(0, 255);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.initial_lbt_sf = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.codebook_size_determination = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.drms_table_flag = rand_range(0, 1);
-
- // if the tpm extention is present of not.
- if(rand_range(0, 1))
- {
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag = rand_range(0, 1);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_prb_per_subband = rand_range(0, 8);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands = rand_range(0, 13);
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas = 1; // rand_range(0, 8);
-
- for(int j = 0; j < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands; ++j)
- {
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].subband_index = j;
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].scheduled_ues = 1; //rand_range(1, 4);
-
- for(int k = 0; k < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas; ++k)
- for(int l = 0; l < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].scheduled_ues; ++l)
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].precoding_value[k][l] = rand_range(0, 65535);
- }
- }
- else
- {
- dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag = 0;
- }
-
- }
- break;
-
- case NFAPI_DL_CONFIG_BCH_PDU_TYPE:
- {
- dl_config_pdus[i].bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG;
- dl_config_pdus[i].bch_pdu.bch_pdu_rel8.length = rand_range(0, 42);
- dl_config_pdus[i].bch_pdu.bch_pdu_rel8.pdu_index = rand_range(0, 65535);
- dl_config_pdus[i].bch_pdu.bch_pdu_rel8.transmission_power = rand_range(0, 10000);
- }
- break;
-
- case NFAPI_DL_CONFIG_MCH_PDU_TYPE:
- {
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG;
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.length = rand_range(0, 42);
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.pdu_index = rand_range(0, 65535);
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.rnti = 0xFFFD;
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.resource_allocation_type = 0;
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.resource_block_coding = 0;
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.modulation = rand_range(0, 8);
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.transmission_power = rand_range(0, 10000);
- dl_config_pdus[i].mch_pdu.mch_pdu_rel8.mbsfn_area_id = rand_range(0, 255);
- }
- break;
-
- case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE:
- {
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.length = rand_range(0, 42);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.pdu_index = rand_range(0, 65535);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.rnti = rand_range(1, 65535);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = rand_range(0, 5);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = rand_range(0, 32000);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.modulation = rand_range(2, 8);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.redundancy_version = rand_range(0, 3);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transport_blocks = rand_range(1, 2);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = rand_range(0, 13);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.number_of_layers = rand_range(1, 8);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 2; //rand_range(0, 13);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.codebook_index[0] = rand_range(0, 15);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.codebook_index[1] = rand_range(0, 15);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = rand_range(0, 14);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.pa = rand_range(0, 7);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.ngap = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.nprb = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transmission_mode = rand_range(1, 10);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 2; //rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 2; //rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].subband_index = rand_range(0, 4);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].num_antennas = 1;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].bf_value[0] = rand_range(0, 128);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].subband_index = rand_range(0, 4);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].num_antennas = 1;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].bf_value[0] = rand_range(0, 128);
-
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel9.nscid = rand_range(0, 1);
-
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_flag = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_resource_config_r10 = 0;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_zero_tx_power_resource_config_bitmap_r10 = rand_range(0, 65535);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_number_nzp_configuration = 1;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_resource_config[0] = rand_range(0, 31);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.pdsch_start = rand_range(0, 4);
-
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.drms_config_flag = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.drms_scrambling = rand_range(0, 503);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.csi_config_flag = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.csi_scrambling = rand_range(0, 503);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_flag = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_atenna_ports = rand_range(1,4);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_freq_shift = rand_range(0, 5);
-
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG;
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.altcqi_table_r12 = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.maxlayers = rand_range(1, 8);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.n_dl_harq = rand_range(0, 255);
-
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.dwpts_symbols = rand_range(3, 14);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.initial_lbt_sf = rand_range(0, 1);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.ue_type = rand_range(0, 2);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = rand_range(0, 2);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
- dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = rand_range(0, 1);
- }
- break;
-
- case NFAPI_DL_CONFIG_PCH_PDU_TYPE:
- {
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.length = rand_range(0, 42);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.pdu_index = rand_range(0, 65535);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.p_rnti = 0xFFFE;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.resource_allocation_type = rand_range(2, 6);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.resource_block_coding = rand_range(0, 34000);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.mcs = 0;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.redundancy_version = 0;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.number_of_transport_blocks = 1;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transmission_scheme = rand_range(1, 6);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.number_of_layers = rand_range(1, 4);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.codebook_index = 0;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.ue_category_capacity = rand_range(0, 14);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.pa = rand_range(0, 7);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transmission_power = rand_range(0, 10000);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.nprb = rand_range(0, 1);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel8.ngap = rand_range(0, 1);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG;
- dl_config_pdus[i].pch_pdu.pch_pdu_rel13.ue_mode = rand_range(0, 1);
- dl_config_pdus[i].pch_pdu.pch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
- }
- break;
-
- case NFAPI_DL_CONFIG_PRS_PDU_TYPE:
- {
- dl_config_pdus[i].prs_pdu.prs_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG;
- dl_config_pdus[i].prs_pdu.prs_pdu_rel9.transmission_power = rand_range(0, 10000);
- dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_bandwidth = rand_range(6, 100);
- dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_cyclic_prefix_type = rand_range(0, 1);
- dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_muting = rand_range(0, 1);
- }
- break;
-
- case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE:
- {
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG;
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_antenna_port_count_r10 = rand_range(1, 16);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config_r10 = 0;
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.transmission_power = rand_range(0, 10000);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_zero_tx_power_resource_config_bitmap_r10 = rand_range(0, 8);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_number_of_nzp_configuration = 2;
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config[0] = rand_range(0, 31);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config[1] = rand_range(0, 31);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG;
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.csi_rs_class = rand_range(0, 2);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.cdm_type = rand_range(0, 1);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.num_bf_vector = 0; // set to zero as not clear how to handle bf value array
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.bf_vector[0].csi_rs_resource_index = rand_range(0, 7);
- dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.bf_vector[0].bf_value[0] = 42;
- }
- break;
-
- case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE:
- {
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.dci_format = rand_range(0, 9);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.cce_idx = rand_range(0, 255);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.aggregation_level = rand_range(0, 32);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.rnti = rand_range(0, (uint16_t)-1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.resource_allocation_type = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.resource_block_coding = rand_range(0, 320000);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.mcs_1 = rand_range(0, 31);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.redundancy_version_1 = rand_range(0, 3);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.new_data_indicator_1 = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.mcs_2 = rand_range(0, 31);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.redundancy_version_2 = rand_range(0, 31);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.new_data_indicator_2 = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.harq_process = rand_range(0, 31);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tpmi = rand_range(0, 15);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.pmi = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.precoding_information = rand_range(0, 63);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tpc = rand_range(0, 3);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.downlink_assignment_index = rand_range(0, 15);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.ngap = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transport_block_size_index = rand_range(0, 31);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.downlink_power_offset = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.allocate_prach_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.preamble_index = rand_range(0, 63);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.prach_mask_index = rand_range(0, 15);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.rnti_type = rand_range(0, 3);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transmission_power = rand_range(0, 10000);
-
-
-
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.mcch_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.mcch_change_notification = rand_range(0, 255);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.scrambling_identity = rand_range(0, 1);
-
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.carrier_indicator = rand_range(0, 7);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.srs_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.srs_request = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.antenna_ports_scrambling_and_layers = rand_range(0, 15);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.n_dl_rb = rand_range(0, 100);
-
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.harq_ack_resource_offset = rand_range(0, 3);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.pdsch_re_mapping_quasi_co_location_indicator = rand_range(0, 3);
-
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.primary_cell_type = rand_range(0, 2);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.number_ul_dl_configurations = 2;
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_indication[0] = rand_range(1, 5);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_indication[1] = rand_range(1, 5);
-
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.laa_end_partial_sf_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.laa_end_partial_sf_configuration = rand_range(0, 255);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.initial_lbt_sf = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.codebook_size_determination = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.drms_table_flag = rand_range(0, 1);
+ struct sockaddr_in addr;
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_resource_assignment_flag = rand_range(0, 1);
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_id = rand_range(0, 503);
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_start_symbol = rand_range(1, 4);
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb = rand_range(2, 8);
- for(int j = 0; j < dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb; ++j)
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_prb_index[j] = rand_range(0, 99);
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.subband_index = rand_range(0, 25);
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.num_antennas= rand_range(1, 4);
- for(int j = 0; j < dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb; ++j)
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.bf_value[j] = rand_range(0, 65535);
-
-
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG;
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.dwpts_symbols = rand_range(3, 14);
- dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.initial_lbt_sf = rand_range(0, 1);
- }
- break;
-
- case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE:
- {
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG;
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = rand_range(0, 15);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = rand_range(2, 6);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = rand_range(0, 14);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = rand_range(1, 4);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = rand_range(0, 22);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = rand_range(2, 24);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = rand_range(0, 4);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.rnti = rand_range(1, 65535);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = rand_range(1, 2);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = rand_range(0, 503);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = rand_range(0, 10000);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.dci_format = rand_range(10, 12);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = rand_range(0, 0xFFFF);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mcs = rand_range(0, 15);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = rand_range(1, 8);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rand_range(0, 3);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.harq_process = rand_range(0, 15);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = rand_range(0, 4);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpmi = rand_range(0, 15);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pmi = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = rand_range(0, 3);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rand_range(1, 4);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpc = rand_range(0, 3);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = rand_range(0, 4);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = rand_range(0, 15);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = rand_range(0, 63);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = rand_range(0, 15);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = rand_range(0, 3);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.srs_request = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = rand_range(0, 3);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = rand_range(0, 255);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = rand_range(0, 1);
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = rand_range(0, 8);
- for(int j = 0 ; j < dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports; ++j)
- dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.precoding_value[j] = rand_range(0, 65535);
- }
- break;
-
- case NFAPI_DL_CONFIG_NBCH_PDU_TYPE:
- {
- dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG;
- dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.length = rand_range(0, 5555);
- dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.pdu_index = rand_range(0, 65535);
- dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.transmission_power = rand_range(0, 10000);
- dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.hyper_sfn_2_lsbs = rand_range(0, 3);
- }
- break;
-
- case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE:
- {
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG;
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.length = rand_range(0, 5555);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.pdu_index = rand_range(0, 65535);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.ncce_index = rand_range(0, 1);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.aggregation_level = rand_range(1, 2);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.start_symbol = rand_range(0, 4);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.rnti_type = rand_range(0, 3);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.rnti = rand_range(1, 65535);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.scrambling_reinitialization_batch_index = rand_range(1, 4);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.dci_format = rand_range(0, 1);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.scheduling_delay = rand_range(0, 7);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.resource_assignment = rand_range(0, 7);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.repetition_number = rand_range(0, 15);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.mcs = rand_range(0, 13);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.new_data_indicator = rand_range(0, 1);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource = rand_range(0, 15);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.npdcch_order_indication = rand_range(0, 1);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.starting_number_of_nprach_repetitions = rand_range(0, 3);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.subcarrier_indication_of_nprach = rand_range(0, 63);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.paging_direct_indication_differentation_flag = rand_range(0, 1);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.direct_indication = rand_range(0, 255);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number = rand_range(0, 7);
- dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.total_dci_length_including_padding = rand_range(0, 255);
- }
- break;
-
- case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE:
- {
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG;
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.length = rand_range(0, 5555);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.pdu_index = rand_range(0, 65535);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.start_symbol = rand_range(0, 4);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.rnti_type = rand_range(0, 1);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.rnti = rand_range(1, 65535);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment = rand_range(0, 7);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.repetition_number = rand_range(0, 15);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.modulation = 2;
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment = rand_range(1, 10);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.scrambling_sequence_initialization_cinit = rand_range(0, 65535);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.sf_idx = rand_range(1, 10240);
- dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2);
- }
- break;
-
- };
- }
+ memset(&addr, 0, sizeof(sockaddr_in));
+ addr.sin_family = AF_INET;
- dl_config_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdus;
- mac->dl_config_req(mac, &dl_config_req);
-
- uint8_t num_ul_pdus = 18;
- nfapi_ul_config_request_pdu_t ul_config_pdus[num_ul_pdus];
- memset(&ul_config_pdus, 0, sizeof(ul_config_pdus));
-
- nfapi_ul_config_request_t ul_config_req;
- memset(&ul_config_req, 0, sizeof(ul_config_req));
- ul_config_req.header.message_id = NFAPI_UL_CONFIG_REQUEST;
- ul_config_req.header.phy_id = phy_id;
- ul_config_req.sfn_sf = sfn_sf;
- ul_config_req.ul_config_request_body.tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
- ul_config_req.ul_config_request_body.number_of_pdus = num_ul_pdus;
- ul_config_req.ul_config_request_body.rach_prach_frequency_resources = rand_range(0, 255);
- ul_config_req.ul_config_request_body.srs_present = rand_range(0, 1);
-
- auto ul_config_ulsch_pdu_test_gen = [](nfapi_ul_config_ulsch_pdu& ulsch_pdu)
- {
- ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG;
- ulsch_pdu.ulsch_pdu_rel8.handle = rand_range(0, 50000);
- ulsch_pdu.ulsch_pdu_rel8.size = rand_range(0, 32000);
- ulsch_pdu.ulsch_pdu_rel8.rnti = rand_range(1, 65535);
- ulsch_pdu.ulsch_pdu_rel8.resource_block_start = rand_range(0, 99);
- ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = rand_range(1, 100);
- ulsch_pdu.ulsch_pdu_rel8.modulation_type = rand_range(2, 6);
- ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
- ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = rand_range(0, 3);
- ulsch_pdu.ulsch_pdu_rel8.new_data_indication = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rand_range(0, 3);
- ulsch_pdu.ulsch_pdu_rel8.harq_process_number = rand_range(0, 15);
- ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = rand_range(0, 5);
- ulsch_pdu.ulsch_pdu_rel8.n_srs = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG;
- ulsch_pdu.ulsch_pdu_rel10.resource_allocation_type = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel10.resource_block_coding = rand_range(0, 35000);
- ulsch_pdu.ulsch_pdu_rel10.transport_blocks = rand_range(1, 2);
- ulsch_pdu.ulsch_pdu_rel10.transmission_scheme = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel10.number_of_layers = rand_range(1, 4);
- ulsch_pdu.ulsch_pdu_rel10.codebook_index = rand_range(0, 23);
- ulsch_pdu.ulsch_pdu_rel10.disable_sequence_hopping_flag = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG;
- ulsch_pdu.ulsch_pdu_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel11.npusch_identity = rand_range(0, 509);
- ulsch_pdu.ulsch_pdu_rel11.dmrs_config_flag = rand_range(0, 1);
- ulsch_pdu.ulsch_pdu_rel11.ndmrs_csh_identity = rand_range(0, 509);
- ulsch_pdu.ulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG;
- ulsch_pdu.ulsch_pdu_rel13.ue_type = rand_range(0, 2);
- ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = rand_range(1, 2048);
- ulsch_pdu.ulsch_pdu_rel13.repetition_number = rand_range(1, 2048);
- ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
- ulsch_pdu.ulsch_pdu_rel13.empty_symbols_due_to_re_tunning = rand_range(0, 8);
- };
-
- auto ul_config_cqi_ri_info_test_gen = [](nfapi_ul_config_cqi_ri_information& cqi_ri_information)
- {
- cqi_ri_information.cqi_ri_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG;
- cqi_ri_information.cqi_ri_information_rel8.dl_cqi_pmi_size_rank_1 = rand_range(0, 255);
- cqi_ri_information.cqi_ri_information_rel8.dl_cqi_pmi_size_rank_greater_1 = rand_range(0, 255);
- cqi_ri_information.cqi_ri_information_rel8.ri_size = rand_range(0, 3);
- cqi_ri_information.cqi_ri_information_rel8.delta_offset_cqi = rand_range(0, 15);
- cqi_ri_information.cqi_ri_information_rel8.delta_offset_ri = rand_range(0, 15);
+ addr.sin_port = htons(rx_port);
- cqi_ri_information.cqi_ri_information_rel9.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG;
- cqi_ri_information.cqi_ri_information_rel9.report_type = 1; // rand_range(0, 1);
- cqi_ri_information.cqi_ri_information_rel9.delta_offset_cqi = rand_range(0, 15);
- cqi_ri_information.cqi_ri_information_rel9.delta_offset_ri = rand_range(0, 15);
-
- if(cqi_ri_information.cqi_ri_information_rel9.report_type == 0)
- {
- cqi_ri_information.cqi_ri_information_rel9.periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size = rand_range(0, 255);
- cqi_ri_information.cqi_ri_information_rel9.periodic_cqi_pmi_ri_report.control_type = rand_range(0, 1);
- }
- else
- {
- cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.number_of_cc = 1;
- cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = rand_range(0, 3);
- cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[0] = rand_range(0, 255);
- }
-
- cqi_ri_information.cqi_ri_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG;
- cqi_ri_information.cqi_ri_information_rel13.report_type = rand_range(0, 1);
-
- if(cqi_ri_information.cqi_ri_information_rel13.report_type == 0)
- {
- cqi_ri_information.cqi_ri_information_rel13.periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size_2 = rand_range(255, 10000);
- }
- };
-
- auto ul_config_init_tx_params_test_gen = [](nfapi_ul_config_initial_transmission_parameters& initial_transmission_parameters)
- {
- initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG;
- initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = rand_range(0, 1);
- initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rand_range(1, 100);
- };
-
- auto ul_config_harqinfo_test_gen = [](nfapi_ul_config_ulsch_harq_information& harq_information)
- {
- harq_information.harq_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG;
- harq_information.harq_information_rel10.harq_size = rand_range(0, 21);
- harq_information.harq_information_rel10.delta_offset_harq = rand_range(0, 15);
- harq_information.harq_information_rel10.ack_nack_mode = rand_range(0, 5);
- harq_information.harq_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG;
- harq_information.harq_information_rel13.harq_size_2 = rand_range(0, 21);
- harq_information.harq_information_rel13.delta_offset_harq_2 = rand_range(0, 15);
- };
+ addr.sin_addr.s_addr = INADDR_ANY;
- auto ul_config_sr_info_test_gen = [](nfapi_ul_config_sr_information& sr_info)
- {
- sr_info.sr_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG;
- sr_info.sr_information_rel8.pucch_index = rand_range(0, 2047);
- sr_info.sr_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG;
- sr_info.sr_information_rel10.number_of_pucch_resources = rand_range(1, 2);
- sr_info.sr_information_rel10.pucch_index_p1 = rand_range(0, 2047);
- };
-
- auto ul_config_ue_info_test_gen = [](nfapi_ul_config_ue_information& ue_information)
- {
- ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG;
- ue_information.ue_information_rel8.handle = rand_range(0, 99999);
- ue_information.ue_information_rel8.rnti = rand_range(1, 65535);
- ue_information.ue_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG;
- ue_information.ue_information_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1);
- ue_information.ue_information_rel11.npusch_identity = rand_range(0, 503);
- ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG;
- ue_information.ue_information_rel13.ue_type = rand_range(0, 2);
- ue_information.ue_information_rel13.empty_symbols = rand_range(0, 2);
- ue_information.ue_information_rel13.total_number_of_repetitions = rand_range(1, 32);
- ue_information.ue_information_rel13.repetition_number = rand_range(1, 32);
- };
-
- auto ul_config_cqi_info_test_gen = [](nfapi_ul_config_cqi_information& cqi_information)
- {
- cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG;
- cqi_information.cqi_information_rel8.pucch_index = rand_range(0, 1184);
- cqi_information.cqi_information_rel8.dl_cqi_pmi_size = rand_range(0, 255);
- cqi_information.cqi_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG;
- cqi_information.cqi_information_rel10.number_of_pucch_resource = rand_range(1, 2);
- cqi_information.cqi_information_rel10.pucch_index_p1 = rand_range(0, 1184);
- cqi_information.cqi_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG;
- cqi_information.cqi_information_rel13.csi_mode = rand_range(0, 2);
- cqi_information.cqi_information_rel13.dl_cqi_pmi_size_2 = rand_range(0, 999);
- cqi_information.cqi_information_rel13.starting_prb = rand_range(0, 109);
- cqi_information.cqi_information_rel13.n_prb = rand_range(0, 7);
- cqi_information.cqi_information_rel13.cdm_index = rand_range(0, 1);
- cqi_information.cqi_information_rel13.n_srs = rand_range(0, 1);
- };
-
- auto ul_config_harq_info_test_gen = [](nfapi_ul_config_harq_information& harq_information)
- {
- harq_information.harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG;
- harq_information.harq_information_rel10_tdd.harq_size = rand_range(0, 21);
- harq_information.harq_information_rel10_tdd.ack_nack_mode = rand_range(0, 5);
- harq_information.harq_information_rel10_tdd.number_of_pucch_resources = rand_range(0, 4);
- harq_information.harq_information_rel10_tdd.n_pucch_1_0 = rand_range(0, 2047);
- harq_information.harq_information_rel10_tdd.n_pucch_1_1 = rand_range(0, 2047);
- harq_information.harq_information_rel10_tdd.n_pucch_1_2 = rand_range(0, 2047);
- harq_information.harq_information_rel10_tdd.n_pucch_1_3 = rand_range(0, 2047);
- harq_information.harq_information_rel8_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG;
- harq_information.harq_information_rel8_fdd.n_pucch_1_0 = rand_range(0, 2047);
- harq_information.harq_information_rel8_fdd.harq_size = rand_range(1, 2);
- harq_information.harq_information_rel9_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG;
- harq_information.harq_information_rel9_fdd.harq_size = rand_range(1, 10);
- harq_information.harq_information_rel9_fdd.ack_nack_mode = rand_range(0, 4);
- harq_information.harq_information_rel9_fdd.number_of_pucch_resources = rand_range(0, 4);
- harq_information.harq_information_rel9_fdd.n_pucch_1_0 = rand_range(0, 2047);
- harq_information.harq_information_rel9_fdd.n_pucch_1_1 = rand_range(0, 2047);
- harq_information.harq_information_rel9_fdd.n_pucch_1_2 = rand_range(0, 2047);
- harq_information.harq_information_rel9_fdd.n_pucch_1_3 = rand_range(0, 2047);
- harq_information.harq_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG;
- harq_information.harq_information_rel11.num_ant_ports = rand_range(1, 2);
- harq_information.harq_information_rel11.n_pucch_2_0 = rand_range(0, 2047);
- harq_information.harq_information_rel11.n_pucch_2_1 = rand_range(0, 2047);
- harq_information.harq_information_rel11.n_pucch_2_2 = rand_range(0, 2047);
- harq_information.harq_information_rel11.n_pucch_2_3 = rand_range(0, 2047);
- harq_information.harq_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG;
- harq_information.harq_information_rel13.harq_size_2 = rand_range(0, 999);
- harq_information.harq_information_rel13.starting_prb = rand_range(0, 109);
- harq_information.harq_information_rel13.n_prb = rand_range(0, 7);
- harq_information.harq_information_rel13.cdm_index = rand_range(0, 1);
- harq_information.harq_information_rel13.n_srs = rand_range(0, 1);
- };
-
-
- ul_config_pdus[0].pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
- ul_config_ulsch_pdu_test_gen(ul_config_pdus[0].ulsch_pdu);
+ if(bind(instance->rx_sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
+ printf("[MAC] Failed to bind to %u\n", rx_port);
+ close(instance->rx_sock);
+ return;
+ }
- ul_config_pdus[1].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE;
- ul_config_ulsch_pdu_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.ulsch_pdu);
- ul_config_cqi_ri_info_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.cqi_ri_information);
- ul_config_init_tx_params_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.initial_transmission_parameters);
-
- ul_config_pdus[2].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE;
- ul_config_ulsch_pdu_test_gen(ul_config_pdus[2].ulsch_harq_pdu.ulsch_pdu);
- ul_config_harqinfo_test_gen(ul_config_pdus[2].ulsch_harq_pdu.harq_information);
- ul_config_init_tx_params_test_gen(ul_config_pdus[2].ulsch_harq_pdu.initial_transmission_parameters);
-
- ul_config_pdus[3].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE;
- ul_config_ulsch_pdu_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.ulsch_pdu);
- ul_config_cqi_ri_info_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.cqi_ri_information);
- ul_config_harqinfo_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.harq_information);
- ul_config_init_tx_params_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters);
-
-
- ul_config_pdus[4].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[4].uci_cqi_pdu.ue_information);
- ul_config_cqi_info_test_gen(ul_config_pdus[4].uci_cqi_pdu.cqi_information);
-
- ul_config_pdus[5].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[5].uci_sr_pdu.ue_information);
- ul_config_sr_info_test_gen(ul_config_pdus[5].uci_sr_pdu.sr_information);
-
-
- ul_config_pdus[6].pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[6].uci_harq_pdu.ue_information);
- ul_config_harq_info_test_gen(ul_config_pdus[6].uci_harq_pdu.harq_information);
-
-
- ul_config_pdus[7].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.ue_information);
- ul_config_sr_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.sr_information);
- ul_config_harq_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.harq_information);
-
- ul_config_pdus[8].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.ue_information);
- ul_config_cqi_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.cqi_information);
- ul_config_harq_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.harq_information);
-
- ul_config_pdus[9].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.ue_information);
- ul_config_cqi_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.cqi_information);
- ul_config_sr_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.sr_information);
-
- ul_config_pdus[10].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.ue_information);
- ul_config_cqi_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.cqi_information);
- ul_config_sr_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.sr_information);
- ul_config_harq_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.harq_information);
-
- ul_config_pdus[11].pdu_type = NFAPI_UL_CONFIG_SRS_PDU_TYPE;
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG;
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.handle = rand_range(0, 9999);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.size = rand_range(1, 999);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.rnti = rand_range(1, 65535);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.srs_bandwidth = rand_range(0, 3);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.frequency_domain_position = rand_range(0, 23);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = rand_range(0, 3);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.transmission_comb = rand_range(0, 3);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.i_srs = rand_range(0, 1023);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift = rand_range(0, 11);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG;
- ul_config_pdus[11].srs_pdu.srs_pdu_rel10.antenna_port = rand_range(0, 2);
- ul_config_pdus[11].srs_pdu.srs_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG;
- ul_config_pdus[11].srs_pdu.srs_pdu_rel13.number_of_combs = rand_range(0, 1);
-
- ul_config_pdus[12].pdu_type = NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE;
- ul_config_ue_info_test_gen(ul_config_pdus[12].harq_buffer_pdu.ue_information);
-
- ul_config_pdus[13].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE;
- ul_config_ulsch_pdu_test_gen(ul_config_pdus[13].ulsch_uci_csi_pdu.ulsch_pdu);
- ul_config_cqi_info_test_gen(ul_config_pdus[13].ulsch_uci_csi_pdu.csi_information);
-
- ul_config_pdus[14].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE;
- ul_config_ulsch_pdu_test_gen(ul_config_pdus[14].ulsch_uci_harq_pdu.ulsch_pdu);
- ul_config_harq_info_test_gen(ul_config_pdus[14].ulsch_uci_harq_pdu.harq_information);
-
- ul_config_pdus[15].pdu_type = NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE;
- ul_config_ulsch_pdu_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.ulsch_pdu);
- ul_config_cqi_info_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.csi_information);
- ul_config_harq_info_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.harq_information);
-
- ul_config_pdus[16].pdu_type = NFAPI_UL_CONFIG_NULSCH_PDU_TYPE;
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG;
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nulsch_format = rand_range(0, 1);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.handle = rand_range(0, 0xFFFF);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.size = rand_range(0, 65535);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.rnti = rand_range(1, 65535);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.subcarrier_indication = rand_range(0, 47);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.resource_assignment = rand_range(0, 7);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.mcs = rand_range(0, 12);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.redudancy_version = rand_range(0, 1);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.repetition_number = rand_range(0, 7);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.new_data_indication = rand_range(0, 1);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.n_srs = rand_range(0, 1);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.scrambling_sequence_initialization_cinit = rand_range(0, 65535);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.sf_idx = rand_range(0, 40960);
-
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG;
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.handle = rand_range(0, 0xFF);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.rnti = rand_range(1, 65535);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG;
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.npusch_identity = rand_range(0, 503);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG;
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.ue_type = rand_range(0, 2);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.empty_symbols = rand_range(0, 0x3);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.total_number_of_repetitions = rand_range(1, 32);
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.repetition_number = rand_range(1, 32);
-
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG;
- ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.harq_ack_resource = rand_range(0, 15);
-
- ul_config_pdus[17].pdu_type = NFAPI_UL_CONFIG_NRACH_PDU_TYPE;
- ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG;
- ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_0 = rand_range(0, 1);
- ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_1 = rand_range(0, 1);
- ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_2 = rand_range(0, 1);
-
- ul_config_req.ul_config_request_body.ul_config_pdu_list = ul_config_pdus;
- mac->ul_config_req(mac, &ul_config_req);
-
-
- uint8_t num_dci_pdus = 4;
- uint8_t num_hi_pdus = 1;
- nfapi_hi_dci0_request_pdu_t hi_dci0_pdus[num_dci_pdus + num_hi_pdus];
- memset(&hi_dci0_pdus, 0, sizeof(hi_dci0_pdus));
-
- nfapi_hi_dci0_request_t hi_dci0_req;
- memset(&hi_dci0_req, 0, sizeof(hi_dci0_req));
- hi_dci0_req.header.message_id = NFAPI_HI_DCI0_REQUEST;
- hi_dci0_req.header.phy_id = phy_id;
- hi_dci0_req.sfn_sf = sfn_sf;
-
- hi_dci0_req.hi_dci0_request_body.tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG;
- hi_dci0_req.hi_dci0_request_body.sfnsf = sfn_sf;
- hi_dci0_req.hi_dci0_request_body.number_of_dci = num_dci_pdus;
- hi_dci0_req.hi_dci0_request_body.number_of_hi = num_hi_pdus;
-
- hi_dci0_pdus[0].pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE;
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG;
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.resource_block_start = rand_range(0, 100);
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.hi_value = rand_range(0, 1);
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.i_phich = rand_range(0, 1);
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.transmission_power = rand_range(0, 10000);
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG;
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.flag_tb2 = rand_range(0, 1);
- hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.hi_value_2 = rand_range(0, 1);
-
- hi_dci0_pdus[1].pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE;
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG;
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.dci_format = rand_range(0, 4);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cce_index = rand_range(0, 88);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.aggregation_level = rand_range(1, 8);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.rnti = rand_range(1, 65535);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.resource_block_start = rand_range(0, 100);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.number_of_resource_block = rand_range(0, 100);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.mcs_1 = rand_range(0, 31);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.frequency_hopping_bits = rand_range(0, 3);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.new_data_indication_1 = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.ue_tx_antenna_seleciton = rand_range(0, 2);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tpc = rand_range(0, 3);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cqi_csi_request = rand_range(0, 7);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.ul_index = rand_range(0, 3);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.dl_assignment_index = rand_range(1, 4);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tpc_bitmap = rand_range(0, 9999);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.transmission_power = rand_range(0, 10000);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG;
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.carrier_indicator = rand_range(0, 7);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.size_of_cqi_csi_feild = rand_range(0, 2);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.srs_flag = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.srs_request = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_allocation_flag = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_allocation_type = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_block_coding = rand_range(0, 9999);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.mcs_2 = rand_range(0, 31);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.new_data_indication_2 = rand_range(0, 1);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.number_of_antenna_ports = rand_range(0, 2);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.tpmi = rand_range(0, 63);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.n_ul_rb = rand_range(6, 100);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG;
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.pscch_resource = rand_range(0, 16);
- hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.time_resource_pattern = rand_range(0, 32);
-
-
- hi_dci0_pdus[2].pdu_type = NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE;
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG;
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.dci_format = rand_range(0, 4);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cce_index = rand_range(0, 88);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.aggregation_level = rand_range(1, 8);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.rnti = rand_range(1, 65535);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.resource_block_start = rand_range(0, 100);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.number_of_resource_block = rand_range(0, 100);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.mcs_1 = rand_range(0, 31);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.frequency_hopping_bits = rand_range(0, 3);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.new_data_indication_1 = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.ue_tx_antenna_seleciton = rand_range(0, 2);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tpc = rand_range(0, 3);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cqi_csi_request = rand_range(0, 7);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.ul_index = rand_range(0, 3);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.dl_assignment_index = rand_range(1, 4);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tpc_bitmap = rand_range(0, 9999);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.transmission_power = rand_range(0, 10000);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG;
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.carrier_indicator = rand_range(0, 7);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.size_of_cqi_csi_feild = rand_range(0, 2);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.srs_flag = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.srs_request = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_allocation_flag = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_allocation_type = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_block_coding = rand_range(0, 9999);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.mcs_2 = rand_range(0, 31);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.new_data_indication_2 = rand_range(0, 1);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.number_of_antenna_ports = rand_range(0, 2);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.tpmi = rand_range(0, 63);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.n_ul_rb = rand_range(6, 100);
- hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_parameters_rel11.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG;
-
- hi_dci0_pdus[3].pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
- hi_dci0_pdus[3].mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG;
-
- hi_dci0_pdus[4].pdu_type = NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE;
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG;
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.ncce_index = rand_range(0, 1);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.aggregation_level = rand_range(1, 2);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.start_symbol = rand_range(0, 4);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.rnti = rand_range(1, 65535);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scrambling_reinitialization_batch_index = rand_range(1, 4);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.subcarrier_indication = rand_range(0, 63);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.resource_assignment = rand_range(0, 7);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scheduling_delay = rand_range(0, 3);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.mcs = rand_range(0, 12);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.redudancy_version = rand_range(0, 1);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.repetition_number = rand_range(0, 7);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.new_data_indicator = rand_range(0, 1);
- hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.dci_subframe_repetition_number = rand_range(0, 3);
-
- hi_dci0_req.hi_dci0_request_body.hi_dci0_pdu_list = hi_dci0_pdus;
- mac->hi_dci0_req(mac, &hi_dci0_req);
-
- uint8_t num_tx_pdus = 2;
- nfapi_tx_request_pdu_t tx_pdus[num_tx_pdus];
- memset(&tx_pdus, 0, sizeof(tx_pdus));
-
- nfapi_tx_request_t tx_req;
- memset(&tx_req, 0, sizeof(tx_req));
- tx_req.header.message_id = NFAPI_TX_REQUEST;
- tx_req.header.phy_id = phy_id;
- tx_req.sfn_sf = sfn_sf;
-
- tx_req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
- tx_req.tx_request_body.number_of_pdus = num_tx_pdus;
-
- uint32_t data[2];
- data[0] = 0x11223344;
- data[1] = 0x55667788;
-
- tx_pdus[0].pdu_length = 8;
- tx_pdus[0].pdu_index = 1;
- tx_pdus[0].num_segments = 2;
- tx_pdus[0].segments[0].segment_length = 4;
- tx_pdus[0].segments[0].segment_data = (uint8_t*)&data[0];
- tx_pdus[0].segments[1].segment_length = 4;
- tx_pdus[0].segments[1].segment_data = (uint8_t*)&data[1];
-
- tx_pdus[1].pdu_length = 8;
- tx_pdus[1].pdu_index = 2;
- tx_pdus[1].num_segments = 2;
- tx_pdus[1].segments[0].segment_length = 4;
- tx_pdus[1].segments[0].segment_data = (uint8_t*)&data[0];
- tx_pdus[1].segments[1].segment_length = 4;
- tx_pdus[1].segments[1].segment_data = (uint8_t*)&data[1];
-
-
- tx_req.tx_request_body.tx_pdu_list = tx_pdus;
- mac->tx_req(mac, &tx_req);
- }
-
- void generate_subframe(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf)
- {
- mac_internal_t* instance = (mac_internal_t*)mac;
-
- nfapi_dl_config_request_t dl_config_req;
- memset(&dl_config_req, 0, sizeof(dl_config_req));
- dl_config_req.header.message_id = NFAPI_DL_CONFIG_REQUEST;
- dl_config_req.header.phy_id = phy_id;
- dl_config_req.sfn_sf = sfn_sf;
-
- dl_config_req.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
- dl_config_req.dl_config_request_body.number_pdu = 8;
-
- nfapi_dl_config_request_pdu_t pdus[8];
- memset(&pdus, 0, sizeof(pdus));
- for(int i = 0; i < 8; i++)
- {
- pdus[i].pdu_type = NFAPI_DL_CONFIG_BCH_PDU_TYPE;
-
- pdus[i].bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG;
- pdus[i].bch_pdu.bch_pdu_rel8.length = 42;
- pdus[i].bch_pdu.bch_pdu_rel8.pdu_index = i;
- pdus[i].bch_pdu.bch_pdu_rel8.transmission_power = 56;
-
- }
-
- dl_config_req.dl_config_request_body.dl_config_pdu_list = pdus;
-
- /*
- vendor_ext_tlv_1 ve;
- ve.tl.tag = VENDOR_EXT_TLV_1_TAG;
- ve.dummy = 999;
- dl_config_req.vendor_extension = &ve.tl;
- */
-
- mac->dl_config_req(mac, &dl_config_req);
-
-
- nfapi_ul_config_request_t ul_config_req;
- memset(&ul_config_req, 0, sizeof(ul_config_req));
- ul_config_req.header.message_id = NFAPI_UL_CONFIG_REQUEST;
- ul_config_req.header.phy_id = phy_id;
- ul_config_req.sfn_sf = sfn_sf;
- mac->ul_config_req(mac, &ul_config_req);
-
- nfapi_hi_dci0_request_t hi_dci0_req;
- memset(&hi_dci0_req, 0, sizeof(hi_dci0_req));
- hi_dci0_req.header.message_id = NFAPI_HI_DCI0_REQUEST;
- hi_dci0_req.header.phy_id = phy_id;
- hi_dci0_req.sfn_sf = sfn_sf;
- mac->hi_dci0_req(mac, &hi_dci0_req);
+ pthread_t mac_rx_thread;
+ pthread_create(&mac_rx_thread, NULL, &mac_rx_thread_start, instance);
+ instance->tx_sock = socket(AF_INET, SOCK_DGRAM, 0);
+ instance->tx_addr.sin_family = AF_INET;
+ instance->tx_addr.sin_port = htons(tx_port);
+ instance->tx_addr.sin_addr.s_addr = inet_addr(tx_address);
+ }
- nfapi_tx_request_t tx_req;
- memset(&tx_req, 0, sizeof(tx_req));
- tx_req.header.message_id = NFAPI_TX_REQUEST;
- tx_req.header.phy_id = phy_id;
- tx_req.sfn_sf = sfn_sf;
+ void generate_test_subframe(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf) {
+ //mac_internal_t* instance = (mac_internal_t*)mac;
+ uint8_t max_num_dl_pdus = 50;
+ nfapi_dl_config_request_pdu_t dl_config_pdus[max_num_dl_pdus];
+ memset(&dl_config_pdus, 0, sizeof(dl_config_pdus));
+ nfapi_dl_config_request_t dl_config_req;
+ memset(&dl_config_req, 0, sizeof(dl_config_req));
+ dl_config_req.header.message_id = NFAPI_DL_CONFIG_REQUEST;
+ dl_config_req.header.phy_id = phy_id;
+ dl_config_req.sfn_sf = sfn_sf;
+ dl_config_req.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
+ dl_config_req.dl_config_request_body.number_pdu = rand_range(4, max_num_dl_pdus);
+ uint16_t i = 0;
- nfapi_tx_request_pdu_t tx_pdus[8];
+ for(i = 0; i < dl_config_req.dl_config_request_body.number_pdu; ++i) {
+ dl_config_pdus[i].pdu_type = rand_range(0, 11);
- tx_req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
- tx_req.tx_request_body.number_of_pdus = 0;
- tx_req.tx_request_body.tx_pdu_list = &tx_pdus[0];
+ switch(dl_config_pdus[i].pdu_type) {
+ case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: {
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.dci_format = rand_range(0, 9);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx = rand_range(0, 255);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = rand_range(0, 32);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti = rand_range(0, (uint16_t)-1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = rand_range(0, 320000);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = rand_range(0, 31);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = rand_range(0, 3);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = rand_range(0, 31);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = rand_range(0, 31);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_2 = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.harq_process = rand_range(0, 31);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tpmi = rand_range(0, 15);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.pmi = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.precoding_information = rand_range(0, 63);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.tpc = rand_range(0, 3);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = rand_range(0, 15);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.ngap = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transport_block_size_index = rand_range(0, 31);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.downlink_power_offset = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.allocate_prach_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.preamble_index = rand_range(0, 63);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.prach_mask_index = rand_range(0, 15);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = rand_range(0, 3);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.mcch_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.mcch_change_notification = rand_range(0, 255);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel9.scrambling_identity = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.carrier_indicator = rand_range(0, 7);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.srs_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.srs_request = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.antenna_ports_scrambling_and_layers = rand_range(0, 15);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel10.n_dl_rb = rand_range(0, 100);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.harq_ack_resource_offset = rand_range(0, 3);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel11.pdsch_re_mapping_quasi_co_location_indicator = rand_range(0, 3);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.primary_cell_type = rand_range(0, 2);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.number_ul_dl_configurations = 2;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[0] = rand_range(1, 5);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel12.ul_dl_configuration_indication[1] = rand_range(1, 5);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.laa_end_partial_sf_configuration = rand_range(0, 255);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.initial_lbt_sf = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.codebook_size_determination = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.drms_table_flag = rand_range(0, 1);
- mac_pdu* buff = 0;
- int i = 0;
- std::list free_list;
- do
- {
- buff = instance->mac->pop_rx_buffer();
- if(buff != 0)
- {
- if(buff->len == 0)
- {
- printf("[MAC] Buffer length = 0\n");
- }
+ // if the tpm extention is present of not.
+ if(rand_range(0, 1)) {
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag = rand_range(0, 1);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_prb_per_subband = rand_range(0, 8);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands = rand_range(0, 13);
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas = 1; // rand_range(0, 8);
- tx_req.tx_request_body.tx_pdu_list[i].pdu_length = buff->len;
- tx_req.tx_request_body.tx_pdu_list[i].pdu_index = i;
- tx_req.tx_request_body.tx_pdu_list[i].num_segments = 1;
- tx_req.tx_request_body.tx_pdu_list[i].segments[0].segment_length = buff->len;
- tx_req.tx_request_body.tx_pdu_list[i].segments[0].segment_data = (uint8_t*)buff->buffer;
+ for(int j = 0; j < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.number_of_subbands; ++j) {
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].subband_index = j;
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].scheduled_ues = 1; //rand_range(1, 4);
- tx_req.tx_request_body.number_of_pdus++;
- i++;
+ for(int k = 0; k < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.num_antennas; ++k)
+ for(int l = 0; l < dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].scheduled_ues; ++l)
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm.subband_info[j].precoding_value[k][l] = rand_range(0, 65535);
+ }
+ } else {
+ dl_config_pdus[i].dci_dl_pdu.dci_dl_pdu_rel13.tpm_struct_flag = 0;
+ }
+ }
+ break;
- instance->mac->byte_count += buff->len;
+ case NFAPI_DL_CONFIG_BCH_PDU_TYPE: {
+ dl_config_pdus[i].bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG;
+ dl_config_pdus[i].bch_pdu.bch_pdu_rel8.length = rand_range(0, 42);
+ dl_config_pdus[i].bch_pdu.bch_pdu_rel8.pdu_index = rand_range(0, 65535);
+ dl_config_pdus[i].bch_pdu.bch_pdu_rel8.transmission_power = rand_range(0, 10000);
+ }
+ break;
- free_list.push_back(buff);
- }
- }while(buff != 0 && i < 8);
+ case NFAPI_DL_CONFIG_MCH_PDU_TYPE: {
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG;
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.length = rand_range(0, 42);
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.pdu_index = rand_range(0, 65535);
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.rnti = 0xFFFD;
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.resource_allocation_type = 0;
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.resource_block_coding = 0;
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.modulation = rand_range(0, 8);
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].mch_pdu.mch_pdu_rel8.mbsfn_area_id = rand_range(0, 255);
+ }
+ break;
- mac->tx_req(mac, &tx_req);
+ case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: {
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.length = rand_range(0, 42);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.pdu_index = rand_range(0, 65535);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.rnti = rand_range(1, 65535);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = rand_range(0, 5);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = rand_range(0, 32000);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.modulation = rand_range(2, 8);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.redundancy_version = rand_range(0, 3);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transport_blocks = rand_range(1, 2);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = rand_range(0, 13);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.number_of_layers = rand_range(1, 8);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 2; //rand_range(0, 13);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.codebook_index[0] = rand_range(0, 15);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.codebook_index[1] = rand_range(0, 15);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = rand_range(0, 14);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.pa = rand_range(0, 7);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.ngap = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.nprb = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.transmission_mode = rand_range(1, 10);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 2; //rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 2; //rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].subband_index = rand_range(0, 4);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].num_antennas = 1;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[0].bf_value[0] = rand_range(0, 128);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].subband_index = rand_range(0, 4);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].num_antennas = 1;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel8.bf_vector[1].bf_value[0] = rand_range(0, 128);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel9.nscid = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_flag = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_resource_config_r10 = 0;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_zero_tx_power_resource_config_bitmap_r10 = rand_range(0, 65535);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_number_nzp_configuration = 1;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.csi_rs_resource_config[0] = rand_range(0, 31);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel10.pdsch_start = rand_range(0, 4);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.drms_config_flag = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.drms_scrambling = rand_range(0, 503);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.csi_config_flag = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.csi_scrambling = rand_range(0, 503);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_flag = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_atenna_ports = rand_range(1,4);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel11.pdsch_re_mapping_freq_shift = rand_range(0, 5);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG;
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.altcqi_table_r12 = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.maxlayers = rand_range(1, 8);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel12.n_dl_harq = rand_range(0, 255);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.dwpts_symbols = rand_range(3, 14);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.initial_lbt_sf = rand_range(0, 1);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.ue_type = rand_range(0, 2);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = rand_range(0, 2);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
+ dl_config_pdus[i].dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = rand_range(0, 1);
+ }
+ break;
- //for(int j = 0; j < tx_req.tx_request_body.number_of_pdus; ++j)
- for(mac_pdu* pdu : free_list)
- {
- instance->mac->release_mac_pdu(pdu);
- //free(tx_req.tx_request_body.tx_pdu_list[j].segments[0].segment_data);
- }
- }
-
- void mac_subframe_ind(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf)
- {
+ case NFAPI_DL_CONFIG_PCH_PDU_TYPE: {
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.length = rand_range(0, 42);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.pdu_index = rand_range(0, 65535);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.p_rnti = 0xFFFE;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.resource_allocation_type = rand_range(2, 6);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.resource_block_coding = rand_range(0, 34000);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.mcs = 0;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.redundancy_version = 0;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.number_of_transport_blocks = 1;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transmission_scheme = rand_range(1, 6);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.number_of_layers = rand_range(1, 4);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.codebook_index = 0;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.ue_category_capacity = rand_range(0, 14);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.pa = rand_range(0, 7);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.nprb = rand_range(0, 1);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel8.ngap = rand_range(0, 1);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG;
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel13.ue_mode = rand_range(0, 1);
+ dl_config_pdus[i].pch_pdu.pch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
+ }
+ break;
-
- //printf("[MAC] subframe indication phyid:%d sfnsf:%d\n", phy_id, sfn_sf);
- mac_internal_t* instance = (mac_internal_t*)mac;
+ case NFAPI_DL_CONFIG_PRS_PDU_TYPE: {
+ dl_config_pdus[i].prs_pdu.prs_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG;
+ dl_config_pdus[i].prs_pdu.prs_pdu_rel9.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_bandwidth = rand_range(6, 100);
+ dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_cyclic_prefix_type = rand_range(0, 1);
+ dl_config_pdus[i].prs_pdu.prs_pdu_rel9.prs_muting = rand_range(0, 1);
+ }
+ break;
- if(instance->mac->tick == 1000)
- {
- if(instance->mac->byte_count > 0)
- {
- printf("[MAC] Rx rate %d bytes/sec\n", instance->mac->byte_count);
- instance->mac->byte_count = 0;
- }
- instance->mac->tick = 0;
- }
- instance->mac->tick++;
-
- if(instance->mac->wireshark_test_mode)
- {
- generate_test_subframe(mac, phy_id, sfn_sf);
- }
- else
- {
- generate_subframe(mac, phy_id, sfn_sf);
- }
- }
-
- void mac_harq_ind(mac_t* mac, nfapi_harq_indication_t* ind)
- {
- }
- void mac_crc_ind(mac_t* mac, nfapi_crc_indication_t* ind)
- {
- }
- void mac_rx_ind(mac_t* mac, nfapi_rx_indication_t* ind)
- {
- mac_internal_t* instance = (mac_internal_t*)mac;
+ case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: {
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG;
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_antenna_port_count_r10 = rand_range(1, 16);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config_r10 = 0;
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_zero_tx_power_resource_config_bitmap_r10 = rand_range(0, 8);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_number_of_nzp_configuration = 2;
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config[0] = rand_range(0, 31);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel10.csi_rs_resource_config[1] = rand_range(0, 31);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG;
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.csi_rs_class = rand_range(0, 2);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.cdm_type = rand_range(0, 1);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.num_bf_vector = 0; // set to zero as not clear how to handle bf value array
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.bf_vector[0].csi_rs_resource_index = rand_range(0, 7);
+ dl_config_pdus[i].csi_rs_pdu.csi_rs_pdu_rel13.bf_vector[0].bf_value[0] = 42;
+ }
+ break;
- for(int i = 0; i < ind->rx_indication_body.number_of_pdus; ++i)
- {
- uint16_t len = ind->rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length;
- uint8_t* data = ind->rx_indication_body.rx_pdu_list[i].data;
- //printf("[MAC] sfnsf:%d len:%d\n", ind->sfn_sf,len);
- //
- instance->tx_byte_count += len;
+ case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: {
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.dci_format = rand_range(0, 9);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.cce_idx = rand_range(0, 255);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.aggregation_level = rand_range(0, 32);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.rnti = rand_range(0, (uint16_t)-1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.resource_allocation_type = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.virtual_resource_block_assignment_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.resource_block_coding = rand_range(0, 320000);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.mcs_1 = rand_range(0, 31);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.redundancy_version_1 = rand_range(0, 3);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.new_data_indicator_1 = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transport_block_to_codeword_swap_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.mcs_2 = rand_range(0, 31);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.redundancy_version_2 = rand_range(0, 31);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.new_data_indicator_2 = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.harq_process = rand_range(0, 31);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tpmi = rand_range(0, 15);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.pmi = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.precoding_information = rand_range(0, 63);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.tpc = rand_range(0, 3);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.downlink_assignment_index = rand_range(0, 15);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.ngap = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transport_block_size_index = rand_range(0, 31);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.downlink_power_offset = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.allocate_prach_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.preamble_index = rand_range(0, 63);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.prach_mask_index = rand_range(0, 15);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.rnti_type = rand_range(0, 3);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel8.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.mcch_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.mcch_change_notification = rand_range(0, 255);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel9.scrambling_identity = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.carrier_indicator = rand_range(0, 7);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.srs_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.srs_request = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.antenna_ports_scrambling_and_layers = rand_range(0, 15);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel10.n_dl_rb = rand_range(0, 100);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.harq_ack_resource_offset = rand_range(0, 3);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel11.pdsch_re_mapping_quasi_co_location_indicator = rand_range(0, 3);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.primary_cell_type = rand_range(0, 2);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.number_ul_dl_configurations = 2;
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_indication[0] = rand_range(1, 5);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel12.ul_dl_configuration_indication[1] = rand_range(1, 5);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.laa_end_partial_sf_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.laa_end_partial_sf_configuration = rand_range(0, 255);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.initial_lbt_sf = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.codebook_size_determination = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_pdu_rel13.drms_table_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_resource_assignment_flag = rand_range(0, 1);
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_id = rand_range(0, 503);
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_start_symbol = rand_range(1, 4);
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb = rand_range(2, 8);
- int sendto_result = sendto(instance->tx_sock, data, len, 0, (struct sockaddr*)&(instance->tx_addr), sizeof(instance->tx_addr));
-
- if(sendto_result < 0)
- {
- // error
- }
- }
+ for(int j = 0; j < dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb; ++j)
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_prb_index[j] = rand_range(0, 99);
- }
- void mac_rach_ind(mac_t* mac, nfapi_rach_indication_t* ind)
- {
- }
- void mac_srs_ind(mac_t* mac, nfapi_srs_indication_t* ind)
- {
- }
- void mac_sr_ind(mac_t* mac, nfapi_sr_indication_t* ind)
- {
- }
- void mac_cqi_ind(mac_t* mac, nfapi_cqi_indication_t* ind)
- {
- }
- void mac_lbt_dl_ind(mac_t* mac, nfapi_lbt_dl_indication_t* ind)
- {
- }
- void mac_nb_harq_ind(mac_t* mac, nfapi_nb_harq_indication_t* ind)
- {
- }
- void mac_nrach_ind(mac_t* mac, nfapi_nrach_indication_t* ind)
- {
- }
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.subband_index = rand_range(0, 25);
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.num_antennas= rand_range(1, 4);
+
+ for(int j = 0; j < dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.epdcch_num_prb; ++j)
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel11.bf_vector.bf_value[j] = rand_range(0, 65535);
+
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG;
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.dwpts_symbols = rand_range(3, 14);
+ dl_config_pdus[i].epdcch_pdu.epdcch_params_rel13.initial_lbt_sf = rand_range(0, 1);
+ }
+ break;
+
+ case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: {
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG;
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = rand_range(0, 15);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = rand_range(2, 6);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = rand_range(0, 14);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = rand_range(1, 4);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = rand_range(0, 22);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = rand_range(2, 24);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = rand_range(0, 4);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.rnti = rand_range(1, 65535);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = rand_range(1, 2);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = rand_range(0, 503);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.dci_format = rand_range(10, 12);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = rand_range(0, 0xFFFF);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.mcs = rand_range(0, 15);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = rand_range(1, 8);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rand_range(0, 3);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.harq_process = rand_range(0, 15);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = rand_range(0, 4);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpmi = rand_range(0, 15);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.pmi = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = rand_range(0, 3);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = rand_range(1, 4);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.tpc = rand_range(0, 3);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = rand_range(0, 4);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = rand_range(0, 15);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = rand_range(0, 63);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = rand_range(0, 15);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = rand_range(0, 3);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.srs_request = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = rand_range(0, 3);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = rand_range(0, 255);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = rand_range(0, 1);
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = rand_range(0, 8);
+
+ for(int j = 0 ; j < dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports; ++j)
+ dl_config_pdus[i].mpdcch_pdu.mpdcch_pdu_rel13.precoding_value[j] = rand_range(0, 65535);
+ }
+ break;
+
+ case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: {
+ dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG;
+ dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.length = rand_range(0, 5555);
+ dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.pdu_index = rand_range(0, 65535);
+ dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.transmission_power = rand_range(0, 10000);
+ dl_config_pdus[i].nbch_pdu.nbch_pdu_rel13.hyper_sfn_2_lsbs = rand_range(0, 3);
+ }
+ break;
+
+ case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: {
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG;
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.length = rand_range(0, 5555);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.pdu_index = rand_range(0, 65535);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.ncce_index = rand_range(0, 1);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.aggregation_level = rand_range(1, 2);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.start_symbol = rand_range(0, 4);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.rnti_type = rand_range(0, 3);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.rnti = rand_range(1, 65535);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.scrambling_reinitialization_batch_index = rand_range(1, 4);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.dci_format = rand_range(0, 1);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.scheduling_delay = rand_range(0, 7);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.resource_assignment = rand_range(0, 7);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.repetition_number = rand_range(0, 15);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.mcs = rand_range(0, 13);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.new_data_indicator = rand_range(0, 1);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource = rand_range(0, 15);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.npdcch_order_indication = rand_range(0, 1);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.starting_number_of_nprach_repetitions = rand_range(0, 3);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.subcarrier_indication_of_nprach = rand_range(0, 63);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.paging_direct_indication_differentation_flag = rand_range(0, 1);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.direct_indication = rand_range(0, 255);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number = rand_range(0, 7);
+ dl_config_pdus[i].npdcch_pdu.npdcch_pdu_rel13.total_dci_length_including_padding = rand_range(0, 255);
+ }
+ break;
+
+ case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: {
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.tl.tag = NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG;
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.length = rand_range(0, 5555);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.pdu_index = rand_range(0, 65535);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.start_symbol = rand_range(0, 4);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.rnti_type = rand_range(0, 1);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.rnti = rand_range(1, 65535);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment = rand_range(0, 7);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.repetition_number = rand_range(0, 15);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.modulation = 2;
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment = rand_range(1, 10);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.scrambling_sequence_initialization_cinit = rand_range(0, 65535);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.sf_idx = rand_range(1, 10240);
+ dl_config_pdus[i].ndlsch_pdu.ndlsch_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2);
+ }
+ break;
+ };
+ }
+
+ dl_config_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdus;
+ mac->dl_config_req(mac, &dl_config_req);
+ uint8_t num_ul_pdus = 18;
+ nfapi_ul_config_request_pdu_t ul_config_pdus[num_ul_pdus];
+ memset(&ul_config_pdus, 0, sizeof(ul_config_pdus));
+ nfapi_ul_config_request_t ul_config_req;
+ memset(&ul_config_req, 0, sizeof(ul_config_req));
+ ul_config_req.header.message_id = NFAPI_UL_CONFIG_REQUEST;
+ ul_config_req.header.phy_id = phy_id;
+ ul_config_req.sfn_sf = sfn_sf;
+ ul_config_req.ul_config_request_body.tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
+ ul_config_req.ul_config_request_body.number_of_pdus = num_ul_pdus;
+ ul_config_req.ul_config_request_body.rach_prach_frequency_resources = rand_range(0, 255);
+ ul_config_req.ul_config_request_body.srs_present = rand_range(0, 1);
+ auto ul_config_ulsch_pdu_test_gen = [](nfapi_ul_config_ulsch_pdu& ulsch_pdu) {
+ ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG;
+ ulsch_pdu.ulsch_pdu_rel8.handle = rand_range(0, 50000);
+ ulsch_pdu.ulsch_pdu_rel8.size = rand_range(0, 32000);
+ ulsch_pdu.ulsch_pdu_rel8.rnti = rand_range(1, 65535);
+ ulsch_pdu.ulsch_pdu_rel8.resource_block_start = rand_range(0, 99);
+ ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = rand_range(1, 100);
+ ulsch_pdu.ulsch_pdu_rel8.modulation_type = rand_range(2, 6);
+ ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
+ ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = rand_range(0, 3);
+ ulsch_pdu.ulsch_pdu_rel8.new_data_indication = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rand_range(0, 3);
+ ulsch_pdu.ulsch_pdu_rel8.harq_process_number = rand_range(0, 15);
+ ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = rand_range(0, 5);
+ ulsch_pdu.ulsch_pdu_rel8.n_srs = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG;
+ ulsch_pdu.ulsch_pdu_rel10.resource_allocation_type = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel10.resource_block_coding = rand_range(0, 35000);
+ ulsch_pdu.ulsch_pdu_rel10.transport_blocks = rand_range(1, 2);
+ ulsch_pdu.ulsch_pdu_rel10.transmission_scheme = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel10.number_of_layers = rand_range(1, 4);
+ ulsch_pdu.ulsch_pdu_rel10.codebook_index = rand_range(0, 23);
+ ulsch_pdu.ulsch_pdu_rel10.disable_sequence_hopping_flag = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG;
+ ulsch_pdu.ulsch_pdu_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel11.npusch_identity = rand_range(0, 509);
+ ulsch_pdu.ulsch_pdu_rel11.dmrs_config_flag = rand_range(0, 1);
+ ulsch_pdu.ulsch_pdu_rel11.ndmrs_csh_identity = rand_range(0, 509);
+ ulsch_pdu.ulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG;
+ ulsch_pdu.ulsch_pdu_rel13.ue_type = rand_range(0, 2);
+ ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = rand_range(1, 2048);
+ ulsch_pdu.ulsch_pdu_rel13.repetition_number = rand_range(1, 2048);
+ ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = rand_range(0, 10239);
+ ulsch_pdu.ulsch_pdu_rel13.empty_symbols_due_to_re_tunning = rand_range(0, 8);
+ };
+ auto ul_config_cqi_ri_info_test_gen = [](nfapi_ul_config_cqi_ri_information& cqi_ri_information) {
+ cqi_ri_information.cqi_ri_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG;
+ cqi_ri_information.cqi_ri_information_rel8.dl_cqi_pmi_size_rank_1 = rand_range(0, 255);
+ cqi_ri_information.cqi_ri_information_rel8.dl_cqi_pmi_size_rank_greater_1 = rand_range(0, 255);
+ cqi_ri_information.cqi_ri_information_rel8.ri_size = rand_range(0, 3);
+ cqi_ri_information.cqi_ri_information_rel8.delta_offset_cqi = rand_range(0, 15);
+ cqi_ri_information.cqi_ri_information_rel8.delta_offset_ri = rand_range(0, 15);
+ cqi_ri_information.cqi_ri_information_rel9.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG;
+ cqi_ri_information.cqi_ri_information_rel9.report_type = 1; // rand_range(0, 1);
+ cqi_ri_information.cqi_ri_information_rel9.delta_offset_cqi = rand_range(0, 15);
+ cqi_ri_information.cqi_ri_information_rel9.delta_offset_ri = rand_range(0, 15);
+
+ if(cqi_ri_information.cqi_ri_information_rel9.report_type == 0) {
+ cqi_ri_information.cqi_ri_information_rel9.periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size = rand_range(0, 255);
+ cqi_ri_information.cqi_ri_information_rel9.periodic_cqi_pmi_ri_report.control_type = rand_range(0, 1);
+ } else {
+ cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.number_of_cc = 1;
+ cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = rand_range(0, 3);
+ cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[0] = rand_range(0, 255);
+ }
+
+ cqi_ri_information.cqi_ri_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG;
+ cqi_ri_information.cqi_ri_information_rel13.report_type = rand_range(0, 1);
+
+ if(cqi_ri_information.cqi_ri_information_rel13.report_type == 0) {
+ cqi_ri_information.cqi_ri_information_rel13.periodic_cqi_pmi_ri_report.dl_cqi_pmi_ri_size_2 = rand_range(255, 10000);
+ }
+ };
+ auto ul_config_init_tx_params_test_gen = [](nfapi_ul_config_initial_transmission_parameters& initial_transmission_parameters) {
+ initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG;
+ initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = rand_range(0, 1);
+ initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rand_range(1, 100);
+ };
+ auto ul_config_harqinfo_test_gen = [](nfapi_ul_config_ulsch_harq_information& harq_information) {
+ harq_information.harq_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG;
+ harq_information.harq_information_rel10.harq_size = rand_range(0, 21);
+ harq_information.harq_information_rel10.delta_offset_harq = rand_range(0, 15);
+ harq_information.harq_information_rel10.ack_nack_mode = rand_range(0, 5);
+ harq_information.harq_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG;
+ harq_information.harq_information_rel13.harq_size_2 = rand_range(0, 21);
+ harq_information.harq_information_rel13.delta_offset_harq_2 = rand_range(0, 15);
+ };
+ auto ul_config_sr_info_test_gen = [](nfapi_ul_config_sr_information& sr_info) {
+ sr_info.sr_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG;
+ sr_info.sr_information_rel8.pucch_index = rand_range(0, 2047);
+ sr_info.sr_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG;
+ sr_info.sr_information_rel10.number_of_pucch_resources = rand_range(1, 2);
+ sr_info.sr_information_rel10.pucch_index_p1 = rand_range(0, 2047);
+ };
+ auto ul_config_ue_info_test_gen = [](nfapi_ul_config_ue_information& ue_information) {
+ ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG;
+ ue_information.ue_information_rel8.handle = rand_range(0, 99999);
+ ue_information.ue_information_rel8.rnti = rand_range(1, 65535);
+ ue_information.ue_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG;
+ ue_information.ue_information_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1);
+ ue_information.ue_information_rel11.npusch_identity = rand_range(0, 503);
+ ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG;
+ ue_information.ue_information_rel13.ue_type = rand_range(0, 2);
+ ue_information.ue_information_rel13.empty_symbols = rand_range(0, 2);
+ ue_information.ue_information_rel13.total_number_of_repetitions = rand_range(1, 32);
+ ue_information.ue_information_rel13.repetition_number = rand_range(1, 32);
+ };
+ auto ul_config_cqi_info_test_gen = [](nfapi_ul_config_cqi_information& cqi_information) {
+ cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG;
+ cqi_information.cqi_information_rel8.pucch_index = rand_range(0, 1184);
+ cqi_information.cqi_information_rel8.dl_cqi_pmi_size = rand_range(0, 255);
+ cqi_information.cqi_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG;
+ cqi_information.cqi_information_rel10.number_of_pucch_resource = rand_range(1, 2);
+ cqi_information.cqi_information_rel10.pucch_index_p1 = rand_range(0, 1184);
+ cqi_information.cqi_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG;
+ cqi_information.cqi_information_rel13.csi_mode = rand_range(0, 2);
+ cqi_information.cqi_information_rel13.dl_cqi_pmi_size_2 = rand_range(0, 999);
+ cqi_information.cqi_information_rel13.starting_prb = rand_range(0, 109);
+ cqi_information.cqi_information_rel13.n_prb = rand_range(0, 7);
+ cqi_information.cqi_information_rel13.cdm_index = rand_range(0, 1);
+ cqi_information.cqi_information_rel13.n_srs = rand_range(0, 1);
+ };
+ auto ul_config_harq_info_test_gen = [](nfapi_ul_config_harq_information& harq_information) {
+ harq_information.harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG;
+ harq_information.harq_information_rel10_tdd.harq_size = rand_range(0, 21);
+ harq_information.harq_information_rel10_tdd.ack_nack_mode = rand_range(0, 5);
+ harq_information.harq_information_rel10_tdd.number_of_pucch_resources = rand_range(0, 4);
+ harq_information.harq_information_rel10_tdd.n_pucch_1_0 = rand_range(0, 2047);
+ harq_information.harq_information_rel10_tdd.n_pucch_1_1 = rand_range(0, 2047);
+ harq_information.harq_information_rel10_tdd.n_pucch_1_2 = rand_range(0, 2047);
+ harq_information.harq_information_rel10_tdd.n_pucch_1_3 = rand_range(0, 2047);
+ harq_information.harq_information_rel8_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG;
+ harq_information.harq_information_rel8_fdd.n_pucch_1_0 = rand_range(0, 2047);
+ harq_information.harq_information_rel8_fdd.harq_size = rand_range(1, 2);
+ harq_information.harq_information_rel9_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG;
+ harq_information.harq_information_rel9_fdd.harq_size = rand_range(1, 10);
+ harq_information.harq_information_rel9_fdd.ack_nack_mode = rand_range(0, 4);
+ harq_information.harq_information_rel9_fdd.number_of_pucch_resources = rand_range(0, 4);
+ harq_information.harq_information_rel9_fdd.n_pucch_1_0 = rand_range(0, 2047);
+ harq_information.harq_information_rel9_fdd.n_pucch_1_1 = rand_range(0, 2047);
+ harq_information.harq_information_rel9_fdd.n_pucch_1_2 = rand_range(0, 2047);
+ harq_information.harq_information_rel9_fdd.n_pucch_1_3 = rand_range(0, 2047);
+ harq_information.harq_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG;
+ harq_information.harq_information_rel11.num_ant_ports = rand_range(1, 2);
+ harq_information.harq_information_rel11.n_pucch_2_0 = rand_range(0, 2047);
+ harq_information.harq_information_rel11.n_pucch_2_1 = rand_range(0, 2047);
+ harq_information.harq_information_rel11.n_pucch_2_2 = rand_range(0, 2047);
+ harq_information.harq_information_rel11.n_pucch_2_3 = rand_range(0, 2047);
+ harq_information.harq_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG;
+ harq_information.harq_information_rel13.harq_size_2 = rand_range(0, 999);
+ harq_information.harq_information_rel13.starting_prb = rand_range(0, 109);
+ harq_information.harq_information_rel13.n_prb = rand_range(0, 7);
+ harq_information.harq_information_rel13.cdm_index = rand_range(0, 1);
+ harq_information.harq_information_rel13.n_srs = rand_range(0, 1);
+ };
+ ul_config_pdus[0].pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
+ ul_config_ulsch_pdu_test_gen(ul_config_pdus[0].ulsch_pdu);
+ ul_config_pdus[1].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE;
+ ul_config_ulsch_pdu_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.ulsch_pdu);
+ ul_config_cqi_ri_info_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.cqi_ri_information);
+ ul_config_init_tx_params_test_gen(ul_config_pdus[1].ulsch_cqi_ri_pdu.initial_transmission_parameters);
+ ul_config_pdus[2].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE;
+ ul_config_ulsch_pdu_test_gen(ul_config_pdus[2].ulsch_harq_pdu.ulsch_pdu);
+ ul_config_harqinfo_test_gen(ul_config_pdus[2].ulsch_harq_pdu.harq_information);
+ ul_config_init_tx_params_test_gen(ul_config_pdus[2].ulsch_harq_pdu.initial_transmission_parameters);
+ ul_config_pdus[3].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE;
+ ul_config_ulsch_pdu_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.ulsch_pdu);
+ ul_config_cqi_ri_info_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.cqi_ri_information);
+ ul_config_harqinfo_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.harq_information);
+ ul_config_init_tx_params_test_gen(ul_config_pdus[3].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters);
+ ul_config_pdus[4].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[4].uci_cqi_pdu.ue_information);
+ ul_config_cqi_info_test_gen(ul_config_pdus[4].uci_cqi_pdu.cqi_information);
+ ul_config_pdus[5].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[5].uci_sr_pdu.ue_information);
+ ul_config_sr_info_test_gen(ul_config_pdus[5].uci_sr_pdu.sr_information);
+ ul_config_pdus[6].pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[6].uci_harq_pdu.ue_information);
+ ul_config_harq_info_test_gen(ul_config_pdus[6].uci_harq_pdu.harq_information);
+ ul_config_pdus[7].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.ue_information);
+ ul_config_sr_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.sr_information);
+ ul_config_harq_info_test_gen(ul_config_pdus[7].uci_sr_harq_pdu.harq_information);
+ ul_config_pdus[8].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.ue_information);
+ ul_config_cqi_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.cqi_information);
+ ul_config_harq_info_test_gen(ul_config_pdus[8].uci_cqi_harq_pdu.harq_information);
+ ul_config_pdus[9].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.ue_information);
+ ul_config_cqi_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.cqi_information);
+ ul_config_sr_info_test_gen(ul_config_pdus[9].uci_cqi_sr_pdu.sr_information);
+ ul_config_pdus[10].pdu_type = NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.ue_information);
+ ul_config_cqi_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.cqi_information);
+ ul_config_sr_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.sr_information);
+ ul_config_harq_info_test_gen(ul_config_pdus[10].uci_cqi_sr_harq_pdu.harq_information);
+ ul_config_pdus[11].pdu_type = NFAPI_UL_CONFIG_SRS_PDU_TYPE;
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG;
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.handle = rand_range(0, 9999);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.size = rand_range(1, 999);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.rnti = rand_range(1, 65535);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.srs_bandwidth = rand_range(0, 3);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.frequency_domain_position = rand_range(0, 23);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.srs_hopping_bandwidth = rand_range(0, 3);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.transmission_comb = rand_range(0, 3);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.i_srs = rand_range(0, 1023);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift = rand_range(0, 11);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG;
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel10.antenna_port = rand_range(0, 2);
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG;
+ ul_config_pdus[11].srs_pdu.srs_pdu_rel13.number_of_combs = rand_range(0, 1);
+ ul_config_pdus[12].pdu_type = NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE;
+ ul_config_ue_info_test_gen(ul_config_pdus[12].harq_buffer_pdu.ue_information);
+ ul_config_pdus[13].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE;
+ ul_config_ulsch_pdu_test_gen(ul_config_pdus[13].ulsch_uci_csi_pdu.ulsch_pdu);
+ ul_config_cqi_info_test_gen(ul_config_pdus[13].ulsch_uci_csi_pdu.csi_information);
+ ul_config_pdus[14].pdu_type = NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE;
+ ul_config_ulsch_pdu_test_gen(ul_config_pdus[14].ulsch_uci_harq_pdu.ulsch_pdu);
+ ul_config_harq_info_test_gen(ul_config_pdus[14].ulsch_uci_harq_pdu.harq_information);
+ ul_config_pdus[15].pdu_type = NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE;
+ ul_config_ulsch_pdu_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.ulsch_pdu);
+ ul_config_cqi_info_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.csi_information);
+ ul_config_harq_info_test_gen(ul_config_pdus[15].ulsch_csi_uci_harq_pdu.harq_information);
+ ul_config_pdus[16].pdu_type = NFAPI_UL_CONFIG_NULSCH_PDU_TYPE;
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG;
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nulsch_format = rand_range(0, 1);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.handle = rand_range(0, 0xFFFF);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.size = rand_range(0, 65535);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.rnti = rand_range(1, 65535);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.subcarrier_indication = rand_range(0, 47);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.resource_assignment = rand_range(0, 7);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.mcs = rand_range(0, 12);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.redudancy_version = rand_range(0, 1);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.repetition_number = rand_range(0, 7);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.new_data_indication = rand_range(0, 1);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.n_srs = rand_range(0, 1);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.scrambling_sequence_initialization_cinit = rand_range(0, 65535);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.sf_idx = rand_range(0, 40960);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG;
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.handle = rand_range(0, 0xFF);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel8.rnti = rand_range(1, 65535);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG;
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.virtual_cell_id_enabled_flag = rand_range(0, 1);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel11.npusch_identity = rand_range(0, 503);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG;
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.ue_type = rand_range(0, 2);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.empty_symbols = rand_range(0, 0x3);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.total_number_of_repetitions = rand_range(1, 32);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.ue_information.ue_information_rel13.repetition_number = rand_range(1, 32);
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG;
+ ul_config_pdus[16].nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.harq_ack_resource = rand_range(0, 15);
+ ul_config_pdus[17].pdu_type = NFAPI_UL_CONFIG_NRACH_PDU_TYPE;
+ ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.tl.tag = NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG;
+ ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_0 = rand_range(0, 1);
+ ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_1 = rand_range(0, 1);
+ ul_config_pdus[17].nrach_pdu.nrach_pdu_rel13.nprach_config_2 = rand_range(0, 1);
+ ul_config_req.ul_config_request_body.ul_config_pdu_list = ul_config_pdus;
+ mac->ul_config_req(mac, &ul_config_req);
+ uint8_t num_dci_pdus = 4;
+ uint8_t num_hi_pdus = 1;
+ nfapi_hi_dci0_request_pdu_t hi_dci0_pdus[num_dci_pdus + num_hi_pdus];
+ memset(&hi_dci0_pdus, 0, sizeof(hi_dci0_pdus));
+ nfapi_hi_dci0_request_t hi_dci0_req;
+ memset(&hi_dci0_req, 0, sizeof(hi_dci0_req));
+ hi_dci0_req.header.message_id = NFAPI_HI_DCI0_REQUEST;
+ hi_dci0_req.header.phy_id = phy_id;
+ hi_dci0_req.sfn_sf = sfn_sf;
+ hi_dci0_req.hi_dci0_request_body.tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG;
+ hi_dci0_req.hi_dci0_request_body.sfnsf = sfn_sf;
+ hi_dci0_req.hi_dci0_request_body.number_of_dci = num_dci_pdus;
+ hi_dci0_req.hi_dci0_request_body.number_of_hi = num_hi_pdus;
+ hi_dci0_pdus[0].pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE;
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG;
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.resource_block_start = rand_range(0, 100);
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.hi_value = rand_range(0, 1);
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.i_phich = rand_range(0, 1);
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel8.transmission_power = rand_range(0, 10000);
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG;
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.flag_tb2 = rand_range(0, 1);
+ hi_dci0_pdus[0].hi_pdu.hi_pdu_rel10.hi_value_2 = rand_range(0, 1);
+ hi_dci0_pdus[1].pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE;
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG;
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.dci_format = rand_range(0, 4);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cce_index = rand_range(0, 88);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.aggregation_level = rand_range(1, 8);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.rnti = rand_range(1, 65535);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.resource_block_start = rand_range(0, 100);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.number_of_resource_block = rand_range(0, 100);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.mcs_1 = rand_range(0, 31);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.frequency_hopping_bits = rand_range(0, 3);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.new_data_indication_1 = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.ue_tx_antenna_seleciton = rand_range(0, 2);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tpc = rand_range(0, 3);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.cqi_csi_request = rand_range(0, 7);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.ul_index = rand_range(0, 3);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.dl_assignment_index = rand_range(1, 4);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.tpc_bitmap = rand_range(0, 9999);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel8.transmission_power = rand_range(0, 10000);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG;
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.carrier_indicator = rand_range(0, 7);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.size_of_cqi_csi_feild = rand_range(0, 2);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.srs_flag = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.srs_request = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_allocation_flag = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_allocation_type = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.resource_block_coding = rand_range(0, 9999);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.mcs_2 = rand_range(0, 31);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.new_data_indication_2 = rand_range(0, 1);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.number_of_antenna_ports = rand_range(0, 2);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.tpmi = rand_range(0, 63);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel10.n_ul_rb = rand_range(6, 100);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG;
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.pscch_resource = rand_range(0, 16);
+ hi_dci0_pdus[1].dci_pdu.dci_pdu_rel12.time_resource_pattern = rand_range(0, 32);
+ hi_dci0_pdus[2].pdu_type = NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE;
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG;
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.dci_format = rand_range(0, 4);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cce_index = rand_range(0, 88);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.aggregation_level = rand_range(1, 8);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.rnti = rand_range(1, 65535);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.resource_block_start = rand_range(0, 100);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.number_of_resource_block = rand_range(0, 100);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.mcs_1 = rand_range(0, 31);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cyclic_shift_2_for_drms = rand_range(0, 7);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.frequency_hopping_enabled_flag = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.frequency_hopping_bits = rand_range(0, 3);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.new_data_indication_1 = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.ue_tx_antenna_seleciton = rand_range(0, 2);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tpc = rand_range(0, 3);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.cqi_csi_request = rand_range(0, 7);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.ul_index = rand_range(0, 3);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.dl_assignment_index = rand_range(1, 4);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.tpc_bitmap = rand_range(0, 9999);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel8.transmission_power = rand_range(0, 10000);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG;
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.cross_carrier_scheduling_flag = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.carrier_indicator = rand_range(0, 7);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.size_of_cqi_csi_feild = rand_range(0, 2);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.srs_flag = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.srs_request = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_allocation_flag = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_allocation_type = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.resource_block_coding = rand_range(0, 9999);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.mcs_2 = rand_range(0, 31);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.new_data_indication_2 = rand_range(0, 1);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.number_of_antenna_ports = rand_range(0, 2);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.tpmi = rand_range(0, 63);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.total_dci_length_including_padding = rand_range(0, 255);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_dci_pdu_rel10.n_ul_rb = rand_range(6, 100);
+ hi_dci0_pdus[2].epdcch_dci_pdu.epdcch_parameters_rel11.tl.tag = NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG;
+ hi_dci0_pdus[3].pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
+ hi_dci0_pdus[3].mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG;
+ hi_dci0_pdus[4].pdu_type = NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE;
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.tl.tag = NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG;
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.ncce_index = rand_range(0, 1);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.aggregation_level = rand_range(1, 2);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.start_symbol = rand_range(0, 4);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.rnti = rand_range(1, 65535);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scrambling_reinitialization_batch_index = rand_range(1, 4);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.nrs_antenna_ports_assumed_by_the_ue = rand_range(1, 2);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.subcarrier_indication = rand_range(0, 63);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.resource_assignment = rand_range(0, 7);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.scheduling_delay = rand_range(0, 3);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.mcs = rand_range(0, 12);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.redudancy_version = rand_range(0, 1);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.repetition_number = rand_range(0, 7);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.new_data_indicator = rand_range(0, 1);
+ hi_dci0_pdus[4].npdcch_dci_pdu.npdcch_dci_pdu_rel13.dci_subframe_repetition_number = rand_range(0, 3);
+ hi_dci0_req.hi_dci0_request_body.hi_dci0_pdu_list = hi_dci0_pdus;
+ mac->hi_dci0_req(mac, &hi_dci0_req);
+ uint8_t num_tx_pdus = 2;
+ nfapi_tx_request_pdu_t tx_pdus[num_tx_pdus];
+ memset(&tx_pdus, 0, sizeof(tx_pdus));
+ nfapi_tx_request_t tx_req;
+ memset(&tx_req, 0, sizeof(tx_req));
+ tx_req.header.message_id = NFAPI_TX_REQUEST;
+ tx_req.header.phy_id = phy_id;
+ tx_req.sfn_sf = sfn_sf;
+ tx_req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
+ tx_req.tx_request_body.number_of_pdus = num_tx_pdus;
+ uint32_t data[2];
+ data[0] = 0x11223344;
+ data[1] = 0x55667788;
+ tx_pdus[0].pdu_length = 8;
+ tx_pdus[0].pdu_index = 1;
+ tx_pdus[0].num_segments = 2;
+ tx_pdus[0].segments[0].segment_length = 4;
+ tx_pdus[0].segments[0].segment_data = (uint8_t *)&data[0];
+ tx_pdus[0].segments[1].segment_length = 4;
+ tx_pdus[0].segments[1].segment_data = (uint8_t *)&data[1];
+ tx_pdus[1].pdu_length = 8;
+ tx_pdus[1].pdu_index = 2;
+ tx_pdus[1].num_segments = 2;
+ tx_pdus[1].segments[0].segment_length = 4;
+ tx_pdus[1].segments[0].segment_data = (uint8_t *)&data[0];
+ tx_pdus[1].segments[1].segment_length = 4;
+ tx_pdus[1].segments[1].segment_data = (uint8_t *)&data[1];
+ tx_req.tx_request_body.tx_pdu_list = tx_pdus;
+ mac->tx_req(mac, &tx_req);
+ }
+
+ void generate_subframe(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf) {
+ mac_internal_t *instance = (mac_internal_t *)mac;
+ nfapi_dl_config_request_t dl_config_req;
+ memset(&dl_config_req, 0, sizeof(dl_config_req));
+ dl_config_req.header.message_id = NFAPI_DL_CONFIG_REQUEST;
+ dl_config_req.header.phy_id = phy_id;
+ dl_config_req.sfn_sf = sfn_sf;
+ dl_config_req.dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
+ dl_config_req.dl_config_request_body.number_pdu = 8;
+ nfapi_dl_config_request_pdu_t pdus[8];
+ memset(&pdus, 0, sizeof(pdus));
+
+ for(int i = 0; i < 8; i++) {
+ pdus[i].pdu_type = NFAPI_DL_CONFIG_BCH_PDU_TYPE;
+ pdus[i].bch_pdu.bch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG;
+ pdus[i].bch_pdu.bch_pdu_rel8.length = 42;
+ pdus[i].bch_pdu.bch_pdu_rel8.pdu_index = i;
+ pdus[i].bch_pdu.bch_pdu_rel8.transmission_power = 56;
+ }
+
+ dl_config_req.dl_config_request_body.dl_config_pdu_list = pdus;
+ /*
+ vendor_ext_tlv_1 ve;
+ ve.tl.tag = VENDOR_EXT_TLV_1_TAG;
+ ve.dummy = 999;
+ dl_config_req.vendor_extension = &ve.tl;
+ */
+ mac->dl_config_req(mac, &dl_config_req);
+ nfapi_ul_config_request_t ul_config_req;
+ memset(&ul_config_req, 0, sizeof(ul_config_req));
+ ul_config_req.header.message_id = NFAPI_UL_CONFIG_REQUEST;
+ ul_config_req.header.phy_id = phy_id;
+ ul_config_req.sfn_sf = sfn_sf;
+ mac->ul_config_req(mac, &ul_config_req);
+ nfapi_hi_dci0_request_t hi_dci0_req;
+ memset(&hi_dci0_req, 0, sizeof(hi_dci0_req));
+ hi_dci0_req.header.message_id = NFAPI_HI_DCI0_REQUEST;
+ hi_dci0_req.header.phy_id = phy_id;
+ hi_dci0_req.sfn_sf = sfn_sf;
+ mac->hi_dci0_req(mac, &hi_dci0_req);
+ nfapi_tx_request_t tx_req;
+ memset(&tx_req, 0, sizeof(tx_req));
+ tx_req.header.message_id = NFAPI_TX_REQUEST;
+ tx_req.header.phy_id = phy_id;
+ tx_req.sfn_sf = sfn_sf;
+ nfapi_tx_request_pdu_t tx_pdus[8];
+ tx_req.tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
+ tx_req.tx_request_body.number_of_pdus = 0;
+ tx_req.tx_request_body.tx_pdu_list = &tx_pdus[0];
+ mac_pdu *buff = 0;
+ int i = 0;
+ std::list free_list;
+
+ do {
+ buff = instance->mac->pop_rx_buffer();
+
+ if(buff != 0) {
+ if(buff->len == 0) {
+ printf("[MAC] Buffer length = 0\n");
+ }
+
+ tx_req.tx_request_body.tx_pdu_list[i].pdu_length = buff->len;
+ tx_req.tx_request_body.tx_pdu_list[i].pdu_index = i;
+ tx_req.tx_request_body.tx_pdu_list[i].num_segments = 1;
+ tx_req.tx_request_body.tx_pdu_list[i].segments[0].segment_length = buff->len;
+ tx_req.tx_request_body.tx_pdu_list[i].segments[0].segment_data = (uint8_t *)buff->buffer;
+ tx_req.tx_request_body.number_of_pdus++;
+ i++;
+ instance->mac->byte_count += buff->len;
+ free_list.push_back(buff);
+ }
+ } while(buff != 0 && i < 8);
+
+ mac->tx_req(mac, &tx_req);
+
+ //for(int j = 0; j < tx_req.tx_request_body.number_of_pdus; ++j)
+ for(mac_pdu *pdu : free_list) {
+ instance->mac->release_mac_pdu(pdu);
+ //free(tx_req.tx_request_body.tx_pdu_list[j].segments[0].segment_data);
+ }
+ }
+
+ void mac_subframe_ind(mac_t *mac, uint16_t phy_id, uint16_t sfn_sf) {
+ //printf("[MAC] subframe indication phyid:%d sfnsf:%d\n", phy_id, sfn_sf);
+ mac_internal_t *instance = (mac_internal_t *)mac;
+
+ if(instance->mac->tick == 1000) {
+ if(instance->mac->byte_count > 0) {
+ printf("[MAC] Rx rate %d bytes/sec\n", instance->mac->byte_count);
+ instance->mac->byte_count = 0;
+ }
+
+ instance->mac->tick = 0;
+ }
+
+ instance->mac->tick++;
+
+ if(instance->mac->wireshark_test_mode) {
+ generate_test_subframe(mac, phy_id, sfn_sf);
+ } else {
+ generate_subframe(mac, phy_id, sfn_sf);
+ }
+ }
+
+ void mac_harq_ind(mac_t *mac, nfapi_harq_indication_t *ind) {
+ }
+ void mac_crc_ind(mac_t *mac, nfapi_crc_indication_t *ind) {
+ }
+ void mac_rx_ind(mac_t *mac, nfapi_rx_indication_t *ind) {
+ mac_internal_t *instance = (mac_internal_t *)mac;
+
+ for(int i = 0; i < ind->rx_indication_body.number_of_pdus; ++i) {
+ uint16_t len = ind->rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length;
+ uint8_t *data = ind->rx_indication_body.rx_pdu_list[i].data;
+ //printf("[MAC] sfnsf:%d len:%d\n", ind->sfn_sf,len);
+ //
+ instance->tx_byte_count += len;
+ int sendto_result = sendto(instance->tx_sock, data, len, 0, (struct sockaddr *)&(instance->tx_addr), sizeof(instance->tx_addr));
+
+ if(sendto_result < 0) {
+ // error
+ }
+ }
+ }
+ void mac_rach_ind(mac_t *mac, nfapi_rach_indication_t *ind) {
+ }
+ void mac_srs_ind(mac_t *mac, nfapi_srs_indication_t *ind) {
+ }
+ void mac_sr_ind(mac_t *mac, nfapi_sr_indication_t *ind) {
+ }
+ void mac_cqi_ind(mac_t *mac, nfapi_cqi_indication_t *ind) {
+ }
+ void mac_lbt_dl_ind(mac_t *mac, nfapi_lbt_dl_indication_t *ind) {
+ }
+ void mac_nb_harq_ind(mac_t *mac, nfapi_nb_harq_indication_t *ind) {
+ }
+ void mac_nrach_ind(mac_t *mac, nfapi_nrach_indication_t *ind) {
+ }
}
diff --git a/nfapi/open-nFAPI/vnf_sim/src/main.cpp b/nfapi/open-nFAPI/vnf_sim/src/main.cpp
index 5dc7161157..dedf06174f 100644
--- a/nfapi/open-nFAPI/vnf_sim/src/main.cpp
+++ b/nfapi/open-nFAPI/vnf_sim/src/main.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Cisco Systems, Inc.
- *
+ *
* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
- *
+ *
* 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.
@@ -38,8 +38,8 @@
#include
#include
#include
-#include
-#include
+#include
+#include
extern "C" {
#include
@@ -48,606 +48,486 @@ extern "C" {
#include
-//int vnf_main(int iPortP5, int, int);
-int start_simulated_mac(int*, int*);
-int read_xml(const char *xml_file);
+ //int vnf_main(int iPortP5, int, int);
+ int start_simulated_mac(int *, int *);
+ int read_xml(const char *xml_file);
}
-static uint32_t rand_range(uint32_t min, uint32_t max)
-{
- return ((rand() % (max + 1 - min)) + min);
+static uint32_t rand_range(uint32_t min, uint32_t max) {
+ return ((rand() % (max + 1 - min)) + min);
}
-void* vnf_allocate(size_t size)
-{
- return (void*)memory_pool::allocate(size);
+void *vnf_allocate(size_t size) {
+ return (void *)memory_pool::allocate(size);
}
-void vnf_deallocate(void* ptr)
-{
- memory_pool::deallocate((uint8_t*)ptr);
+void vnf_deallocate(void *ptr) {
+ memory_pool::deallocate((uint8_t *)ptr);
}
-class udp_data
-{
- public:
- bool enabled;
- uint32_t rx_port;
- uint32_t tx_port;
- std::string tx_addr;
+class udp_data {
+ public:
+ bool enabled;
+ uint32_t rx_port;
+ uint32_t tx_port;
+ std::string tx_addr;
};
-class phy_info
-{
- public:
+class phy_info {
+ public:
- uint16_t index;
- uint16_t id;
+ uint16_t index;
+ uint16_t id;
- std::vector rfs;
- std::vector excluded_rfs;
+ std::vector rfs;
+ std::vector excluded_rfs;
- int remote_port;
- std::string remote_addr;
+ int remote_port;
+ std::string remote_addr;
- uint16_t earfcn;
+ uint16_t earfcn;
};
-class rf_info
-{
- public:
+class rf_info {
+ public:
- uint16_t index;
- uint16_t band;
+ uint16_t index;
+ uint16_t band;
};
-class pnf_info
-{
- public:
+class pnf_info {
+ public:
- std::vector phys;
- std::vector rfs;
+ std::vector phys;
+ std::vector rfs;
};
-class vnf_p7_info
-{
- public:
- vnf_p7_info()
- : thread_started(false),
- config(nfapi_vnf_p7_config_create(),
- [] (nfapi_vnf_p7_config_t* f) { nfapi_vnf_p7_config_destory(f); }),
- mac(0)
- {
- local_port = 0;
-
- timing_window = 0;
- periodic_timing_enabled = 0;
- aperiodic_timing_enabled = 0;
- periodic_timing_period = 0;
-
- //config = nfapi_vnf_p7_config_create();
- }
-
- vnf_p7_info(const vnf_p7_info& other) = default;
-
- vnf_p7_info(vnf_p7_info&& other) = default;
-
- vnf_p7_info& operator=(const vnf_p7_info&) = default;
-
- vnf_p7_info& operator=(vnf_p7_info&&) = default;
-
-
-
- virtual ~vnf_p7_info()
- {
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "*** vnf_p7_info delete ***\n");
-
- //nfapi_vnf_p7_config_destory(config);
-
- // should we delete the mac?
- }
-
+class vnf_p7_info {
+ public:
- int local_port;
- std::string local_addr;
+ vnf_p7_info()
+ : thread_started(false),
+ config(nfapi_vnf_p7_config_create(),
+ [] (nfapi_vnf_p7_config_t *f) {
+ nfapi_vnf_p7_config_destory(f);
+ }),
+ mac(0) {
+ local_port = 0;
+ udp=0;
+ timing_window = 0;
+ periodic_timing_enabled = 0;
+ aperiodic_timing_enabled = 0;
+ periodic_timing_period = 0;
+ //config = nfapi_vnf_p7_config_create();
+ }
- unsigned timing_window;
- unsigned periodic_timing_enabled;
- unsigned aperiodic_timing_enabled;
- unsigned periodic_timing_period;
+ vnf_p7_info(const vnf_p7_info &other) = default;
- // This is not really the right place if we have multiple PHY,
- // should be part of the phy struct
- udp_data udp;
+ vnf_p7_info(vnf_p7_info &&other) = default;
- bool thread_started;
+ vnf_p7_info &operator=(const vnf_p7_info &) = default;
- //nfapi_vnf_p7_config_t* config;
- std::shared_ptr config;
+ vnf_p7_info &operator=(vnf_p7_info &&) = default;
- mac_t* mac;
+ virtual ~vnf_p7_info() {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "*** vnf_p7_info delete ***\n");
+ //nfapi_vnf_p7_config_destory(config);
+ // should we delete the mac?
+ }
+
+
+ int local_port;
+ std::string local_addr;
+
+ unsigned timing_window;
+ unsigned periodic_timing_enabled;
+ unsigned aperiodic_timing_enabled;
+ unsigned periodic_timing_period;
+
+ // This is not really the right place if we have multiple PHY,
+ // should be part of the phy struct
+ udp_data udp;
+
+ bool thread_started;
+
+ //nfapi_vnf_p7_config_t* config;
+ std::shared_ptr config;
+
+ mac_t *mac;
+
};
-class vnf_info
-{
- public:
-
- uint8_t wireshark_test_mode;
+class vnf_info {
+ public:
- std::map pnfs;
+ uint8_t wireshark_test_mode;
+
+ std::map pnfs;
+
+ std::vector p7_vnfs;
- std::vector p7_vnfs;
-
};
/// maybe these should be in the mac file...
-int phy_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p7_codec_config_t* codec)
-{
- (void)tl;
- (void)ppReadPackedMessage;
- (void)ve;
- return -1;
+int phy_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p7_codec_config_t *codec) {
+ (void)tl;
+ (void)ppReadPackedMessage;
+ (void)ve;
+ return -1;
}
-int phy_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* codec)
-{
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n");
+int phy_pack_vendor_extension_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *codec) {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "phy_pack_vendor_extension_tlv\n");
+ nfapi_tl_t *tlv = (nfapi_tl_t *)ve;
- nfapi_tl_t* tlv = (nfapi_tl_t*)ve;
- switch(tlv->tag)
- {
- case VENDOR_EXT_TLV_1_TAG:
- {
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n");
- vendor_ext_tlv_1* ve = (vendor_ext_tlv_1*)tlv;
- if(!push32(ve->dummy, ppWritePackedMsg, end))
- return 0;
- return 1;
- }
- break;
- default:
- return -1;
- break;
- }
+ switch(tlv->tag) {
+ case VENDOR_EXT_TLV_1_TAG: {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_1\n");
+ vendor_ext_tlv_1 *ve = (vendor_ext_tlv_1 *)tlv;
+
+ if(!push32(ve->dummy, ppWritePackedMsg, end))
+ return 0;
+
+ return 1;
+ }
+ break;
+
+ default:
+ return -1;
+ break;
+ }
}
-int vnf_sim_pack_vendor_extension_tlv(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec)
-{
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "pnf_sim_pack_vendor_extension_tlv\n");
- nfapi_tl_t* tlv = (nfapi_tl_t*)ve;
- switch(tlv->tag)
- {
- case VENDOR_EXT_TLV_2_TAG:
- {
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n");
- vendor_ext_tlv_2* ve = (vendor_ext_tlv_2*)tlv;
- if(!push32(ve->dummy, ppWritePackedMsg, end))
- return 0;
- return 1;
- }
- break;
- }
- return -1;
+int vnf_sim_pack_vendor_extension_tlv(void *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "pnf_sim_pack_vendor_extension_tlv\n");
+ nfapi_tl_t *tlv = (nfapi_tl_t *)ve;
+
+ switch(tlv->tag) {
+ case VENDOR_EXT_TLV_2_TAG: {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "Packing VENDOR_EXT_TLV_2\n");
+ vendor_ext_tlv_2 *ve = (vendor_ext_tlv_2 *)tlv;
+
+ if(!push32(ve->dummy, ppWritePackedMsg, end))
+ return 0;
+
+ return 1;
+ }
+ break;
+ }
+
+ return -1;
}
-int vnf_sim_unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMessage, uint8_t *end, void** ve, nfapi_p4_p5_codec_config_t* codec)
-{
- return -1;
+int vnf_sim_unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMessage, uint8_t *end, void **ve, nfapi_p4_p5_codec_config_t *codec) {
+ return -1;
}
-int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t* config)
-{
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
- if(header->message_id == P7_VENDOR_EXT_IND)
- {
- vendor_ext_p7_ind* req = (vendor_ext_p7_ind*)(header);
- if(!pull16(ppReadPackedMessage, &req->error_code, end))
- return 0;
- }
- return 1;
+int phy_unpack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p7_codec_config_t *config) {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
+ if(header->message_id == P7_VENDOR_EXT_IND) {
+ vendor_ext_p7_ind *req = (vendor_ext_p7_ind *)(header);
+
+ if(!pull16(ppReadPackedMessage, &req->error_code, end))
+ return 0;
+ }
+
+ return 1;
}
-int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
-{
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
- if(header->message_id == P7_VENDOR_EXT_REQ)
- {
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
- vendor_ext_p7_req* req = (vendor_ext_p7_req*)(header);
- if(!(push16(req->dummy1, ppWritePackedMsg, end) &&
- push16(req->dummy2, ppWritePackedMsg, end)))
- return 0;
- }
- return 1;
+int phy_pack_p7_vendor_extension(nfapi_p7_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
+ if(header->message_id == P7_VENDOR_EXT_REQ) {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
+ vendor_ext_p7_req *req = (vendor_ext_p7_req *)(header);
+
+ if(!(push16(req->dummy1, ppWritePackedMsg, end) &&
+ push16(req->dummy2, ppWritePackedMsg, end)))
+ return 0;
+ }
+
+ return 1;
}
-int vnf_sim_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t* codec)
-{
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
- if(header->message_id == P5_VENDOR_EXT_RSP)
- {
- vendor_ext_p5_rsp* req = (vendor_ext_p5_rsp*)(header);
- return(!pull16(ppReadPackedMessage, &req->error_code, end));
- }
- return 0;
-}
-
-int vnf_sim_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t* header, uint8_t** ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* codec)
-{
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
- if(header->message_id == P5_VENDOR_EXT_REQ)
- {
- vendor_ext_p5_req* req = (vendor_ext_p5_req*)(header);
- //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2);
- return (!(push16(req->dummy1, ppWritePackedMsg, end) &&
- push16(req->dummy2, ppWritePackedMsg, end)));
- }
- return 0;
-}
-
-void vnf_sim_trace(nfapi_trace_level_t level, const char* message, ...)
-{
- va_list args;
- va_start(args, message);
- vprintf(message, args);
- va_end(args);
-}
-
-void mac_dl_config_req(mac_t* mac, nfapi_dl_config_request_t* req)
-{
- vnf_p7_info* info = (vnf_p7_info*)(mac->user_data);
-
- nfapi_vnf_p7_dl_config_req(info->config.get(), req);
-}
-
-void mac_ul_config_req(mac_t* mac, nfapi_ul_config_request_t* req)
-{
- vnf_p7_info* info = (vnf_p7_info*)(mac->user_data);
-
- nfapi_vnf_p7_ul_config_req(info->config.get(), req);
-}
-
-void mac_hi_dci0_req(mac_t* mac, nfapi_hi_dci0_request_t* req)
-{
- vnf_p7_info* info = (vnf_p7_info*)(mac->user_data);
-
- nfapi_vnf_p7_hi_dci0_req(info->config.get(), req);
-}
-
-void mac_tx_req(mac_t* mac, nfapi_tx_request_t* req)
-{
- vnf_p7_info* info = (vnf_p7_info*)(mac->user_data);
-
- nfapi_vnf_p7_tx_req(info->config.get(), req);
-}
-
-int phy_subframe_indication(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf)
-{
- //printf("[VNF_SIM] subframe indication %d\n", sfn_sf);
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_subframe_ind(p7_vnf->mac, phy_id, sfn_sf);
- return 0;
-}
-int phy_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_harq_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_harq_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_crc_indication(struct nfapi_vnf_p7_config* config, nfapi_crc_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_crc_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_rx_indication(struct nfapi_vnf_p7_config* config, nfapi_rx_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_rx_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_rach_indication(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_rach_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_srs_indication(struct nfapi_vnf_p7_config* config, nfapi_srs_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_srs_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_sr_indication(struct nfapi_vnf_p7_config* config, nfapi_sr_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_sr_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_cqi_indication(struct nfapi_vnf_p7_config* config, nfapi_cqi_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_cqi_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_lbt_dl_indication(struct nfapi_vnf_p7_config* config, nfapi_lbt_dl_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_lbt_dl_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_nb_harq_indication(struct nfapi_vnf_p7_config* config, nfapi_nb_harq_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_nb_harq_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_nrach_indication(struct nfapi_vnf_p7_config* config, nfapi_nrach_indication_t* ind)
-{
- vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
- mac_nrach_ind(p7_vnf->mac, ind);
- return 1;
-}
-int phy_vendor_ext(struct nfapi_vnf_p7_config* config, nfapi_p7_message_header_t* msg)
-{
- if(msg->message_id == P7_VENDOR_EXT_IND)
- {
- //vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg;
- //printf("[VNF_SIM] vendor_ext (error_code:%d)\n", ind->error_code);
- }
- else
- {
- printf("[VNF_SIM] unknown %d\n", msg->message_id);
- }
- return 0;
-}
-nfapi_p7_message_header_t* phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t* msg_size)
-{
- if(message_id == P7_VENDOR_EXT_IND)
- {
- *msg_size = sizeof(vendor_ext_p7_ind);
- return (nfapi_p7_message_header_t*)malloc(sizeof(vendor_ext_p7_ind));
- }
- return 0;
-}
-void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t* header)
-{
- free(header);
-}
-
-//static pthread_t vnf_start_pthread;
-static pthread_t vnf_p7_start_pthread;
-void* vnf_p7_start_thread(void *ptr)
-{
- printf("%s()\n", __FUNCTION__);
-
- //std::shared_ptr config = std::shared_ptr(ptr);
- nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr;
-
- nfapi_vnf_p7_start(config);
+int vnf_sim_unpack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppReadPackedMessage, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
+ if(header->message_id == P5_VENDOR_EXT_RSP) {
+ vendor_ext_p5_rsp *req = (vendor_ext_p5_rsp *)(header);
+ return(!pull16(ppReadPackedMessage, &req->error_code, end));
+ }
return 0;
}
-void set_thread_priority(int priority)
-{
- //printf("%s(priority:%d)\n", __FUNCTION__, priority);
-
- pthread_attr_t ptAttr;
-
- struct sched_param schedParam;
- schedParam.__sched_priority = priority; //79;
- if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0)
- {
- printf("Failed to set scheduler to SCHED_RR\n");
- }
+int vnf_sim_pack_p4_p5_vendor_extension(nfapi_p4_p5_message_header_t *header, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *codec) {
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s\n", __FUNCTION__);
+ if(header->message_id == P5_VENDOR_EXT_REQ) {
+ vendor_ext_p5_req *req = (vendor_ext_p5_req *)(header);
+ //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s %d %d\n", __FUNCTION__, req->dummy1, req->dummy2);
+ return (!(push16(req->dummy1, ppWritePackedMsg, end) &&
+ push16(req->dummy2, ppWritePackedMsg, end)));
+ }
- if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0)
- {
- printf("Failed to set pthread sched policy SCHED_RR\n");
- }
-
- pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED);
-
- struct sched_param thread_params;
- thread_params.sched_priority = 20;
- if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0)
- {
- printf("failed to set sched param\n");
- }
+ return 0;
}
-void* vnf_p7_thread_start(void* ptr)
-{
+void vnf_sim_trace(nfapi_trace_level_t level, const char *message, ...) {
+ va_list args;
+ va_start(args, message);
+ vprintf(message, args);
+ va_end(args);
+}
+
+void mac_dl_config_req(mac_t *mac, nfapi_dl_config_request_t *req) {
+ vnf_p7_info *info = (vnf_p7_info *)(mac->user_data);
+ nfapi_vnf_p7_dl_config_req(info->config.get(), req);
+}
+
+void mac_ul_config_req(mac_t *mac, nfapi_ul_config_request_t *req) {
+ vnf_p7_info *info = (vnf_p7_info *)(mac->user_data);
+ nfapi_vnf_p7_ul_config_req(info->config.get(), req);
+}
+
+void mac_hi_dci0_req(mac_t *mac, nfapi_hi_dci0_request_t *req) {
+ vnf_p7_info *info = (vnf_p7_info *)(mac->user_data);
+ nfapi_vnf_p7_hi_dci0_req(info->config.get(), req);
+}
+
+void mac_tx_req(mac_t *mac, nfapi_tx_request_t *req) {
+ vnf_p7_info *info = (vnf_p7_info *)(mac->user_data);
+ nfapi_vnf_p7_tx_req(info->config.get(), req);
+}
+
+int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn_sf) {
+ //printf("[VNF_SIM] subframe indication %d\n", sfn_sf);
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_subframe_ind(p7_vnf->mac, phy_id, sfn_sf);
+ return 0;
+}
+int phy_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_harq_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_harq_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_crc_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_rx_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_rach_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_srs_indication(struct nfapi_vnf_p7_config *config, nfapi_srs_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_srs_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_sr_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_cqi_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_lbt_dl_indication(struct nfapi_vnf_p7_config *config, nfapi_lbt_dl_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_lbt_dl_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_nb_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_nb_harq_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_nb_harq_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_nrach_indication(struct nfapi_vnf_p7_config *config, nfapi_nrach_indication_t *ind) {
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)(config->user_data);
+ mac_nrach_ind(p7_vnf->mac, ind);
+ return 1;
+}
+int phy_vendor_ext(struct nfapi_vnf_p7_config *config, nfapi_p7_message_header_t *msg) {
+ if(msg->message_id == P7_VENDOR_EXT_IND) {
+ //vendor_ext_p7_ind* ind = (vendor_ext_p7_ind*)msg;
+ //printf("[VNF_SIM] vendor_ext (error_code:%d)\n", ind->error_code);
+ } else {
+ printf("[VNF_SIM] unknown %d\n", msg->message_id);
+ }
+
+ return 0;
+}
+nfapi_p7_message_header_t *phy_allocate_p7_vendor_ext(uint16_t message_id, uint16_t *msg_size) {
+ if(message_id == P7_VENDOR_EXT_IND) {
+ *msg_size = sizeof(vendor_ext_p7_ind);
+ return (nfapi_p7_message_header_t *)malloc(sizeof(vendor_ext_p7_ind));
+ }
+
+ return 0;
+}
+void phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) {
+ free(header);
+}
+
+//static pthread_t vnf_start_pthread;
+static pthread_t vnf_p7_start_pthread;
+void *vnf_p7_start_thread(void *ptr) {
printf("%s()\n", __FUNCTION__);
-
- set_thread_priority(79);
-
- vnf_p7_info* p7_vnf = (vnf_p7_info*)ptr;
-
- p7_vnf->config->port = p7_vnf->local_port;
- p7_vnf->config->subframe_indication = &phy_subframe_indication;
- p7_vnf->config->harq_indication = &phy_harq_indication;
- p7_vnf->config->crc_indication = &phy_crc_indication;
- p7_vnf->config->rx_indication = &phy_rx_indication;
- p7_vnf->config->rach_indication = &phy_rach_indication;
- p7_vnf->config->srs_indication = &phy_srs_indication;
- p7_vnf->config->sr_indication = &phy_sr_indication;
- p7_vnf->config->cqi_indication = &phy_cqi_indication;
- p7_vnf->config->lbt_dl_indication = &phy_lbt_dl_indication;
- p7_vnf->config->nb_harq_indication = &phy_nb_harq_indication;
- p7_vnf->config->nrach_indication = &phy_nrach_indication;
- p7_vnf->config->malloc = &vnf_allocate;
- p7_vnf->config->free = &vnf_deallocate;
-
- p7_vnf->config->trace = &vnf_sim_trace;
-
- p7_vnf->config->vendor_ext = &phy_vendor_ext;
- p7_vnf->config->user_data = p7_vnf;
-
- p7_vnf->mac->user_data = p7_vnf;
-
- p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension;
- p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension;
- p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv;
- p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv;
- p7_vnf->config->codec_config.allocate = &vnf_allocate;
- p7_vnf->config->codec_config.deallocate = &vnf_deallocate;
-
- p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext;
- p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext;
-
- printf("[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
- pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config.get());
-
- return 0;
+ //std::shared_ptr config = std::shared_ptr(ptr);
+ nfapi_vnf_p7_config_t *config = (nfapi_vnf_p7_config_t *)ptr;
+ nfapi_vnf_p7_start(config);
+ return 0;
}
-int pnf_connection_indication_cb(nfapi_vnf_config_t* config, int p5_idx)
-{
- printf("[VNF_SIM] pnf connection indication idx:%d\n", p5_idx);
+void set_thread_priority(int priority) {
+ //printf("%s(priority:%d)\n", __FUNCTION__, priority);
+ pthread_attr_t ptAttr;
+ struct sched_param schedParam;
+ schedParam.__sched_priority = priority; //79;
- pnf_info pnf;
- vnf_info* vnf = (vnf_info*)(config->user_data);
- vnf->pnfs.insert(std::pair(p5_idx, pnf));
+ if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) {
+ printf("Failed to set scheduler to SCHED_RR\n");
+ }
- nfapi_pnf_param_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_PNF_PARAM_REQUEST;
- nfapi_vnf_pnf_param_req(config, p5_idx, &req);
- return 0;
-}
-int pnf_disconnection_indication_cb(nfapi_vnf_config_t* config, int p5_idx)
-{
- printf("[VNF_SIM] pnf disconnection indication idx:%d\n", p5_idx);
+ if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) {
+ printf("Failed to set pthread sched policy SCHED_RR\n");
+ }
-
- vnf_info* vnf = (vnf_info*)(config->user_data);
- auto find_result = vnf->pnfs.find(p5_idx);
-
- if(find_result != vnf->pnfs.end())
- {
- pnf_info& pnf = find_result->second;
+ pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED);
+ struct sched_param thread_params;
+ thread_params.sched_priority = 20;
- for(phy_info& phy : pnf.phys)
- {
- vnf_p7_info& p7_vnf = vnf->p7_vnfs[0];
- nfapi_vnf_p7_del_pnf((p7_vnf.config.get()), phy.id);
- }
- }
-
- return 0;
+ if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) {
+ printf("failed to set sched param\n");
+ }
}
-int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_response_t* resp)
-{
- printf("[VNF_SIM] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code);
-
- vnf_info* vnf = (vnf_info*)(config->user_data);
-
- auto find_result = vnf->pnfs.find(p5_idx);
- if(find_result != vnf->pnfs.end())
- {
- pnf_info& pnf = find_result->second;
-
- for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i)
- {
- phy_info phy;
- phy.index = resp->pnf_phy.phy[i].phy_config_index;
-
- printf("[VNF_SIM] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index);
-
- nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id));
-
-
-
- for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j)
- {
- printf("[VNF_SIM] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index);
- phy.rfs.push_back(resp->pnf_phy.phy[i].rf_config[j].rf_config_index);
- }
-
-
- pnf.phys.push_back(phy);
- }
- for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i)
- {
- rf_info rf;
- rf.index = resp->pnf_rf.rf[i].rf_config_index;
-
- printf("[VNF_SIM] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index);
-
- pnf.rfs.push_back(rf);
- }
-
- nfapi_pnf_config_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_PNF_CONFIG_REQUEST;
-
- req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG;
- req.pnf_phy_rf_config.number_phy_rf_config_info = pnf.phys.size();
-
- for(unsigned i = 0; i < pnf.phys.size(); ++i)
- {
- req.pnf_phy_rf_config.phy_rf_config[i].phy_id = pnf.phys[i].id;
- req.pnf_phy_rf_config.phy_rf_config[i].phy_config_index = pnf.phys[i].index;
- req.pnf_phy_rf_config.phy_rf_config[i].rf_config_index = pnf.phys[i].rfs[0];
- }
-
-
- nfapi_vnf_pnf_config_req(config, p5_idx, &req);
- }
- return 0;
+void *vnf_p7_thread_start(void *ptr) {
+ printf("%s()\n", __FUNCTION__);
+ set_thread_priority(79);
+ vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr;
+ p7_vnf->config->port = p7_vnf->local_port;
+ p7_vnf->config->subframe_indication = &phy_subframe_indication;
+ p7_vnf->config->harq_indication = &phy_harq_indication;
+ p7_vnf->config->crc_indication = &phy_crc_indication;
+ p7_vnf->config->rx_indication = &phy_rx_indication;
+ p7_vnf->config->rach_indication = &phy_rach_indication;
+ p7_vnf->config->srs_indication = &phy_srs_indication;
+ p7_vnf->config->sr_indication = &phy_sr_indication;
+ p7_vnf->config->cqi_indication = &phy_cqi_indication;
+ p7_vnf->config->lbt_dl_indication = &phy_lbt_dl_indication;
+ p7_vnf->config->nb_harq_indication = &phy_nb_harq_indication;
+ p7_vnf->config->nrach_indication = &phy_nrach_indication;
+ p7_vnf->config->malloc = &vnf_allocate;
+ p7_vnf->config->free = &vnf_deallocate;
+ p7_vnf->config->trace = &vnf_sim_trace;
+ p7_vnf->config->vendor_ext = &phy_vendor_ext;
+ p7_vnf->config->user_data = p7_vnf;
+ p7_vnf->mac->user_data = p7_vnf;
+ p7_vnf->config->codec_config.unpack_p7_vendor_extension = &phy_unpack_p7_vendor_extension;
+ p7_vnf->config->codec_config.pack_p7_vendor_extension = &phy_pack_p7_vendor_extension;
+ p7_vnf->config->codec_config.unpack_vendor_extension_tlv = &phy_unpack_vendor_extension_tlv;
+ p7_vnf->config->codec_config.pack_vendor_extension_tlv = &phy_pack_vendor_extension_tlv;
+ p7_vnf->config->codec_config.allocate = &vnf_allocate;
+ p7_vnf->config->codec_config.deallocate = &vnf_deallocate;
+ p7_vnf->config->allocate_p7_vendor_ext = &phy_allocate_p7_vendor_ext;
+ p7_vnf->config->deallocate_p7_vendor_ext = &phy_deallocate_p7_vendor_ext;
+ printf("[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
+ pthread_create(&vnf_p7_start_pthread, NULL, &vnf_p7_start_thread, p7_vnf->config.get());
+ return 0;
}
-int pnf_config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_config_response_t* resp)
-{
- printf("[VNF_SIM] pnf config response idx:%d\n", p5_idx);
-
- if(1)
- {
- vnf_info* vnf = (vnf_info*)(config->user_data);
- auto find_result = vnf->pnfs.find(p5_idx);
- if(find_result != vnf->pnfs.end())
- {
- //pnf_info& pnf = find_result->second;
+int pnf_connection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
+ printf("[VNF_SIM] pnf connection indication idx:%d\n", p5_idx);
+ pnf_info pnf;
+ vnf_info *vnf = (vnf_info *)(config->user_data);
+ vnf->pnfs.insert(std::pair(p5_idx, pnf));
+ nfapi_pnf_param_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_PNF_PARAM_REQUEST;
+ nfapi_vnf_pnf_param_req(config, p5_idx, &req);
+ return 0;
+}
+int pnf_disconnection_indication_cb(nfapi_vnf_config_t *config, int p5_idx) {
+ printf("[VNF_SIM] pnf disconnection indication idx:%d\n", p5_idx);
+ vnf_info *vnf = (vnf_info *)(config->user_data);
+ auto find_result = vnf->pnfs.find(p5_idx);
- nfapi_pnf_start_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_PNF_START_REQUEST;
- nfapi_vnf_pnf_start_req(config, p5_idx, &req);
- }
- }
- else
- {
- // Rather than send the pnf_start_request we will demonstrate
- // sending a vendor extention message. The start request will be
- // send when the vendor extension response is received
+ if(find_result != vnf->pnfs.end()) {
+ pnf_info &pnf = find_result->second;
- //vnf_info* vnf = (vnf_info*)(config->user_data);
- vendor_ext_p5_req req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = P5_VENDOR_EXT_REQ;
- req.dummy1 = 45;
- req.dummy2 = 1977;
- nfapi_vnf_vendor_extension(config, p5_idx, &req.header);
- }
- return 0;
+ for(phy_info &phy : pnf.phys) {
+ vnf_p7_info &p7_vnf = vnf->p7_vnfs[0];
+ nfapi_vnf_p7_del_pnf((p7_vnf.config.get()), phy.id);
+ }
+ }
+
+ return 0;
}
+int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_response_t *resp) {
+ printf("[VNF_SIM] pnf param response idx:%d error:%d\n", p5_idx, resp->error_code);
+ vnf_info *vnf = (vnf_info *)(config->user_data);
+ auto find_result = vnf->pnfs.find(p5_idx);
+
+ if(find_result != vnf->pnfs.end()) {
+ pnf_info &pnf = find_result->second;
+
+ for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) {
+ phy_info phy;
+ phy.index = resp->pnf_phy.phy[i].phy_config_index;
+ printf("[VNF_SIM] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index);
+ nfapi_vnf_allocate_phy(config, p5_idx, &(phy.id));
+
+ for(int j = 0; j < resp->pnf_phy.phy[i].number_of_rfs; ++j) {
+ printf("[VNF_SIM] (PHY:%d) (RF%d) %d\n", i, j, resp->pnf_phy.phy[i].rf_config[j].rf_config_index);
+ phy.rfs.push_back(resp->pnf_phy.phy[i].rf_config[j].rf_config_index);
+ }
+
+ pnf.phys.push_back(phy);
+ }
+
+ for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) {
+ rf_info rf;
+ rf.index = resp->pnf_rf.rf[i].rf_config_index;
+ printf("[VNF_SIM] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index);
+ pnf.rfs.push_back(rf);
+ }
+
+ nfapi_pnf_config_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_PNF_CONFIG_REQUEST;
+ req.pnf_phy_rf_config.tl.tag = NFAPI_PNF_PHY_RF_TAG;
+ req.pnf_phy_rf_config.number_phy_rf_config_info = pnf.phys.size();
+
+ for(unsigned i = 0; i < pnf.phys.size(); ++i) {
+ req.pnf_phy_rf_config.phy_rf_config[i].phy_id = pnf.phys[i].id;
+ req.pnf_phy_rf_config.phy_rf_config[i].phy_config_index = pnf.phys[i].index;
+ req.pnf_phy_rf_config.phy_rf_config[i].rf_config_index = pnf.phys[i].rfs[0];
+ }
+
+ nfapi_vnf_pnf_config_req(config, p5_idx, &req);
+ }
+}
int pnf_start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_start_response_t* resp)
{
printf("[VNF_SIM] pnf start response idx:%d\n", p5_idx);
@@ -716,7 +596,7 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t
// for now just 1
vnf_p7_info& p7_vnf = vnf->p7_vnfs[0];
- printf("[VNF_SIM] %d.%d pnf p7 %s:%d timing %d %d %d %d\n", p5_idx, phy.id, phy.remote_addr.c_str(), phy.remote_port, p7_vnf.timing_window, p7_vnf.periodic_timing_period, p7_vnf.aperiodic_timing_enabled, p7_vnf.periodic_timing_period);
+ printf("[VNF_SIM] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy.id, phy.remote_addr.c_str(), phy.remote_port, p7_vnf.timing_window, p7_vnf.periodic_timing_period, p7_vnf.aperiodic_timing_enabled, p7_vnf.periodic_timing_period);
nfapi_config_request_t req;
@@ -1065,461 +945,768 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t
return 0;
}
-int config_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_config_response_t* resp)
-{
- printf("[VNF_SIM] config response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
+int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_response_t *resp) {
+ printf("[VNF_SIM] pnf config response idx:%d\n", p5_idx);
+ if(1) {
+ vnf_info *vnf = (vnf_info *)(config->user_data);
+ auto find_result = vnf->pnfs.find(p5_idx);
- nfapi_start_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_START_REQUEST;
- req.header.phy_id = resp->header.phy_id;
- nfapi_vnf_start_req(config, p5_idx, &req);
+ if(find_result != vnf->pnfs.end()) {
+ //pnf_info& pnf = find_result->second;
+ nfapi_pnf_start_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_PNF_START_REQUEST;
+ nfapi_vnf_pnf_start_req(config, p5_idx, &req);
+ }
+ } else {
+ // Rather than send the pnf_start_request we will demonstrate
+ // sending a vendor extention message. The start request will be
+ // send when the vendor extension response is received
+ //vnf_info* vnf = (vnf_info*)(config->user_data);
+ vendor_ext_p5_req req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = P5_VENDOR_EXT_REQ;
+ req.dummy1 = 45;
+ req.dummy2 = 1977;
+ nfapi_vnf_vendor_extension(config, p5_idx, &req.header);
+ }
- return 0;
+ return 0;
}
-void test_p4_requests(nfapi_vnf_config_t* config, int p5_idx, int phy_id)
-{
- {
- nfapi_measurement_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_MEASUREMENT_REQUEST;
- req.header.phy_id = phy_id;
-
- req.dl_rs_tx_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG;
- req.dl_rs_tx_power.value = 42;
- req.received_interference_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG;
- req.received_interference_power.value = 42;
- req.thermal_noise_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG;
- req.thermal_noise_power.value = 42;
-
- nfapi_vnf_measurement_req(config, p5_idx, &req);
- }
- {
- nfapi_rssi_request_t lte_req;
- memset(<e_req, 0, sizeof(lte_req));
- lte_req.header.message_id = NFAPI_RSSI_REQUEST;
- lte_req.header.phy_id = phy_id;
-
- lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
- lte_req.lte_rssi_request.tl.tag = NFAPI_LTE_RSSI_REQUEST_TAG;
- lte_req.lte_rssi_request.frequency_band_indicator = 2;
- lte_req.lte_rssi_request.measurement_period = 1000;
- lte_req.lte_rssi_request.bandwidth = 50;
- lte_req.lte_rssi_request.timeout = 0;
- lte_req.lte_rssi_request.number_of_earfcns = 2;
- lte_req.lte_rssi_request.earfcn[0] = 389;
- lte_req.lte_rssi_request.earfcn[1] = 123;
-
- nfapi_vnf_rssi_request(config, p5_idx, <e_req);
-
- nfapi_rssi_request_t utran_req;
- memset(&utran_req, 0, sizeof(utran_req));
- utran_req.header.message_id = NFAPI_RSSI_REQUEST;
- utran_req.header.phy_id = phy_id;
-
- utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN;
- utran_req.utran_rssi_request.tl.tag = NFAPI_UTRAN_RSSI_REQUEST_TAG;
- utran_req.utran_rssi_request.frequency_band_indicator = 2;
- utran_req.utran_rssi_request.measurement_period = 1000;
- utran_req.utran_rssi_request.timeout = 0;
- utran_req.utran_rssi_request.number_of_uarfcns = 2;
- utran_req.utran_rssi_request.uarfcn[0] = 2348;
- utran_req.utran_rssi_request.uarfcn[1] = 52;
-
- nfapi_vnf_rssi_request(config, p5_idx, &utran_req);
-
-
- nfapi_rssi_request_t geran_req;
- memset(&geran_req, 0, sizeof(geran_req));
- geran_req.header.message_id = NFAPI_RSSI_REQUEST;
- geran_req.header.phy_id = phy_id;
-
- geran_req.rat_type = NFAPI_RAT_TYPE_GERAN;
- geran_req.geran_rssi_request.tl.tag = NFAPI_GERAN_RSSI_REQUEST_TAG;
- geran_req.geran_rssi_request.frequency_band_indicator = 2;
- geran_req.geran_rssi_request.measurement_period = 1000;
- geran_req.geran_rssi_request.timeout = 0;
- geran_req.geran_rssi_request.number_of_arfcns = 1;
- geran_req.geran_rssi_request.arfcn[0].arfcn = 34;
- geran_req.geran_rssi_request.arfcn[0].direction = 0;
-
- nfapi_vnf_rssi_request(config, p5_idx, &geran_req);
- }
- {
- nfapi_cell_search_request_t lte_req;
- memset(<e_req, 0, sizeof(lte_req));
- lte_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST;
- lte_req.header.phy_id = phy_id;
-
- lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
- lte_req.lte_cell_search_request.tl.tag = NFAPI_LTE_CELL_SEARCH_REQUEST_TAG;
- lte_req.lte_cell_search_request.earfcn = 1234;
- lte_req.lte_cell_search_request.measurement_bandwidth = 50;
- lte_req.lte_cell_search_request.exhaustive_search = 1;
- lte_req.lte_cell_search_request.timeout = 1000;
- lte_req.lte_cell_search_request.number_of_pci = 1;
- lte_req.lte_cell_search_request.pci[0] = 234;
-
- nfapi_vnf_cell_search_request(config, p5_idx, <e_req);
-
- nfapi_cell_search_request_t utran_req;
- memset(&utran_req, 0, sizeof(utran_req));
- utran_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST;
- utran_req.header.phy_id = phy_id;
-
- utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN;
- utran_req.utran_cell_search_request.tl.tag = NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG;
- utran_req.utran_cell_search_request.uarfcn = 1234;
- utran_req.utran_cell_search_request.exhaustive_search = 0;
- utran_req.utran_cell_search_request.timeout = 1000;
- utran_req.utran_cell_search_request.number_of_psc = 1;
- utran_req.utran_cell_search_request.psc[0] = 234;
-
- nfapi_vnf_cell_search_request(config, p5_idx, &utran_req);
-
- nfapi_cell_search_request_t geran_req;
- memset(&geran_req, 0, sizeof(geran_req));
- geran_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST;
- geran_req.header.phy_id = phy_id;
-
- geran_req.rat_type = NFAPI_RAT_TYPE_GERAN;
- geran_req.geran_cell_search_request.tl.tag = NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG;
- geran_req.geran_cell_search_request.timeout = 1000;
- geran_req.geran_cell_search_request.number_of_arfcn = 1;
- geran_req.geran_cell_search_request.arfcn[0] = 8765;
-
- nfapi_vnf_cell_search_request(config, p5_idx, &geran_req);
- }
- {
- nfapi_broadcast_detect_request_t lte_req;
- memset(<e_req, 0, sizeof(lte_req));
- lte_req.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST;
- lte_req.header.phy_id = phy_id;
-
- lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
- lte_req.lte_broadcast_detect_request.tl.tag = NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG;
- lte_req.lte_broadcast_detect_request.earfcn = 1234;
- lte_req.lte_broadcast_detect_request.pci = 50;
- lte_req.lte_broadcast_detect_request.timeout = 1000;
-
- lte_req.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG;
- lte_req.pnf_cell_search_state.length = 3;
-
- nfapi_vnf_broadcast_detect_request(config, p5_idx, <e_req);
-
- nfapi_broadcast_detect_request_t utran_req;
- memset(&utran_req, 0, sizeof(utran_req));
- utran_req.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST;
- utran_req.header.phy_id = phy_id;
-
- utran_req.rat_type = NFAPI_RAT_TYPE_LTE;
- utran_req.utran_broadcast_detect_request.tl.tag = NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG;
- utran_req.utran_broadcast_detect_request.uarfcn = 1234;
- utran_req.utran_broadcast_detect_request.psc = 50;
- utran_req.utran_broadcast_detect_request.timeout = 1000;
-
- utran_req.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG;
- utran_req.pnf_cell_search_state.length = 3;
-
- nfapi_vnf_broadcast_detect_request(config, p5_idx, &utran_req);
- }
- {
- nfapi_system_information_schedule_request_t lte_req;
- memset(<e_req, 0, sizeof(lte_req));
- lte_req.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST;
- lte_req.header.phy_id = phy_id;
-
- lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
- lte_req.lte_system_information_schedule_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG;
- lte_req.lte_system_information_schedule_request.earfcn = 1234;
- lte_req.lte_system_information_schedule_request.pci = 50;
- lte_req.lte_system_information_schedule_request.downlink_channel_bandwidth = 100;
- lte_req.lte_system_information_schedule_request.phich_configuration = 3;
- lte_req.lte_system_information_schedule_request.number_of_tx_antenna = 2;
- lte_req.lte_system_information_schedule_request.retry_count = 4;
- lte_req.lte_system_information_schedule_request.timeout = 1000;
-
- lte_req.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG;
- lte_req.pnf_cell_broadcast_state.length = 3;
-
- nfapi_vnf_system_information_schedule_request(config, p5_idx, <e_req);
- }
- {
- nfapi_system_information_request_t lte_req;
- memset(<e_req, 0, sizeof(lte_req));
- lte_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST;
- lte_req.header.phy_id = phy_id;
-
- lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
- lte_req.lte_system_information_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG;
- lte_req.lte_system_information_request.earfcn = 1234;
- lte_req.lte_system_information_request.pci= 456;
- lte_req.lte_system_information_request.downlink_channel_bandwidth = 5;
- lte_req.lte_system_information_request.phich_configuration = 2;
- lte_req.lte_system_information_request.number_of_tx_antenna = 2;
- lte_req.lte_system_information_request.number_of_si_periodicity = 1;
- lte_req.lte_system_information_request.si_periodicity[0].si_periodicity = 3;
- lte_req.lte_system_information_request.si_periodicity[0].si_index = 3;
- lte_req.lte_system_information_request.si_window_length = 15;
- lte_req.lte_system_information_request.timeout = 1000;
-
- nfapi_vnf_system_information_request(config, p5_idx, <e_req);
-
- nfapi_system_information_request_t utran_req;
- memset(&utran_req, 0, sizeof(utran_req));
- utran_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST;
- utran_req.header.phy_id = phy_id;
-
- utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN;
- utran_req.utran_system_information_request.tl.tag = NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG;
- utran_req.utran_system_information_request.uarfcn = 1234;
- utran_req.utran_system_information_request.psc = 456;
- utran_req.utran_system_information_request.timeout = 1000;
-
- nfapi_vnf_system_information_request(config, p5_idx, &utran_req);
-
- nfapi_system_information_request_t geran_req;
- memset(&geran_req, 0, sizeof(geran_req));
- geran_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST;
- geran_req.header.phy_id = phy_id;
-
- geran_req.rat_type = NFAPI_RAT_TYPE_GERAN;
- geran_req.geran_system_information_request.tl.tag = NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG;
- geran_req.geran_system_information_request.arfcn = 1234;
- geran_req.geran_system_information_request.bsic = 21;
- geran_req.geran_system_information_request.timeout = 1000;
-
- nfapi_vnf_system_information_request(config, p5_idx, &geran_req);
- }
- {
- nfapi_nmm_stop_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_NMM_STOP_REQUEST;
- req.header.phy_id = phy_id;
- nfapi_vnf_nmm_stop_request(config, p5_idx, &req);
- }
+int pnf_start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_start_response_t *resp) {
+ printf("[VNF_SIM] pnf start response idx:%d\n", p5_idx);
+ vnf_info *vnf = (vnf_info *)(config->user_data);
+ vnf_p7_info &p7_vnf = vnf->p7_vnfs[0];
+
+ if(p7_vnf.thread_started == false) {
+ pthread_t vnf_p7_thread;
+ pthread_create(&vnf_p7_thread, NULL, &vnf_p7_thread_start, &p7_vnf);
+ p7_vnf.thread_started = true;
+ } else {
+ // P7 thread already running.
+ }
+
+ // start all the phys in the pnf.
+ auto find_result = vnf->pnfs.find(p5_idx);
+
+ if(find_result != vnf->pnfs.end()) {
+ pnf_info &pnf = find_result->second;
+
+ for(unsigned i = 0; i < pnf.phys.size(); ++i) {
+ pnf_info &pnf = find_result->second;
+ nfapi_param_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_PARAM_REQUEST;
+ req.header.phy_id = pnf.phys[i].id;
+ nfapi_vnf_param_req(config, p5_idx, &req);
+ }
+ }
+
+ return 0;
+}
+int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_param_response_t *resp) {
+ printf("[VNF_SIM] param response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
+ vnf_info *vnf = (vnf_info *)(config->user_data);
+ auto find_result = vnf->pnfs.find(p5_idx);
+
+ if(find_result != vnf->pnfs.end()) {
+ pnf_info &pnf = find_result->second;
+ auto found = std::find_if(pnf.phys.begin(), pnf.phys.end(), [&](phy_info& item) {
+ return item.id == resp->header.phy_id;
+ });
+
+ if(found != pnf.phys.end()) {
+ phy_info &phy = (*found);
+ phy.remote_port = resp->nfapi_config.p7_pnf_port.value;
+ struct sockaddr_in pnf_p7_sockaddr;
+ memcpy(&pnf_p7_sockaddr.sin_addr.s_addr, &(resp->nfapi_config.p7_pnf_address_ipv4.address[0]), 4);
+ phy.remote_addr = inet_ntoa(pnf_p7_sockaddr.sin_addr);
+ // for now just 1
+ vnf_p7_info &p7_vnf = vnf->p7_vnfs[0];
+ printf("[VNF_SIM] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy.id, phy.remote_addr.c_str(), phy.remote_port, p7_vnf.timing_window, p7_vnf.periodic_timing_period,
+ p7_vnf.aperiodic_timing_enabled, p7_vnf.periodic_timing_period);
+ nfapi_config_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_CONFIG_REQUEST;
+ req.header.phy_id = phy.id;
+ req.nfapi_config.p7_vnf_port.tl.tag = NFAPI_NFAPI_P7_VNF_PORT_TAG;
+ req.nfapi_config.p7_vnf_port.value = p7_vnf.local_port;
+ req.num_tlv++;
+ req.nfapi_config.p7_vnf_address_ipv4.tl.tag = NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG;
+ struct sockaddr_in vnf_p7_sockaddr;
+ vnf_p7_sockaddr.sin_addr.s_addr = inet_addr(p7_vnf.local_addr.c_str());
+ memcpy(&(req.nfapi_config.p7_vnf_address_ipv4.address[0]), &vnf_p7_sockaddr.sin_addr.s_addr, 4);
+ req.num_tlv++;
+ req.nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG;
+ req.nfapi_config.timing_window.value = p7_vnf.timing_window;
+ req.num_tlv++;
+
+ if(p7_vnf.periodic_timing_enabled || p7_vnf.aperiodic_timing_enabled) {
+ req.nfapi_config.timing_info_mode.tl.tag = NFAPI_NFAPI_TIMING_INFO_MODE_TAG;
+ req.nfapi_config.timing_info_mode.value = (p7_vnf.aperiodic_timing_enabled << 1) | (p7_vnf.periodic_timing_enabled);
+ req.num_tlv++;
+
+ if(p7_vnf.periodic_timing_enabled) {
+ req.nfapi_config.timing_info_period.tl.tag = NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG;
+ req.nfapi_config.timing_info_period.value = p7_vnf.periodic_timing_period;
+ req.num_tlv++;
+ }
+ }
+
+ req.nfapi_config.earfcn.tl.tag = NFAPI_NFAPI_EARFCN_TAG;
+ req.nfapi_config.earfcn.value = phy.earfcn;
+ req.num_tlv++;
+
+ if(1) {
+ // Poplate all tlv for wireshark testing
+ req.subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG;
+ req.num_tlv++;
+ req.subframe_config.pcfich_power_offset.tl.tag = NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG;
+ req.num_tlv++;
+ req.subframe_config.pb.tl.tag = NFAPI_SUBFRAME_CONFIG_PB_TAG;
+ req.num_tlv++;
+ req.subframe_config.dl_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG;
+ req.num_tlv++;
+ req.subframe_config.ul_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG;
+ req.num_tlv++;
+ req.rf_config.dl_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG;
+ req.num_tlv++;
+ req.rf_config.ul_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG;
+ req.num_tlv++;
+ req.rf_config.reference_signal_power.tl.tag = NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG;
+ req.num_tlv++;
+ req.rf_config.tx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG;
+ req.num_tlv++;
+ req.rf_config.rx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG;
+ req.num_tlv++;
+ req.phich_config.phich_resource.tl.tag = NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG;
+ req.num_tlv++;
+ req.phich_config.phich_duration.tl.tag = NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG;
+ req.num_tlv++;
+ req.phich_config.phich_power_offset.tl.tag = NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG;
+ req.num_tlv++;
+ req.sch_config.primary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG;
+ req.num_tlv++;
+ req.sch_config.secondary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG;
+ req.num_tlv++;
+ req.sch_config.physical_cell_id.tl.tag = NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG;
+ req.num_tlv++;
+ req.prach_config.configuration_index.tl.tag = NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG;
+ req.num_tlv++;
+ req.prach_config.root_sequence_index.tl.tag = NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG;
+ req.num_tlv++;
+ req.prach_config.zero_correlation_zone_configuration.tl.tag = NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG;
+ req.num_tlv++;
+ req.prach_config.high_speed_flag.tl.tag = NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG;
+ req.num_tlv++;
+ req.prach_config.frequency_offset.tl.tag = NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG;
+ req.num_tlv++;
+ req.pusch_config.hopping_mode.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG;
+ req.num_tlv++;
+ req.pusch_config.hopping_offset.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG;
+ req.num_tlv++;
+ req.pusch_config.number_of_subbands.tl.tag = NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG;
+ req.num_tlv++;
+ req.pucch_config.delta_pucch_shift.tl.tag = NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG;
+ req.num_tlv++;
+ req.pucch_config.n_cqi_rb.tl.tag = NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG;
+ req.num_tlv++;
+ req.pucch_config.n_an_cs.tl.tag = NFAPI_PUCCH_CONFIG_N_AN_CS_TAG;
+ req.num_tlv++;
+ req.pucch_config.n1_pucch_an.tl.tag = NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG;
+ req.num_tlv++;
+ req.srs_config.bandwidth_configuration.tl.tag = NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG;
+ req.num_tlv++;
+ req.srs_config.max_up_pts.tl.tag = NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG;
+ req.num_tlv++;
+ req.srs_config.srs_subframe_configuration.tl.tag = NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG;
+ req.num_tlv++;
+ req.srs_config.srs_acknack_srs_simultaneous_transmission.tl.tag = NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG;
+ req.num_tlv++;
+ req.uplink_reference_signal_config.uplink_rs_hopping.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG;
+ req.num_tlv++;
+ req.uplink_reference_signal_config.group_assignment.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG;
+ req.num_tlv++;
+ req.uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG;
+ req.num_tlv++;
+ req.laa_config.ed_threshold_lbt_pdsch.tl.tag = NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG;
+ req.num_tlv++;
+ req.laa_config.ed_threshold_lbt_drs.tl.tag = NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG;
+ req.num_tlv++;
+ req.laa_config.pd_threshold.tl.tag = NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG;
+ req.num_tlv++;
+ req.laa_config.multi_carrier_type.tl.tag = NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG;
+ req.num_tlv++;
+ req.laa_config.multi_carrier_tx.tl.tag = NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG;
+ req.num_tlv++;
+ req.laa_config.multi_carrier_freeze.tl.tag = NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG;
+ req.num_tlv++;
+ req.laa_config.tx_antenna_ports_drs.tl.tag = NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG;
+ req.num_tlv++;
+ req.laa_config.tx_power_drs.tl.tag = NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG;
+ req.num_tlv++;
+ req.emtc_config.pbch_repetitions_enable_r13.tl.tag = NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_catm_root_sequence_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_catm_zero_correlation_zone_configuration.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_catm_high_speed_flag.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_0_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_0_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_0_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_0_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_0_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_1_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_1_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_1_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_1_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_1_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_1_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_2_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_2_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_2_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_2_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_2_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_3_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_3_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_3_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_3_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG;
+ req.num_tlv++;
+ req.emtc_config.prach_ce_level_3_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG;
+ req.num_tlv++;
+ req.emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG;
+ req.num_tlv++;
+ req.emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG;
+ req.num_tlv++;
+ req.nb_iot_config.operating_mode.tl.tag = NFAPI_NB_IOT_CONFIG_OPERATING_MODE_TAG;
+ req.nb_iot_config.operating_mode.value = rand_range(0, 3);
+ req.num_tlv++;
+ req.nb_iot_config.anchor.tl.tag = NFAPI_NB_IOT_CONFIG_ANCHOR_TAG;
+ req.nb_iot_config.anchor.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.prb_index.tl.tag = NFAPI_NB_IOT_CONFIG_PRB_INDEX_TAG;
+ req.nb_iot_config.prb_index.value = rand_range(0, 0x1F);
+ req.num_tlv++;
+ req.nb_iot_config.control_region_size.tl.tag = NFAPI_NB_IOT_CONFIG_CONTROL_REGION_SIZE_TAG;
+ req.nb_iot_config.control_region_size.value = rand_range(1, 4);
+ req.num_tlv++;
+ req.nb_iot_config.assumed_crs_aps.tl.tag = NFAPI_NB_IOT_CONFIG_ASSUMED_CRS_APS_TAG;
+ req.nb_iot_config.assumed_crs_aps.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_0_enabled.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_ENABLED_TAG;
+ req.nb_iot_config.nprach_config_0_enabled.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_0_sf_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SF_PERIODICITY_TAG;
+ req.nb_iot_config.nprach_config_0_sf_periodicity.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_0_start_time.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_START_TIME_TAG;
+ req.nb_iot_config.nprach_config_0_start_time.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_0_subcarrier_offset.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SUBCARRIER_OFFSET_TAG;
+ req.nb_iot_config.nprach_config_0_subcarrier_offset.value = rand_range(0, 6);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_0_number_of_subcarriers.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_SUBCARRIERS_TAG;
+ req.nb_iot_config.nprach_config_0_number_of_subcarriers.value = rand_range(0, 3);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_0_cp_length.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_CP_LENGTH_TAG;
+ req.nb_iot_config.nprach_config_0_cp_length.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
+ req.nb_iot_config.nprach_config_0_number_of_repetitions_per_attempt.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_1_enabled.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_ENABLED_TAG;
+ req.nb_iot_config.nprach_config_1_enabled.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_1_sf_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SF_PERIODICITY_TAG;
+ req.nb_iot_config.nprach_config_1_sf_periodicity.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_1_start_time.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_START_TIME_TAG;
+ req.nb_iot_config.nprach_config_1_start_time.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_1_subcarrier_offset.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SUBCARRIER_OFFSET_TAG;
+ req.nb_iot_config.nprach_config_1_subcarrier_offset.value = rand_range(0, 6);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_1_number_of_subcarriers.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_SUBCARRIERS_TAG;
+ req.nb_iot_config.nprach_config_1_number_of_subcarriers.value = rand_range(0, 3);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_1_cp_length.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_CP_LENGTH_TAG;
+ req.nb_iot_config.nprach_config_1_cp_length.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
+ req.nb_iot_config.nprach_config_1_number_of_repetitions_per_attempt.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_2_enabled.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_ENABLED_TAG;
+ req.nb_iot_config.nprach_config_2_enabled.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_2_sf_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SF_PERIODICITY_TAG;
+ req.nb_iot_config.nprach_config_2_sf_periodicity.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_2_start_time.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_START_TIME_TAG;
+ req.nb_iot_config.nprach_config_2_start_time.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_2_subcarrier_offset.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SUBCARRIER_OFFSET_TAG;
+ req.nb_iot_config.nprach_config_2_subcarrier_offset.value = rand_range(0, 6);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_2_number_of_subcarriers.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_SUBCARRIERS_TAG;
+ req.nb_iot_config.nprach_config_2_number_of_subcarriers.value = rand_range(0, 3);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_2_cp_length.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_CP_LENGTH_TAG;
+ req.nb_iot_config.nprach_config_2_cp_length.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.nprach_config_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG;
+ req.nb_iot_config.nprach_config_2_number_of_repetitions_per_attempt.value = rand_range(0, 7);
+ req.num_tlv++;
+ req.nb_iot_config.three_tone_base_sequence.tl.tag = NFAPI_NB_IOT_CONFIG_THREE_TONE_BASE_SEQUENCE_TAG;
+ req.nb_iot_config.three_tone_base_sequence.value = rand_range(0, 0x0F);
+ req.num_tlv++;
+ req.nb_iot_config.six_tone_base_sequence.tl.tag = NFAPI_NB_IOT_CONFIG_SIX_TONE_BASE_SEQUENCE_TAG;
+ req.nb_iot_config.six_tone_base_sequence.value = rand_range(0, 0x03);
+ req.num_tlv++;
+ req.nb_iot_config.twelve_tone_base_sequence.tl.tag = NFAPI_NB_IOT_CONFIG_TWELVE_TONE_BASE_SEQUENCE_TAG;
+ req.nb_iot_config.twelve_tone_base_sequence.value = rand_range(0, 0x1F);
+ req.num_tlv++;
+ req.nb_iot_config.three_tone_cyclic_shift.tl.tag = NFAPI_NB_IOT_CONFIG_THREE_TONE_CYCLIC_SHIFT_TAG;
+ req.nb_iot_config.three_tone_cyclic_shift.value = rand_range(0, 5); // what is the max
+ req.num_tlv++;
+ req.nb_iot_config.six_tone_cyclic_shift.tl.tag = NFAPI_NB_IOT_CONFIG_SIX_TONE_CYCLIC_SHIFT_TAG;
+ req.nb_iot_config.six_tone_cyclic_shift.value = rand_range(0, 5); // what is the max
+ req.num_tlv++;
+ req.nb_iot_config.dl_gap_config_enable.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_CONFIG_ENABLE_TAG;
+ req.nb_iot_config.dl_gap_config_enable.value = rand_range(0, 1);
+ req.num_tlv++;
+ req.nb_iot_config.dl_gap_threshold.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_THRESHOLD_TAG;
+ req.nb_iot_config.dl_gap_threshold.value = rand_range(0, 3);
+ req.num_tlv++;
+ req.nb_iot_config.dl_gap_periodicity.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_PERIODICITY_TAG;
+ req.nb_iot_config.dl_gap_periodicity.value = rand_range(0, 3);
+ req.num_tlv++;
+ req.nb_iot_config.dl_gap_duration_coefficient.tl.tag = NFAPI_NB_IOT_CONFIG_DL_GAP_DURATION_COEFFICIENT_TAG;
+ req.nb_iot_config.dl_gap_duration_coefficient.value = rand_range(0, 3);
+ req.num_tlv++;
+ req.tdd_frame_structure_config.subframe_assignment.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG;
+ req.num_tlv++;
+ req.tdd_frame_structure_config.special_subframe_patterns.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG;
+ req.num_tlv++;
+ req.l23_config.data_report_mode.tl.tag = NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG;
+ req.num_tlv++;
+ req.l23_config.sfnsf.tl.tag = NFAPI_L23_CONFIG_SFNSF_TAG;
+ req.num_tlv++;
+ }
+
+ vendor_ext_tlv_2 ve2;
+ memset(&ve2, 0, sizeof(ve2));
+ ve2.tl.tag = VENDOR_EXT_TLV_2_TAG;
+ ve2.dummy = 2016;
+ req.vendor_extension = &ve2.tl;
+ nfapi_vnf_config_req(config, p5_idx, &req);
+ } else {
+ printf("[VNF_SIM] param response failed to find pnf %d phy %d\n", p5_idx, resp->header.phy_id);
+ }
+ } else {
+ printf("[VNF_SIM] param response failed to find pnf %d\n", p5_idx);
+ }
+
+ return 0;
+}
+
+int config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_config_response_t *resp) {
+ printf("[VNF_SIM] config response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
+ nfapi_start_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_START_REQUEST;
+ req.header.phy_id = resp->header.phy_id;
+ nfapi_vnf_start_req(config, p5_idx, &req);
+ return 0;
+}
+
+void test_p4_requests(nfapi_vnf_config_t *config, int p5_idx, int phy_id) {
+ {
+ nfapi_measurement_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_MEASUREMENT_REQUEST;
+ req.header.phy_id = phy_id;
+ req.dl_rs_tx_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG;
+ req.dl_rs_tx_power.value = 42;
+ req.received_interference_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG;
+ req.received_interference_power.value = 42;
+ req.thermal_noise_power.tl.tag = NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG;
+ req.thermal_noise_power.value = 42;
+ nfapi_vnf_measurement_req(config, p5_idx, &req);
+ }
+ {
+ nfapi_rssi_request_t lte_req;
+ memset(<e_req, 0, sizeof(lte_req));
+ lte_req.header.message_id = NFAPI_RSSI_REQUEST;
+ lte_req.header.phy_id = phy_id;
+ lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
+ lte_req.lte_rssi_request.tl.tag = NFAPI_LTE_RSSI_REQUEST_TAG;
+ lte_req.lte_rssi_request.frequency_band_indicator = 2;
+ lte_req.lte_rssi_request.measurement_period = 1000;
+ lte_req.lte_rssi_request.bandwidth = 50;
+ lte_req.lte_rssi_request.timeout = 0;
+ lte_req.lte_rssi_request.number_of_earfcns = 2;
+ lte_req.lte_rssi_request.earfcn[0] = 389;
+ lte_req.lte_rssi_request.earfcn[1] = 123;
+ nfapi_vnf_rssi_request(config, p5_idx, <e_req);
+ nfapi_rssi_request_t utran_req;
+ memset(&utran_req, 0, sizeof(utran_req));
+ utran_req.header.message_id = NFAPI_RSSI_REQUEST;
+ utran_req.header.phy_id = phy_id;
+ utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN;
+ utran_req.utran_rssi_request.tl.tag = NFAPI_UTRAN_RSSI_REQUEST_TAG;
+ utran_req.utran_rssi_request.frequency_band_indicator = 2;
+ utran_req.utran_rssi_request.measurement_period = 1000;
+ utran_req.utran_rssi_request.timeout = 0;
+ utran_req.utran_rssi_request.number_of_uarfcns = 2;
+ utran_req.utran_rssi_request.uarfcn[0] = 2348;
+ utran_req.utran_rssi_request.uarfcn[1] = 52;
+ nfapi_vnf_rssi_request(config, p5_idx, &utran_req);
+ nfapi_rssi_request_t geran_req;
+ memset(&geran_req, 0, sizeof(geran_req));
+ geran_req.header.message_id = NFAPI_RSSI_REQUEST;
+ geran_req.header.phy_id = phy_id;
+ geran_req.rat_type = NFAPI_RAT_TYPE_GERAN;
+ geran_req.geran_rssi_request.tl.tag = NFAPI_GERAN_RSSI_REQUEST_TAG;
+ geran_req.geran_rssi_request.frequency_band_indicator = 2;
+ geran_req.geran_rssi_request.measurement_period = 1000;
+ geran_req.geran_rssi_request.timeout = 0;
+ geran_req.geran_rssi_request.number_of_arfcns = 1;
+ geran_req.geran_rssi_request.arfcn[0].arfcn = 34;
+ geran_req.geran_rssi_request.arfcn[0].direction = 0;
+ nfapi_vnf_rssi_request(config, p5_idx, &geran_req);
+ }
+ {
+ nfapi_cell_search_request_t lte_req;
+ memset(<e_req, 0, sizeof(lte_req));
+ lte_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST;
+ lte_req.header.phy_id = phy_id;
+ lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
+ lte_req.lte_cell_search_request.tl.tag = NFAPI_LTE_CELL_SEARCH_REQUEST_TAG;
+ lte_req.lte_cell_search_request.earfcn = 1234;
+ lte_req.lte_cell_search_request.measurement_bandwidth = 50;
+ lte_req.lte_cell_search_request.exhaustive_search = 1;
+ lte_req.lte_cell_search_request.timeout = 1000;
+ lte_req.lte_cell_search_request.number_of_pci = 1;
+ lte_req.lte_cell_search_request.pci[0] = 234;
+ nfapi_vnf_cell_search_request(config, p5_idx, <e_req);
+ nfapi_cell_search_request_t utran_req;
+ memset(&utran_req, 0, sizeof(utran_req));
+ utran_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST;
+ utran_req.header.phy_id = phy_id;
+ utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN;
+ utran_req.utran_cell_search_request.tl.tag = NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG;
+ utran_req.utran_cell_search_request.uarfcn = 1234;
+ utran_req.utran_cell_search_request.exhaustive_search = 0;
+ utran_req.utran_cell_search_request.timeout = 1000;
+ utran_req.utran_cell_search_request.number_of_psc = 1;
+ utran_req.utran_cell_search_request.psc[0] = 234;
+ nfapi_vnf_cell_search_request(config, p5_idx, &utran_req);
+ nfapi_cell_search_request_t geran_req;
+ memset(&geran_req, 0, sizeof(geran_req));
+ geran_req.header.message_id = NFAPI_CELL_SEARCH_REQUEST;
+ geran_req.header.phy_id = phy_id;
+ geran_req.rat_type = NFAPI_RAT_TYPE_GERAN;
+ geran_req.geran_cell_search_request.tl.tag = NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG;
+ geran_req.geran_cell_search_request.timeout = 1000;
+ geran_req.geran_cell_search_request.number_of_arfcn = 1;
+ geran_req.geran_cell_search_request.arfcn[0] = 8765;
+ nfapi_vnf_cell_search_request(config, p5_idx, &geran_req);
+ }
+ {
+ nfapi_broadcast_detect_request_t lte_req;
+ memset(<e_req, 0, sizeof(lte_req));
+ lte_req.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST;
+ lte_req.header.phy_id = phy_id;
+ lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
+ lte_req.lte_broadcast_detect_request.tl.tag = NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG;
+ lte_req.lte_broadcast_detect_request.earfcn = 1234;
+ lte_req.lte_broadcast_detect_request.pci = 50;
+ lte_req.lte_broadcast_detect_request.timeout = 1000;
+ lte_req.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG;
+ lte_req.pnf_cell_search_state.length = 3;
+ nfapi_vnf_broadcast_detect_request(config, p5_idx, <e_req);
+ nfapi_broadcast_detect_request_t utran_req;
+ memset(&utran_req, 0, sizeof(utran_req));
+ utran_req.header.message_id = NFAPI_BROADCAST_DETECT_REQUEST;
+ utran_req.header.phy_id = phy_id;
+ utran_req.rat_type = NFAPI_RAT_TYPE_LTE;
+ utran_req.utran_broadcast_detect_request.tl.tag = NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG;
+ utran_req.utran_broadcast_detect_request.uarfcn = 1234;
+ utran_req.utran_broadcast_detect_request.psc = 50;
+ utran_req.utran_broadcast_detect_request.timeout = 1000;
+ utran_req.pnf_cell_search_state.tl.tag = NFAPI_PNF_CELL_SEARCH_STATE_TAG;
+ utran_req.pnf_cell_search_state.length = 3;
+ nfapi_vnf_broadcast_detect_request(config, p5_idx, &utran_req);
+ }
+ {
+ nfapi_system_information_schedule_request_t lte_req;
+ memset(<e_req, 0, sizeof(lte_req));
+ lte_req.header.message_id = NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST;
+ lte_req.header.phy_id = phy_id;
+ lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
+ lte_req.lte_system_information_schedule_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG;
+ lte_req.lte_system_information_schedule_request.earfcn = 1234;
+ lte_req.lte_system_information_schedule_request.pci = 50;
+ lte_req.lte_system_information_schedule_request.downlink_channel_bandwidth = 100;
+ lte_req.lte_system_information_schedule_request.phich_configuration = 3;
+ lte_req.lte_system_information_schedule_request.number_of_tx_antenna = 2;
+ lte_req.lte_system_information_schedule_request.retry_count = 4;
+ lte_req.lte_system_information_schedule_request.timeout = 1000;
+ lte_req.pnf_cell_broadcast_state.tl.tag = NFAPI_PNF_CELL_BROADCAST_STATE_TAG;
+ lte_req.pnf_cell_broadcast_state.length = 3;
+ nfapi_vnf_system_information_schedule_request(config, p5_idx, <e_req);
+ }
+ {
+ nfapi_system_information_request_t lte_req;
+ memset(<e_req, 0, sizeof(lte_req));
+ lte_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST;
+ lte_req.header.phy_id = phy_id;
+ lte_req.rat_type = NFAPI_RAT_TYPE_LTE;
+ lte_req.lte_system_information_request.tl.tag = NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG;
+ lte_req.lte_system_information_request.earfcn = 1234;
+ lte_req.lte_system_information_request.pci= 456;
+ lte_req.lte_system_information_request.downlink_channel_bandwidth = 5;
+ lte_req.lte_system_information_request.phich_configuration = 2;
+ lte_req.lte_system_information_request.number_of_tx_antenna = 2;
+ lte_req.lte_system_information_request.number_of_si_periodicity = 1;
+ lte_req.lte_system_information_request.si_periodicity[0].si_periodicity = 3;
+ lte_req.lte_system_information_request.si_periodicity[0].si_index = 3;
+ lte_req.lte_system_information_request.si_window_length = 15;
+ lte_req.lte_system_information_request.timeout = 1000;
+ nfapi_vnf_system_information_request(config, p5_idx, <e_req);
+ nfapi_system_information_request_t utran_req;
+ memset(&utran_req, 0, sizeof(utran_req));
+ utran_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST;
+ utran_req.header.phy_id = phy_id;
+ utran_req.rat_type = NFAPI_RAT_TYPE_UTRAN;
+ utran_req.utran_system_information_request.tl.tag = NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG;
+ utran_req.utran_system_information_request.uarfcn = 1234;
+ utran_req.utran_system_information_request.psc = 456;
+ utran_req.utran_system_information_request.timeout = 1000;
+ nfapi_vnf_system_information_request(config, p5_idx, &utran_req);
+ nfapi_system_information_request_t geran_req;
+ memset(&geran_req, 0, sizeof(geran_req));
+ geran_req.header.message_id = NFAPI_SYSTEM_INFORMATION_REQUEST;
+ geran_req.header.phy_id = phy_id;
+ geran_req.rat_type = NFAPI_RAT_TYPE_GERAN;
+ geran_req.geran_system_information_request.tl.tag = NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG;
+ geran_req.geran_system_information_request.arfcn = 1234;
+ geran_req.geran_system_information_request.bsic = 21;
+ geran_req.geran_system_information_request.timeout = 1000;
+ nfapi_vnf_system_information_request(config, p5_idx, &geran_req);
+ }
+ {
+ nfapi_nmm_stop_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_NMM_STOP_REQUEST;
+ req.header.phy_id = phy_id;
+ nfapi_vnf_nmm_stop_request(config, p5_idx, &req);
+ }
}
-int start_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp)
-{
- printf("[VNF_SIM] start response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
+int start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_start_response_t *resp) {
+ printf("[VNF_SIM] start response idx:%d phy_id:%d\n", p5_idx, resp->header.phy_id);
+ vnf_info *vnf = (vnf_info *)(config->user_data);
- vnf_info* vnf = (vnf_info*)(config->user_data);
-
- if(vnf->wireshark_test_mode)
- test_p4_requests(config, p5_idx, resp->header.phy_id);
+ if(vnf->wireshark_test_mode)
+ test_p4_requests(config, p5_idx, resp->header.phy_id);
- auto find_result = vnf->pnfs.find(p5_idx);
- if(find_result != vnf->pnfs.end())
- {
- pnf_info& pnf = find_result->second;
-
-
- auto found = std::find_if(pnf.phys.begin(), pnf.phys.end(), [&](phy_info& item)
- { return item.id == resp->header.phy_id; });
+ auto find_result = vnf->pnfs.find(p5_idx);
- if(found != pnf.phys.end())
- {
- phy_info& phy = (*found);
+ if(find_result != vnf->pnfs.end()) {
+ pnf_info &pnf = find_result->second;
+ auto found = std::find_if(pnf.phys.begin(), pnf.phys.end(), [&](phy_info& item) {
+ return item.id == resp->header.phy_id;
+ });
- vnf_p7_info& p7_vnf = vnf->p7_vnfs[0];
+ if(found != pnf.phys.end()) {
+ phy_info &phy = (*found);
+ vnf_p7_info &p7_vnf = vnf->p7_vnfs[0];
+ nfapi_vnf_p7_add_pnf((p7_vnf.config.get()), phy.remote_addr.c_str(), phy.remote_port, phy.id);
+ }
+ }
- nfapi_vnf_p7_add_pnf((p7_vnf.config.get()), phy.remote_addr.c_str(), phy.remote_port, phy.id);
-
-
- }
-
-
- }
- return 0;
+ return 0;
}
-nfapi_p4_p5_message_header_t* vnf_sim_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t* msg_size)
-{
- if(message_id == P5_VENDOR_EXT_RSP)
- {
- *msg_size = sizeof(vendor_ext_p5_rsp);
- return (nfapi_p4_p5_message_header_t*)malloc(sizeof(vendor_ext_p5_rsp));
- }
- return 0;
+nfapi_p4_p5_message_header_t *vnf_sim_allocate_p4_p5_vendor_ext(uint16_t message_id, uint16_t *msg_size) {
+ if(message_id == P5_VENDOR_EXT_RSP) {
+ *msg_size = sizeof(vendor_ext_p5_rsp);
+ return (nfapi_p4_p5_message_header_t *)malloc(sizeof(vendor_ext_p5_rsp));
+ }
+
+ return 0;
}
-void vnf_sim_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t* header)
-{
- free(header);
+void vnf_sim_deallocate_p4_p5_vendor_ext(nfapi_p4_p5_message_header_t *header) {
+ free(header);
}
-int vendor_ext_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_p4_p5_message_header_t* msg)
-{
- printf("[VNF_SIM] %s\n", __FUNCTION__);
+int vendor_ext_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_p4_p5_message_header_t *msg) {
+ printf("[VNF_SIM] %s\n", __FUNCTION__);
- switch(msg->message_id)
- {
- case P5_VENDOR_EXT_RSP:
- {
- vendor_ext_p5_rsp* rsp = (vendor_ext_p5_rsp*)msg;
- printf("[VNF_SIM] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code);
+ switch(msg->message_id) {
+ case P5_VENDOR_EXT_RSP: {
+ vendor_ext_p5_rsp *rsp = (vendor_ext_p5_rsp *)msg;
+ printf("[VNF_SIM] P5_VENDOR_EXT_RSP error_code:%d\n", rsp->error_code);
+ // send the start request
+ nfapi_pnf_start_request_t req;
+ memset(&req, 0, sizeof(req));
+ req.header.message_id = NFAPI_PNF_START_REQUEST;
+ nfapi_vnf_pnf_start_req(config, p5_idx, &req);
+ }
+ break;
+ }
- // send the start request
-
- nfapi_pnf_start_request_t req;
- memset(&req, 0, sizeof(req));
- req.header.message_id = NFAPI_PNF_START_REQUEST;
- nfapi_vnf_pnf_start_req(config, p5_idx, &req);
- }
- break;
-
- }
-
- return 0;
+ return 0;
}
-int read_vnf_xml(vnf_info& vnf, const char* xml_file)
-{
- try
- {
-
- std::ifstream input(xml_file);
-
- using boost::property_tree::ptree;
- ptree pt;
-
- read_xml(input, pt);
-
-
-
- for(const auto& v : pt.get_child("vnf.vnf_p7_list"))
- {
- if(v.first == "vnf_p7")
- {
- vnf_p7_info vnf_p7;
- vnf_p7.local_port = v.second.get("port");
- vnf_p7.local_addr = v.second.get("address");
-
- vnf_p7.timing_window = v.second.get("timing_window");
- vnf_p7.periodic_timing_enabled = v.second.get("periodic_timing_enabled");
- vnf_p7.aperiodic_timing_enabled = v.second.get("aperiodic_timing_enabled");
- vnf_p7.periodic_timing_period = v.second.get("periodic_timing_window");
-
-
- boost::optional d = v.second.get_child_optional("data.udp");
- if(d.is_initialized())
- {
- vnf_p7.udp.enabled = true;
- vnf_p7.udp.rx_port = d.get().get("rx_port");
- vnf_p7.udp.tx_port = d.get().get("tx_port");
- vnf_p7.udp.tx_addr = d.get().get("tx_addr");
- }
- else
- {
- vnf_p7.udp.enabled = false;
- }
-
- vnf.wireshark_test_mode = v.second.get("wireshark_test_mode", 0);
-
- vnf_p7.mac = mac_create(vnf.wireshark_test_mode);
- vnf_p7.mac->dl_config_req = &mac_dl_config_req;
- vnf_p7.mac->ul_config_req = &mac_ul_config_req;
- vnf_p7.mac->hi_dci0_req = &mac_hi_dci0_req;
- vnf_p7.mac->tx_req = &mac_tx_req;
-
- if(vnf_p7.udp.enabled)
- {
- mac_start_data(vnf_p7.mac,
- vnf_p7.udp.rx_port,
- vnf_p7.udp.tx_addr.c_str(),
- vnf_p7.udp.tx_port);
- }
-
- vnf.p7_vnfs.push_back(vnf_p7);
- }
- }
- }
- catch(std::exception& e)
- {
- printf("%s", e.what());
- return -1;
- }
- catch(boost::exception& e)
- {
- printf("%s", boost::diagnostic_information(e).c_str());
- }
+int read_vnf_xml(vnf_info &vnf, const char *xml_file) {
+ try {
+ std::ifstream input(xml_file);
+ using boost::property_tree::ptree;
+ ptree pt;
+ read_xml(input, pt);
- struct ifaddrs *ifaddr;
- getifaddrs(&ifaddr);
+ for(const auto &v : pt.get_child("vnf.vnf_p7_list")) {
+ if(v.first == "vnf_p7") {
+ vnf_p7_info vnf_p7;
+ vnf_p7.local_port = v.second.get("port");
+ vnf_p7.local_addr = v.second.get("address");
+ vnf_p7.timing_window = v.second.get("timing_window");
+ vnf_p7.periodic_timing_enabled = v.second.get("periodic_timing_enabled");
+ vnf_p7.aperiodic_timing_enabled = v.second.get("aperiodic_timing_enabled");
+ vnf_p7.periodic_timing_period = v.second.get("periodic_timing_window");
+ boost::optional d = v.second.get_child_optional("data.udp");
+ if(d.is_initialized()) {
+ vnf_p7.udp.enabled = true;
+ vnf_p7.udp.rx_port = d.get().get("rx_port");
+ vnf_p7.udp.tx_port = d.get().get("tx_port");
+ vnf_p7.udp.tx_addr = d.get().get("tx_addr");
+ } else {
+ vnf_p7.udp.enabled = false;
+ }
- while(ifaddr)
- {
- int family = ifaddr->ifa_addr->sa_family;
- if(family == AF_INET)
- {
- char host[128];
- getnameinfo(ifaddr->ifa_addr, sizeof(sockaddr_in), host, sizeof(host), NULL, 0, 0);
- printf("%s\n", host);
- }
- ifaddr = ifaddr->ifa_next;
- }
-
- return 0;
+ vnf.wireshark_test_mode = v.second.get("wireshark_test_mode", 0);
+ vnf_p7.mac = mac_create(vnf.wireshark_test_mode);
+ vnf_p7.mac->dl_config_req = &mac_dl_config_req;
+ vnf_p7.mac->ul_config_req = &mac_ul_config_req;
+ vnf_p7.mac->hi_dci0_req = &mac_hi_dci0_req;
+ vnf_p7.mac->tx_req = &mac_tx_req;
+ if(vnf_p7.udp.enabled) {
+ mac_start_data(vnf_p7.mac,
+ vnf_p7.udp.rx_port,
+ vnf_p7.udp.tx_addr.c_str(),
+ vnf_p7.udp.tx_port);
+ }
+
+ vnf.p7_vnfs.push_back(vnf_p7);
+ }
+ }
+ } catch(std::exception &e) {
+ printf("%s", e.what());
+ return -1;
+ } catch(boost::exception &e) {
+ printf("%s", boost::diagnostic_information(e).c_str());
+ }
+
+ struct ifaddrs *ifaddr;
+
+ getifaddrs(&ifaddr);
+
+ while(ifaddr) {
+ int family = ifaddr->ifa_addr->sa_family;
+
+ if(family == AF_INET) {
+ char host[128];
+ getnameinfo(ifaddr->ifa_addr, sizeof(sockaddr_in), host, sizeof(host), NULL, 0, 0);
+ printf("%s\n", host);
+ }
+
+ ifaddr = ifaddr->ifa_next;
+ }
+
+ return 0;
}
-int main(int argc, char *argv[])
-{
- if (argc < 3)
- {
- printf("Use parameters: \n");
- return 0;
- }
+int main(int argc, char *argv[]) {
+ if (argc < 3) {
+ printf("Use parameters: \n");
+ return 0;
+ }
- set_thread_priority(50);
+ set_thread_priority(50);
+ vnf_info vnf;
- vnf_info vnf;
+ if(read_vnf_xml(vnf, argv[2]) < 0) {
+ printf("Failed to read xml file>\n");
+ return 0;
+ }
- if(read_vnf_xml(vnf, argv[2]) < 0)
- {
- printf("Failed to read xml file>\n");
- return 0;
- }
-
- nfapi_vnf_config_t* config = nfapi_vnf_config_create();
-
- config->vnf_ipv4 = 1;
- config->vnf_p5_port = atoi(argv[1]);
- config->pnf_connection_indication = &pnf_connection_indication_cb;
- config->pnf_disconnect_indication = &pnf_disconnection_indication_cb;
- config->pnf_param_resp = &pnf_param_resp_cb;
- config->pnf_config_resp = &pnf_config_resp_cb;
- config->pnf_start_resp = &pnf_start_resp_cb;
- config->param_resp = ¶m_resp_cb;
- config->config_resp = &config_resp_cb;
- config->start_resp = &start_resp_cb;
- config->vendor_ext = &vendor_ext_cb;
-
-
-
- config->trace = &vnf_sim_trace;
-
- config->malloc = &vnf_allocate;
- config->free = &vnf_deallocate;
-
- config->user_data = &vnf;
-
- config->codec_config.unpack_vendor_extension_tlv = &vnf_sim_unpack_vendor_extension_tlv;
- config->codec_config.pack_vendor_extension_tlv = &vnf_sim_pack_vendor_extension_tlv;
-
- config->codec_config.unpack_p4_p5_vendor_extension = &vnf_sim_unpack_p4_p5_vendor_extension;
- config->codec_config.pack_p4_p5_vendor_extension = &vnf_sim_pack_p4_p5_vendor_extension;
- config->allocate_p4_p5_vendor_ext = &vnf_sim_allocate_p4_p5_vendor_ext;
- config->deallocate_p4_p5_vendor_ext = &vnf_sim_deallocate_p4_p5_vendor_ext;
- config->codec_config.allocate = &vnf_allocate;
- config->codec_config.deallocate = &vnf_deallocate;
-
-
- printf("Calling nfapi_vnf_start\n");
- return nfapi_vnf_start(config);
+ nfapi_vnf_config_t *config = nfapi_vnf_config_create();
+ config->vnf_ipv4 = 1;
+ config->vnf_p5_port = atoi(argv[1]);
+ config->pnf_connection_indication = &pnf_connection_indication_cb;
+ config->pnf_disconnect_indication = &pnf_disconnection_indication_cb;
+ config->pnf_param_resp = &pnf_param_resp_cb;
+ config->pnf_config_resp = &pnf_config_resp_cb;
+ config->pnf_start_resp = &pnf_start_resp_cb;
+ config->param_resp = ¶m_resp_cb;
+ config->config_resp = &config_resp_cb;
+ config->start_resp = &start_resp_cb;
+ config->vendor_ext = &vendor_ext_cb;
+ config->trace = &vnf_sim_trace;
+ config->malloc = &vnf_allocate;
+ config->free = &vnf_deallocate;
+ config->user_data = &vnf;
+ config->codec_config.unpack_vendor_extension_tlv = &vnf_sim_unpack_vendor_extension_tlv;
+ config->codec_config.pack_vendor_extension_tlv = &vnf_sim_pack_vendor_extension_tlv;
+ config->codec_config.unpack_p4_p5_vendor_extension = &vnf_sim_unpack_p4_p5_vendor_extension;
+ config->codec_config.pack_p4_p5_vendor_extension = &vnf_sim_pack_p4_p5_vendor_extension;
+ config->allocate_p4_p5_vendor_ext = &vnf_sim_allocate_p4_p5_vendor_ext;
+ config->deallocate_p4_p5_vendor_ext = &vnf_sim_deallocate_p4_p5_vendor_ext;
+ config->codec_config.allocate = &vnf_allocate;
+ config->codec_config.deallocate = &vnf_deallocate;
+ printf("Calling nfapi_vnf_start\n");
+ return nfapi_vnf_start(config);
}
diff --git a/openair1/PHY/CODING/ccoding_byte.c b/openair1/PHY/CODING/ccoding_byte.c
index e4617d1404..576a947cff 100644
--- a/openair1/PHY/CODING/ccoding_byte.c
+++ b/openair1/PHY/CODING/ccoding_byte.c
@@ -130,7 +130,7 @@ ccodedot11_encode (unsigned int numbytes,
*outPtr++ = (out>>1)&1;
#ifdef DEBUG_CCODE
- printf("%d: %u -> %d (%u)\n",dummy,state,out,ccodedot11_table[state]);
+ printf("%u: %u -> %d (%u)\n",dummy,state,out,ccodedot11_table[state]);
dummy+=2;
#endif //DEBUG_CCODE
bit_index=(bit_index==0)?1:0;
diff --git a/openair1/PHY/CODING/lte_rate_matching.c b/openair1/PHY/CODING/lte_rate_matching.c
index f850d47549..548b7bfcba 100644
--- a/openair1/PHY/CODING/lte_rate_matching.c
+++ b/openair1/PHY/CODING/lte_rate_matching.c
@@ -236,7 +236,7 @@ void sub_block_deinterleaving_cc(uint32_t D,int8_t *d,int8_t *w) {
ND = Kpi - D;
#ifdef RM_DEBUG2
printf("sub_block_interleaving_cc : D = %d (%d), d %p, w %p\n",D,D*3,d,w);
- printf("RCC = %d, Kpi=%d, ND=%ld\n",RCC,Kpi,ND);
+ printf("RCC = %d, Kpi=%d, ND=%ld\n",RCC,Kpi,(long)ND);
#endif
ND3 = ND*3;
k=0;
@@ -253,7 +253,8 @@ void sub_block_deinterleaving_cc(uint32_t D,int8_t *d,int8_t *w) {
d[index3-ND3+1] = w[Kpi+k];
d[index3-ND3+2] = w[(Kpi<<1)+k];
#ifdef RM_DEBUG2
- printf("row %d, index %d k %d index3-ND3 %ld w(%d,%d,%d)\n",row,index,k,index3-ND3,w[k],w[Kpi+k],w[(Kpi<<1)+k]);
+ printf("row %d, index %d k %d index3-ND3 %ld w(%d,%d,%d)\n",
+ row,index,k,(long)(index3-ND3),w[k],w[Kpi+k],w[(Kpi<<1)+k]);
#endif
index3+=96;
index+=32;
@@ -453,7 +454,6 @@ uint32_t lte_rate_matching_turbo(uint32_t RTC,
int threed =0;
uint32_t nulled=0;
static unsigned char *counter_buffer[MAX_NUM_DLSCH_SEGMENTS][4];
- FILE *counter_fd;
char fname[512];
#endif
@@ -476,7 +476,6 @@ uint32_t lte_rate_matching_turbo(uint32_t RTC,
} else if(rvidx==3) {
sprintf(fname, "mcs%d_rate_matching_RB_%d.txt", m, nb_rb);
// sprintf(fname,"mcs0_rate_matching_RB_6.txt");
- counter_fd = fopen(fname,"w");
}
#endif
diff --git a/openair1/PHY/CODING/lte_segmentation.c b/openair1/PHY/CODING/lte_segmentation.c
index 4dc531c58f..0f9f8b00e0 100644
--- a/openair1/PHY/CODING/lte_segmentation.c
+++ b/openair1/PHY/CODING/lte_segmentation.c
@@ -124,7 +124,8 @@ int lte_segmentation(unsigned char *input_buffer,
Bprime,*Cplus,*Kplus,*Cminus,*Kminus);
*F = ((*Cplus)*(*Kplus) + (*Cminus)*(*Kminus) - (Bprime));
#ifdef DEBUG_SEGMENTATION
- printf("C %u, Cplus %u, Cminus %u, Kplus %u, Kminus %u, Bprime_bytes %u, Bprime %u, F %u\n",*C,*Cplus,*Cminus,*Kplus,*Kminus,Bprime>>3,Bprime,*F);
+ printf("C %u, Cplus %u, Cminus %u, Kplus %u, Kminus %u, Bprime_bytes %u, Bprime %u, F %u\n",
+ *C,*Cplus,*Cminus,*Kplus,*Kminus,Bprime>>3,Bprime,*F);
#endif
if ((input_buffer) && (output_buffers)) {
diff --git a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c
index 54f52ef40b..b0af8f6b0b 100644
--- a/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c
+++ b/openair1/PHY/LTE_REFSIG/lte_dl_mbsfn.c
@@ -35,30 +35,22 @@
int lte_dl_mbsfn(PHY_VARS_eNB *eNB, int32_t *output,
short amp,
int subframe,
- unsigned char l)
-{
-
+ unsigned char l) {
unsigned int mprime,mprime_dword,mprime_qpsk_symb,m;
unsigned short k=0,a;
int32_t qpsk[4];
-
a = (amp*ONE_OVER_SQRT2_Q15)>>15;
((short *)&qpsk[0])[0] = a;
((short *)&qpsk[0])[1] = a;
-
((short *)&qpsk[1])[0] = -a;
((short *)&qpsk[1])[1] = a;
((short *)&qpsk[2])[0] = a;
((short *)&qpsk[2])[1] = -a;
-
((short *)&qpsk[3])[0] = -a;
((short *)&qpsk[3])[1] = -a;
-
-
mprime = 3*(110 - eNB->frame_parms.N_RB_DL);
for (m=0; mframe_parms.N_RB_DL*6; m++) {
-
if ((l==0) || (l==2))
k = m<<1;
else if (l==1)
@@ -69,7 +61,6 @@ int lte_dl_mbsfn(PHY_VARS_eNB *eNB, int32_t *output,
}
k+=eNB->frame_parms.first_carrier_offset;
-
mprime_dword = mprime>>4;
mprime_qpsk_symb = mprime&0xf;
@@ -80,22 +71,18 @@ int lte_dl_mbsfn(PHY_VARS_eNB *eNB, int32_t *output,
output[k] = qpsk[(eNB->lte_gold_mbsfn_table[subframe][l][mprime_dword]>>(2*mprime_qpsk_symb))&3];
//output[k] = (lte_gold_table[eNB_offset][subframe][l][mprime_dword]>>(2*mprime_qpsk_symb))&3;
-
-
#ifdef DEBUG_DL_MBSFN
LOG_D(PHY,"subframe %d, l %d, m %d, mprime %d, mprime_dword %d, mprime_qpsk_symbol %d\n",
- subframe,l,m,mprime,mprime_dword,mprime_qpsk_symb);
+ subframe,l,m,mprime,mprime_dword,mprime_qpsk_symb);
LOG_D(PHY,"index = %d (k %d)(%x)\n",(eNB->lte_gold_mbsfn_table[subframe][l][mprime_dword]>>(2*mprime_qpsk_symb))&3,k,eNB->lte_gold_mbsfn_table[subframe][l][mprime_dword]);
#endif
mprime++;
-
#ifdef DEBUG_DL_MBSFN
if (m<18)
printf("subframe %d, l %d output[%d] = (%d,%d)\n",subframe,l,k,((short *)&output[k])[0],((short *)&output[k])[1]);
#endif
-
}
return(0);
@@ -106,15 +93,11 @@ int lte_dl_mbsfn(PHY_VARS_eNB *eNB, int32_t *output,
int lte_dl_mbsfn_rx(PHY_VARS_UE *ue,
int *output,
int subframe,
- unsigned char l)
-{
-
+ unsigned char l) {
unsigned int mprime,mprime_dword,mprime_qpsk_symb,m;
unsigned short k=0;
unsigned int qpsk[4];
-
// This includes complex conjugate for channel estimation
-
((short *)&qpsk[0])[0] = ONE_OVER_SQRT2_Q15;
((short *)&qpsk[0])[1] = -ONE_OVER_SQRT2_Q15;
((short *)&qpsk[1])[0] = -ONE_OVER_SQRT2_Q15;
@@ -123,23 +106,18 @@ int lte_dl_mbsfn_rx(PHY_VARS_UE *ue,
((short *)&qpsk[2])[1] = ONE_OVER_SQRT2_Q15;
((short *)&qpsk[3])[0] = -ONE_OVER_SQRT2_Q15;
((short *)&qpsk[3])[1] = ONE_OVER_SQRT2_Q15;
-
mprime = 3*(110 - ue->frame_parms.N_RB_DL);
for (m=0; mframe_parms.N_RB_DL*6; m++) {
-
mprime_dword = mprime>>4;
mprime_qpsk_symb = mprime&0xf;
-
// this is r_mprime from 3GPP 36-211 6.10.1.2
output[k] = qpsk[(ue->lte_gold_mbsfn_table[subframe][l][mprime_dword]>>(2*mprime_qpsk_symb))&3];
-
#ifdef DEBUG_DL_MBSFN
- printf("subframe %d, l %d, m %d, mprime %d, mprime_dword %d, mprime_qpsk_symbol %d\n",
+ printf("subframe %d, l %d, m %u, mprime %u, mprime_dword %u, mprime_qpsk_symbol %u\n",
subframe,l,m,mprime, mprime_dword,mprime_qpsk_symb);
printf("index = %d (k %d) (%x)\n",(ue->lte_gold_mbsfn_table[subframe][l][mprime_dword]>>(2*mprime_qpsk_symb))&3,k,ue->lte_gold_mbsfn_table[subframe][l][mprime_dword]);
#endif
-
mprime++;
#ifdef DEBUG_DL_MBSFN
@@ -148,7 +126,6 @@ int lte_dl_mbsfn_rx(PHY_VARS_UE *ue,
#endif
k++;
-
}
return(0);
diff --git a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c
index ee7619c23c..be090214f8 100644
--- a/openair1/PHY/LTE_REFSIG/lte_ul_ref.c
+++ b/openair1/PHY/LTE_REFSIG/lte_ul_ref.c
@@ -20,9 +20,9 @@
*/
#ifdef MAIN
-#include
-#include
-#include
+ #include
+ #include
+ #include
#endif
#include "lte_refsig.h"
#include "PHY/defs_eNB.h"
@@ -43,8 +43,7 @@ char ref24[720] = {
-1,3,1,-3,3,-1,1,3,-3,3,1,3,-3,3,1,1,-1,1,3,-3,3,-3,-1,-3,-3,3,-3,-3,-3,1,-3,-3,3,-1,1,1,1,3,1,-1,3,-3,-3,1,3,1,1,-3,3,-1,3,3,1,1,-3,3,3,3,3,1,-1,3,-1,1,1,-1,-3,-1,-1,1,3,3,-1,-3,1,1,3,-3,1,1,-3,-1,-1,1,3,1,3,1,-1,3,1,1,-3,-1,-3,-1,-1,-1,-1,-3,-3,-1,1,1,3,3,-1,3,-1,1,-1,-3,1,-1,-3,-3,1,-3,-1,-1,-3,1,1,3,-1,1,3,1,-3,1,-3,1,1,-1,-1,3,-1,-3,3,-3,-3,-3,1,1,1,1,-1,-1,3,-3,-3,3,-3,1,-1,-1,1,-1,1,1,-1,-3,-1,1,-1,3,-1,-3,-3,3,3,-1,-1,-3,-1,3,1,3,1,3,1,1,-1,3,1,-1,1,3,-3,-1,-1,1,-3,1,3,-3,1,-1,-3,3,-3,3,-1,-1,-1,-1,1,-3,-3,-3,1,-3,-3,-3,1,-3,1,1,-3,3,3,-1,-3,-1,3,-3,3,3,3,-1,1,1,-3,1,-1,1,1,-3,1,1,-1,1,-3,-3,3,-1,3,-1,-1,-3,-3,-3,-1,-3,-3,1,-1,1,3,3,-1,1,-1,3,1,3,3,-3,-3,1,3,1,-1,-3,-3,-3,3,3,-3,3,3,-1,-3,3,-1,1,-3,1,1,3,3,1,1,1,-1,-1,1,-3,3,-1,1,1,-3,3,3,-1,-3,3,-3,-1,-3,-1,3,-1,-1,-1,-1,-3,-1,3,3,1,-1,1,3,3,3,-1,1,1,-3,1,3,-1,-3,3,-3,-3,3,1,3,1,-3,3,1,3,1,1,3,3,-1,-1,-3,1,-3,-1,3,1,1,3,-1,-1,1,-3,1,3,-3,1,-1,-3,-1,3,1,3,1,-1,-3,-3,-1,-1,-3,-3,-3,-1,-1,-3,3,-1,-1,-1,-1,1,1,-3,3,1,3,3,1,-1,1,-3,1,-3,1,1,-3,-1,1,3,-1,3,3,-1,-3,1,-1,-3,3,3,3,-1,1,1,3,-1,-3,-1,3,-1,-1,-1,1,1,1,1,1,-1,3,-1,-3,1,1,3,-3,1,-3,-1,1,1,-3,-3,3,1,1,-3,1,3,3,1,-1,-3,3,-1,3,3,3,-3,1,-1,1,-1,-3,-1,1,3,-1,3,-3,-3,-1,-3,3,-3,-3,-3,-1,-1,-3,-1,-3,3,1,3,-3,-1,3,-1,1,-1,3,-3,1,-1,-3,-3,1,1,-1,1,-1,1,-1,3,1,-3,-1,1,-1,1,-1,-1,3,3,-3,-1,1,-3,-3,-1,-3,3,1,-1,-3,-1,-3,-3,3,-3,3,-3,-1,1,3,1,-3,1,3,3,-1,-3,-1,-1,-1,-1,3,3,3,1,3,3,-3,1,3,-1,3,-1,3,3,-3,3,1,-1,3,3,1,-1,3,3,-1,-3,3,-3,-1,-1,3,-1,3,-1,-1,1,1,1,1,-1,-1,-3,-1,3,1,-1,1,-1,3,-1,3,1,1,-1,-1,-3,1,1,-3,1,3,-3,1,1,-3,-3,-1,-1,-3,-1,1,3,1,1,-3,-1,-1,-3,3,-3,3,1,-3,3,-3,1,-1,1,-3,1,1,1,-1,-3,3,3,1,1,3,-1,-3,-1,-1,-1,3,1,-3,-3,-1,3,-3,-1,-3,-1,-3,-1,-1,-3,-1,-1,1,-3,-1,-1,1,-1,-3,1,1,-3,1,-3,-3,3,1,1,-1,3,-1,-1,1,1,-1,-1,-3,-1,3,-1,3,-1,1,3,1,-1,3,1,3,-3,-3,1,-1,-1,1,3
};
-void generate_ul_ref_sigs(void)
-{
+void generate_ul_ref_sigs(void) {
double qbar,phase;
unsigned int u,v,Msc_RS,q,m,n;
@@ -53,7 +52,7 @@ void generate_ul_ref_sigs(void)
for (u=0; u<30; u++) {
for (v=0; v<2; v++) {
qbar = ref_primes[Msc_RS] * (u+1)/(double)31;
- ul_ref_sigs[u][v][Msc_RS] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[Msc_RS]);
+ ul_ref_sigs[u][v][Msc_RS] = (int16_t *)malloc16(2*sizeof(int16_t)*dftsizes[Msc_RS]);
if ((((int)floor(2*qbar))&1) == 0)
q = (int)(floor(qbar+.5)) - v;
@@ -61,7 +60,7 @@ void generate_ul_ref_sigs(void)
q = (int)(floor(qbar+.5)) + v;
#ifdef MAIN
- printf("Msc_RS %d (%d), u %d, v %d -> q %d (qbar %f)\n",Msc_RS,dftsizes[Msc_RS],u,v,q,qbar);
+ printf("Msc_RS %u (%d), u %u, v %u -> q %u (qbar %f)\n",Msc_RS,dftsizes[Msc_RS],u,v,q,qbar);
#endif
for (n=0; n q %d (qbar %f)\n",Msc_RS,dftsizes[Msc_RS],u,v,q,qbar);
+ printf("Msc_RS %u (%d), u %u, v %u -> q %u (qbar %f)\n",Msc_RS,dftsizes[Msc_RS],u,v,q,qbar);
#endif
for (n=0; nue_spec_bf_weights[layer][aa], OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
- free16(dlsch->ue_spec_bf_weights[layer], 64*sizeof(int32_t*));
+
+ free16(dlsch->ue_spec_bf_weights[layer], 64*sizeof(int32_t *));
}
+
for (i=0; iMdlharq; i++) {
if (dlsch->harq_processes[i]) {
if (dlsch->harq_processes[i]->b) {
free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES);
dlsch->harq_processes[i]->b = NULL;
}
+
for (r=0; rharq_processes[i]->c[r]) {
free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
dlsch->harq_processes[i]->c[r] = NULL;
}
+
if (dlsch->harq_processes[i]->d[r]) {
free16(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144)));
dlsch->harq_processes[i]->d[r] = NULL;
}
- }
- free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
- dlsch->harq_processes[i] = NULL;
+ }
+
+ free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
+ dlsch->harq_processes[i] = NULL;
}
}
+
free16(dlsch,sizeof(LTE_eNB_DLSCH_t));
- dlsch = NULL;
}
}
-LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t Nsoft,unsigned char N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS* frame_parms)
-{
-
+LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t Nsoft,unsigned char N_RB_DL, uint8_t abstraction_flag, LTE_DL_FRAME_PARMS *frame_parms) {
LTE_eNB_DLSCH_t *dlsch;
unsigned char exit_flag = 0,i,j,r,aa,layer;
int re;
unsigned char bw_scaling =1;
switch (N_RB_DL) {
- case 6:
- bw_scaling =16;
- break;
+ case 6:
+ bw_scaling =16;
+ break;
- case 25:
- bw_scaling =4;
- break;
+ case 25:
+ bw_scaling =4;
+ break;
- case 50:
- bw_scaling =2;
- break;
+ case 50:
+ bw_scaling =2;
+ break;
- default:
- bw_scaling =1;
- break;
+ default:
+ bw_scaling =1;
+ break;
}
dlsch = (LTE_eNB_DLSCH_t *)malloc16(sizeof(LTE_eNB_DLSCH_t));
@@ -128,15 +130,16 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
dlsch->Mdlharq = Mdlharq;
dlsch->Mlimit = 8;
dlsch->Nsoft = Nsoft;
-
+
for (layer=0; layer<4; layer++) {
- dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(64*sizeof(int32_t*));
-
+ dlsch->ue_spec_bf_weights[layer] = (int32_t **)malloc16(64*sizeof(int32_t *));
+
for (aa=0; aa<64; aa++) {
- dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
- for (re=0;reue_spec_bf_weights[layer][aa][re] = 0x00007fff;
- }
+ dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
+
+ for (re=0; reue_spec_bf_weights[layer][aa][re] = 0x00007fff;
+ }
}
}
@@ -159,7 +162,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
if (dlsch->harq_processes[i]) {
bzero(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
// dlsch->harq_processes[i]->first_tx=1;
- dlsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
+ dlsch->harq_processes[i]->b = (unsigned char *)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
if (dlsch->harq_processes[i]->b) {
bzero(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
@@ -171,14 +174,16 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
if (abstraction_flag==0) {
for (r=0; rharq_processes[i]->c[r] = (uint8_t*)malloc16(((r==0)?8:0) + 3+ 768);
- dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16((96+12+3+(3*6144)));
+ dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(((r==0)?8:0) + 3+ 768);
+ dlsch->harq_processes[i]->d[r] = (uint8_t *)malloc16((96+12+3+(3*6144)));
+
if (dlsch->harq_processes[i]->c[r]) {
bzero(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+ 768);
} else {
printf("Can't get c\n");
exit_flag=2;
}
+
if (dlsch->harq_processes[i]->d[r]) {
bzero(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144)));
} else {
@@ -197,13 +202,12 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
for (i=0; iharq_processes[i]->round=0;
- for (j=0; j<96; j++)
- for (r=0; rharq_processes[%d]->d[%d] %p\n",i,r,dlsch->harq_processes[i]->d[r]);
- if (dlsch->harq_processes[i]->d[r])
- dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
- }
-
+ for (j=0; j<96; j++)
+ for (r=0; rharq_processes[%d]->d[%d] %p\n",i,r,dlsch->harq_processes[i]->d[r]);
+ if (dlsch->harq_processes[i]->d[r])
+ dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
+ }
}
return(dlsch);
@@ -211,16 +215,12 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
}
LOG_D(PHY,"new_eNB_dlsch exit flag %d, size of %ld\n",
- exit_flag, sizeof(LTE_eNB_DLSCH_t));
+ exit_flag, sizeof(LTE_eNB_DLSCH_t));
free_eNB_dlsch(dlsch);
return(NULL);
-
-
}
-void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch)
-{
-
+void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) {
unsigned char Mdlharq;
unsigned char i,j,r;
@@ -228,8 +228,10 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch)
Mdlharq = dlsch->Mdlharq;
dlsch->rnti = 0;
#ifdef PHY_TX_THREAD
+
for (i=0; i<10; i++)
dlsch->active[i] = 0;
+
#else
dlsch->active = 0;
#endif
@@ -244,11 +246,10 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch)
dlsch->harq_processes[i]->status = 0;
dlsch->harq_processes[i]->round = 0;
- for (j=0; j<96; j++)
- for (r=0; rharq_processes[i]->d[r])
- dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
-
+ for (j=0; j<96; j++)
+ for (r=0; rharq_processes[i]->d[r])
+ dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
}
}
}
@@ -258,31 +259,24 @@ 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 nb_rb = dlsch->harq_processes[harq_pid]->nb_rb;
unsigned int Kr=0,Kr_bytes,r,r_offset=0;
// unsigned short m=dlsch->harq_processes[harq_pid]->mcs;
-
-
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_IN);
if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet
-
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 (rharq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus;
else
Kr = dlsch->harq_processes[harq_pid]->Kplus;
Kr_bytes = Kr>>3;
-
encoder(dlsch->harq_processes[harq_pid]->c[r],
Kr>>3,
&dlsch->harq_processes[harq_pid]->d[r][96],
@@ -293,25 +287,24 @@ int dlsch_encoding_2threads0(te_params *tep) {
&dlsch->harq_processes[harq_pid]->d[r][96],
dlsch->harq_processes[harq_pid]->w[r]);
}
-
}
// 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_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;
+ 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);
+ r_offset += Nl*Qm * (Gp/C);
else
- r_offset += Nl*Qm * ((GpmodC==0?0:1) + (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],
@@ -330,7 +323,6 @@ int dlsch_encoding_2threads0(te_params *tep) {
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT);
-
return(0);
}
@@ -339,19 +331,16 @@ 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\n", syscall(__NR_gettid));
-
-
te_params *tep = (te_params *)param;
-
- //wait_sync("te_thread");
-
- while (!oai_exit) {
+ //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;
dlsch_encoding_2threads0(tep);
@@ -363,6 +352,7 @@ void *te_thread(void *param) {
exit_fun( "ERROR pthread_cond_signal" );
return(NULL);
}
+
/*if(opp_enabled == 1 && te_wakeup_stats0->p_time>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);
@@ -375,61 +365,56 @@ void *te_thread(void *param) {
int dlsch_encoding_2threads(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 worker_num)
-{
-
+ 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 worker_num) {
//start_meas(&eNB->dlsch_turbo_encoding_preperation_stats);
-
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
L1_proc_t *proc = &eNB->proc;
unsigned int G;
unsigned int crc=1;
-
unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe];
+
if(harq_pid >= dlsch->Mdlharq) {
LOG_E(PHY,"dlsch_encoding_2threads illegal harq_pid %d\n", harq_pid);
return(-1);
}
+
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;
-
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
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);
+ 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];
-
+ 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,
@@ -442,48 +427,46 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
return(-1);
stop_meas(&eNB->dlsch_turbo_encoding_segmentation_stats);
-
start_meas(&eNB->dlsch_turbo_encoding_signal_stats);
- for(int i=0;itep[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 );
}
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; rharq_processes[harq_pid]->C; r++) {
+ for (r=(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num; rharq_processes[harq_pid]->C; r++) {
if (rharq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus;
else
Kr = dlsch->harq_processes[harq_pid]->Kplus;
Kr_bytes = Kr>>3;
-
start_meas(te_stats);
encoder(dlsch->harq_processes[harq_pid]->c[r],
Kr>>3,
@@ -491,7 +474,6 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
(r==0) ? dlsch->harq_processes[harq_pid]->F : 0
);
stop_meas(te_stats);
-
start_meas(i_stats);
dlsch->harq_processes[harq_pid]->RTC[r] =
sub_block_interleaving_turbo(4+(Kr_bytes*8),
@@ -499,17 +481,14 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
dlsch->harq_processes[harq_pid]->w[r]);
stop_meas(i_stats);
}
-
- }
- else {
-
- for(int i=0;itep[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" );
@@ -521,7 +500,6 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
// 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_offset=0; rharq_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/(worker_num+1))*worker_num) {
int Nl=dlsch->harq_processes[harq_pid]->Nl;
@@ -529,209 +507,186 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB,
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);
+ r_offset += Nl*Qm * (Gp/C);
else
- r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C));
- }
- else {
+ r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C));
+ } else {
start_meas(rm_stats);
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
+ 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);
}
}
- stop_meas(te_main_stats);
+ stop_meas(te_main_stats);
start_meas(te_wait_stats);
- if(worker_num == 1)
- {
+
+ 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)
- {
+ } 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
- {
+ } 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->p_time>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);
+ 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[frame%2][subframe]]->B;
- if(B<=6144)
- {
- L=0;
- C=1;
- }
- else
- {
- L=24;
- C = B/(6144-L);
- if((6144-L)*C < B)
- {
- C = C+1;
- }
- }
+ 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[frame%2][subframe]]->B;
+ if(B<=6144) {
+ L=0;
+ C=1;
+ } else {
+ L=24;
+ C = B/(6144-L);
- if(get_thread_worker_conf() == WORKER_ENABLE)
- {
- if(C >= 8)//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)//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)//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);
- }
+ if((6144-L)*C < B) {
+ C = C+1;
}
- else
- {
- encoding_return =
- dlsch_encoding(eNB,
- a,
- num_pdcch_symbols,
- dlsch,
- frame,
- subframe,
- rm_stats,
- te_stats,
- i_stats);
+ }
+
+ if(get_thread_worker_conf() == WORKER_ENABLE) {
+ if(C >= 8) { //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) { //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) { //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;
+ } 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,
+ 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)
-{
-
+ time_stats_t *i_stats) {
unsigned int G;
unsigned int crc=1;
-
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe];
+
if(harq_pid >= dlsch->Mdlharq) {
LOG_E(PHY,"dlsch_encoding illegal harq_pid %d\n", harq_pid);
return(-1);
}
+
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;
@@ -742,8 +697,8 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
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);
+ 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
@@ -758,14 +713,12 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
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];
+ 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);
@@ -782,25 +735,20 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
return(-1);
for (r=0; rharq_processes[harq_pid]->C; r++) {
-
if (rharq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus;
else
Kr = dlsch->harq_processes[harq_pid]->Kplus;
Kr_bytes = Kr>>3;
-
#ifdef DEBUG_DLSCH_CODING
- printf("Generating Code Segment %d (%d bits)\n",r,Kr);
+ printf("Generating Code Segment %u (%u bits)\n",r,Kr);
// generate codewords
-
- printf("bits_per_codeword (Kr)= %d, A %d\n",Kr,A);
+ printf("bits_per_codeword (Kr)= %u, A %u\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
-
-
start_meas(te_stats);
encoder(dlsch->harq_processes[harq_pid]->c[r],
Kr>>3,
@@ -821,7 +769,6 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
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
@@ -829,16 +776,15 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
for (r=0; rharq_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);
+ printf("Rate Matching, Code segment %u (coded bits (G) %u,unpunctured/repeated bits per code segment %u,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 encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx);
+ printf("rvidx in 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
@@ -853,7 +799,7 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
dlsch->harq_processes[harq_pid]->Nl,
r,
nb_rb);
- // m); // r
+ // m); // r
stop_meas(rm_stats);
#ifdef DEBUG_DLSCH_CODING
@@ -864,7 +810,6 @@ int dlsch_encoding(PHY_VARS_eNB *eNB,
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
-
return(0);
}
diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
index bfdcdc1e94..0b27392fd1 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c
@@ -1960,6 +1960,10 @@ int allocate_REs_in_RB_MCH(int32_t **txdataF,
case 4: //16QAM
+ if (qam_table_s == NULL) {
+ LOG_E(PHY,"qam table pointer is NULL\n");
+ return -1;
+ }
qam16_table_offset_re = 0;
qam16_table_offset_im = 0;
@@ -2029,7 +2033,9 @@ int allocate_REs_in_RB_MCH(int32_t **txdataF,
((int16_t *)&txdataF[4][tti_offset])[1]=qam_table_s[qam64_table_offset_im];//(int16_t)(((int32_t)amp*qam64_table[qam64_table_offset_im])>>15);
break;
-
+ default:
+ LOG_E(PHY,"Invalid modulation order %i_n",mod_order);
+ break;
}
}
diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c
index a27c6dbc90..37997c94b4 100644
--- a/openair1/PHY/LTE_TRANSPORT/pbch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pbch.c
@@ -308,7 +308,7 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
#ifdef DEBUG_PBCH
if (frame_mod4==0) {
- LOG_M"pbch_e.m","pbch_e",
+ LOG_M("pbch_e.m","pbch_e",
eNB_pbch->pbch_e,
pbch_E,
1,
@@ -325,7 +325,7 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
pbch_E);
#ifdef DEBUG_PBCH
if (frame_mod4==0) {
- LOG_M"pbch_e_s.m","pbch_e_s",
+ LOG_M("pbch_e_s.m","pbch_e_s",
eNB_pbch->pbch_e,
pbch_E,
1,
diff --git a/openair1/PHY/LTE_TRANSPORT/phich_common.c b/openair1/PHY/LTE_TRANSPORT/phich_common.c
index a3bc5250d5..72e9ad134a 100644
--- a/openair1/PHY/LTE_TRANSPORT/phich_common.c
+++ b/openair1/PHY/LTE_TRANSPORT/phich_common.c
@@ -33,105 +33,98 @@
#include "PHY/defs_eNB.h"
-uint8_t get_mi(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe)
-{
-
+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);
- case 0:
- if ((subframe==0) || (subframe==5))
- return(2);
- else return(1);
+ break;
- break;
+ case 1:
+ if ((subframe==0) || (subframe==5))
+ return(0);
+ else return(1);
- case 1:
- if ((subframe==0) || (subframe==5))
+ 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);
- 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)
-{
-
+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);
- }
+ 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;
+ 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;
+ 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 phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe) {
int pusch_frame;
if (frame_parms->frame_type == FDD) {
@@ -145,127 +138,124 @@ int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int sub
return pusch_frame % 1024;
}
-uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe)
-{
+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);
+ 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);
- }
-
- 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)
-{
-
+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]) ||
@@ -275,9 +265,7 @@ int check_pcfich(LTE_DL_FRAME_PARMS *frame_parms,uint16_t reg)
return(0);
}
-void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
-{
-
+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;
@@ -285,11 +273,9 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
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++;
@@ -299,25 +285,24 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
}
#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);
+ 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));
+ 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])
@@ -334,10 +319,9 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
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]++;
@@ -346,10 +330,9 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
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]++;
@@ -361,21 +344,19 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
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 :%u => %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
}
diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c
index 59450cf081..2639e318c9 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach.c
@@ -56,7 +56,7 @@ void rx_prach0(PHY_VARS_eNB *eNB,
#endif
) {
int i;
- LTE_DL_FRAME_PARMS *fp;
+ LTE_DL_FRAME_PARMS *fp=NULL;
lte_frame_type_t frame_type;
uint16_t rootSequenceIndex;
uint8_t prach_ConfigIndex;
@@ -66,7 +66,7 @@ void rx_prach0(PHY_VARS_eNB *eNB,
int subframe;
int16_t *prachF=NULL;
int16_t **rxsigF=NULL;
- int nb_rx;
+ int nb_rx=0;
int16_t *prach2;
uint8_t preamble_index;
uint16_t NCS,NCS2;
@@ -96,13 +96,17 @@ void rx_prach0(PHY_VARS_eNB *eNB,
int prach_ifft_cnt=0;
#endif
- if (ru) {
- fp = &ru->frame_parms;
- nb_rx = ru->nb_rx;
- } else if (eNB) {
- fp = &eNB->frame_parms;
+
+ if(eNB) {
+ fp = &(eNB->frame_parms);
nb_rx = fp->nb_antennas_rx;
- } else AssertFatal(1==0,"rx_prach called without valid RU or eNB descriptor\n");
+ } else {
+ fp = &(ru->frame_parms);
+ nb_rx = ru->nb_rx;
+ }
+ AssertFatal(fp!=NULL,"rx_prach called without valid RU or eNB descriptor\n");
+
+ frame_type = fp->frame_type;
frame_type = fp->frame_type;
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
@@ -148,29 +152,26 @@ void rx_prach0(PHY_VARS_eNB *eNB,
prachF = eNB->prach_vars_br.prachF;
rxsigF = eNB->prach_vars_br.rxsigF[ce_level];
- if (LOG_DEBUGFLAG(PRACH)) {
- if (((ru->proc.frame_prach)&1023) < 20) LOG_I(PHY,
- "PRACH (eNB) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d, rootSequenceIndex %d, repetition number %d,numRepetitionsPrePreambleAttempt %d\n",
- br_flag,ce_level,ru->proc.frame_prach,subframe,
- fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level],
- prach_ConfigIndex,rootSequenceIndex,
- eNB->prach_vars_br.repetition_number[ce_level],
- fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level]);
+ if (LOG_DEBUGFLAG(PRACH)){
+ if (((eNB->proc.frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (eNB) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d, rootSequenceIndex %d, repetition number %d,numRepetitionsPrePreambleAttempt %d\n",
+ br_flag,ce_level,eNB->proc.frame_prach,subframe,
+ fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level],
+ prach_ConfigIndex,rootSequenceIndex,
+ eNB->prach_vars_br.repetition_number[ce_level],
+ fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[ce_level]);
}
} else
#endif
- {
- prach_ifftp = eNB->prach_vars.prach_ifft[0];
- subframe = eNB->proc.subframe_prach;
- prachF = eNB->prach_vars.prachF;
- rxsigF = eNB->prach_vars.rxsigF[0];
-
- if (LOG_DEBUGFLAG(PRACH)) {
- if (((ru->proc.frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (eNB) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d , rootSequenceIndex %d\n", subframe,
- fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset,prach_ConfigIndex,rootSequenceIndex);
+ {
+ prach_ifftp = eNB->prach_vars.prach_ifft[0];
+ subframe = eNB->proc.subframe_prach;
+ prachF = eNB->prach_vars.prachF;
+ rxsigF = eNB->prach_vars.rxsigF[0];
+ if (LOG_DEBUGFLAG(PRACH)){
+ if (((eNB->proc.frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (eNB) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d , rootSequenceIndex %d\n", subframe,fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset,prach_ConfigIndex,rootSequenceIndex);
+ }
}
- }
- } else {
+ } else {
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
if (br_flag == 1) {
@@ -421,7 +422,7 @@ void rx_prach0(PHY_VARS_eNB *eNB,
}
}
- if ((eNB==NULL) && ru->function == NGFI_RRU_IF4p5) {
+ if ((eNB==NULL) && ru->function == NGFI_RRU_IF4p5) {
/// **** send_IF4 of rxsigF to RAU **** ///
#if (LTE_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);
@@ -445,26 +446,27 @@ void rx_prach0(PHY_VARS_eNB *eNB,
uint8_t update_TA2 = 1;
switch (eNB->frame_parms.N_RB_DL) {
- case 6:
- update_TA = 16;
- break;
- case 25:
- update_TA = 4;
- break;
+ case 6:
+ update_TA = 16;
+ break;
+
+ case 25:
+ update_TA = 4;
+ break;
+
+ case 50:
+ update_TA = 2;
+ break;
+
+ case 75:
+ update_TA = 3;
+ update_TA2 = 2;
+ break;
+ case 100:
+ update_TA = 1;
+ break;
- case 50:
- update_TA = 2;
- break;
-
- case 75:
- update_TA = 3;
- update_TA2 = 2;
- break;
-
- case 100:
- update_TA = 1;
- break;
}
*max_preamble_energy=0;
diff --git a/openair1/PHY/LTE_TRANSPORT/prach_common.c b/openair1/PHY/LTE_TRANSPORT/prach_common.c
index 4962f6a7f9..7e38d6a590 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach_common.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach_common.c
@@ -565,17 +565,16 @@ int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex
return(prach_mask);
}
-int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) {
+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);
+ int prach_mask = is_prach_subframe0(frame_parms, prach_ConfigIndex, frame, subframe);
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- int i;
-
- for (i=0;i<4;i++) {
+ for (int 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));
+ 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);
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
index cc62f83f4c..041679f649 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
@@ -47,9 +47,7 @@
extern WORKER_CONF_t get_thread_worker_conf(void);
-void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch)
-{
-
+void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch) {
int i,r;
if (ulsch) {
@@ -77,33 +75,30 @@ void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch)
}
free16(ulsch,sizeof(LTE_eNB_ULSCH_t));
- ulsch = NULL;
}
}
-LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag)
-{
-
+LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag) {
LTE_eNB_ULSCH_t *ulsch;
uint8_t exit_flag = 0,i,r;
unsigned char bw_scaling =1;
switch (N_RB_UL) {
- case 6:
- bw_scaling =16;
- break;
+ case 6:
+ bw_scaling =16;
+ break;
- case 25:
- bw_scaling =4;
- break;
+ case 25:
+ bw_scaling =4;
+ break;
- case 50:
- bw_scaling =2;
- break;
+ case 50:
+ bw_scaling =2;
+ break;
- default:
- bw_scaling =1;
- break;
+ default:
+ bw_scaling =1;
+ break;
}
ulsch = (LTE_eNB_ULSCH_t *)malloc16(sizeof(LTE_eNB_ULSCH_t));
@@ -119,7 +114,7 @@ LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uin
if (ulsch->harq_processes[i]) {
memset(ulsch->harq_processes[i],0,sizeof(LTE_UL_eNB_HARQ_t));
- ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_ULSCH_PAYLOAD_BYTES/bw_scaling);
+ ulsch->harq_processes[i]->b = (uint8_t *)malloc16(MAX_ULSCH_PAYLOAD_BYTES/bw_scaling);
if (ulsch->harq_processes[i]->b)
memset(ulsch->harq_processes[i]->b,0,MAX_ULSCH_PAYLOAD_BYTES/bw_scaling);
@@ -128,13 +123,14 @@ LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uin
if (abstraction_flag==0) {
for (r=0; rharq_processes[i]->c[r] = (uint8_t*)malloc16(((r==0)?8:0) + 3+768);
+ ulsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(((r==0)?8:0) + 3+768);
+
if (ulsch->harq_processes[i]->c[r])
memset(ulsch->harq_processes[i]->c[r],0,((r==0)?8:0) + 3+768);
else
exit_flag=2;
- ulsch->harq_processes[i]->d[r] = (short*)malloc16(((3*8*6144)+12+96)*sizeof(short));
+ ulsch->harq_processes[i]->d[r] = (short *)malloc16(((3*8*6144)+12+96)*sizeof(short));
if (ulsch->harq_processes[i]->d[r])
memset(ulsch->harq_processes[i]->d[r],0,((3*8*6144)+12+96)*sizeof(short));
@@ -153,13 +149,10 @@ LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uin
LOG_E(PHY,"new_ue_ulsch: exit_flag = %d\n",exit_flag);
free_eNB_ulsch(ulsch);
-
return(NULL);
}
-void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch)
-{
-
+void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch) {
unsigned char i;
//ulsch = (LTE_eNB_ULSCH_t *)malloc16(sizeof(LTE_eNB_ULSCH_t));
@@ -180,9 +173,11 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch)
ulsch->harq_processes[i]->TBS = 0;
ulsch->harq_processes[i]->Or1 = 0;
ulsch->harq_processes[i]->Or2 = 0;
+
for ( int j = 0; j < 2; j++ ) {
ulsch->harq_processes[i]->o_RI[j] = 0;
}
+
ulsch->harq_processes[i]->O_ACK = 0;
ulsch->harq_processes[i]->srs_active = 0;
ulsch->harq_processes[i]->rvidx = 0;
@@ -190,6 +185,7 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch)
ulsch->harq_processes[i]->Nsymb_initial = 0;
}
}
+
ulsch->beta_offset_cqi_times8 = 0;
ulsch->beta_offset_ri_times8 = 0;
ulsch->beta_offset_harqack_times8 = 0;
@@ -198,11 +194,8 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch)
}
-uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH)
-{
-
+uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH) {
uint8_t crc;
-
crc = cqi[CQI_LENGTH>>3];
// printf("crc1: %x, shift %d\n",crc,CQI_LENGTH&0x7);
crc = (crc<<(CQI_LENGTH&0x7));
@@ -212,22 +205,18 @@ uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH)
crc |= (cqi[1+(CQI_LENGTH>>3)])>>(8-(CQI_LENGTH&0x7));
// clear crc bits
//(((char *)cqi)[1+(CQI_LENGTH>>3)]) = 0;
-
// printf("crc : %x\n",crc);
return(crc);
-
}
-int ulsch_decoding_data_2thread0(td_params* tdp) {
-
+int ulsch_decoding_data_2thread0(td_params *tdp) {
PHY_VARS_eNB *eNB = tdp->eNB;
int UE_id = tdp->UE_id;
int harq_pid = tdp->harq_pid;
int llr8_flag = tdp->llr8_flag;
-
unsigned int r,r_offset=0,Kr,Kr_bytes;
uint8_t crc_type;
int offset = 0;
@@ -247,11 +236,8 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
else
tc = decoder8;
-
-
// go through first half of segments to get r_offset
for (r=0; r<(ulsch_harq->C/2); r++) {
-
// Get Turbo interleaver parameters
if (rCminus)
Kr = ulsch_harq->Kminus;
@@ -259,17 +245,15 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
Kr = ulsch_harq->Kplus;
Kr_bytes = Kr>>3;
-
// This is stolen from rate-matching algorithm to get the value of E
-
Gp = G/Nl/Q_m;
GpmodC = Gp%C;
-
+
if (r < (C-(GpmodC)))
E = Nl*Q_m * (Gp/C);
else
E = Nl*Q_m * ((GpmodC==0?0:1) + (Gp/C));
-
+
r_offset += E;
if (r==0) {
@@ -281,8 +265,6 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
// go through second half of segments
for (; r<(ulsch_harq->C); r++) {
-
-
// printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]);
// Get Turbo interleaver parameters
if (rCminus)
@@ -291,26 +273,23 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
Kr = ulsch_harq->Kplus;
Kr_bytes = Kr>>3;
-
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
- (uint8_t*)&dummy_w[r][0],
+ (uint8_t *)&dummy_w[r][0],
(r==0) ? ulsch_harq->F : 0);
-
#ifdef DEBUG_ULSCH_DECODING
- printf("Rate Matching Segment %d (coded bits (G) %d,unpunctured/repeated bits %d, Q_m %d, nb_rb %d, Nl %d)...\n",
- r, G,
- Kr*3,
- Q_m,
- nb_rb,
- ulsch_harq->Nl);
+ printf("Rate Matching Segment %u (coded bits (G) %d,unpunctured/repeated bits %u, Q_m %d, nb_rb %d, Nl %d)...\n",
+ r, G,
+ Kr*3,
+ Q_m,
+ nb_rb,
+ ulsch_harq->Nl);
#endif
-
if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r],
G,
ulsch_harq->w[r],
- (uint8_t*) &dummy_w[r][0],
+ (uint8_t *) &dummy_w[r][0],
ulsch_harq->e+r_offset,
ulsch_harq->C,
NSOFT,
@@ -327,7 +306,6 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
}
r_offset += E;
-
sub_block_deinterleaving_turbo(4+Kr,
&ulsch_harq->d[r][96],
ulsch_harq->w[r]);
@@ -336,44 +314,39 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
crc_type = CRC24_A;
else
crc_type = CRC24_B;
-
-
+
ret = tc(&ulsch_harq->d[r][96],
NULL,
- ulsch_harq->c[r],
+ ulsch_harq->c[r],
NULL,
- Kr,
- ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
- crc_type,
- (r==0) ? ulsch_harq->F : 0,
- &eNB->ulsch_tc_init_stats,
- &eNB->ulsch_tc_alpha_stats,
- &eNB->ulsch_tc_beta_stats,
- &eNB->ulsch_tc_gamma_stats,
- &eNB->ulsch_tc_ext_stats,
- &eNB->ulsch_tc_intl1_stats,
- &eNB->ulsch_tc_intl2_stats);
-
+ Kr,
+ ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
+ crc_type,
+ (r==0) ? ulsch_harq->F : 0,
+ &eNB->ulsch_tc_init_stats,
+ &eNB->ulsch_tc_alpha_stats,
+ &eNB->ulsch_tc_beta_stats,
+ &eNB->ulsch_tc_gamma_stats,
+ &eNB->ulsch_tc_ext_stats,
+ &eNB->ulsch_tc_intl1_stats,
+ &eNB->ulsch_tc_intl2_stats);
+
// Reassembly of Transport block here
if (ret != (1+ulsch->max_turbo_iterations)) {
if (rCminus)
- Kr = ulsch_harq->Kminus;
+ Kr = ulsch_harq->Kminus;
else
- Kr = ulsch_harq->Kplus;
-
+ Kr = ulsch_harq->Kplus;
+
Kr_bytes = Kr>>3;
-
memcpy(ulsch_harq->b+offset,
- ulsch_harq->c[r],
- Kr_bytes - ((ulsch_harq->C>1)?3:0));
+ ulsch_harq->c[r],
+ Kr_bytes - ((ulsch_harq->C>1)?3:0));
offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
-
-
} else {
break;
}
-
}
return(ret);
@@ -381,22 +354,21 @@ int ulsch_decoding_data_2thread0(td_params* tdp) {
extern int oai_exit;
void *td_thread(void *param) {
- PHY_VARS_eNB *eNB = ((td_params*)param)->eNB;
+ PHY_VARS_eNB *eNB = ((td_params *)param)->eNB;
L1_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 (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);
+ ((td_params *)param)->ret = ulsch_decoding_data_2thread0((td_params *)param);
if (release_thread(&proc->mutex_td,&proc->instance_cnt_td,"td thread")<0) break;
@@ -411,7 +383,6 @@ void *td_thread(void *param) {
}
int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) {
-
L1_proc_t *proc = &eNB->proc;
unsigned int r,r_offset=0,Kr,Kr_bytes;
uint8_t crc_type;
@@ -420,18 +391,14 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id];
LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
-
int G = ulsch_harq->G;
unsigned int E;
int Cby2;
decoder_if_t *tc;
-
struct timespec wait;
-
wait.tv_sec=0;
wait.tv_nsec=5000000L;
-
if (llr8_flag == 0)
tc = decoder16;
else
@@ -443,23 +410,21 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr
exit_fun( "error locking mutex_fep" );
return -1;
}
-
+
if (proc->instance_cnt_td==0) {
printf("[eNB] TD thread busy\n");
exit_fun("TD thread busy");
pthread_mutex_unlock( &proc->mutex_td );
return -1;
}
-
+
++proc->instance_cnt_td;
-
proc->tdp.eNB = eNB;
proc->tdp.UE_id = UE_id;
proc->tdp.harq_pid = harq_pid;
proc->tdp.llr8_flag = llr8_flag;
-
-
- // wakeup worker to do second half segments
+
+ // wakeup worker to do second half segments
if (pthread_cond_signal(&proc->cond_td) != 0) {
printf("[eNB] ERROR pthread_cond_signal for td thread exit\n");
exit_fun( "ERROR pthread_cond_signal" );
@@ -468,14 +433,12 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr
pthread_mutex_unlock( &proc->mutex_td );
Cby2 = ulsch_harq->C/2;
- }
- else {
+ } else {
Cby2 = 1;
}
// go through first half of segments in main thread
for (r=0; rc[r]);
// Get Turbo interleaver parameters
if (rCminus)
@@ -484,27 +447,24 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr
Kr = ulsch_harq->Kplus;
Kr_bytes = Kr>>3;
-
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
- (uint8_t*)&dummy_w[r][0],
+ (uint8_t *)&dummy_w[r][0],
(r==0) ? ulsch_harq->F : 0);
-
#ifdef DEBUG_ULSCH_DECODING
- printf("Rate Matching Segment %d (coded bits (G) %d,unpunctured/repeated bits %d, Q_m %d, nb_rb %d, Nl %d)...\n",
- r, G,
- Kr*3,
- Q_m,
- nb_rb,
- ulsch_harq->Nl);
+ printf("Rate Matching Segment %u (coded bits (G) %d,unpunctured/repeated bits %u, Q_m %d, nb_rb %d, Nl %d)...\n",
+ r, G,
+ Kr*3,
+ Q_m,
+ nb_rb,
+ ulsch_harq->Nl);
#endif
-
start_meas(&eNB->ulsch_rate_unmatching_stats);
if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r],
G,
ulsch_harq->w[r],
- (uint8_t*) &dummy_w[r][0],
+ (uint8_t *) &dummy_w[r][0],
ulsch_harq->e+r_offset,
ulsch_harq->C,
NSOFT,
@@ -522,7 +482,6 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr
stop_meas(&eNB->ulsch_rate_unmatching_stats);
r_offset += E;
-
start_meas(&eNB->ulsch_deinterleaving_stats);
sub_block_deinterleaving_turbo(4+Kr,
&ulsch_harq->d[r][96],
@@ -535,61 +494,57 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr
crc_type = CRC24_B;
start_meas(&eNB->ulsch_turbo_decoding_stats);
-
ret = tc(&ulsch_harq->d[r][96],
NULL,
- ulsch_harq->c[r],
+ ulsch_harq->c[r],
NULL,
- Kr,
- ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
- crc_type,
- (r==0) ? ulsch_harq->F : 0,
- &eNB->ulsch_tc_init_stats,
- &eNB->ulsch_tc_alpha_stats,
- &eNB->ulsch_tc_beta_stats,
- &eNB->ulsch_tc_gamma_stats,
- &eNB->ulsch_tc_ext_stats,
- &eNB->ulsch_tc_intl1_stats,
- &eNB->ulsch_tc_intl2_stats);
+ Kr,
+ ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
+ crc_type,
+ (r==0) ? ulsch_harq->F : 0,
+ &eNB->ulsch_tc_init_stats,
+ &eNB->ulsch_tc_alpha_stats,
+ &eNB->ulsch_tc_beta_stats,
+ &eNB->ulsch_tc_gamma_stats,
+ &eNB->ulsch_tc_ext_stats,
+ &eNB->ulsch_tc_intl1_stats,
+ &eNB->ulsch_tc_intl2_stats);
- // Reassembly of Transport block here
+ // Reassembly of Transport block here
if (ret != (1+ulsch->max_turbo_iterations)) {
if (rCminus)
- Kr = ulsch_harq->Kminus;
+ Kr = ulsch_harq->Kminus;
else
- Kr = ulsch_harq->Kplus;
-
+ Kr = ulsch_harq->Kplus;
+
Kr_bytes = Kr>>3;
-
+
if (r==0) {
- memcpy(ulsch_harq->b,
- &ulsch_harq->c[0][(ulsch_harq->F>>3)],
- Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0));
- offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
+ memcpy(ulsch_harq->b,
+ &ulsch_harq->c[0][(ulsch_harq->F>>3)],
+ Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0));
+ offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
} else {
- memcpy(ulsch_harq->b+offset,
- ulsch_harq->c[r],
- Kr_bytes - ((ulsch_harq->C>1)?3:0));
- offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
+ memcpy(ulsch_harq->b+offset,
+ ulsch_harq->c[r],
+ Kr_bytes - ((ulsch_harq->C>1)?3:0));
+ offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
}
-
} else {
break;
}
- stop_meas(&eNB->ulsch_turbo_decoding_stats);
- //printf("/////////////////////////////////////////**************************loop for %d time in ulsch_decoding main\n",r);
+
+ stop_meas(&eNB->ulsch_turbo_decoding_stats);
+ //printf("/////////////////////////////////////////**************************loop for %d time in ulsch_decoding main\n",r);
}
- // wait for worker to finish
-
- wait_on_busy_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread");
-
+ // wait for worker to finish
+ wait_on_busy_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread");
return( (ret>proc->tdp.ret) ? ret : proc->tdp.ret );
}
int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) {
-
unsigned int r,r_offset=0,Kr,Kr_bytes;
uint8_t crc_type;
int offset = 0;
@@ -597,7 +552,6 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag)
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id];
LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
-
int G = ulsch_harq->G;
unsigned int E;
decoder_if_t *tc;
@@ -607,9 +561,7 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag)
else
tc = *decoder8;
-
for (r=0; rC; r++) {
-
// printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]);
// Get Turbo interleaver parameters
if (rCminus)
@@ -618,27 +570,24 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag)
Kr = ulsch_harq->Kplus;
Kr_bytes = Kr>>3;
-
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
- (uint8_t*)&dummy_w[r][0],
+ (uint8_t *)&dummy_w[r][0],
(r==0) ? ulsch_harq->F : 0);
-
#ifdef DEBUG_ULSCH_DECODING
- printf("Rate Matching Segment %d (coded bits (G) %d,unpunctured/repeated bits %d, Q_m %d, nb_rb %d, Nl %d)...\n",
- r, G,
- Kr*3,
- Q_m,
- nb_rb,
- ulsch_harq->Nl);
+ printf("Rate Matching Segment %u (coded bits (G) %d,unpunctured/repeated bits %u, Q_m %d, nb_rb %d, Nl %d)...\n",
+ r, G,
+ Kr*3,
+ Q_m,
+ nb_rb,
+ ulsch_harq->Nl);
#endif
-
start_meas(&eNB->ulsch_rate_unmatching_stats);
if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r],
G,
ulsch_harq->w[r],
- (uint8_t*) &dummy_w[r][0],
+ (uint8_t *) &dummy_w[r][0],
ulsch_harq->e+r_offset,
ulsch_harq->C,
NSOFT,
@@ -656,7 +605,6 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag)
stop_meas(&eNB->ulsch_rate_unmatching_stats);
r_offset += E;
-
start_meas(&eNB->ulsch_deinterleaving_stats);
sub_block_deinterleaving_turbo(4+Kr,
&ulsch_harq->d[r][96],
@@ -667,61 +615,55 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag)
crc_type = CRC24_A;
else
crc_type = CRC24_B;
-
-
+
start_meas(&eNB->ulsch_turbo_decoding_stats);
-
ret = tc(&ulsch_harq->d[r][96],
NULL,
- ulsch_harq->c[r],
+ ulsch_harq->c[r],
NULL,
- Kr,
- ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
- crc_type,
- (r==0) ? ulsch_harq->F : 0,
- &eNB->ulsch_tc_init_stats,
- &eNB->ulsch_tc_alpha_stats,
- &eNB->ulsch_tc_beta_stats,
- &eNB->ulsch_tc_gamma_stats,
- &eNB->ulsch_tc_ext_stats,
- &eNB->ulsch_tc_intl1_stats,
- &eNB->ulsch_tc_intl2_stats);
-
+ Kr,
+ ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
+ crc_type,
+ (r==0) ? ulsch_harq->F : 0,
+ &eNB->ulsch_tc_init_stats,
+ &eNB->ulsch_tc_alpha_stats,
+ &eNB->ulsch_tc_beta_stats,
+ &eNB->ulsch_tc_gamma_stats,
+ &eNB->ulsch_tc_ext_stats,
+ &eNB->ulsch_tc_intl1_stats,
+ &eNB->ulsch_tc_intl2_stats);
stop_meas(&eNB->ulsch_turbo_decoding_stats);
-
- // Reassembly of Transport block here
+
+ // Reassembly of Transport block here
if (ret != (1+ulsch->max_turbo_iterations)) {
if (rCminus)
- Kr = ulsch_harq->Kminus;
+ Kr = ulsch_harq->Kminus;
else
- Kr = ulsch_harq->Kplus;
-
+ Kr = ulsch_harq->Kplus;
+
Kr_bytes = Kr>>3;
-
+
if (r==0) {
- memcpy(ulsch_harq->b,
- &ulsch_harq->c[0][(ulsch_harq->F>>3)],
- Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0));
- offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
+ memcpy(ulsch_harq->b,
+ &ulsch_harq->c[0][(ulsch_harq->F>>3)],
+ Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0));
+ offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
} else {
- memcpy(ulsch_harq->b+offset,
- ulsch_harq->c[r],
- Kr_bytes - ((ulsch_harq->C>1)?3:0));
- offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
+ memcpy(ulsch_harq->b+offset,
+ ulsch_harq->c[r],
+ Kr_bytes - ((ulsch_harq->C>1)?3:0));
+ offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
}
-
} else {
break;
}
-
}
return(ret);
}
-int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag)
-{
+int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) {
int ret = 0;
/*if(get_thread_worker_conf() == WORKER_ENABLE)
{
@@ -735,8 +677,7 @@ int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_fl
}
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)
-{
+static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2, unsigned char reset) {
int n;
if (reset) {
@@ -759,17 +700,13 @@ static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2,
*x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28);
return(*x1^*x2);
// printf("n=%d : c %x\n",n,x1^x2);
-
}
-
+
unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
- uint8_t llr8_flag)
-{
-
-
+ uint8_t llr8_flag) {
int16_t *ulsch_llr = eNB->pusch_vars[UE_id]->llr;
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id];
@@ -780,10 +717,8 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
unsigned int i,i2,q,j,j2;
int iprime;
unsigned int ret=0;
-
// uint8_t dummy_channel_output[(3*8*block_length)+12];
int r,Kr;
-
uint8_t *columnset;
unsigned int sumKr=0;
unsigned int Qprime,L,G,Q_CQI,Q_RI,H,Hprime,Hpp,Cmux,Rmux_prime,O_RCC;
@@ -799,13 +734,10 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
// uint8_t ytag2[6*14*1200],*ytag2_ptr;
int16_t cseq[6*14*1200] __attribute__((aligned(32)));
int off;
-
int frame = proc->frame_rx;
int subframe = proc->subframe_rx;
LTE_UL_eNB_HARQ_t *ulsch_harq;
-
-
#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
if (ulsch->ue_type>0) harq_pid = 0;
else
@@ -819,56 +751,45 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
// x1 is set in lte_gold_generic
x2 = ((uint32_t)ulsch->rnti<<14) + ((uint32_t)subframe<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.3.1
ulsch_harq = ulsch->harq_processes[harq_pid];
-
AssertFatal(harq_pid!=255,
"FATAL ERROR: illegal harq_pid, returning\n");
-
AssertFatal(ulsch_harq->Nsymb_pusch != 0,
"FATAL ERROR: harq_pid %d, Nsymb 0!\n",harq_pid);
-
-
nb_rb = ulsch_harq->nb_rb;
-
A = ulsch_harq->TBS;
-
-
Q_m = ulsch_harq->Qm;
G = nb_rb * (12 * Q_m) * ulsch_harq->Nsymb_pusch;
-
-
//#ifdef DEBUG_ULSCH_DECODING
LOG_D(PHY,"[PUSCH %d] Frame %d, Subframe %d: ulsch_decoding (Nid_cell %d, rnti %x, x2 %x): A %d, round %d, RV %d, O_r1 %d, O_RI %d, O_ACK %d, G %d, Q_m %d Nsymb_pusch %d nb_rb %d\n",
- harq_pid,
- proc->frame_rx,subframe,
- frame_parms->Nid_cell,ulsch->rnti,x2,
- A,
- ulsch_harq->round,
- ulsch_harq->rvidx,
- ulsch_harq->Or1,
- ulsch_harq->O_RI,
- ulsch_harq->O_ACK,
- G,
+ harq_pid,
+ proc->frame_rx,subframe,
+ frame_parms->Nid_cell,ulsch->rnti,x2,
+ A,
+ ulsch_harq->round,
+ ulsch_harq->rvidx,
+ ulsch_harq->Or1,
+ ulsch_harq->O_RI,
+ ulsch_harq->O_ACK,
+ G,
ulsch_harq->Qm,
ulsch_harq->Nsymb_pusch,
nb_rb);
-
//#endif
//if (ulsch_harq->round == 0) { // delete for RB shortage pattern
- // This is a new packet, so compute quantities regarding segmentation
- ulsch_harq->B = A+24;
- lte_segmentation(NULL,
- NULL,
- ulsch_harq->B,
- &ulsch_harq->C,
- &ulsch_harq->Cplus,
- &ulsch_harq->Cminus,
- &ulsch_harq->Kplus,
- &ulsch_harq->Kminus,
- &ulsch_harq->F);
- // CLEAR LLR's HERE for first packet in process
+ // This is a new packet, so compute quantities regarding segmentation
+ ulsch_harq->B = A+24;
+ lte_segmentation(NULL,
+ NULL,
+ ulsch_harq->B,
+ &ulsch_harq->C,
+ &ulsch_harq->Cplus,
+ &ulsch_harq->Cminus,
+ &ulsch_harq->Kplus,
+ &ulsch_harq->Kminus,
+ &ulsch_harq->F);
+ // CLEAR LLR's HERE for first packet in process
//}
// printf("after segmentation c[%d] = %p\n",0,ulsch_harq->c[0]);
-
sumKr = 0;
for (r=0; rC; r++) {
@@ -881,17 +802,15 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
}
AssertFatal(sumKr>0,
- "[eNB] ulsch_decoding.c: FATAL sumKr is 0! (Nid_cell %d, rnti %x, x2 %x): harq_pid %d round %d, RV %d, O_RI %d, O_ACK %d, G %d, subframe %d\n",
- frame_parms->Nid_cell,ulsch->rnti,x2,
- harq_pid,
- ulsch_harq->round,
- ulsch_harq->rvidx,
- ulsch_harq->O_RI,
- ulsch_harq->O_ACK,
- G,
- subframe);
-
-
+ "[eNB] ulsch_decoding.c: FATAL sumKr is 0! (Nid_cell %d, rnti %x, x2 %x): harq_pid %d round %d, RV %d, O_RI %d, O_ACK %d, G %d, subframe %d\n",
+ frame_parms->Nid_cell,ulsch->rnti,x2,
+ harq_pid,
+ ulsch_harq->round,
+ ulsch_harq->rvidx,
+ ulsch_harq->O_RI,
+ ulsch_harq->O_ACK,
+ G,
+ subframe);
// Compute Q_ri
Qprime = ulsch_harq->O_RI*ulsch_harq->Msc_initial*ulsch_harq->Nsymb_initial * ulsch->beta_offset_ri_times8;
@@ -907,10 +826,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
Q_RI = Q_m*Qprime;
Qprime_RI = Qprime;
-
-
// Compute Q_ack
-
Qprime = ulsch_harq->O_ACK*ulsch_harq->Msc_initial*ulsch_harq->Nsymb_initial * ulsch->beta_offset_harqack_times8;
if (Qprime > 0) {
@@ -926,8 +842,8 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
// Q_ACK = Qprime * Q_m;
Qprime_ACK = Qprime;
#ifdef DEBUG_ULSCH_DECODING
- printf("ulsch_decoding.c: Qprime_ACK %d, Msc_initial %d, Nsymb_initial %d, sumKr %d\n",
- Qprime_ACK,ulsch_harq->Msc_initial,ulsch_harq->Nsymb_initial,sumKr);
+ printf("ulsch_decoding.c: Qprime_ACK %u, Msc_initial %d, Nsymb_initial %d, sumKr %u\n",
+ Qprime_ACK,ulsch_harq->Msc_initial,ulsch_harq->Nsymb_initial,sumKr);
#endif
// Compute Q_cqi
@@ -950,43 +866,27 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
}
G = nb_rb * (12 * Q_m) * (ulsch_harq->Nsymb_pusch);
-
-
-
Q_CQI = Q_m * Qprime;
#ifdef DEBUG_ULSCH_DECODING
- printf("ulsch_decoding: G %d, Q_RI %d, Q_CQI %d (L %d, Or1 %d) O_ACK %d\n",G,Q_RI,Q_CQI,L,ulsch_harq->Or1,ulsch_harq->O_ACK);
+ printf("ulsch_decoding: G %u, Q_RI %u, Q_CQI %u (L %u, Or1 %d) O_ACK %d\n",G,Q_RI,Q_CQI,L,ulsch_harq->Or1,ulsch_harq->O_ACK);
#endif
-
G = G - Q_RI - Q_CQI;
ulsch_harq->G = G;
-
AssertFatal((int)G > 0,
"FATAL: ulsch_decoding.c G < 0 (%d) : Q_RI %d, Q_CQI %d\n",G,Q_RI,Q_CQI);
-
H = G + Q_CQI;
Hprime = H/Q_m;
-
-
// Demultiplexing/Deinterleaving of PUSCH/ACK/RI/CQI
start_meas(&eNB->ulsch_demultiplexing_stats);
Hpp = Hprime + Qprime_RI;
-
Cmux = ulsch_harq->Nsymb_pusch;
Rmux_prime = Hpp/Cmux;
-
// Clear "tag" interleaving matrix to allow for CQI/DATA identification
memset(ytag,0,Cmux*Rmux_prime);
-
-
-
i=0;
memset(y,LTE_NULL,Q_m*Hpp);
-
// read in buffer and unscramble llrs for everything but placeholder bits
// llrs stored per symbol correspond to columns of interleaving matrix
-
-
s = lte_gold_unscram(&x1, &x2, 1);
i2=0;
@@ -998,26 +898,25 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
*/
#if defined(__x86_64__) || defined(__i386__)
#ifndef __AVX2__
- ((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut)[(s&65535)<<1];
- ((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut)[1+((s&65535)<<1)];
+ ((__m128i *)cseq)[i2++] = ((__m128i *)unscrambling_lut)[(s&65535)<<1];
+ ((__m128i *)cseq)[i2++] = ((__m128i *)unscrambling_lut)[1+((s&65535)<<1)];
s>>=16;
- ((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut)[(s&65535)<<1];
- ((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut)[1+((s&65535)<<1)];
+ ((__m128i *)cseq)[i2++] = ((__m128i *)unscrambling_lut)[(s&65535)<<1];
+ ((__m128i *)cseq)[i2++] = ((__m128i *)unscrambling_lut)[1+((s&65535)<<1)];
#else
- ((__m256i*)cseq)[i2++] = ((__m256i*)unscrambling_lut)[s&65535];
- ((__m256i*)cseq)[i2++] = ((__m256i*)unscrambling_lut)[(s>>16)&65535];
+ ((__m256i *)cseq)[i2++] = ((__m256i *)unscrambling_lut)[s&65535];
+ ((__m256i *)cseq)[i2++] = ((__m256i *)unscrambling_lut)[(s>>16)&65535];
#endif
#elif defined(__arm__)
- ((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut)[(s&65535)<<1];
- ((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut)[1+((s&65535)<<1)];
+ ((int16x8_t *)cseq)[i2++] = ((int16x8_t *)unscrambling_lut)[(s&65535)<<1];
+ ((int16x8_t *)cseq)[i2++] = ((int16x8_t *)unscrambling_lut)[1+((s&65535)<<1)];
s>>=16;
- ((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut)[(s&65535)<<1];
- ((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut)[1+((s&65535)<<1)];
+ ((int16x8_t *)cseq)[i2++] = ((int16x8_t *)unscrambling_lut)[(s&65535)<<1];
+ ((int16x8_t *)cseq)[i2++] = ((int16x8_t *)unscrambling_lut)[1+((s&65535)<<1)];
#endif
s = lte_gold_unscram(&x1, &x2, 0);
}
-
// printf("after unscrambling c[%d] = %p\n",0,ulsch_harq->c[0]);
if (frame_parms->Ncp == 0)
@@ -1040,7 +939,6 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
cseq[off+q] = -1; // PUSCH_x
j=(j+3)&3;
-
}
// printf("after RI c[%d] = %p\n",0,ulsch_harq->c[0]);
@@ -1069,87 +967,82 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
}
#ifdef DEBUG_ULSCH_DECODING
- printf("ulsch_decoding.c: ACK i %d, r %d, j %d, ColumnSet[j] %d\n",i,r,j,columnset[j]);
+ printf("ulsch_decoding.c: ACK i %u, r %d, j %u, ColumnSet[j] %d\n",i,r,j,columnset[j]);
#endif
j=(j+3)&3;
}
-
-
i=0;
switch (Q_m) {
- case 2:
- for (j=0; jO_ACK == 1) {
switch (Q_m) {
- case 2:
- len_ACK = 2;
- break;
+ case 2:
+ len_ACK = 2;
+ break;
- case 4:
- len_ACK = 4;
- break;
+ case 4:
+ len_ACK = 4;
+ break;
- case 6:
- len_ACK = 6;
- break;
+ case 6:
+ len_ACK = 6;
+ break;
}
}
if (ulsch_harq->O_ACK == 2) {
switch (Q_m) {
- case 2:
- len_ACK = 6;
- break;
+ case 2:
+ len_ACK = 6;
+ break;
- case 4:
- len_ACK = 12;
- break;
+ case 4:
+ len_ACK = 12;
+ break;
- case 6:
- len_ACK = 18;
- break;
+ case 6:
+ len_ACK = 18;
+ break;
}
}
@@ -1202,13 +1095,13 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
for (i=0; iq_ACK[i] = 0;
-
for (i=0; i>2);
for (q=0; qq_ACK[(q+(Q_m*i))%len_ACK] += y[q+(Q_m*((r*Cmux) + columnset[j]))];
+
y[q+(Q_m*((r*Cmux) + columnset[j]))]=0; // NULL LLRs in ACK positions
}
@@ -1221,17 +1114,17 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
if (ulsch_harq->O_RI == 1) {
switch (Q_m) {
- case 2:
- len_RI=2;
- break;
+ case 2:
+ len_RI=2;
+ break;
- case 4:
- len_RI=4;
- break;
+ case 4:
+ len_RI=4;
+ break;
- case 6:
- len_RI=6;
- break;
+ case 6:
+ len_RI=6;
+ break;
}
}
@@ -1261,7 +1154,6 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
}
// printf("after RI2 c[%d] = %p\n",0,ulsch_harq->c[0]);
-
// CQI and Data bits
j=0;
j2=0;
@@ -1269,116 +1161,108 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
// r=0;
if (Q_RI>0) {
for (i=0; i<(Q_CQI/Q_m); i++) {
-
while (ytag[j]==LTE_NULL) {
- j++;
- j2+=Q_m;
+ j++;
+ j2+=Q_m;
}
-
+
for (q=0; q127)
- ulsch_harq->q[q+(Q_m*i)] = 127;
- else if (ys<-128)
- ulsch_harq->q[q+(Q_m*i)] = -128;
- else
- ulsch_harq->q[q+(Q_m*i)] = ys;
+ // ys = y[q+(Q_m*((r*Cmux)+j))];
+ ys = y[q+j2];
+
+ if (ys>127)
+ ulsch_harq->q[q+(Q_m*i)] = 127;
+ else if (ys<-128)
+ ulsch_harq->q[q+(Q_m*i)] = -128;
+ else
+ ulsch_harq->q[q+(Q_m*i)] = ys;
}
-
+
j2+=Q_m;
}
-
-
+
switch (Q_m) {
- case 2:
- for (iprime=0; iprimee[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
-
- }
-
-
- break;
-
- case 4:
- for (iprime=0; iprimee[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
-
- }
-
- break;
-
- case 6:
- for (iprime=0; iprimee[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
- ulsch_harq->e[iprime++] = y[j2++];
-
- }
-
- break;
+ case 2:
+ for (iprime=0; iprimee[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ }
+
+ break;
+
+ case 4:
+ for (iprime=0; iprimee[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ }
+
+ break;
+
+ case 6:
+ for (iprime=0; iprimee[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ ulsch_harq->e[iprime++] = y[j2++];
+ }
+
+ break;
}
-
-
} // Q_RI>0
else {
-
for (i=0; i<(Q_CQI/Q_m); i++) {
-
for (q=0; q127)
- ulsch_harq->q[q+(Q_m*i)] = 127;
- else if (ys<-128)
- ulsch_harq->q[q+(Q_m*i)] = -128;
- else
- ulsch_harq->q[q+(Q_m*i)] = ys;
+ ys = y[q+j2];
+
+ if (ys>127)
+ ulsch_harq->q[q+(Q_m*i)] = 127;
+ else if (ys<-128)
+ ulsch_harq->q[q+(Q_m*i)] = -128;
+ else
+ ulsch_harq->q[q+(Q_m*i)] = ys;
}
-
+
j2+=Q_m;
}
+
/* To be improved according to alignment of j2
-#if defined(__x86_64__)||defined(__i386__)
-#ifndef __AVX2__
+ #if defined(__x86_64__)||defined(__i386__)
+ #ifndef __AVX2__
for (iprime=0; iprimee[iprime]) = *((__m128i *)&y[j2]);
-#else
+ #else
for (iprime=0; iprimee[iprime]) = *((__m256i *)&y[j2]);
-#endif
-#elif defined(__arm__)
+ #endif
+ #elif defined(__arm__)
for (iprime=0; iprimee[iprime]) = *((int16x8_t *)&y[j2]);
-#endif
+ #endif
*/
int16_t *yp,*ep;
- for (iprime=0,yp=&y[j2],ep=&ulsch_harq->e[0];
- iprimee[0];
+ iprimeulsch_demultiplexing_stats);
-
// printf("after ACKNAK2 c[%d] = %p (iprime %d, G %d)\n",0,ulsch_harq->c[0],iprime,G);
-
// Do CQI/RI/HARQ-ACK Decoding first and pass to MAC
-
// HARQ-ACK
wACK_idx = (ulsch->bundling==0) ? 4 : ((Nbundled-1)&3);
@@ -1412,22 +1292,23 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
if (ulsch_harq->O_ACK == 2) {
switch (Q_m) {
+ case 2:
+ ulsch_harq->q_ACK[0] = ulsch_harq->q_ACK[0]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[3]*wACK_RX[wACK_idx][1];
+ ulsch_harq->q_ACK[1] = ulsch_harq->q_ACK[1]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[4]*wACK_RX[wACK_idx][1];
+ ulsch_harq->q_ACK[2] = ulsch_harq->q_ACK[2]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[5]*wACK_RX[wACK_idx][1];
+ break;
- case 2:
- ulsch_harq->q_ACK[0] = ulsch_harq->q_ACK[0]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[3]*wACK_RX[wACK_idx][1];
- ulsch_harq->q_ACK[1] = ulsch_harq->q_ACK[1]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[4]*wACK_RX[wACK_idx][1];
- ulsch_harq->q_ACK[2] = ulsch_harq->q_ACK[2]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[5]*wACK_RX[wACK_idx][1];
- break;
- case 4:
- ulsch_harq->q_ACK[0] = ulsch_harq->q_ACK[0]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[5]*wACK_RX[wACK_idx][1];
- ulsch_harq->q_ACK[1] = ulsch_harq->q_ACK[1]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[8]*wACK_RX[wACK_idx][1];
- ulsch_harq->q_ACK[2] = ulsch_harq->q_ACK[4]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[9]*wACK_RX[wACK_idx][1];
- break;
- case 6:
- ulsch_harq->q_ACK[0] = ulsch_harq->q_ACK[0]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[7]*wACK_RX[wACK_idx][1];
- ulsch_harq->q_ACK[1] = ulsch_harq->q_ACK[1]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[12]*wACK_RX[wACK_idx][1];
- ulsch_harq->q_ACK[2] = ulsch_harq->q_ACK[6]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[13]*wACK_RX[wACK_idx][1];
- break;
+ case 4:
+ ulsch_harq->q_ACK[0] = ulsch_harq->q_ACK[0]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[5]*wACK_RX[wACK_idx][1];
+ ulsch_harq->q_ACK[1] = ulsch_harq->q_ACK[1]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[8]*wACK_RX[wACK_idx][1];
+ ulsch_harq->q_ACK[2] = ulsch_harq->q_ACK[4]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[9]*wACK_RX[wACK_idx][1];
+ break;
+
+ case 6:
+ ulsch_harq->q_ACK[0] = ulsch_harq->q_ACK[0]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[7]*wACK_RX[wACK_idx][1];
+ ulsch_harq->q_ACK[1] = ulsch_harq->q_ACK[1]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[12]*wACK_RX[wACK_idx][1];
+ ulsch_harq->q_ACK[2] = ulsch_harq->q_ACK[6]*wACK_RX[wACK_idx][0] + ulsch_harq->q_ACK[13]*wACK_RX[wACK_idx][1];
+ break;
}
ulsch_harq->o_ACK[0] = 1;
@@ -1443,7 +1324,6 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
metric_new = ulsch_harq->q_ACK[0]-ulsch_harq->q_ACK[1]+ulsch_harq->q_ACK[2];
-
if (metric_new > metric) {
ulsch_harq->o_ACK[0] = 1;
ulsch_harq->o_ACK[1] = 0;
@@ -1467,26 +1347,21 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
}
// CQI
-
// printf("before cqi c[%d] = %p\n",0,ulsch_harq->c[0]);
ulsch_harq->cqi_crc_status = 0;
+
if (Q_CQI>0) {
memset((void *)&dummy_w_cc[0],0,3*(ulsch_harq->Or1+8+32));
-
O_RCC = generate_dummy_w_cc(ulsch_harq->Or1+8,
&dummy_w_cc[0]);
-
-
lte_rate_matching_cc_rx(O_RCC,
Q_CQI,
ulsch_harq->o_w,
dummy_w_cc,
ulsch_harq->q);
-
sub_block_deinterleaving_cc((unsigned int)(ulsch_harq->Or1+8),
&ulsch_harq->o_d[96],
&ulsch_harq->o_w[0]);
-
memset(ulsch_harq->o,0,(7+8+ulsch_harq->Or1) / 8);
phy_viterbi_lte_sse2(ulsch_harq->o_d+96,ulsch_harq->o,8+ulsch_harq->Or1);
@@ -1497,7 +1372,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
printf("ulsch_decoding: Or1=%d\n",ulsch_harq->Or1);
for (i=0; i<1+((8+ulsch_harq->Or1)/8); i++)
- printf("ulsch_decoding: O[%d] %d\n",i,ulsch_harq->o[i]);
+ printf("ulsch_decoding: O[%u] %d\n",i,ulsch_harq->o[i]);
if (ulsch_harq->cqi_crc_status == 1)
printf("RX CQI CRC OK (%x)\n",extract_cqi_crc(ulsch_harq->o,ulsch_harq->Or1));
@@ -1508,12 +1383,8 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
}
LOG_D(PHY,"frame %d subframe %d O_ACK:%d o_ACK[]=%d:%d:%d:%d\n",frame,subframe,ulsch_harq->O_ACK,ulsch_harq->o_ACK[0],ulsch_harq->o_ACK[1],ulsch_harq->o_ACK[2],ulsch_harq->o_ACK[3]);
-
// Do ULSCH Decoding for data portion
-
ret = ulsch_decoding_data_all(eNB,UE_id,harq_pid,llr8_flag);
-
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0);
-
return(ret);
}
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
index 0c799d8494..8fab8cd0df 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
@@ -687,7 +687,7 @@ void ulsch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms,
ul_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(ul_ch_mag128_0[i],1),_mm_srai_epi16(ul_ch_mag128_1[i],1));
ul_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(ul_ch_mag128_0b[i],1),_mm_srai_epi16(ul_ch_mag128_1b[i],1));
rxdataF_comp128_0[i] = _mm_add_epi16(rxdataF_comp128_0[i],(*(__m128i*)&jitterc[0]));
-
+ }
#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];
@@ -702,10 +702,10 @@ void ulsch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms,
ul_ch_mag128_0[i] = vhaddq_s16(ul_ch_mag128_0[i],ul_ch_mag128_1[i]);
ul_ch_mag128_0b[i] = vhaddq_s16(ul_ch_mag128_0b[i],ul_ch_mag128_1b[i]);
rxdataF_comp128_0[i] = vqaddq_s16(rxdataF_comp128_0[i],(*(int16x8_t*)&jitterc[0]));
-
+ }
#endif
- }
+
}
#if defined(__x86_64__) || defined(__i386__)
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c
index 4a2c8481cb..2c6f31e244 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dci_ue.c
@@ -362,6 +362,10 @@ void pdcch_channel_level(int32_t **dl_ch_estimates_ext,
#elif defined(__arm__)
int16x8_t *dl_ch128;
int32x4_t *avg128P;
+#else
+ int16_t *dl_ch128;
+ int32_t *avg128P;
+#error Unsupported CPU architecture, cannot build __FILE__
#endif
for (aatx=0; aatxnb_antenna_ports_eNB; aatx++)
for (aarx=0; aarxnb_antennas_rx; aarx++) {
@@ -370,7 +374,11 @@ void pdcch_channel_level(int32_t **dl_ch_estimates_ext,
avg128P = _mm_setzero_si128();
dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][0];
#elif defined(__arm__)
-
+ dl_ch128=&dl_ch_estimates_ext[(aatx<<1)+aarx][0];
+#error __arm__ not yet implemented, cannot build __FILE__
+#else
+ dl_ch128=&dl_ch_estimates_ext[(aatx<<1)+aarx][0];
+#error Unsupported CPU architecture, cannot build __FILE__
#endif
for (rb=0; rbN_RB_DL*12];
rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
+#else
+#error Unsupported CPU architecture, cannot build __FILE__
#endif
// MRC on each re of rb on MF output
for (i=0; iN_RB_DL*3; i++) {
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c
index 1b4ca3ed2f..4ca9a7c762 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c
@@ -40,9 +40,7 @@
//#define DEBUG_DLSCH_DECODING
//#define UE_DEBUG_TRACE 1
-void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch)
-{
-
+void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch) {
int i,r;
if (dlsch) {
@@ -70,34 +68,30 @@ void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch)
}
free16(dlsch,sizeof(LTE_UE_DLSCH_t));
- dlsch = NULL;
}
}
-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)
-{
-
+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) {
LTE_UE_DLSCH_t *dlsch;
uint8_t exit_flag = 0,i,r;
-
unsigned char bw_scaling =1;
switch (N_RB_DL) {
- case 6:
- bw_scaling =16;
- break;
+ case 6:
+ bw_scaling =16;
+ break;
- case 25:
- bw_scaling =4;
- break;
+ case 25:
+ bw_scaling =4;
+ break;
- case 50:
- bw_scaling =2;
- break;
+ case 50:
+ bw_scaling =2;
+ break;
- default:
- bw_scaling =1;
- break;
+ default:
+ bw_scaling =1;
+ break;
}
dlsch = (LTE_UE_DLSCH_t *)malloc16(sizeof(LTE_UE_DLSCH_t));
@@ -116,7 +110,7 @@ LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_
if (dlsch->harq_processes[i]) {
memset(dlsch->harq_processes[i],0,sizeof(LTE_DL_UE_HARQ_t));
dlsch->harq_processes[i]->first_tx=1;
- dlsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
+ dlsch->harq_processes[i]->b = (uint8_t *)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
if (dlsch->harq_processes[i]->b)
memset(dlsch->harq_processes[i]->b,0,MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
@@ -125,14 +119,14 @@ LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_
if (abstraction_flag == 0) {
for (r=0; rharq_processes[i]->c[r] = (uint8_t*)malloc16(((r==0)?8:0) + 3+ 768);
+ dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(((r==0)?8:0) + 3+ 768);
if (dlsch->harq_processes[i]->c[r])
memset(dlsch->harq_processes[i]->c[r],0,((r==0)?8:0) + 3+ 768);
else
exit_flag=2;
- dlsch->harq_processes[i]->d[r] = (short*)malloc16(((3*8*6144)+12+96)*sizeof(short));
+ dlsch->harq_processes[i]->d[r] = (short *)malloc16(((3*8*6144)+12+96)*sizeof(short));
if (dlsch->harq_processes[i]->d[r])
memset(dlsch->harq_processes[i]->d[r],0,((3*8*6144)+12+96)*sizeof(short));
@@ -151,7 +145,6 @@ LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_
printf("new_ue_dlsch with size %zu: exit_flag = %u\n",sizeof(LTE_DL_UE_HARQ_t), exit_flag);
free_ue_dlsch(dlsch);
-
return(NULL);
}
@@ -164,9 +157,7 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue,
uint8_t subframe,
uint8_t harq_pid,
uint8_t is_crnti,
- uint8_t llr8_flag)
-{
-
+ uint8_t llr8_flag) {
#if UE_TIMING_TRACE
time_stats_t *dlsch_rate_unmatching_stats=&phy_vars_ue->dlsch_rate_unmatching_stats;
time_stats_t *dlsch_turbo_decoding_stats=&phy_vars_ue->dlsch_turbo_decoding_stats;
@@ -186,26 +177,24 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue,
#if 0
int Kr_last,skipped_last=0;
uint8_t (*tc_2cw)(int16_t *y,
- int16_t *y2,
- uint8_t *,
- uint8_t *,
- uint16_t,
- uint16_t,
- uint16_t,
- uint8_t,
- uint8_t,
- uint8_t,
- time_stats_t *,
- time_stats_t *,
- time_stats_t *,
- time_stats_t *,
- time_stats_t *,
- time_stats_t *,
- time_stats_t *);
-
+ int16_t *y2,
+ uint8_t *,
+ uint8_t *,
+ uint16_t,
+ uint16_t,
+ uint16_t,
+ uint8_t,
+ uint8_t,
+ uint8_t,
+ time_stats_t *,
+ time_stats_t *,
+ time_stats_t *,
+ time_stats_t *,
+ time_stats_t *,
+ time_stats_t *,
+ time_stats_t *);
#endif
-decoder_if_t *tc;
-
+ decoder_if_t *tc;
if (!dlsch_llr) {
printf("dlsch_decoding.c: NULL dlsch_llr pointer\n");
@@ -229,42 +218,32 @@ decoder_if_t *tc;
if (dlsch->harq_ack[subframe].ack != 2) {
LOG_D(PHY, "[UE %d] DLSCH @ SF%d : ACK bit is %d instead of DTX even before PDSCH is decoded!\n",
- phy_vars_ue->Mod_id, subframe, dlsch->harq_ack[subframe].ack);
+ phy_vars_ue->Mod_id, subframe, dlsch->harq_ack[subframe].ack);
}
if (llr8_flag == 0) {
tc = decoder16;
- }
- else
- {
+ } else {
AssertFatal (harq_process->TBS >= 256 , "Mismatch flag nbRB=%d TBS=%d mcs=%d Qm=%d RIV=%d round=%d \n",
- harq_process->nb_rb, harq_process->TBS,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round);
+ harq_process->nb_rb, harq_process->TBS,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round);
tc = decoder8;
}
-
// nb_rb = dlsch->nb_rb;
-
/*
if (nb_rb > frame_parms->N_RB_DL) {
printf("dlsch_decoding.c: Illegal nb_rb %d\n",nb_rb);
return(max_turbo_iterations);
}*/
-
/*harq_pid = dlsch->current_harq_pid[phy_vars_ue->current_thread_id[subframe]];
if (harq_pid >= 8) {
printf("dlsch_decoding.c: Illegal harq_pid %d\n",harq_pid);
return(max_turbo_iterations);
}
*/
-
harq_process->trials[harq_process->round]++;
-
A = harq_process->TBS; //2072 for QPSK 1/3
-
ret = dlsch->max_turbo_iterations;
-
-
G = harq_process->G;
//get_G(frame_parms,nb_rb,dlsch->rb_alloc,mod_order,num_pdcch_symbols,phy_vars_ue->frame,subframe);
@@ -293,40 +272,37 @@ decoder_if_t *tc;
*/
err_flag = 0;
r_offset = 0;
-
unsigned char bw_scaling =1;
switch (frame_parms->N_RB_DL) {
- case 6:
- bw_scaling =16;
- break;
+ case 6:
+ bw_scaling =16;
+ break;
- case 25:
- bw_scaling =4;
- break;
+ case 25:
+ bw_scaling =4;
+ break;
- case 50:
- bw_scaling =2;
- break;
+ case 50:
+ bw_scaling =2;
+ break;
- default:
- bw_scaling =1;
- break;
+ default:
+ bw_scaling =1;
+ break;
}
if (harq_process->C > MAX_NUM_DLSCH_SEGMENTS/bw_scaling) {
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_DLSCH_SEGMENTS/bw_scaling);
return((1+dlsch->max_turbo_iterations));
}
+
#ifdef DEBUG_DLSCH_DECODING
printf("Segmentation: C %d, Cminus %d, Kminus %d, Kplus %d\n",harq_process->C,harq_process->Cminus,harq_process->Kminus,harq_process->Kplus);
#endif
-
opp_enabled=1;
for (r=0; rC; r++) {
-
-
// Get Turbo interleaver parameters
if (rCminus)
Kr = harq_process->Kminus;
@@ -334,15 +310,13 @@ decoder_if_t *tc;
Kr = harq_process->Kplus;
Kr_bytes = Kr>>3;
-
#if UE_TIMING_TRACE
start_meas(dlsch_rate_unmatching_stats);
#endif
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
harq_process->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
- (uint8_t*) &dummy_w[r][0],
+ (uint8_t *) &dummy_w[r][0],
(r==0) ? harq_process->F : 0);
-
#ifdef DEBUG_DLSCH_DECODING
LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n",
harq_pid,r, G,
@@ -354,14 +328,14 @@ decoder_if_t *tc;
harq_process->rvidx,
harq_process->round);
#endif
-
#ifdef DEBUG_DLSCH_DECODING
printf(" in decoding dlsch->harq_processes[harq_pid]->rvidx = %d\n", dlsch->harq_processes[harq_pid]->rvidx);
#endif
+
if (lte_rate_matching_turbo_rx(harq_process->RTC[r],
G,
harq_process->w[r],
- (uint8_t*)&dummy_w[r][0],
+ (uint8_t *)&dummy_w[r][0],
dlsch_llr+r_offset,
harq_process->C,
dlsch->Nsoft,
@@ -378,14 +352,13 @@ decoder_if_t *tc;
#endif
LOG_E(PHY,"dlsch_decoding.c: Problem in rate_matching\n");
return(dlsch->max_turbo_iterations);
- } else
- {
+ } else {
#if UE_TIMING_TRACE
stop_meas(dlsch_rate_unmatching_stats);
#endif
}
- r_offset += E;
+ r_offset += E;
/*
printf("Subblock deinterleaving, d %p w %p\n",
harq_process->d[r],
@@ -396,7 +369,6 @@ decoder_if_t *tc;
#endif
sub_block_deinterleaving_turbo(4+Kr,
&harq_process->d[r][96],
-
harq_process->w[r]);
#if UE_TIMING_TRACE
stop_meas(dlsch_deinterleaving_stats);
@@ -413,8 +385,6 @@ decoder_if_t *tc;
printf("%d : %d\n",i,harq_process->d[r][96+i]);
printf("\n");*/
#endif
-
-
// printf("Clearing c, %p\n",harq_process->c[r]);
memset(harq_process->c[r],0,Kr_bytes);
@@ -432,21 +402,22 @@ decoder_if_t *tc;
printf("%d : %d\n",i,harq_process->d[r][96+i]);
printf("\n");
*/
-
//#ifndef __AVX2__
#if 1
+
if (err_flag == 0) {
-/*
- LOG_I(PHY, "turbo algo Kr=%d cb_cnt=%d C=%d nbRB=%d crc_type %d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d maxIter %d\n",
- Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS,
- harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_turbo_iterations);
-*/
- if (llr8_flag) {
- AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n",
- Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round);
- }
+ /*
+ LOG_I(PHY, "turbo algo Kr=%d cb_cnt=%d C=%d nbRB=%d crc_type %d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d maxIter %d\n",
+ Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS,
+ harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_turbo_iterations);
+ */
+ if (llr8_flag) {
+ AssertFatal (Kr >= 256, "turbo algo issue Kr=%d cb_cnt=%d C=%d nbRB=%d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d\n",
+ Kr,r,harq_process->C,harq_process->nb_rb,A,harq_process->TBS,harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round);
+ }
+
#if UE_TIMING_TRACE
- start_meas(dlsch_turbo_decoding_stats);
+ start_meas(dlsch_turbo_decoding_stats);
#endif
LOG_D(PHY,"AbsSubframe %d.%d Start turbo segment %d/%d \n",frame%1024,subframe,r,harq_process->C-1);
ret = tc
@@ -465,17 +436,17 @@ decoder_if_t *tc;
&phy_vars_ue->dlsch_tc_ext_stats,
&phy_vars_ue->dlsch_tc_intl1_stats,
&phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
-
#if UE_TIMING_TRACE
stop_meas(dlsch_turbo_decoding_stats);
#endif
}
-#else
- if ((harq_process->C == 1) ||
- ((r==harq_process->C-1) && (skipped_last==0))) { // last segment with odd number of segments
+#else
+
+ if ((harq_process->C == 1) ||
+ ((r==harq_process->C-1) && (skipped_last==0))) { // last segment with odd number of segments
#if UE_TIMING_TRACE
- start_meas(dlsch_turbo_decoding_stats);
+ start_meas(dlsch_turbo_decoding_stats);
#endif
ret = tc
(&harq_process->d[r][96],
@@ -491,123 +462,115 @@ decoder_if_t *tc;
&phy_vars_ue->dlsch_tc_ext_stats,
&phy_vars_ue->dlsch_tc_intl1_stats,
&phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
- #if UE_TIMING_TRACE
+#if UE_TIMING_TRACE
stop_meas(dlsch_turbo_decoding_stats);
#endif
// printf("single decode, exit\n");
// exit(-1);
- }
- else {
- // we can merge code segments
+ } else {
+ // we can merge code segments
if ((skipped_last == 0) && (rC-1)) {
- skipped_last = 1;
- Kr_last = Kr;
- }
- else {
- skipped_last=0;
+ skipped_last = 1;
+ Kr_last = Kr;
+ } else {
+ skipped_last=0;
- if (Kr_last == Kr) { // decode 2 code segments with AVX2 version
+ if (Kr_last == Kr) { // decode 2 code segments with AVX2 version
#ifdef DEBUG_DLSCH_DECODING
- printf("single decoding segment %d (%p)\n",r-1,&harq_process->d[r-1][96]);
+ printf("single decoding segment %d (%p)\n",r-1,&harq_process->d[r-1][96]);
#endif
#if UE_TIMING_TRACE
- start_meas(dlsch_turbo_decoding_stats);
+ start_meas(dlsch_turbo_decoding_stats);
#endif
#ifdef DEBUG_DLSCH_DECODING
- printf("double decoding segments %d,%d (%p,%p)\n",r-1,r,&harq_process->d[r-1][96],&harq_process->d[r][96]);
+ printf("double decoding segments %d,%d (%p,%p)\n",r-1,r,&harq_process->d[r-1][96],&harq_process->d[r][96]);
#endif
- ret = tc_2cw
- (&harq_process->d[r-1][96],
- &harq_process->d[r][96],
- harq_process->c[r-1],
- harq_process->c[r],
- Kr,
- dlsch->max_turbo_iterations,
- crc_type,
- (r==0) ? harq_process->F : 0,
- &phy_vars_ue->dlsch_tc_init_stats,
- &phy_vars_ue->dlsch_tc_alpha_stats,
- &phy_vars_ue->dlsch_tc_beta_stats,
- &phy_vars_ue->dlsch_tc_gamma_stats,
- &phy_vars_ue->dlsch_tc_ext_stats,
- &phy_vars_ue->dlsch_tc_intl1_stats,
- &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
- /*
- ret = tc
- (&harq_process->d[r-1][96],
- harq_process->c[r-1],
- Kr_last,
- dlsch->max_turbo_iterations,
- crc_type,
- (r==0) ? harq_process->F : 0,
- &phy_vars_ue->dlsch_tc_init_stats,
- &phy_vars_ue->dlsch_tc_alpha_stats,
- &phy_vars_ue->dlsch_tc_beta_stats,
- &phy_vars_ue->dlsch_tc_gamma_stats,
- &phy_vars_ue->dlsch_tc_ext_stats,
- &phy_vars_ue->dlsch_tc_intl1_stats,
- &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+ ret = tc_2cw
+ (&harq_process->d[r-1][96],
+ &harq_process->d[r][96],
+ harq_process->c[r-1],
+ harq_process->c[r],
+ Kr,
+ dlsch->max_turbo_iterations,
+ crc_type,
+ (r==0) ? harq_process->F : 0,
+ &phy_vars_ue->dlsch_tc_init_stats,
+ &phy_vars_ue->dlsch_tc_alpha_stats,
+ &phy_vars_ue->dlsch_tc_beta_stats,
+ &phy_vars_ue->dlsch_tc_gamma_stats,
+ &phy_vars_ue->dlsch_tc_ext_stats,
+ &phy_vars_ue->dlsch_tc_intl1_stats,
+ &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+ /*
+ ret = tc
+ (&harq_process->d[r-1][96],
+ harq_process->c[r-1],
+ Kr_last,
+ dlsch->max_turbo_iterations,
+ crc_type,
+ (r==0) ? harq_process->F : 0,
+ &phy_vars_ue->dlsch_tc_init_stats,
+ &phy_vars_ue->dlsch_tc_alpha_stats,
+ &phy_vars_ue->dlsch_tc_beta_stats,
+ &phy_vars_ue->dlsch_tc_gamma_stats,
+ &phy_vars_ue->dlsch_tc_ext_stats,
+ &phy_vars_ue->dlsch_tc_intl1_stats,
+ &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
- exit(-1);*/
+ exit(-1);*/
#if UE_TIMING_TRACE
- stop_meas(dlsch_turbo_decoding_stats);
+ stop_meas(dlsch_turbo_decoding_stats);
#endif
- }
- else { // Kr_last != Kr
+ } else { // Kr_last != Kr
#if UE_TIMING_TRACE
- start_meas(dlsch_turbo_decoding_stats);
+ start_meas(dlsch_turbo_decoding_stats);
#endif
- ret = tc
- (&harq_process->d[r-1][96],
- harq_process->c[r-1],
- Kr_last,
- dlsch->max_turbo_iterations,
- crc_type,
- (r==0) ? harq_process->F : 0,
- &phy_vars_ue->dlsch_tc_init_stats,
- &phy_vars_ue->dlsch_tc_alpha_stats,
- &phy_vars_ue->dlsch_tc_beta_stats,
- &phy_vars_ue->dlsch_tc_gamma_stats,
- &phy_vars_ue->dlsch_tc_ext_stats,
- &phy_vars_ue->dlsch_tc_intl1_stats,
- &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
+ ret = tc
+ (&harq_process->d[r-1][96],
+ harq_process->c[r-1],
+ Kr_last,
+ dlsch->max_turbo_iterations,
+ crc_type,
+ (r==0) ? harq_process->F : 0,
+ &phy_vars_ue->dlsch_tc_init_stats,
+ &phy_vars_ue->dlsch_tc_alpha_stats,
+ &phy_vars_ue->dlsch_tc_beta_stats,
+ &phy_vars_ue->dlsch_tc_gamma_stats,
+ &phy_vars_ue->dlsch_tc_ext_stats,
+ &phy_vars_ue->dlsch_tc_intl1_stats,
+ &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
#if UE_TIMING_TRACE
- stop_meas(dlsch_turbo_decoding_stats);
-
- start_meas(dlsch_turbo_decoding_stats);
+ stop_meas(dlsch_turbo_decoding_stats);
+ start_meas(dlsch_turbo_decoding_stats);
#endif
-
- ret = tc
- (&harq_process->d[r][96],
- harq_process->c[r],
- Kr,
- dlsch->max_turbo_iterations,
- crc_type,
- (r==0) ? harq_process->F : 0,
- &phy_vars_ue->dlsch_tc_init_stats,
- &phy_vars_ue->dlsch_tc_alpha_stats,
- &phy_vars_ue->dlsch_tc_beta_stats,
- &phy_vars_ue->dlsch_tc_gamma_stats,
- &phy_vars_ue->dlsch_tc_ext_stats,
- &phy_vars_ue->dlsch_tc_intl1_stats,
- &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
-
+ ret = tc
+ (&harq_process->d[r][96],
+ harq_process->c[r],
+ Kr,
+ dlsch->max_turbo_iterations,
+ crc_type,
+ (r==0) ? harq_process->F : 0,
+ &phy_vars_ue->dlsch_tc_init_stats,
+ &phy_vars_ue->dlsch_tc_alpha_stats,
+ &phy_vars_ue->dlsch_tc_beta_stats,
+ &phy_vars_ue->dlsch_tc_gamma_stats,
+ &phy_vars_ue->dlsch_tc_ext_stats,
+ &phy_vars_ue->dlsch_tc_intl1_stats,
+ &phy_vars_ue->dlsch_tc_intl2_stats); //(is_crnti==0)?harq_pid:harq_pid+1);
#if UE_TIMING_TRACE
-
- stop_meas(dlsch_turbo_decoding_stats);
-
- /*printf("Segmentation: C %d r %d, dlsch_rate_unmatching_stats %5.3f dlsch_deinterleaving_stats %5.3f dlsch_turbo_decoding_stats %5.3f \n",
- harq_process->C,
- r,
- dlsch_rate_unmatching_stats->p_time/(cpuf*1000.0),
- dlsch_deinterleaving_stats->p_time/(cpuf*1000.0),
- dlsch_turbo_decoding_stats->p_time/(cpuf*1000.0));*/
+ stop_meas(dlsch_turbo_decoding_stats);
+ /*printf("Segmentation: C %d r %d, dlsch_rate_unmatching_stats %5.3f dlsch_deinterleaving_stats %5.3f dlsch_turbo_decoding_stats %5.3f \n",
+ harq_process->C,
+ r,
+ dlsch_rate_unmatching_stats->p_time/(cpuf*1000.0),
+ dlsch_deinterleaving_stats->p_time/(cpuf*1000.0),
+ dlsch_turbo_decoding_stats->p_time/(cpuf*1000.0));*/
#endif
- }
+ }
}
}
-#endif
+#endif
if ((err_flag == 0) && (ret>=(1+dlsch->max_turbo_iterations))) {// a Code segment is in error so break;
LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,subframe,r,harq_process->C-1);
@@ -617,16 +580,18 @@ decoder_if_t *tc;
int32_t frame_rx_prev = frame;
int32_t subframe_rx_prev = subframe - 1;
+
if (subframe_rx_prev < 0) {
frame_rx_prev--;
subframe_rx_prev += 10;
}
+
frame_rx_prev = frame_rx_prev%1024;
if (err_flag == 1) {
#if UE_DEBUG_TRACE
LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n",
- phy_vars_ue->Mod_id, frame, subframe, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round);
+ phy_vars_ue->Mod_id, frame, subframe, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round);
#endif
dlsch->harq_ack[subframe].ack = 0;
dlsch->harq_ack[subframe].harq_id = harq_pid;
@@ -634,39 +599,36 @@ decoder_if_t *tc;
harq_process->errors[harq_process->round]++;
harq_process->round++;
-
// printf("Rate: [UE %d] DLSCH: Setting NACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round);
if (harq_process->round >= dlsch->Mdlharq) {
harq_process->status = SCH_IDLE;
harq_process->round = 0;
}
- if(is_crnti)
- {
- LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for subframe %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
- phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS);
+
+ if(is_crnti) {
+ LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for subframe %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
+ phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS);
}
return((1+dlsch->max_turbo_iterations));
} else {
#if UE_DEBUG_TRACE
- LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d TBS %d mcs %d nb_rb %d\n",
- phy_vars_ue->Mod_id,subframe,harq_process->TBS,harq_process->mcs,harq_process->nb_rb);
+ LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d TBS %d mcs %d nb_rb %d\n",
+ phy_vars_ue->Mod_id,subframe,harq_process->TBS,harq_process->mcs,harq_process->nb_rb);
#endif
-
harq_process->status = SCH_IDLE;
harq_process->round = 0;
dlsch->harq_ack[subframe].ack = 1;
dlsch->harq_ack[subframe].harq_id = harq_pid;
dlsch->harq_ack[subframe].send_harq_status = 1;
//LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n",
- // phy_vars_ue->Mod_id, frame, subframe, harq_pid, harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs);
+ // phy_vars_ue->Mod_id, frame, subframe, harq_pid, harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs);
- if(is_crnti)
- {
- LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round,harq_process->TBS);
+ if(is_crnti) {
+ LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round,harq_process->TBS);
}
- //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round);
+ //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round);
}
// Reassembly of Transport block here
@@ -706,24 +668,20 @@ decoder_if_t *tc;
}
dlsch->last_iteration_cnt = ret;
-
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 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;
-
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;
@@ -732,9 +690,7 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue,
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;
@@ -745,13 +701,13 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue,
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);
+ 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");
+ printf("SIC encoding thinks this is a new packet \n");
#endif
/*
int i;
@@ -763,11 +719,10 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue,
// 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];
+ 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);
@@ -784,25 +739,20 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue,
return(-1);
for (r=0; rharq_processes[harq_pid]->C; r++) {
-
if (rharq_processes[harq_pid]->Cminus)
Kr = dlsch->harq_processes[harq_pid]->Kminus;
else
Kr = dlsch->harq_processes[harq_pid]->Kplus;
Kr_bytes = Kr>>3;
-
#ifdef DEBUG_DLSCH_CODING
- printf("Generating Code Segment %d (%d bits)\n",r,Kr);
+ printf("Generating Code Segment %u (%u bits)\n",r,Kr);
// generate codewords
-
- printf("bits_per_codeword (Kr)= %d, A %d\n",Kr,A);
+ printf("bits_per_codeword (Kr)= %u, A %u\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
-
-
start_meas(te_stats);
encoder(dlsch->harq_processes[harq_pid]->c[r],
Kr>>3,
@@ -823,7 +773,6 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue,
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
@@ -831,13 +780,12 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue,
for (r=0; rharq_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);
+ printf("Rate Matching, Code segment %u (coded bits (G) %u,unpunctured/repeated bits per code segment %u,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);
@@ -866,6 +814,5 @@ int dlsch_encoding_SIC(PHY_VARS_UE *ue,
}
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_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c
index ace1459306..aafd579899 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c
@@ -42,11 +42,11 @@
#include
#include
#if RHEL_RELEASE_CODE >= 1796
-#include
-#include
+ #include
+ #include
#else
-#include
-#include
+ #include
+ #include
#endif
#include
#include "linear_preprocessing_rec.h"
@@ -72,10 +72,12 @@ int16_t interf_unaw_shift = 13;
// [MCS][i_mod (0,1,2) = (2,4,6)]
unsigned char offset_mumimo_llr_drange_fix=0;
//inferference-free case
-unsigned char interf_unaw_shift_tm4_mcs[29]={5, 3, 4, 3, 3, 2, 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
- 1, 1, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 0} ;
-unsigned char interf_unaw_shift_tm1_mcs[29]={5, 5, 4, 3, 3, 3, 2, 2, 4, 4, 2, 3, 3, 3, 1, 1,
- 0, 1, 1, 2, 5, 4, 4, 6, 5, 1, 0, 5, 6} ; // mcs 21, 26, 28 seem to be errorneous
+unsigned char interf_unaw_shift_tm4_mcs[29]= {5, 3, 4, 3, 3, 2, 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
+ 1, 1, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 0
+ } ;
+unsigned char interf_unaw_shift_tm1_mcs[29]= {5, 5, 4, 3, 3, 3, 2, 2, 4, 4, 2, 3, 3, 3, 1, 1,
+ 0, 1, 1, 2, 5, 4, 4, 6, 5, 1, 0, 5, 6
+ } ; // mcs 21, 26, 28 seem to be errorneous
/*
//original values from sebastion + same hand tuning
@@ -83,14 +85,14 @@ unsigned char offset_mumimo_llr_drange[29][3]={{8,8,8},{7,7,7},{7,7,7},{7,7,7},{
{5,5,4},{5,5,5},{5,5,5},{3,3,3},{2,2,2},{2,2,2},{2,2,2}, // 16-QAM
{2,2,1},{3,3,3},{3,3,3},{3,3,1},{2,2,2},{2,2,2},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; //64-QAM
*/
- /*
- //first optimization try
- unsigned char offset_mumimo_llr_drange[29][3]={{7, 8, 7},{6, 6, 7},{6, 6, 7},{6, 6, 6},{5, 6, 6},{5, 5, 6},{5, 5, 6},{4, 5, 4},{4, 3, 4},{3, 2, 2},{6, 5, 5},{5, 4, 4},{5, 5, 4},{3, 3, 2},{2, 2, 1},{2, 1, 1},{2, 2, 2},{3, 3, 3},{3, 3, 2},{3, 3, 2},{3, 2, 1},{2, 2, 2},{2, 2, 2},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};
- */
- //second optimization try
- /*
- unsigned char offset_mumimo_llr_drange[29][3]={{5, 8, 7},{4, 6, 8},{3, 6, 7},{7, 7, 6},{4, 7, 8},{4, 7, 4},{6, 6, 6},{3, 6, 6},{3, 6, 6},{1, 3, 4},{1, 1, 0},{3, 3, 2},{3, 4, 1},{4, 0, 1},{4, 2, 2},{3, 1, 2},{2, 1, 0},{2, 1, 1},{1, 0, 1},{1, 0, 1},{0, 0, 0},{1, 0, 0},{0, 0, 0},{0, 1, 0},{1, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}}; w
- */
+/*
+//first optimization try
+unsigned char offset_mumimo_llr_drange[29][3]={{7, 8, 7},{6, 6, 7},{6, 6, 7},{6, 6, 6},{5, 6, 6},{5, 5, 6},{5, 5, 6},{4, 5, 4},{4, 3, 4},{3, 2, 2},{6, 5, 5},{5, 4, 4},{5, 5, 4},{3, 3, 2},{2, 2, 1},{2, 1, 1},{2, 2, 2},{3, 3, 3},{3, 3, 2},{3, 3, 2},{3, 2, 1},{2, 2, 2},{2, 2, 2},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};
+*/
+//second optimization try
+/*
+ unsigned char offset_mumimo_llr_drange[29][3]={{5, 8, 7},{4, 6, 8},{3, 6, 7},{7, 7, 6},{4, 7, 8},{4, 7, 4},{6, 6, 6},{3, 6, 6},{3, 6, 6},{1, 3, 4},{1, 1, 0},{3, 3, 2},{3, 4, 1},{4, 0, 1},{4, 2, 2},{3, 1, 2},{2, 1, 0},{2, 1, 1},{1, 0, 1},{1, 0, 1},{0, 0, 0},{1, 0, 0},{0, 0, 0},{0, 1, 0},{1, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}}; w
+*/
unsigned char offset_mumimo_llr_drange[29][3]= {{0, 6, 5},{0, 4, 5},{0, 4, 5},{0, 5, 4},{0, 5, 6},{0, 5, 3},{0, 4, 4},{0, 4, 4},{0, 3, 3},{0, 1, 2},{1, 1, 0},{1, 3, 2},{3, 4, 1},{2, 0, 0},{2, 2, 2},{1, 1, 1},{2, 1, 0},{2, 1, 1},{1, 0, 1},{1, 0, 1},{0, 0, 0},{1, 0, 0},{0, 0, 0},{0, 1, 0},{1, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};
@@ -107,111 +109,99 @@ int rx_pdsch(PHY_VARS_UE *ue,
unsigned char first_symbol_flag,
RX_type_t rx_type,
unsigned char i_mod,
- unsigned char harq_pid)
-{
-
+ unsigned char harq_pid) {
LTE_UE_COMMON *common_vars = &ue->common_vars;
LTE_UE_PDSCH **pdsch_vars;
LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
PHY_MEASUREMENTS *measurements = &ue->measurements;
LTE_UE_DLSCH_t **dlsch;
-
int avg[4];
int avg_0[2];
int avg_1[2];
unsigned short mmse_flag=0;
-
#if UE_TIMING_TRACE
uint8_t slot = 0;
#endif
-
unsigned char aatx,aarx;
-
unsigned short nb_rb = 0, round;
int avgs = 0, rb;
LTE_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0;
-
uint8_t beamforming_mode;
uint32_t *rballoc;
-
int32_t **rxdataF_comp_ptr;
int32_t **dl_ch_mag_ptr;
int32_t codeword_TB0 = -1;
int32_t codeword_TB1 = -1;
-
-
switch (type) {
- case SI_PDSCH:
- pdsch_vars = &ue->pdsch_vars_SI[eNB_id];
- dlsch = &ue->dlsch_SI[eNB_id];
- dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
- beamforming_mode = 0;
- break;
-
- case RA_PDSCH:
- pdsch_vars = &ue->pdsch_vars_ra[eNB_id];
- dlsch = &ue->dlsch_ra[eNB_id];
- dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
- beamforming_mode = 0;
- break;
-
- case PDSCH:
- pdsch_vars = ue->pdsch_vars[ue->current_thread_id[subframe]];
- dlsch = ue->dlsch[ue->current_thread_id[subframe]][eNB_id];
- //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status);
- LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n",
- frame,subframe,symbol,harq_pid,
- dlsch[0]->harq_processes[harq_pid]->status,
- dlsch[1]->harq_processes[harq_pid]->status);
-
- if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
- (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE)){
- codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
- codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
- dlsch0_harq = dlsch[codeword_TB0]->harq_processes[harq_pid];
- dlsch1_harq = dlsch[codeword_TB1]->harq_processes[harq_pid];
-#ifdef DEBUG_HARQ
- printf("[DEMOD] I am assuming both TBs are active\n");
-#endif
- }
- else if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
- (dlsch[1]->harq_processes[harq_pid]->status != ACTIVE) ) {
- codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
+ case SI_PDSCH:
+ pdsch_vars = &ue->pdsch_vars_SI[eNB_id];
+ dlsch = &ue->dlsch_SI[eNB_id];
dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
- dlsch1_harq = NULL;
- codeword_TB1 = -1;
-#ifdef DEBUG_HARQ
- printf("[DEMOD] I am assuming only TB0 is active\n");
-#endif
- }
- else if ((dlsch[0]->harq_processes[harq_pid]->status != ACTIVE) &&
- (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE) ){
- codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
- dlsch0_harq = dlsch[1]->harq_processes[harq_pid];
- dlsch1_harq = NULL;
- codeword_TB0 = -1;
-#ifdef DEBUG_HARQ
- printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", dlsch0_harq->codeword);
-#endif
- }
- else {
- LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: no active DLSCH\n",ue->proc.proc_rxtx[0].frame_rx,subframe);
- return(-1);
- }
- beamforming_mode = ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id];
- break;
+ beamforming_mode = 0;
+ break;
- default:
- LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: Unknown PDSCH format %d\n",ue->proc.proc_rxtx[0].frame_rx,subframe,type);
- return(-1);
- break;
+ case RA_PDSCH:
+ pdsch_vars = &ue->pdsch_vars_ra[eNB_id];
+ dlsch = &ue->dlsch_ra[eNB_id];
+ dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
+ beamforming_mode = 0;
+ break;
+
+ case PDSCH:
+ pdsch_vars = ue->pdsch_vars[ue->current_thread_id[subframe]];
+ dlsch = ue->dlsch[ue->current_thread_id[subframe]][eNB_id];
+ //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status);
+ LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n",
+ frame,subframe,symbol,harq_pid,
+ dlsch[0]->harq_processes[harq_pid]->status,
+ dlsch[1]->harq_processes[harq_pid]->status);
+
+ if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
+ (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE)) {
+ codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
+ codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
+ dlsch0_harq = dlsch[codeword_TB0]->harq_processes[harq_pid];
+ dlsch1_harq = dlsch[codeword_TB1]->harq_processes[harq_pid];
+#ifdef DEBUG_HARQ
+ printf("[DEMOD] I am assuming both TBs are active\n");
+#endif
+ } else if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
+ (dlsch[1]->harq_processes[harq_pid]->status != ACTIVE) ) {
+ codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
+ dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
+ dlsch1_harq = NULL;
+ codeword_TB1 = -1;
+#ifdef DEBUG_HARQ
+ printf("[DEMOD] I am assuming only TB0 is active\n");
+#endif
+ } else if ((dlsch[0]->harq_processes[harq_pid]->status != ACTIVE) &&
+ (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE) ) {
+ codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
+ dlsch0_harq = dlsch[1]->harq_processes[harq_pid];
+ dlsch1_harq = NULL;
+ codeword_TB0 = -1;
+#ifdef DEBUG_HARQ
+ printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", dlsch0_harq->codeword);
+#endif
+ } else {
+ LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: no active DLSCH\n",ue->proc.proc_rxtx[0].frame_rx,subframe);
+ return(-1);
+ }
+
+ beamforming_mode = ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id];
+ break;
+
+ default:
+ LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: Unknown PDSCH format %d\n",ue->proc.proc_rxtx[0].frame_rx,subframe,type);
+ return(-1);
+ break;
}
+
#ifdef DEBUG_HARQ
printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode);
printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1);
#endif
-
DevAssert(dlsch0_harq);
round = dlsch0_harq->round;
//printf("round = %d\n", round);
@@ -247,15 +237,14 @@ int rx_pdsch(PHY_VARS_UE *ue,
else
rballoc = dlsch0_harq->rb_alloc_even;
-
if (dlsch0_harq->mimo_mode>DUALSTREAM_PUSCH_PRECODING) {
LOG_E(PHY,"This transmission mode is not yet supported!\n");
return(-1);
}
-
if ((dlsch0_harq->mimo_mode==LARGE_CDD) || ((dlsch0_harq->mimo_mode>=DUALSTREAM_UNIFORM_PRECODING1) && (dlsch0_harq->mimo_mode<=DUALSTREAM_PUSCH_PRECODING))) {
DevAssert(dlsch1_harq);
+
if (eNB_id!=eNB_id_i) {
LOG_E(PHY,"TM3/TM4 requires to set eNB_id==eNB_id_i!\n");
return(-1);
@@ -263,12 +252,12 @@ int rx_pdsch(PHY_VARS_UE *ue,
}
#if UE_TIMING_TRACE
- if(symbol > ue->frame_parms.symbols_per_tti>>1)
- {
- slot = 1;
- }
-#endif
+ if(symbol > ue->frame_parms.symbols_per_tti>>1) {
+ slot = 1;
+ }
+
+#endif
#ifdef DEBUG_HARQ
printf("Demod dlsch0_harq->pmi_alloc %d\n", dlsch0_harq->pmi_alloc);
#endif
@@ -277,7 +266,6 @@ int rx_pdsch(PHY_VARS_UE *ue,
#ifdef DEBUG_DLSCH_MOD
LOG_I(PHY,"dlsch: using pmi %x (%p), rb_alloc %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),dlsch[0],dlsch0_harq->rb_alloc_even[0]);
#endif
-
#if UE_TIMING_TRACE
start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
#endif
@@ -294,15 +282,17 @@ int rx_pdsch(PHY_VARS_UE *ue,
frame_parms,
dlsch0_harq->mimo_mode);
#ifdef DEBUG_DLSCH_MOD
- printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc);
- for (rb=0;rbpmi_ext[rb]);
- printf("\n");
+ printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc);
+
+ for (rb=0; rbpmi_ext[rb]);
+
+ printf("\n");
#endif
- if (rx_type >= rx_IC_single_stream) {
+ if (rx_type >= rx_IC_single_stream) {
if (eNB_id_in_connected_eNB) // we are in TM5
- nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF,
+ nb_rb = dlsch_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_i],
pdsch_vars[eNB_id_i]->rxdataF_ext,
pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
@@ -341,8 +331,8 @@ int rx_pdsch(PHY_VARS_UE *ue,
ue->high_speed_flag,
frame_parms);
- if (rx_type==rx_IC_single_stream) {
- if (eNB_id_in_connected_eNB)
+ if (rx_type==rx_IC_single_stream) {
+ if (eNB_id_in_connected_eNB)
nb_rb = dlsch_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],
pdsch_vars[eNB_id_i]->rxdataF_ext,
@@ -377,7 +367,6 @@ int rx_pdsch(PHY_VARS_UE *ue,
subframe,
ue->high_speed_flag,
frame_parms);
-
} else if(beamforming_mode>7) {
LOG_W(PHY,"dlsch_demodulation: beamforming mode not supported yet.\n");
}
@@ -388,25 +377,21 @@ int rx_pdsch(PHY_VARS_UE *ue,
return(-1);
}
-
#if UE_TIMING_TRACE
- stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+ stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
#if DISABLE_LOG_X
- printf("[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,
- symbol,ue->high_speed_flag,type,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+ printf("[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,
+ symbol,ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
#else
- LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,symbol,
- ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+ LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,symbol,
+ ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
#endif
#endif
-
-
#if UE_TIMING_TRACE
- start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+ start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
#endif
aatx = frame_parms->nb_antenna_ports_eNB;
aarx = frame_parms->nb_antennas_rx;
-
dlsch_scale_channel(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
frame_parms,
dlsch,
@@ -417,8 +402,7 @@ int rx_pdsch(PHY_VARS_UE *ue,
(rx_type==rx_IC_single_stream) &&
(eNB_id_i==ue->n_connected_eNB) &&
(dlsch0_harq->dl_power_off==0)
- ) // TM5 two-user
- {
+ ) { // TM5 two-user
dlsch_scale_channel(pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
frame_parms,
dlsch,
@@ -427,109 +411,100 @@ int rx_pdsch(PHY_VARS_UE *ue,
}
#if UE_TIMING_TRACE
- stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+ stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
#if DISABLE_LOG_X
- printf("[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+ printf("[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
#else
- LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+ LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
#endif
+#endif
+#if UE_TIMING_TRACE
+ start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
#endif
-#if UE_TIMING_TRACE
- start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
-#endif
if (first_symbol_flag==1) {
- if (beamforming_mode==0){
+ if (beamforming_mode==0) {
if (dlsch0_harq->mimo_modedl_ch_estimates_ext,
- frame_parms,
- avg,
- symbol,
- nb_rb);
+ frame_parms,
+ avg,
+ symbol,
+ nb_rb);
avgs = 0;
- for (aatx=0;aatxnb_antenna_ports_eNB;aatx++)
- for (aarx=0;aarxnb_antennas_rx;aarx++)
+
+ for (aatx=0; aatxnb_antenna_ports_eNB; aatx++)
+ for (aarx=0; aarxnb_antennas_rx; aarx++)
avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2)+1;
- }
- else if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
- ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
- (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING)))
- {
- dlsch_channel_level_TM34(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
- frame_parms,
- pdsch_vars[eNB_id]->pmi_ext,
- avg_0,
- avg_1,
- symbol,
- nb_rb,
- mmse_flag,
- dlsch0_harq->mimo_mode);
-
- LOG_D(PHY,"Channel Level TM34 avg_0 %d, avg_1 %d, rx_type %d, rx_standard %d, dlsch_demod_shift %d \n", avg_0[0],
+ } else if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
+ ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
+ (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))) {
+ dlsch_channel_level_TM34(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+ frame_parms,
+ pdsch_vars[eNB_id]->pmi_ext,
+ avg_0,
+ avg_1,
+ symbol,
+ nb_rb,
+ mmse_flag,
+ dlsch0_harq->mimo_mode);
+ LOG_D(PHY,"Channel Level TM34 avg_0 %d, avg_1 %d, rx_type %d, rx_standard %d, dlsch_demod_shift %d \n", avg_0[0],
avg_1[0], rx_type, rx_standard, dlsch_demod_shift);
+
if (rx_type>rx_standard) {
avg_0[0] = (log2_approx(avg_0[0])/2) + dlsch_demod_shift;// + 2 ;//+ 4;
avg_1[0] = (log2_approx(avg_1[0])/2) + dlsch_demod_shift;// + 2 ;//+ 4;
pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
- // printf("dlsch_demod_shift %d\n", dlsch_demod_shift);
- }
- else {
+ // printf("dlsch_demod_shift %d\n", dlsch_demod_shift);
+ } else {
avg_0[0] = (log2_approx(avg_0[0])/2) - 13 + interf_unaw_shift;
avg_1[0] = (log2_approx(avg_1[0])/2) - 13 + interf_unaw_shift;
pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
}
- }
- else if (dlsch0_harq->mimo_modemimo_moden_connected_eNB) && (dlsch0_harq->dl_power_off==0)) {
- dlsch_channel_level_TM56(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
- frame_parms,
- pdsch_vars[eNB_id]->pmi_ext,
- avg,
- symbol,
- nb_rb);
- avg[0] = log2_approx(avg[0]) - 13 + offset_mumimo_llr_drange[dlsch0_harq->mcs][(i_mod>>1)-1];
- pdsch_vars[eNB_id]->log2_maxh = cmax(avg[0],0);
-
- }
- else if (dlsch0_harq->dl_power_off==1) { //TM6
-
- dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+ dlsch_channel_level_TM56(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
frame_parms,
+ pdsch_vars[eNB_id]->pmi_ext,
avg,
symbol,
nb_rb);
-
- avgs = 0;
- for (aatx=0;aatxnb_antenna_ports_eNB;aatx++)
- for (aarx=0;aarxnb_antennas_rx;aarx++)
- avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
-
- pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1;
- pdsch_vars[eNB_id]->log2_maxh++;
-
- }
- }
-
- }
- else if (beamforming_mode==7)
- dlsch_channel_level_TM7(pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
+ avg[0] = log2_approx(avg[0]) - 13 + offset_mumimo_llr_drange[dlsch0_harq->mcs][(i_mod>>1)-1];
+ pdsch_vars[eNB_id]->log2_maxh = cmax(avg[0],0);
+ } else if (dlsch0_harq->dl_power_off==1) { //TM6
+ dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
frame_parms,
avg,
symbol,
nb_rb);
+ avgs = 0;
+
+ for (aatx=0; aatxnb_antenna_ports_eNB; aatx++)
+ for (aarx=0; aarxnb_antennas_rx; aarx++)
+ avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
+
+ pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1;
+ pdsch_vars[eNB_id]->log2_maxh++;
+ }
+ }
+ } else if (beamforming_mode==7)
+ dlsch_channel_level_TM7(pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
+ frame_parms,
+ avg,
+ symbol,
+ nb_rb);
+
#ifdef UE_DEBUG_TRACE
LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n",
- frame%1024,subframe, pdsch_vars[eNB_id]->log2_maxh,
- pdsch_vars[eNB_id]->log2_maxh0,
- pdsch_vars[eNB_id]->log2_maxh1,
- avg[0],avgs);
+ frame%1024,subframe, pdsch_vars[eNB_id]->log2_maxh,
+ pdsch_vars[eNB_id]->log2_maxh0,
+ pdsch_vars[eNB_id]->log2_maxh1,
+ avg[0],avgs);
//LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
#endif
-
//wait until pdcch is decoded
//proc->channel_level = 1;
}
@@ -542,39 +517,36 @@ int rx_pdsch(PHY_VARS_UE *ue,
wait++;
}
*/
-
#if T_TRACER
- if (type == PDSCH)
- {
- T(T_UE_PHY_PDSCH_ENERGY, T_INT(eNB_id), T_INT(frame%1024), T_INT(subframe),
- T_INT(avg[0]), T_INT(avg[1]), T_INT(avg[2]), T_INT(avg[3]));
- }
-#endif
+ if (type == PDSCH) {
+ T(T_UE_PHY_PDSCH_ENERGY, T_INT(eNB_id), T_INT(frame%1024), T_INT(subframe),
+ T_INT(avg[0]), T_INT(avg[1]), T_INT(avg[2]), T_INT(avg[3]));
+ }
+
+#endif
#if UE_TIMING_TRACE
- stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+ stop_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
#if DISABLE_LOG_X
- printf("[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+ printf("[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,
+ ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
#else
- LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
+ LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,
+ ue->generic_stat_bis[ue->current_thread_id[subframe]][slot].p_time/(cpuf*1000.0));
#endif
#endif
-
-
#if UE_TIMING_TRACE
- start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
+ start_meas(&ue->generic_stat_bis[ue->current_thread_id[subframe]][slot]);
#endif
- if (rx_type==rx_IC_dual_stream && mmse_flag==1){
-
+ if (rx_type==rx_IC_dual_stream && mmse_flag==1) {
precode_channel_est(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
frame_parms,
pdsch_vars[eNB_id],
symbol,
nb_rb,
dlsch0_harq->mimo_mode);
-
- mmse_processing_oai(pdsch_vars[eNB_id],
+ mmse_processing_oai(pdsch_vars[eNB_id],
frame_parms,
measurements,
first_symbol_flag,
@@ -585,7 +557,7 @@ int rx_pdsch(PHY_VARS_UE *ue,
nb_rb);
}
-// Now channel compensation
+ // Now channel compensation
if (dlsch0_harq->mimo_moderxdataF_ext,
pdsch_vars[eNB_id]->dl_ch_estimates_ext,
@@ -600,13 +572,14 @@ int rx_pdsch(PHY_VARS_UE *ue,
nb_rb,
pdsch_vars[eNB_id]->log2_maxh,
measurements); // log2_maxh+I0_shift
+
if (symbol == 5) {
- LOG_M("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+ LOG_M("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
}
if ((rx_type==rx_IC_single_stream) &&
(eNB_id_in_connected_eNB)) {
- dlsch_channel_compensation(pdsch_vars[eNB_id_i]->rxdataF_ext,
+ dlsch_channel_compensation(pdsch_vars[eNB_id_i]->rxdataF_ext,
pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
pdsch_vars[eNB_id_i]->dl_ch_mag0,
pdsch_vars[eNB_id_i]->dl_ch_magb0,
@@ -619,6 +592,7 @@ int rx_pdsch(PHY_VARS_UE *ue,
nb_rb,
pdsch_vars[eNB_id]->log2_maxh,
measurements); // log2_maxh+I0_shift
+
if (symbol == 5) {
LOG_M("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
LOG_M("rxF_comp_i.m","rxF_c_i",&pdsch_vars[eNB_id_i]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
@@ -633,55 +607,58 @@ int rx_pdsch(PHY_VARS_UE *ue,
pdsch_vars[eNB_id]->log2_maxh);
}
} else if ((dlsch0_harq->mimo_mode == LARGE_CDD) || ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
- (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){
- dlsch_channel_compensation_TM34(frame_parms,
- pdsch_vars[eNB_id],
- measurements,
- eNB_id,
- symbol,
- dlsch0_harq->Qm,
- dlsch1_harq->Qm,
- harq_pid,
- dlsch0_harq->round,
- dlsch0_harq->mimo_mode,
- nb_rb,
- mmse_flag,
- pdsch_vars[eNB_id]->log2_maxh0,
- pdsch_vars[eNB_id]->log2_maxh1);
- if (symbol == 5) {
- LOG_M("rxF_comp_d00.m","rxF_c_d00",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
- LOG_M("rxF_comp_d01.m","rxF_c_d01",&pdsch_vars[eNB_id]->rxdataF_comp0[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
- LOG_M("rxF_comp_d10.m","rxF_c_d10",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
- LOG_M("rxF_comp_d11.m","rxF_c_d11",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
- }
- // compute correlation between signal and interference channels (rho12 and rho21)
- dlsch_dual_stream_correlation(frame_parms, // this is doing h11'*h12 and h21'*h22
+ (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))) {
+ dlsch_channel_compensation_TM34(frame_parms,
+ pdsch_vars[eNB_id],
+ measurements,
+ eNB_id,
symbol,
+ dlsch0_harq->Qm,
+ dlsch1_harq->Qm,
+ harq_pid,
+ dlsch0_harq->round,
+ dlsch0_harq->mimo_mode,
nb_rb,
- pdsch_vars[eNB_id]->dl_ch_estimates_ext,
- &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
- pdsch_vars[eNB_id]->dl_ch_rho2_ext,
- pdsch_vars[eNB_id]->log2_maxh0);
- //printf("rho stream1 =%d\n", &pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round] );
- //to be optimized (just take complex conjugate)
- dlsch_dual_stream_correlation(frame_parms, // this is doing h12'*h11 and h22'*h21
- symbol,
- nb_rb,
- &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
- pdsch_vars[eNB_id]->dl_ch_estimates_ext,
- pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+ mmse_flag,
+ pdsch_vars[eNB_id]->log2_maxh0,
pdsch_vars[eNB_id]->log2_maxh1);
+
+ if (symbol == 5) {
+ LOG_M("rxF_comp_d00.m","rxF_c_d00",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
+ LOG_M("rxF_comp_d01.m","rxF_c_d01",&pdsch_vars[eNB_id]->rxdataF_comp0[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+ LOG_M("rxF_comp_d10.m","rxF_c_d10",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+ LOG_M("rxF_comp_d11.m","rxF_c_d11",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
+ }
+
+ // compute correlation between signal and interference channels (rho12 and rho21)
+ dlsch_dual_stream_correlation(frame_parms, // this is doing h11'*h12 and h21'*h22
+ symbol,
+ nb_rb,
+ pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+ &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
+ pdsch_vars[eNB_id]->dl_ch_rho2_ext,
+ pdsch_vars[eNB_id]->log2_maxh0);
+ //printf("rho stream1 =%d\n", &pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round] );
+ //to be optimized (just take complex conjugate)
+ dlsch_dual_stream_correlation(frame_parms, // this is doing h12'*h11 and h22'*h21
+ symbol,
+ nb_rb,
+ &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
+ pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+ pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
+ pdsch_vars[eNB_id]->log2_maxh1);
+
// printf("rho stream2 =%d\n",&pdsch_vars[eNB_id]->dl_ch_rho2_ext );
- //printf("TM3 log2_maxh : %d\n",pdsch_vars[eNB_id]->log2_maxh);
- if (symbol == 5) {
- LOG_M("rho0_0.m","rho0_0",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
- LOG_M("rho2_0.m","rho2_0",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
- LOG_M("rho0_1.m.m","rho0_1",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
- LOG_M("rho2_1.m","rho2_1",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
- }
- } else if (dlsch0_harq->mimo_moden_connected_eNB) && (dlsch0_harq->dl_power_off==0)) {
- dlsch_channel_compensation_TM56(pdsch_vars[eNB_id]->rxdataF_ext,
+ //printf("TM3 log2_maxh : %d\n",pdsch_vars[eNB_id]->log2_maxh);
+ if (symbol == 5) {
+ LOG_M("rho0_0.m","rho0_0",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
+ LOG_M("rho2_0.m","rho2_0",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+ LOG_M("rho0_1.m.m","rho0_1",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
+ LOG_M("rho2_1.m","rho2_1",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
+ }
+ } else if (dlsch0_harq->mimo_mode