Commit 290ca22d authored by laurent's avatar laurent

fix rfsimulator initialized variable, first pass on gNB scope, bugs

parent b6c2f9c1
......@@ -2114,11 +2114,18 @@ if (${XFORMS})
${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_scope.c
)
set(XFORMS_SOURCE_SOFTMODEM
${OPENAIR_DIR}/executables/stats.c
${OPENAIR_DIR}/targets/RT/USER/stats.c
)
set(XFORMS_LIBRARIES "forms")
endif (${XFORMS})
include_directories ("/usr/include/X11")
add_library(gnbScope MODULE
${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_scope.c
)
target_link_libraries(gnbScope forms)
set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODULE_PATH}")
#include T directory even if the T is off because T macros are in the code
......@@ -2351,8 +2358,7 @@ add_executable(nr-softmodem
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${GTPU_need_ITTI}
${XFORMS_SOURCE}
${XFORMS_SOURCE_SOFTMODEM}
${XFORMS_SOURCE_NR}
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
......@@ -2389,8 +2395,7 @@ add_executable(nr-softmodem-nos1
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${GTPU_need_ITTI}
${XFORMS_SOURCE}
${XFORMS_SOURCE_SOFTMODEM}
${XFORMS_SOURCE_NR}
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
......@@ -2426,7 +2431,6 @@ add_executable(nr-uesoftmodem
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${XFORMS_SOURCE_NR}
${XFORMS_SOURCE_SOFTMODEM}
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
......@@ -2458,7 +2462,6 @@ add_executable(nr-uesoftmodem-nos1
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
${XFORMS_SOURCE_NR}
${XFORMS_SOURCE_SOFTMODEM}
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
......
#ifndef __SIMPLE_EXE_H__
#define __SIMPLE_EXE_H__
#ifndef __USE_GNU
#define __USE_GNU
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <pthread.h>
#include <sched.h>
......
......@@ -204,7 +204,7 @@ static inline notifiedFIFO_elt_t *pullTpool(notifiedFIFO_t *responseFifo, tpool_
if (t->measurePerf)
msg->returnTime=rdtsc();
if (t->traceFd)
if (t->traceFd >= 0)
if(write(t->traceFd, msg, sizeof(*msg)));
return msg;
......
......@@ -81,7 +81,7 @@ unsigned short config_frames[4] = {2,9,11,13};
#include <openair2/GNB_APP/gnb_app.h>
#ifdef XFORMS
#include "PHY/TOOLS/lte_phy_scope.h"
#include "PHY/TOOLS/nr_phy_scope.h"
#include "stats.h"
#endif
#include "nr-softmodem.h"
......@@ -91,8 +91,7 @@ unsigned short config_frames[4] = {2,9,11,13};
// current status is that every UE has a DL scope for a SINGLE eNB (gnb_id=0)
// at eNB 0, an UL scope for every UE
FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX];
FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
FD_phy_scope_gnb *form_gnb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
char title[255];
unsigned char scope_enb_num_ue = 2;
......@@ -408,7 +407,7 @@ static void *scope_thread(void *arg) {
if ((ue_cnt<scope_enb_num_ue)) {
/*
//this function needs to be written
phy_scope_gNB(form_enb[CC_id][ue_cnt],
phy_scope_gNB(form_gnb[CC_id][ue_cnt],
RC.gNB[0][CC_id],
UE_id);
*/
......@@ -1050,16 +1049,16 @@ int main( int argc, char **argv ) {
for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) {
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
form_enb[CC_id][UE_id] = create_lte_phy_scope_enb();
form_gnb[CC_id][UE_id] = create_phy_scope_gnb();
sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id);
fl_show_form (form_enb[CC_id][UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
fl_show_form (form_gnb[CC_id][UE_id]->phy_scope_gnb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
if (otg_enabled) {
fl_set_button(form_enb[CC_id][UE_id]->button_0,1);
fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic ON");
fl_set_button(form_gnb[CC_id][UE_id]->button_0,1);
fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic ON");
} else {
fl_set_button(form_enb[CC_id][UE_id]->button_0,0);
fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic OFF");
fl_set_button(form_gnb[CC_id][UE_id]->button_0,0);
fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic OFF");
}
} // CC_id
} // UE_id
......@@ -1187,8 +1186,8 @@ int main( int argc, char **argv ) {
for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) {
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
fl_hide_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb);
fl_free_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb);
fl_hide_form(form_enb[CC_id][UE_id]->phy_scope_gNB);
fl_free_form(form_enb[CC_id][UE_id]->phy_scope_gNB);
}
}
}
......
......@@ -119,22 +119,6 @@
/*------------------------------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters specific to UE */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_UEPARAMS_DESC { \
{"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:0, TYPE_DOUBLE, 0}, \
{"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, dblptr:&rx_gain_off, defdblval:0, TYPE_DOUBLE, 0}, \
{"ue-txgain", CONFIG_HLP_UETXG, 0, dblptr:&(tx_gain[0][0]), defdblval:0, TYPE_DOUBLE, 0}, \
{"ue-nb-ant-rx", CONFIG_HLP_UENANTR, 0, u8ptr:&nb_antenna_rx, defuintval:1, TYPE_UINT8, 0}, \
{"ue-nb-ant-tx", CONFIG_HLP_UENANTT, 0, u8ptr:&nb_antenna_tx, defuintval:1, TYPE_UINT8, 0}, \
{"ue-scan-carrier", CONFIG_HLP_UESCAN, PARAMFLAG_BOOL, iptr:&UE_scan_carrier, defintval:0, TYPE_INT, 0}, \
{"ue-max-power", NULL, 0, iptr:&(tx_max_power[0]), defintval:90, TYPE_INT, 0}, \
{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \
{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
}
#define DEFAULT_DLF 2680000000
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
......@@ -189,6 +173,11 @@
#define CMDLINE_STARTTELN_IDX 3
typedef struct {
int *argc;
char **argv;
} scopeParms_t;
extern int T_port;
extern int T_nowait;
extern int T_dont_fork;
......
......@@ -377,7 +377,7 @@ void processSubframeRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
#else
uint64_t a=rdtsc();
phy_procedures_nrUE_RX( UE, proc, 0, 1, UE->mode);
printf("phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500);
LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500);
// printf(">>> nr_ue_pdcch_procedures ended\n");
#endif
}
......
......@@ -97,11 +97,11 @@ extern FD_stats_form *create_form_stats_form( void );
//#include "stats.h"
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
// at eNB 0, an UL scope for every UE
FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX];
FD_phy_scope_nrue *form_nrue[NUMBER_OF_UE_MAX];
//FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
//FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
char title[255];
//unsigned char scope_enb_num_ue = 2;
unsigned char scope_enb_num_ue = 2;
static pthread_t forms_thread; //xforms
#endif //XFORMS
#include <executables/nr-uesoftmodem.h>
......@@ -313,7 +313,7 @@ static void *scope_thread(void *arg) {
sleep(5);
while (!oai_exit) {
phy_scope_UE(form_ue[0],
phy_scope_nrUE(form_nrue[0],
PHY_vars_UE_g[0][0],
0,0,1);
usleep(100*1000);
......@@ -325,18 +325,15 @@ static void *scope_thread(void *arg) {
void init_scope(void) {
#ifdef XFORMS
int ret;
int fl_argc=1;
if (do_forms==1) {
char *name="5G-UE-scope";
fl_initialize (&fl_argc, &name, NULL, 0, 0);
int UE_id = 0;
form_ue[UE_id] = create_lte_phy_scope_ue();
form_nrue[UE_id] = create_phy_scope_nrue();
sprintf (title, "NR DL SCOPE UE");
fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
fl_set_button(form_ue[UE_id]->button_0,0);
fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF");
fl_show_form (form_nrue[UE_id]->phy_scope_nrue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
threadCreate(&forms_thread, scope_thread, NULL, "scope", -1, OAI_PRIORITY_RT_LOW);
}
......
/*
* 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
*/
/* Form definition file generated by fdesign */
#include <stdlib.h>
#include "stats.h"
/***************************************
***************************************/
FD_stats_form *
create_form_stats_form( void ) {
FL_OBJECT *obj;
FD_stats_form *fdui = fl_malloc( sizeof *fdui );
fdui->vdata = fdui->cdata = NULL;
fdui->ldata = 0;
fdui->stats_form = fl_bgn_form( FL_NO_BOX, 1115, 900 );
obj = fl_add_box( FL_UP_BOX, 0, 0, 1115, 900, "" );
//fdui->stats_text = obj = fl_add_text( FL_NORMAL_TEXT, 60, 50, 1000, 810, "test" );
//fl_set_object_lsize( obj, FL_TINY_SIZE );
fdui->stats_text = obj = fl_add_browser( FL_NORMAL_BROWSER, 60, 50, 1000, 810, "test" );
fl_set_browser_fontsize(obj,FL_TINY_SIZE);
fdui->stats_button = obj = fl_add_button( FL_PUSH_BUTTON, 60, 10, 130, 30, "Reset Stats" );
fl_set_object_lalign( obj, FL_ALIGN_CENTER );
fl_set_object_color( obj, FL_GREEN, FL_GREEN);
fl_set_object_callback( obj, reset_stats, 0 );
fl_end_form( );
fdui->stats_form->fdui = fdui;
return fdui;
}
......@@ -53,7 +53,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
// printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
//Else, initialize and add node to the end of the linked list.
t_nrPolar_params *newPolarInitNode = malloc(sizeof(t_nrPolar_params));
t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1);
if (newPolarInitNode != NULL) {
newPolarInitNode->idx = (messageType * messageLength * aggregation_prime);
......
......@@ -369,7 +369,7 @@ void phy_config_harq_ue(module_id_t Mod_id,
for (num_of_threads=0;num_of_threads<RX_NB_TH_MAX;num_of_threads++)
for (num_of_code_words=0;num_of_code_words<NR_MAX_NB_CODEWORDS;num_of_code_words++)
phy_vars_ue->ulsch[eNB_id][num_of_threads][num_of_code_words]->Mlimit = max_harq_tx;
phy_vars_ue->ulsch[num_of_threads][eNB_id][num_of_code_words]->Mlimit = max_harq_tx;
}
extern uint16_t beta_cqi[16];
......
......@@ -35,8 +35,6 @@ float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
float tput_ue_max[NUMBER_OF_UE_MAX] = {0};
extern int64_t *pss_corr_ue[3];
static void ia_receiver_on_off( FL_OBJECT *button, long arg)
{
......@@ -66,14 +64,14 @@ static void dl_traffic_on_off( FL_OBJECT *button, long arg)
}
}
FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void )
FD_phy_scope_gnb *create_phy_scope_gnb( void )
{
FL_OBJECT *obj;
FD_lte_phy_scope_enb *fdui = fl_malloc( sizeof *fdui );
FD_phy_scope_gnb *fdui = fl_malloc( sizeof *fdui );
// Define form
fdui->lte_phy_scope_enb = fl_bgn_form( FL_NO_BOX, 800, 800 );
fdui->phy_scope_gnb = fl_bgn_form( FL_NO_BOX, 800, 800 );
// This the whole UI box
obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 800, "" );
......@@ -146,19 +144,17 @@ FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void )
fl_set_object_callback(fdui->button_0, dl_traffic_on_off, 0 );
fl_end_form( );
fdui->lte_phy_scope_enb->fdui = fdui;
fdui->phy_scope_gnb->fdui = fdui;
return fdui;
}
/*
void phy_scope_eNB(FD_lte_phy_scope_enb *form,
PHY_VARS_eNB *phy_vars_enb,
void phy_scope_gNB(FD_phy_scope_gnb *form,
PHY_VARS_gNB *phy_vars_gnb,
int UE_id)
{
int eNB_id = 0;
int i,i2,arx,atx,ind,k;
LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_enb->frame_parms;
NR_DL_FRAME_PARMS *frame_parms = &phy_vars_gnb->frame_parms;
int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti;
uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE
......@@ -180,16 +176,18 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form,
float time[FRAME_LENGTH_COMPLEX_SAMPLES];
float time2[2048];
float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx];
int frame = phy_vars_enb->proc.proc_rxtx[0].frame_tx;
uint32_t total_dlsch_bitrate = phy_vars_enb->total_dlsch_bitrate;
uint32_t total_dlsch_bitrate = phy_vars_gnb->total_dlsch_bitrate;
int coded_bits_per_codeword = 0;
uint8_t harq_pid; // in TDD config 3 it is sf-2, i.e., can be 0,1,2
int Qm = 2;
if (!RC.nrmac[0]->UE_list.active[UE_id])
return;
// choose max MCS to compute coded_bits_per_codeword
if (phy_vars_enb->ulsch[UE_id]!=NULL) {
if (phy_vars_gnb->ulsch[UE_id][0]!=NULL) {
for (harq_pid=0; harq_pid<3; harq_pid++) {
Qm = cmax(phy_vars_enb->ulsch[UE_id]->harq_processes[harq_pid]->Qm,Qm);
//Qm = cmax(phy_vars_gnb->ulsch[UE_id][0]->harq_processes->Qm,Qm);
}
}
......@@ -199,15 +197,15 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form,
llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero
bit = malloc(coded_bits_per_codeword*sizeof(float));
rxsig_t = (int16_t**) phy_vars_enb->common_vars.rxdata[eNB_id];
//chest_t = (int16_t**) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id];
chest_t = (int16_t**) phy_vars_enb->srs_vars[UE_id].srs_ch_estimates[eNB_id];
chest_f = (int16_t**) phy_vars_enb->pusch_vars[UE_id]->drs_ch_estimates[eNB_id];
pusch_llr = (int16_t*) phy_vars_enb->pusch_vars[UE_id]->llr;
pusch_comp = (int32_t*) phy_vars_enb->pusch_vars[UE_id]->rxdataF_comp[0];
pucch1_comp = (int32_t*) phy_vars_enb->pucch1_stats[UE_id];
pucch1_thres = (int32_t*) phy_vars_enb->pucch1_stats_thres[UE_id];
pucch1ab_comp = (int32_t*) phy_vars_enb->pucch1ab_stats[UE_id];
rxsig_t = (int16_t**) phy_vars_gnb->common_vars.rxdata;
//chest_t = (int16_t**) phy_vars_gnb->pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id];
chest_t = (int16_t**) phy_vars_gnb->srs_vars[UE_id].srs_ch_estimates;
chest_f = (int16_t**) phy_vars_gnb->pusch_vars[UE_id]->drs_ch_estimates;
pusch_llr = (int16_t*) phy_vars_gnb->pusch_vars[UE_id]->llr;
pusch_comp = (int32_t*) phy_vars_gnb->pusch_vars[UE_id]->rxdataF_comp;
pucch1_comp = (int32_t*) phy_vars_gnb->pucch1_stats[UE_id];
pucch1_thres = (int32_t*) phy_vars_gnb->pucch1_stats_thres[UE_id];
pucch1ab_comp = (int32_t*) phy_vars_gnb->pucch1ab_stats[UE_id];
// Received signal in time domain of receive antenna 0
if (rxsig_t != NULL) {
......@@ -363,7 +361,7 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form,
memmove( tput_time_enb[UE_id], &tput_time_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) );
memmove( tput_enb[UE_id], &tput_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) );
tput_time_enb[UE_id][TPUT_WINDOW_LENGTH-1] = (float) frame;
tput_time_enb[UE_id][TPUT_WINDOW_LENGTH-1] = (float) 0;
tput_enb[UE_id][TPUT_WINDOW_LENGTH-1] = ((float) total_dlsch_bitrate)/1000.0;
fl_set_xyplot_data(form->pusch_tput,tput_time_enb[UE_id],tput_enb[UE_id],TPUT_WINDOW_LENGTH,"","","");
......@@ -377,16 +375,15 @@ void phy_scope_eNB(FD_lte_phy_scope_enb *form,
free(bit);
free(chest_f_abs);
}
*/
FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void )
FD_phy_scope_nrue *create_phy_scope_nrue( void )
{
FL_OBJECT *obj;
FD_lte_phy_scope_ue *fdui = fl_malloc( sizeof *fdui );
FD_phy_scope_nrue *fdui = fl_malloc( sizeof *fdui );
// Define form
fdui->lte_phy_scope_ue = fl_bgn_form( FL_NO_BOX, 800, 900 );
fdui->phy_scope_nrue = fl_bgn_form( FL_NO_BOX, 800, 900 );
// This the whole UI box
obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 900, "" );
......@@ -477,12 +474,12 @@ FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void )
fl_hide_object(fdui->button_0);
fl_end_form( );
fdui->lte_phy_scope_ue->fdui = fdui;
fdui->phy_scope_nrue->fdui = fdui;
return fdui;
}
void phy_scope_UE(FD_lte_phy_scope_ue *form,
void phy_scope_nrUE(FD_phy_scope_nrue *form,
PHY_VARS_NR_UE *phy_vars_ue,
int eNB_id,
int UE_id,
......@@ -629,6 +626,7 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form,
if (phy_vars_ue->is_synchronized==0) {
for (ind=0;ind<3;ind++) {
/*
if (pss_corr_ue[ind]) {
for (i=0; i<samples_per_frame; i++) {
corr[i] = (float) pss_corr_ue[ind][i];
......@@ -642,6 +640,7 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form,
overlay = 1;
}
*/
}
}
else {
......@@ -843,3 +842,91 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form,
free(chest_t_abs);
*/
}
typedef struct {
FL_FORM *stats_form;
void *vdata;
char *cdata;
long ldata;
FL_OBJECT *stats_text;
FL_OBJECT *stats_button;
} FD_stats_form;
void reset_stats_gNB(FL_OBJECT *button, long arg) {
PHY_VARS_gNB *phy_vars_gNB = RC.gNB[0][0];
for (int i=0; i<NUMBER_OF_UE_MAX; i++) {
for (int k=0; k<8; k++) { //harq_processes
/* for (j=0; j<phy_vars_gNB->dlsch[i][0]->Mlimit; j++) {
phy_vars_gNB->UE_stats[i].dlsch_NAK[k][j]=0;
phy_vars_gNB->UE_stats[i].dlsch_ACK[k][j]=0;
phy_vars_gNB->UE_stats[i].dlsch_trials[k][j]=0;
}*/
phy_vars_gNB->UE_stats[i].dlsch_l2_errors[k]=0;
phy_vars_gNB->UE_stats[i].ulsch_errors[k]=0;
phy_vars_gNB->UE_stats[i].ulsch_consecutive_errors=0;
phy_vars_gNB->UE_stats[i].dlsch_sliding_cnt=0;
phy_vars_gNB->UE_stats[i].dlsch_NAK_round0=0;
phy_vars_gNB->UE_stats[i].dlsch_mcs_offset=0;
}
}
}
static FD_phy_scope_gnb *form_gnb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
static void *scope_thread(void *arg) {
int ue_cnt=0;
while (!oai_exit) {
ue_cnt=0;
for(int UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
for(int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
if ((ue_cnt<scope_enb_num_ue))
//this function needs to be written
phy_scope_gNB(form_gnb[CC_id][ue_cnt], RC.gNB[0][CC_id], UE_id);
ue_cnt++;
}
}
sleep(1);
}
return NULL;
}
FD_stats_form * create_form_stats_form( void ) {
FL_OBJECT *obj;
FD_stats_form *fdui = fl_malloc( sizeof *fdui );
fdui->vdata = fdui->cdata = NULL;
fdui->ldata = 0;
fdui->stats_form = fl_bgn_form( FL_NO_BOX, 1115, 900 );
obj = fl_add_box( FL_UP_BOX, 0, 0, 1115, 900, "" );
//fdui->stats_text = obj = fl_add_text( FL_NORMAL_TEXT, 60, 50, 1000, 810, "test" );
//fl_set_object_lsize( obj, FL_TINY_SIZE );
fdui->stats_text = obj = fl_add_browser( FL_NORMAL_BROWSER, 60, 50, 1000, 810, "test" );
fl_set_browser_fontsize(obj,FL_TINY_SIZE);
fdui->stats_button = obj = fl_add_button( FL_PUSH_BUTTON, 60, 10, 130, 30, "Reset Stats" );
fl_set_object_lalign( obj, FL_ALIGN_CENTER );
fl_set_object_color( obj, FL_GREEN, FL_GREEN);
fl_end_form( );
fdui->stats_form->fdui = fdui;
return fdui;
}
void startScope(scopeParms_t * p) {
FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
char title[255];
fl_initialize (p->argc, p->argv, NULL, 0, 0);
form_stats_l2 = create_form_stats_form();
fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats");
form_stats = create_form_stats_form();
fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats");
for(int UE_id=0; UE_id<scope_enb_num_ue; UE_id++) {
for(int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
form_gnb[CC_id][UE_id] = create_phy_scope_gnb();
sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id);
fl_show_form (form_gnb[CC_id][UE_id]->phy_scope_gnb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
} // CC_id
} // UE_id
pthread_t forms_thread;
threadCreate(&forms_thread, scope_thread, NULL, "scope", -1, OAI_PRIORITY_RT_LOW);
}
......@@ -21,19 +21,24 @@
/* Header file generated by fdesign on Tue Nov 13 09:42:50 2012 */
#ifndef FD_lte_scope_h_
#define FD_lte_scope_h_
#ifndef FD_nr_scope_h_
#define FD_nr_scope_h_
#include <simple_executable.h>
#include <common/utils/system.h>
#include <openairinterface5g_limits.h>
#include <openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h>
#include "common/ran_context.h"
#include <openair1/PHY/defs_gNB.h>
#include <nr-softmodem.h>
#include <forms.h>
//#include "PHY/defs_eNB.h"
//#include "PHY/defs_UE.h"
#include "PHY/defs_gNB.h"
//#include "PHY/defs_nrUE.h"
//#include "PHY/impl_defs_top.h"
#include "PHY/defs_nr_UE.h"
/* Forms and Objects */
typedef struct {
FL_FORM * lte_phy_scope_enb;
FL_FORM * phy_scope_gnb;
FL_OBJECT * rxsig_t;
FL_OBJECT * chest_f;
FL_OBJECT * chest_t;
......@@ -43,10 +48,10 @@ typedef struct {
FL_OBJECT * pusch_llr;
FL_OBJECT * pusch_tput;
FL_OBJECT * button_0;
} FD_lte_phy_scope_enb;
} FD_phy_scope_gnb;
typedef struct {
FL_FORM * lte_phy_scope_ue;
FL_FORM * phy_scope_nrue;
FL_OBJECT * rxsig_t;
FL_OBJECT * chest_f;
FL_OBJECT * chest_t;
......@@ -61,24 +66,22 @@ typedef struct {
FL_OBJECT * pdsch_tput;
FL_OBJECT * button_0;
} FD_lte_phy_scope_ue;
} FD_phy_scope_nrue;
FD_lte_phy_scope_enb * create_lte_phy_scope_enb( void );
FD_lte_phy_scope_ue * create_lte_phy_scope_ue( void );
extern unsigned char scope_enb_num_ue;
FD_phy_scope_gnb * create_phy_scope_gnb( void );
FD_phy_scope_nrue * create_phy_scope_nrue( void );
/*
void phy_scope_eNB(FD_lte_phy_scope_enb *form,
PHY_VARS_gNB *phy_vars_enb,
void phy_scope_gNB(FD_phy_scope_gnb *form,
PHY_VARS_gNB *phy_vars_gnb,
int UE_id);
*/
void phy_scope_UE(FD_lte_phy_scope_ue *form,
void phy_scope_nrUE(FD_phy_scope_nrue *form,
PHY_VARS_NR_UE *phy_vars_ue,
int eNB_id,
int UE_id,
uint8_t subframe);
#endif /* FD_lte_scope_h_ */
extern RAN_CONTEXT_t RC;
#endif
......@@ -40,16 +40,9 @@ extern int number_of_cards;
extern short conjugate[8],conjugate2[8];
#ifndef OCP_FRAMEWORK
//extern PHY_VARS_eNB ***PHY_vars_eNB_g;
extern RAN_CONTEXT_t RC;
extern LTE_DL_FRAME_PARMS *lte_frame_parms_g;
#else
#define MAX_UE 10
#define MAX_eNB 20
extern PHY_VARS_eNB * PHY_vars_eNB_g[MAX_eNB][MAX_NUM_CCs];
#endif
extern RAN_CONTEXT_t RC;
extern short primary_synch0[144];
extern short primary_synch1[144];
......
......@@ -38,15 +38,7 @@ extern short conjugate[8],conjugate2[8];
extern int number_of_cards;
#ifndef OCP_FRAMEWORK
extern PHY_VARS_NR_UE ***PHY_vars_UE_g;
extern NR_DL_FRAME_PARMS *lte_frame_parms_g;
#else
#define MAX_UE 10
#define MAX_eNB 20
extern PHY_VARS_NR_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs];
#endif
extern short primary_synch0[144];
extern short primary_synch1[144];
......
......@@ -38,15 +38,8 @@ extern int number_of_cards;
extern short conjugate[8],conjugate2[8];
#ifndef OCP_FRAMEWORK
extern PHY_VARS_UE ***PHY_vars_UE_g;
extern LTE_DL_FRAME_PARMS *lte_frame_parms_g;
#else
#define MAX_UE 10
#define MAX_eNB 20
extern PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs];
#endif
extern PHY_VARS_UE ***PHY_vars_UE_g;
extern short primary_synch0[144];
extern short primary_synch1[144];
......
......@@ -41,19 +41,10 @@ int16_t *primary_synch2_time;
#include "PHY/LTE_TRANSPORT/transport_vars.h"
#include "PHY/MODULATION/modulation_vars.h"
//PHY_VARS *PHY_vars;
#ifndef OCP_FRAMEWORK
PHY_VARS_UE ***PHY_vars_UE_g;
RAN_CONTEXT_t RC;
//PHY_VARS_eNB ***PHY_vars_eNB_g;
//PHY_VARS_RN **PHY_vars_RN_g;
LTE_DL_FRAME_PARMS *lte_frame_parms_g;
#else
PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL};
PHY_VARS_eNB * PHY_vars_eNB_g[MAX_eNB][MAX_NUM_CCs]={NULL};
#endif
PHY_VARS_UE ***PHY_vars_UE_g;
RAN_CONTEXT_t RC;
unsigned short rev[2048],rev_times4[8192],rev_half[1024];
unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192];
......
......@@ -40,16 +40,10 @@ int16_t *primary_synch2_time;
//#include "PHY/CODING/coding_vars.h"
//PHY_VARS *PHY_vars;
#ifndef OCP_FRAMEWORK
PHY_VARS_NR_UE ***PHY_vars_UE_g;
PHY_VARS_eNB ***PHY_vars_eNB_g;
NR_DL_FRAME_PARMS *lte_frame_parms_g;
#else
PHY_VARS_NR_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL};
#endif
PHY_VARS_NR_UE ***PHY_vars_UE_g;
PHY_VARS_eNB ***PHY_vars_eNB_g;
unsigned short rev[2048],rev_times4[8192],rev_half[1024];
unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192];
......
......@@ -37,17 +37,7 @@ int16_t *primary_synch0_time;
int16_t *primary_synch1_time;
int16_t *primary_synch2_time;
//PHY_VARS *PHY_vars;
#ifndef OCP_FRAMEWORK
PHY_VARS_UE ***PHY_vars_UE_g;
LTE_DL_FRAME_PARMS *lte_frame_parms_g;
#else
PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL};
#endif
unsigned short rev[2048],rev_times4[8192],rev_half[1024];
unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192];
......
......@@ -3155,36 +3155,42 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
/*
* This is the NR part
*/
if ((dci_alloc_rx[i].format == format0_0))
if ((dci_alloc_rx[i].format == format1_0) &&
(dci_alloc_rx[i].rnti != crc_scrambled_values[_P_RNTI_]) &&
(dci_alloc_rx[i].rnti != crc_scrambled_values[_SI_RNTI_]) &&
(dci_alloc_rx[i].rnti != crc_scrambled_values[_RA_RNTI_])) ue->dlsch_received[eNB_id]++;
if ((dci_alloc_rx[i].rnti == crc_scrambled_values[_SI_RNTI_]) && (dci_alloc_rx[i].format == format1_0)) ue->dlsch_SI_received[eNB_id]++;
if ((dci_alloc_rx[i].rnti == crc_scrambled_values[_P_RNTI_]) && (dci_alloc_rx[i].format == format1_0)) ue->dlsch_p_received[eNB_id]++;
if ((dci_alloc_rx[i].rnti == crc_scrambled_values[_RA_RNTI_]) && (dci_alloc_rx[i].format == format1_0)) ue->dlsch_ra_received[eNB_id]++;
if ((dci_alloc_rx[i].format == format2_0)){
}
if ((dci_alloc_rx[i].format == format2_1)){
}
if ((dci_alloc_rx[i].format == format2_2)){
}
if ((dci_alloc_rx[i].format == format2_3)){
}
if ((dci_alloc_rx[i].format == format0_1)){ // This format not implemented at a first time. FIXME
}
if ((dci_alloc_rx[i].format == format1_1)){ // This format not implemented at a first time. FIXME
}
if ((dci_alloc_rx[i].format == format0_0)){
}
if (dci_alloc_rx[i].format == format1_0) {
if ((dci_alloc_rx[i].rnti != crc_scrambled_values[_P_RNTI_]) &&
(dci_alloc_rx[i].rnti != crc_scrambled_values[_SI_RNTI_]) &&
(dci_alloc_rx[i].rnti != crc_scrambled_values[_RA_RNTI_]))
ue->dlsch_received[eNB_id]++;
if (dci_alloc_rx[i].rnti == crc_scrambled_values[_SI_RNTI_])
ue->dlsch_SI_received[eNB_id]++;
if (dci_alloc_rx[i].rnti == crc_scrambled_values[_P_RNTI_])
ue->dlsch_p_received[eNB_id]++;
if (dci_alloc_rx[i].rnti == crc_scrambled_values[_RA_RNTI_])
ue->dlsch_ra_received[eNB_id]++;
}
if ((dci_alloc_rx[i].format == format2_0)){
}
if ((dci_alloc_rx[i].format == format2_1)){
}
if ((dci_alloc_rx[i].format == format2_2)){
}
if ((dci_alloc_rx[i].format == format2_3)){
}
if ((dci_alloc_rx[i].format == format0_1)){ // This format not implemented at a first time. FIXME
}
if ((dci_alloc_rx[i].format == format1_1)){ // This format not implemented at a first time. FIXME
}
uint8_t status=0;
LOG_D(PHY,"<-NR_PDCCH_PHY_PROCEDURES_UE (nr_ue_pdcch_procedures)-> dci_format=%d, rnti=%d, dci_length=%d, dci_pdu[0]=0x%lx, dci_pdu[1]=0x%lx\n",dci_alloc_rx[i].format,dci_alloc_rx[i].rnti,dci_alloc_rx[i].dci_length,dci_alloc_rx[i].dci_pdu[0],dci_alloc_rx[i].dci_pdu[1]);
memset(&ue->dci_ind.dci_list[i].dci,0,sizeof(fapi_nr_dci_pdu_rel15_t));
ue->dci_ind.dci_list[i].rnti = dci_alloc_rx[i].rnti;
ue->dci_ind.dci_list[i].dci_format = dci_alloc_rx[i].format;
ue->dci_ind.dci_list[i].n_CCE = dci_alloc_rx[i].firstCCE;
......@@ -3203,15 +3209,15 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
pdcch_vars2->n_RB_BWP[nb_searchspace_active],
pdcch_vars2->n_RB_BWP[nb_searchspace_active],
crc_scrambled_values);
if(status == 0) {
LOG_W(PHY,"<-NR_PDCCH_PHY_PROCEDURES_UE (nr_ue_pdcch_procedures)-> bad DCI %d !!! \n",dci_alloc_rx[i].format);
return(-1);
}
LOG_D(PHY,"<-NR_PDCCH_PHY_PROCEDURES_UE (nr_ue_pdcch_procedures)-> Ending function nr_extract_dci_info()\n");
/*
/*
nr_generate_ue_ul_dlsch_params_from_dci(ue,
eNB_id,
frame_rx,
......
......@@ -46,7 +46,6 @@ typedef struct {
int listen_sock, epollfd;
uint64_t nextTimestamp;
uint64_t typeStamp;
uint64_t initialAhead;
char *ip;
int saveIQfile;
buffer_t buf[FD_SETSIZE];
......@@ -57,6 +56,8 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) {
AssertFatal ( (ptr->circularBuf=(sample_t *) malloc(sampleToByte(CirSize,1))) != NULL, "");
ptr->circularBufEnd=((char *)ptr->circularBuf)+sampleToByte(CirSize,1);
ptr->conn_sock=sock;
ptr->alreadyRead=false;
ptr->lastReceivedTS=0;
ptr->headerMode=true;
ptr->transferPtr=(char *)&ptr->th;
ptr->remainToTransfer=sizeof(samplesBlockHeader_t);
......@@ -86,7 +87,6 @@ void socketError(rfsimulator_state_t *bridge, int sock) {
}
}
#define helpTxt "\
\x1b[31m\
rfsimulator: error: you have to run one UE and one eNB\n\
......@@ -113,14 +113,17 @@ void setblocking(int sock, enum blocking_t active) {
static bool flushInput(rfsimulator_state_t *t);
void fullwrite(int fd, void *_buf, int count, rfsimulator_state_t *t) {
void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t) {
if (t->saveIQfile != -1) {
if (write(t->saveIQfile, _buf, count) != count )
LOG_E(HW,"write in save iq file failed (%s)\n",strerror(errno));
}
AssertFatal(fd>=0 && _buf && count >0 && t,
"Bug: %d/%p/%zd/%p", fd, _buf, count, t);
char *buf = _buf;
int l;
ssize_t l;
setblocking(fd, notBlocking);
while (count) {
......@@ -198,6 +201,7 @@ sin_addr:
t->buf[sock].alreadyRead=true; // UE will start blocking on read
return 0;
}
uint64_t lastW=-1;
int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, void **samplesVoid, int nsamps, int nbAnt, int flags) {
rfsimulator_state_t *t = device->priv;
......@@ -263,7 +267,7 @@ static bool flushInput(rfsimulator_state_t *t) {
continue;
}
int blockSz;
ssize_t blockSz;
if ( b->headerMode)
blockSz=b->remainToTransfer;
......@@ -272,7 +276,7 @@ static bool flushInput(rfsimulator_state_t *t) {
b->remainToTransfer :
b->circularBufEnd - 1 - b->transferPtr ;
int sz=recv(fd, b->transferPtr, blockSz, MSG_DONTWAIT);
ssize_t sz=recv(fd, b->transferPtr, blockSz, MSG_DONTWAIT);
if ( sz < 0 ) {
if ( errno != EAGAIN ) {
......@@ -282,6 +286,7 @@ static bool flushInput(rfsimulator_state_t *t) {
} else if ( sz == 0 )
continue;
LOG_D(HW, "Socket rcv %zd bytes\n", sz);
AssertFatal((b->remainToTransfer-=sz) >= 0, "");
b->transferPtr+=sz;
......@@ -315,14 +320,12 @@ static bool flushInput(rfsimulator_state_t *t) {
if ( b->headerMode==false ) {
LOG_D(HW,"Set b->lastReceivedTS %ld\n", b->lastReceivedTS);
b->lastReceivedTS=b->th.timestamp+b->th.size-byteToSample(b->remainToTransfer,b->th.nbAnt);
// First block in UE, resync with the eNB current TS
if ( t->nextTimestamp == 0 )
t->nextTimestamp=b->lastReceivedTS-b->th.size;
if ( b->remainToTransfer==0) {
LOG_D(HW,"Completed block reception: %ld\n", b->lastReceivedTS);
// First block in UE, resync with the eNB current TS
if ( t->nextTimestamp == 0 )
t->nextTimestamp=b->lastReceivedTS-b->th.size;
b->headerMode=true;
b->transferPtr=(char *)&b->th;
b->remainToTransfer=sizeof(samplesBlockHeader_t);
......@@ -369,12 +372,12 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
have_to_wait=false;
for ( int sock=0; sock<FD_SETSIZE; sock++) {
if ( t->buf[sock].circularBuf &&
t->buf[sock].alreadyRead && //>= t->initialAhead &&
(t->nextTimestamp+nsamps) > t->buf[sock].lastReceivedTS ) {
have_to_wait=true;
break;
}
if ( t->buf[sock].circularBuf && t->buf[sock].alreadyRead )
if ( t->buf[sock].lastReceivedTS == 0 ||
(t->nextTimestamp+nsamps) > t->buf[sock].lastReceivedTS ) {
have_to_wait=true;
break;
}
}
if (have_to_wait)
......@@ -443,6 +446,7 @@ int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_c
__attribute__((__visibility__("default")))
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
//set_log(HW,OAILOG_DEBUG);
//set_log(PHY,OAILOG_DEBUG);
rfsimulator_state_t *rfsimulator = (rfsimulator_state_t *)calloc(sizeof(rfsimulator_state_t),1);
if ((rfsimulator->ip=getenv("RFSIMULATOR")) == NULL ) {
......@@ -450,10 +454,13 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
exit(1);
}
rfsimulator->typeStamp = strncasecmp(rfsimulator->ip,"enb",3) == 0 ?
ENB_MAGICDL_FDD:
UE_MAGICDL_FDD;
LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == ENB_MAGICDL_FDD ? "eNB" : "UE");
if ( strncasecmp(rfsimulator->ip,"enb",3) == 0 ||
strncasecmp(rfsimulator->ip,"server",3) == 0 )
rfsimulator->typeStamp = ENB_MAGICDL_FDD;
else
rfsimulator->typeStamp = UE_MAGICDL_FDD;
LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == ENB_MAGICDL_FDD ? "(eg)NB" : "UE");
char *saveF;
if ((saveF=getenv("saveIQfile")) != NULL) {
......@@ -486,6 +493,5 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
rfsimulator->buf[i].conn_sock=-1;
AssertFatal((rfsimulator->epollfd = epoll_create1(0)) != -1,"");
rfsimulator->initialAhead=openair0_cfg[0].sample_rate/1000; // One sub frame
return 0;
}
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