Commit ae58025b authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'issue394_fix_cppcheck' into develop_integration_2019_w07_v2

--> openair2/LAYER2/MAC/eNB_scheduler_primitives.c is still old (not from issue394_fix_cppcheck branch)
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parents af3e7cea be2fbc20
// *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*
......@@ -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)
......
......@@ -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 {
......
......@@ -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);
}
}
......
This diff is collapsed.
......@@ -5,46 +5,41 @@
#include <string.h>
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;
}
......@@ -7,21 +7,19 @@
#include "config.h"
#include "../T_defs.h"
void usage(void)
{
void usage(void) {
printf(
"options:\n"
" -d <database file> this option is mandatory\n"
" -ip <host> connect to given IP address (default %s)\n"
" -p <port> connect to given port (default %d)\n",
DEFAULT_REMOTE_IP,
DEFAULT_REMOTE_PORT
"options:\n"
" -d <database file> this option is mandatory\n"
" -ip <host> connect to given IP address (default %s)\n"
" -p <port> 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;
}
This diff is collapsed.
......@@ -9,27 +9,38 @@
#include <arpa/inet.h>
#include <math.h>
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); }
close(s);
printf("connected\n");
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);
......
......@@ -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);
}
This diff is collapsed.
......@@ -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);
......
This diff is collapsed.
This diff is collapsed.
......@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = {
/* configuration parameters for telnet utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
{"listenaddr", "<listen ip address>\n", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
{"listenport", "<local port>\n", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
{"priority", "<scheduling policy (0-99)\n", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>\n", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
{"histfile", "<history file name>\n", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
{"histsize", "<history sizes>\n", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
{"phypbsize", "<phy dump buff size (bytes)>\n",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
{"staticmod", "<static modules selection>\n", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
{"shrmod", "<dynamic modules selection>\n", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 }
{"listenaddr", "<listen ip address>", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
{"listenport", "<local port>", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
{"priority", "<scheduling policy (0-99)", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
{"histfile", "<history file name>", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
{"histsize", "<history sizes>", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
{"phypbsize", "<phy dump buff size (bytes)>",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
{"staticmod", "<static modules selection>", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
{"shrmod", "<dynamic modules selection>", 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);
......
......@@ -29,7 +29,7 @@
* \note
* \warning
*/
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <string.h>
#include <pthread.h>
......@@ -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);
void init_phytelnet(void)
{
prnbuff=malloc(get_phybsize() );
if (prnbuff == NULL)
{
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
}
}
extern int dump_eNB_l2_stats(char *buffer, int length);
void init_phytelnet(void) {
prnbuff=malloc(get_phybsize() );
void display_uestatshead( telnet_printfunc_t prnt)
{
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
if (prnbuff == NULL) {
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
}
}
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag)
{
void display_uestatshead( telnet_printfunc_t prnt) {
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
}
int p;
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) {
int p;
prnbuff=malloc(20480);
p=dump_eNB_l2_stats( prnbuff, 20480);
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)
{
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<NUMBER_OF_UE_MAX ; ue++)
{
display_uestats(debug, prnt,ue);
}
} /* else cptr != NULL */
} /* uestat */
if (strcasestr(buf,"uedump") != NULL)
{
dump_uestats(debug, prnt,1);
}
return 0;
int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) {
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<NUMBER_OF_UE_MAX ; ue++) {
display_uestats(debug, prnt,ue);
}
} /* else cptr != NULL */
} /* uestat */
if (strcasestr(buf,"uedump") != NULL) {
dump_uestats(debug, prnt,1);
}
return 0;
}
telnetshell_cmddef_t phy_cmdarray[] = {
{"disp","[phycnt,uedump,uestat UE<x>]", dump_phyvars},
{"disp","[phycnt,uedump,uestat UE<x>]", 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);
}
This diff is collapsed.
......@@ -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;
......
This diff is collapsed.
......@@ -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;
......
This diff is collapsed.
This diff is collapsed.
......@@ -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;
......
......@@ -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
......
......@@ -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)) {
......
......@@ -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; m<eNB->frame_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; m<ue->frame_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);
......
......@@ -20,9 +20,9 @@
*/
#ifdef MAIN
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#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<dftsizes[Msc_RS]; n++) {
......@@ -89,32 +88,26 @@ void generate_ul_ref_sigs(void)
// These are the sequences for RB 1
for (u=0; u<30; u++) {
ul_ref_sigs[u][0][0] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[0]);
ul_ref_sigs[u][0][0] = (int16_t *)malloc16(2*sizeof(int16_t)*dftsizes[0]);
for (n=0; n<dftsizes[0]; n++) {
ul_ref_sigs[u][0][0][n<<1] =(int16_t)(floor(32767*cos(M_PI*ref12[(u*12) + n]/4)));
ul_ref_sigs[u][0][0][1+(n<<1)]=(int16_t)(floor(32767*sin(M_PI*ref12[(u*12) + n]/4)));
}
}
// These are the sequences for RB 2
for (u=0; u<30; u++) {
ul_ref_sigs[u][0][1] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[1]);
ul_ref_sigs[u][0][1] = (int16_t *)malloc16(2*sizeof(int16_t)*dftsizes[1]);
for (n=0; n<dftsizes[1]; n++) {
ul_ref_sigs[u][0][1][n<<1] =(int16_t)(floor(32767*cos(M_PI*ref24[(u*24) + n]/4)));
ul_ref_sigs[u][0][1][1+(n<<1)]=(int16_t)(floor(32767*sin(M_PI*ref24[(u*24) + n]/4)));
}
}
}
void generate_ul_ref_sigs_rx(void)
{
void generate_ul_ref_sigs_rx(void) {
double qbar,phase;
unsigned int u,v,Msc_RS,q,m,n;
......@@ -123,7 +116,7 @@ void generate_ul_ref_sigs_rx(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_rx[u][v][Msc_RS] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[Msc_RS]);
ul_ref_sigs_rx[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;
......@@ -131,7 +124,7 @@ void generate_ul_ref_sigs_rx(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<dftsizes[Msc_RS]; n++) {
......@@ -159,7 +152,7 @@ void generate_ul_ref_sigs_rx(void)
// These are the sequences for RB 1
for (u=0; u<30; u++) {
ul_ref_sigs_rx[u][0][0] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[0]);
ul_ref_sigs_rx[u][0][0] = (int16_t *)malloc16(2*sizeof(int16_t)*dftsizes[0]);
for (n=0; n<dftsizes[0]; n++) {
ul_ref_sigs_rx[u][0][0][n<<1] = (int16_t)(floor(32767*cos(M_PI*ref12[(u*12) + n]/4)));
......@@ -169,21 +162,17 @@ void generate_ul_ref_sigs_rx(void)
// These are the sequences for RB 2
for (u=0; u<30; u++) {
ul_ref_sigs_rx[u][0][1] = (int16_t*)malloc16(2*sizeof(int16_t)*dftsizes[1]);
ul_ref_sigs_rx[u][0][1] = (int16_t *)malloc16(2*sizeof(int16_t)*dftsizes[1]);
for (n=0; n<dftsizes[1]; n++) {
ul_ref_sigs_rx[u][0][1][n<<1] = (int16_t)(floor(32767*cos(M_PI*ref24[(u*24) + n]/4)));
ul_ref_sigs_rx[u][0][1][1+(n<<1)]= (int16_t)(floor(32767*sin(M_PI*ref24[(u*24) + n]/4)));
}
}
}
void free_ul_ref_sigs(void)
{
void free_ul_ref_sigs(void) {
unsigned int u,v,Msc_RS;
for (Msc_RS=0; Msc_RS<34; Msc_RS++) {
......@@ -204,9 +193,7 @@ void free_ul_ref_sigs(void)
}
#ifdef MAIN
main()
{
main() {
generate_ul_ref_sigs();
generate_ul_ref_sigs_rx();
free_ul_ref_sigs();
......
This diff is collapsed.
......@@ -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;
}
}
......
......@@ -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,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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__)
......
......@@ -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; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
for (aarx=0; aarx<frame_parms->nb_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; rb<nb_rb; rb++) {
......@@ -379,7 +387,8 @@ void pdcch_channel_level(int32_t **dl_ch_estimates_ext,
avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[1],dl_ch128[1]));
avg128P = _mm_add_epi32(avg128P,_mm_madd_epi16(dl_ch128[2],dl_ch128[2]));
#elif defined(__arm__)
#else
#error Unsupported CPU architecture, cannot build __FILE__
#endif
dl_ch128+=3;
/*
......@@ -423,6 +432,8 @@ void pdcch_detection_mrc_i(LTE_DL_FRAME_PARMS *frame_parms,
__m128i *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1;
#elif defined(__arm__)
int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*rxdataF_comp128_i0,*rxdataF_comp128_i1,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1;
#else
#error Unsupported CPU architecture, cannot build __FILE__
#endif
int32_t i;
......@@ -436,6 +447,8 @@ void pdcch_detection_mrc_i(LTE_DL_FRAME_PARMS *frame_parms,
#elif defined(__arm__)
rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol*frame_parms->N_RB_DL*12];
rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol*frame_parms->N_RB_DL*12];
#else
#error Unsupported CPU architecture, cannot build __FILE__
#endif
// MRC on each re of rb on MF output
for (i=0; i<frame_parms->N_RB_DL*3; i++) {
......
......@@ -80,7 +80,6 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch)
}
}
free16(ulsch,sizeof(LTE_UE_ULSCH_t));
ulsch = NULL;
}
}
......
......@@ -22,6 +22,7 @@ int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coef
}
printf("%d\n",(int)tdd_calib_coeffs[0][0]);
printf("%d\n",(int)tdd_calib_coeffs[1][599]);
fclose(calibF_fd);
} else
printf("%s not found, running with defaults\n",calibF_fname);
/* TODO: what to return? is this code used at all? */
......
This diff is collapsed.
......@@ -9494,7 +9494,7 @@ int main(int argc, char**argv)
LOG_M("x24576.m","x24576",x,24576,1,1);
int dftsizes[33]={24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,768,864,900,960,972,1080,1152,1200};
void (*dft[33])(int16_t *x,int16_t *y,uint8_t scale) = {dft24,dft36,dft48,dft60,dft72,dft96,dft108,dft120,dft144,dft180,dft192,dft216,dft240,dft288,dft300,dft324,dft360,dft384,dft432,dft480,dft540,dft576,dft600,dft648,dft720,dft768,dft864,dft900,dft960,dft972,dft1080,dft1152,dft1200};
void (*dft)(int16_t *x,int16_t *y,uint8_t scale)[33] = {dft24,dft36,dft48,dft60,dft72,dft96,dft108,dft120,dft144,dft180,dft192,dft216,dft240,dft288,dft300,dft324,dft360,dft384,dft432,dft480,dft540,dft576,dft600,dft648,dft720,dft768,dft864,dft900,dft960,dft972,dft1080,dft1152,dft1200};
for (int n=0;n<33;n++) {
// 4xN-point DFT
memset((void*)x,0,dftsizes[n]*8*sizeof(int16_t));
......
......@@ -19,6 +19,7 @@ int f_read(char *calibF_fname, int nb_antM, int nb_freq, int16_t (*calibF_mtx)[n
}
printf("%d\n",(int)calibF_mtx[0][0]);
printf("%d\n",(int)calibF_mtx[1][599]);
fclose(calibF_fd);
} else
printf("%s not found, running with defaults\n",calibF_fname);
}
......@@ -64,6 +64,7 @@ int smbv_init_config(const char* fname, uint16_t sequence_length)
if (sequence_length>4) {
msg("ERROR invalid sequence length: %d, maximum is 4\n", sequence_length);
fclose(f_ptr);
return -1;
} else
slen = sequence_length;
......@@ -448,13 +449,6 @@ int smbv_send_config (const char* fname, char* smbv_ip)
int bytes_sent, status, sockfd;
char buf[BUFFER_LENGTH];
if (fopen(fname,"r")!=NULL) {
msg("Configuration file: %s\n",fname);
} else {
msg("ERROR: can't open SMBV config file: %s\n",fname);
return -1;
}
memset(buf,0,BUFFER_LENGTH);
// first, load up address structs with getaddrinfo():
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment