Commit 217491cb authored by laurent's avatar laurent

progress in main cleanup coding

parent 8493071b
...@@ -2090,9 +2090,9 @@ target_link_libraries (lte-softmodem ...@@ -2090,9 +2090,9 @@ target_link_libraries (lte-softmodem
-Wl,--end-group z dl) -Wl,--end-group z dl)
add_executable(simple-softmodem add_executable(ocp-softmodem
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_DIR}/executables/simple_main.c ${OPENAIR_DIR}/executables/main-ocp.c
${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c
${OPENAIR_TARGETS}/RT/USER/lte-softmodem-common.c ${OPENAIR_TARGETS}/RT/USER/lte-softmodem-common.c
${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c ${OPENAIR2_DIR}/ENB_APP/NB_IoT_interface.c
...@@ -2113,15 +2113,15 @@ add_executable(simple-softmodem ...@@ -2113,15 +2113,15 @@ add_executable(simple-softmodem
${CONFIG_SOURCES} ${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES} ${SHLIB_LOADER_SOURCES}
) )
add_dependencies(simple-softmodem rrc_flag s1ap_flag x2_flag) add_dependencies(ocp-softmodem rrc_flag s1ap_flag x2_flag)
target_link_libraries (simple-softmodem target_link_libraries (ocp-softmodem
-Wl,--start-group -Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP X2AP_LIB X2AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP X2AP_LIB X2AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} LFDS7
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl) -Wl,--end-group z dl)
target_link_libraries (simple-softmodem ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB}) target_link_libraries (ocp-softmodem ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB})
add_executable(cu_test add_executable(cu_test
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c ${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c
......
...@@ -23,6 +23,7 @@ typedef struct frequency_s { ...@@ -23,6 +23,7 @@ typedef struct frequency_s {
} frequency_t; } frequency_t;
int createListner (port); int createListner (port);
int receiveSubFrame(int sock, uint64_t expectedTS, void* bufferZone, int bufferSize); int receiveSubFrame(int sock, uint64_t expectedTS, void *bufferZone, int bufferSize);
int sendSubFrame(int sock, void* bufferZone, int nbBlocks);} int sendSubFrame(int sock, void *bufferZone, int nbBlocks);
}
#endif #endif
...@@ -47,8 +47,8 @@ pthread_mutex_t Sockmutex; ...@@ -47,8 +47,8 @@ pthread_mutex_t Sockmutex;
typedef struct buffer_s { typedef struct buffer_s {
int conn_sock; int conn_sock;
bool alreadyRead; openair0_timestamp lastReceivedTS;
uint64_t lastReceivedTS; openair0_timestamp lastWroteTS;
bool headerMode; bool headerMode;
samplesBlockHeader_t th; samplesBlockHeader_t th;
char *transferPtr; char *transferPtr;
...@@ -60,7 +60,7 @@ typedef struct buffer_s { ...@@ -60,7 +60,7 @@ typedef struct buffer_s {
typedef struct { typedef struct {
int listen_sock, epollfd; int listen_sock, epollfd;
uint64_t nextTimestamp; openair0_timestamp nextTimestamp;
uint64_t typeStamp; uint64_t typeStamp;
char *ip; char *ip;
int saveIQfile; int saveIQfile;
...@@ -104,9 +104,9 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si ...@@ -104,9 +104,9 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
// Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ? // Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ?
// the parameter "-s" is declared as SNR, but the input power is not well defined // the parameter "-s" is declared as SNR, but the input power is not well defined
// −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise) // −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise)
const double rxGain= 132.24 - snr_dB; const double rxGain= 132.24 - snr_dB;
// sqrt(4*noise_figure_watt) is the thermal noise factor (volts) // sqrt(4*noise_figure_watt) is the thermal noise factor (volts)
// fixme: the last constant is pure trial results to make decent noise // fixme: the last constant is pure trial results to make decent noise
const double noise_per_sample = sqrt(4*noise_figure_watt) * pow(10,rxGain/20) *10; const double noise_per_sample = sqrt(4*noise_figure_watt) * pow(10,rxGain/20) *10;
// Fixme: we don't fill the offset length samples at begining ? // Fixme: we don't fill the offset length samples at begining ?
// anyway, in today code, channel_offset=0 // anyway, in today code, channel_offset=0
...@@ -153,8 +153,8 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) { ...@@ -153,8 +153,8 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) {
AssertFatal ( (ptr->circularBuf=(sample_t *) malloc(sampleToByte(CirSize,1))) != NULL, ""); AssertFatal ( (ptr->circularBuf=(sample_t *) malloc(sampleToByte(CirSize,1))) != NULL, "");
ptr->circularBufEnd=((char *)ptr->circularBuf)+sampleToByte(CirSize,1); ptr->circularBufEnd=((char *)ptr->circularBuf)+sampleToByte(CirSize,1);
ptr->conn_sock=sock; ptr->conn_sock=sock;
ptr->alreadyRead=false;
ptr->lastReceivedTS=0; ptr->lastReceivedTS=0;
ptr->lastWroteTS=0;
ptr->headerMode=true; ptr->headerMode=true;
ptr->transferPtr=(char *)&ptr->th; ptr->transferPtr=(char *)&ptr->th;
ptr->remainToTransfer=sizeof(samplesBlockHeader_t); ptr->remainToTransfer=sizeof(samplesBlockHeader_t);
...@@ -319,21 +319,22 @@ sin_addr: ...@@ -319,21 +319,22 @@ sin_addr:
setblocking(sock, notBlocking); setblocking(sock, notBlocking);
allocCirBuf(t, sock); allocCirBuf(t, sock);
t->buf[sock].alreadyRead=true; // UE will start blocking on read
return 0; return 0;
} }
uint64_t lastW=-1;
int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, void **samplesVoid, int nsamps, int nbAnt, int flags) { int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, void **samplesVoid, int nsamps, int nbAnt, int flags) {
rfsimulator_state_t *t = device->priv; rfsimulator_state_t *t = device->priv;
LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp); LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp);
for (int i=0; i<FD_SETSIZE; i++) { for (int i=0; i<FD_SETSIZE; i++) {
buffer_t *ptr=&t->buf[i]; buffer_t *b=&t->buf[i];
if (ptr->conn_sock >= 0 ) { if (b->conn_sock >= 0 ) {
if ( abs((double)b->lastWroteTS-timestamp) > (double)CirSize)
LOG_E(HW,"Tx/Rx shift too large Tx:%lu, Rx:%lu\n", b->lastWroteTS, b->lastReceivedTS);
samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp}; samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp};
fullwrite(ptr->conn_sock,&header, sizeof(header), t); fullwrite(b->conn_sock,&header, sizeof(header), t);
sample_t tmpSamples[nsamps][nbAnt]; sample_t tmpSamples[nsamps][nbAnt];
for(int a=0; a<nbAnt; a++) { for(int a=0; a<nbAnt; a++) {
...@@ -343,17 +344,17 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi ...@@ -343,17 +344,17 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi
tmpSamples[s][a]=in[s]; tmpSamples[s][a]=in[s];
} }
if (ptr->conn_sock >= 0 ) if (b->conn_sock >= 0 ) {
fullwrite(ptr->conn_sock, (void *)tmpSamples, sampleToByte(nsamps,nbAnt), t); fullwrite(b->conn_sock, (void *)tmpSamples, sampleToByte(nsamps,nbAnt), t);
b->lastWroteTS=timestamp+nsamps;
}
} }
} }
lastW=timestamp;
LOG_D(HW,"sent %d samples at time: %ld->%ld, energy in first antenna: %d\n", LOG_D(HW,"sent %d samples at time: %ld->%ld, energy in first antenna: %d\n",
nsamps, timestamp, timestamp+nsamps, signal_energy(samplesVoid[0], nsamps) ); nsamps, timestamp, timestamp+nsamps, signal_energy(samplesVoid[0], nsamps) );
// Let's verify we don't have incoming data // Let's verify we don't have incoming data
// This is mandatory when the opposite side don't transmit // This is mandatory when the opposite side don't transmit
// This is mandatory when the opposite side don't transmit
flushInput(t, 0); flushInput(t, 0);
pthread_mutex_unlock(&Sockmutex); pthread_mutex_unlock(&Sockmutex);
return nsamps; return nsamps;
...@@ -425,7 +426,6 @@ static bool flushInput(rfsimulator_state_t *t, int timeout) { ...@@ -425,7 +426,6 @@ static bool flushInput(rfsimulator_state_t *t, int timeout) {
AssertFatal( (t->typeStamp == UE_MAGICDL_FDD && b->th.magic==ENB_MAGICDL_FDD) || AssertFatal( (t->typeStamp == UE_MAGICDL_FDD && b->th.magic==ENB_MAGICDL_FDD) ||
(t->typeStamp == ENB_MAGICDL_FDD && b->th.magic==UE_MAGICDL_FDD), "Socket Error in protocol"); (t->typeStamp == ENB_MAGICDL_FDD && b->th.magic==UE_MAGICDL_FDD), "Socket Error in protocol");
b->headerMode=false; b->headerMode=false;
b->alreadyRead=true;
if ( b->lastReceivedTS != b->th.timestamp) { if ( b->lastReceivedTS != b->th.timestamp) {
int nbAnt= b->th.nbAnt; int nbAnt= b->th.nbAnt;
...@@ -441,8 +441,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout) { ...@@ -441,8 +441,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout) {
} }
b->lastReceivedTS=b->th.timestamp; b->lastReceivedTS=b->th.timestamp;
AssertFatal(lastW == -1 || ( abs((double)lastW-b->lastReceivedTS) < (double)CirSize), AssertFatal(b->lastWroteTS == 0 || ( abs((double)b->lastWroteTS-b->lastReceivedTS) < (double)CirSize),
"Tx/Rx shift too large Tx:%lu, Rx:%lu\n", lastW, b->lastReceivedTS); "Tx/Rx shift too large Tx:%lu, Rx:%lu\n", b->lastWroteTS, b->lastReceivedTS);
b->transferPtr=(char *)&b->circularBuf[b->lastReceivedTS%CirSize]; b->transferPtr=(char *)&b->circularBuf[b->lastReceivedTS%CirSize];
b->remainToTransfer=sampleToByte(b->th.size, b->th.nbAnt); b->remainToTransfer=sampleToByte(b->th.size, b->th.nbAnt);
} }
...@@ -498,15 +498,33 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -498,15 +498,33 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
return nsamps; return nsamps;
} }
} else { } else {
bool have_to_wait; bool have_to_wait;
do { do {
have_to_wait=false; have_to_wait=false;
for ( int sock=0; sock<FD_SETSIZE; sock++) { for ( int sock=0; sock<FD_SETSIZE; sock++) {
if ( t->buf[sock].circularBuf && t->buf[sock].alreadyRead ) buffer_t *b=&t->buf[sock];
if ( t->buf[sock].lastReceivedTS == 0 || if ( b->circularBuf) {
(t->nextTimestamp+nsamps) > t->buf[sock].lastReceivedTS ) { LOG_D(HW,"sock: %d, lastWroteTS: %lu, lastRecvTS: %lu, TS must be avail: %lu\n",
sock, b->lastWroteTS,
b->lastReceivedTS,
t->nextTimestamp+nsamps);
if ( b->lastReceivedTS > b->lastWroteTS ) {
// The caller momdem (NB, UE, ...) must send Tx in advance, so we fill TX if Rx is in advance
// This occurs for example when UE is in sync mode: it doesn't transmit
// with USRP, it seems ok: if "tx stream" is off, we may consider it actually cuts the Tx power
struct complex16 v={0};
void *samplesVoid[b->th.nbAnt];
for ( int i=0; i <b->th.nbAnt; i++)
samplesVoid[i]=(void*)&v;
rfsimulator_write(device, b->lastReceivedTS, samplesVoid, 1, b->th.nbAnt, 0);
}
}
if ( b->circularBuf )
if ( t->nextTimestamp+nsamps > b->lastReceivedTS ) {
have_to_wait=true; have_to_wait=true;
break; break;
} }
...@@ -529,7 +547,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -529,7 +547,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
for (int sock=0; sock<FD_SETSIZE; sock++) { for (int sock=0; sock<FD_SETSIZE; sock++) {
buffer_t *ptr=&t->buf[sock]; buffer_t *ptr=&t->buf[sock];
if ( ptr->circularBuf && ptr->alreadyRead ) { if ( ptr->circularBuf ) {
bool reGenerateChannel=false; bool reGenerateChannel=false;
//fixme: when do we regenerate //fixme: when do we regenerate
......
...@@ -80,7 +80,7 @@ unsigned short config_frames[4] = {2,9,11,13}; ...@@ -80,7 +80,7 @@ unsigned short config_frames[4] = {2,9,11,13};
//#include "PHY/TOOLS/time_meas.h" //#include "PHY/TOOLS/time_meas.h"
#ifndef OPENAIR2 #ifndef OPENAIR2
#include "UTIL/OTG/otg_vars.h" #include "UTIL/OTG/otg_vars.h"
#endif #endif
...@@ -91,6 +91,7 @@ unsigned short config_frames[4] = {2,9,11,13}; ...@@ -91,6 +91,7 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "system.h" #include "system.h"
#include "lte-softmodem.h" #include "lte-softmodem.h"
#include "NB_IoT_interface.h" #include "NB_IoT_interface.h"
...@@ -107,6 +108,10 @@ pthread_mutex_t sync_mutex; ...@@ -107,6 +108,10 @@ pthread_mutex_t sync_mutex;
int sync_var=-1; //!< protected by mutex \ref sync_mutex. int sync_var=-1; //!< protected by mutex \ref sync_mutex.
int config_sync_var=-1; int config_sync_var=-1;
uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
volatile int oai_exit = 0; volatile int oai_exit = 0;
uint32_t downlink_frequency[MAX_NUM_CCs][4]; uint32_t downlink_frequency[MAX_NUM_CCs][4];
...@@ -145,10 +150,18 @@ char ref[128] = "internal"; ...@@ -145,10 +150,18 @@ char ref[128] = "internal";
char channels[128] = "0"; char channels[128] = "0";
int rx_input_level_dBm; int rx_input_level_dBm;
int otg_enabled; int otg_enabled;
uint8_t exit_missed_slots=1; uint8_t exit_missed_slots=1;
uint64_t num_missed_slots=0; // counter for the number of missed slots uint64_t num_missed_slots=0; // counter for the number of missed slots
extern void reset_opp_meas(void);
extern void print_opp_meas(void);
extern void init_eNB_afterRU(void); extern void init_eNB_afterRU(void);
extern void phy_free_RU(RU_t *); extern void phy_free_RU(RU_t *);
...@@ -159,11 +172,73 @@ int numerology = 0; ...@@ -159,11 +172,73 @@ int numerology = 0;
THREAD_STRUCT thread_struct; THREAD_STRUCT thread_struct;
/* struct for ethernet specific parameters given in eNB conf file */ /* struct for ethernet specific parameters given in eNB conf file */
eth_params_t *eth_params; eth_params_t *eth_params;
double cpuf; double cpuf;
/* forward declarations */
/* forward declarations */ /* forward declarations */
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
/*---------------------BMC: timespec helpers -----------------------------*/
struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
struct timespec clock_difftime(struct timespec start, struct timespec end) {
struct timespec temp;
if ((end.tv_nsec-start.tv_nsec)<0) {
temp.tv_sec = end.tv_sec-start.tv_sec-1;
temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
} else {
temp.tv_sec = end.tv_sec-start.tv_sec;
temp.tv_nsec = end.tv_nsec-start.tv_nsec;
}
return temp;
}
void print_difftimes(void) {
#ifdef DEBUG
printf("difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec);
#else
LOG_I(HW,"difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec);
#endif
}
void update_difftimes(struct timespec start, struct timespec end) {
struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 };
int changed = 0;
diff_time = clock_difftime(start, end);
if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) {
min_diff_time.tv_nsec = diff_time.tv_nsec;
changed = 1;
}
if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) {
max_diff_time.tv_nsec = diff_time.tv_nsec;
changed = 1;
}
#if 1
if (changed) print_difftimes();
#endif
}
/*------------------------------------------------------------------------*/
unsigned int build_rflocal(int txi, int txq, int rxi, int rxq) {
return (txi + (txq<<6) + (rxi<<12) + (rxq<<18));
}
unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) {
return (dcoff_i_rxfe + (dcoff_q_rxfe<<8));
}
void signal_handler(int sig) { void signal_handler(int sig) {
void *array[10]; void *array[10];
size_t size; size_t size;
...@@ -181,6 +256,7 @@ void signal_handler(int sig) { ...@@ -181,6 +256,7 @@ void signal_handler(int sig) {
} }
} }
void exit_function(const char *file, const char *function, const int line, const char *s) { void exit_function(const char *file, const char *function, const int line, const char *s) {
int ru_id; int ru_id;
...@@ -209,6 +285,7 @@ void exit_function(const char *file, const char *function, const int line, const ...@@ -209,6 +285,7 @@ void exit_function(const char *file, const char *function, const int line, const
exit(1); exit(1);
} }
static void get_options(void) { static void get_options(void) {
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
get_common_options(); get_common_options();
...@@ -232,6 +309,10 @@ static void get_options(void) { ...@@ -232,6 +309,10 @@ static void get_options(void) {
} }
} }
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
int CC_id; int CC_id;
...@@ -446,11 +527,14 @@ int main( int argc, char **argv ) { ...@@ -446,11 +527,14 @@ int main( int argc, char **argv ) {
int CC_id = 0; int CC_id = 0;
int ru_id; int ru_id;
AssertFatal(load_configmodule(argc,argv,0) != NULL, if ( load_configmodule(argc,argv,0) == NULL) {
"[SOFTMODEM] Error, configuration module init failed\n"); exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
mode = normal_txrx; mode = normal_txrx;
logInit(); logInit();
printf("Reading in command-line options\n");
get_options (); get_options ();
AssertFatal(!CONFIG_ISFLAGSET(CONFIG_ABORT),"Getting configuration failed\n"); AssertFatal(!CONFIG_ISFLAGSET(CONFIG_ABORT),"Getting configuration failed\n");
...@@ -472,14 +556,21 @@ int main( int argc, char **argv ) { ...@@ -472,14 +556,21 @@ int main( int argc, char **argv ) {
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
fprintf(stderr,"Getting configuration failed\n");
exit(-1);
}
#if T_TRACER #if T_TRACER
T_Config_Init(); T_Config_Init();
#endif #endif
//randominit (0); //randominit (0);
set_taus_seed (0); set_taus_seed (0);
printf("configuring for RAU/RRU\n");
if (opp_enabled ==1) if (opp_enabled ==1) {
reset_opp_meas(); reset_opp_meas();
}
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// allows to forward in wireshark L2 protocol for decoding // allows to forward in wireshark L2 protocol for decoding
...@@ -491,8 +582,9 @@ int main( int argc, char **argv ) { ...@@ -491,8 +582,9 @@ int main( int argc, char **argv ) {
/* Start the agent. If it is turned off in the configuration, it won't start */ /* Start the agent. If it is turned off in the configuration, it won't start */
RCconfig_flexran(); RCconfig_flexran();
for (i = 0; i < RC.nb_inst; i++) for (i = 0; i < RC.nb_inst; i++) {
flexran_agent_start(i); flexran_agent_start(i);
}
/* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks /* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks
* for monolithic/F1 modes */ * for monolithic/F1 modes */
...@@ -521,7 +613,7 @@ int main( int argc, char **argv ) { ...@@ -521,7 +613,7 @@ int main( int argc, char **argv ) {
ctxt.subframe = 0; ctxt.subframe = 0;
pdcp_run(&ctxt); pdcp_run(&ctxt);
} }
/* start threads if only L1 or not a CU */ /* start threads if only L1 or not a CU */
if (RC.nb_inst == 0 || !NODE_IS_CU(RC.rrc[0]->node_type)) { if (RC.nb_inst == 0 || !NODE_IS_CU(RC.rrc[0]->node_type)) {
// init UE_PF_PO and mutex lock // init UE_PF_PO and mutex lock
...@@ -531,53 +623,56 @@ int main( int argc, char **argv ) { ...@@ -531,53 +623,56 @@ int main( int argc, char **argv ) {
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
rt_sleep_ns(10*100000000ULL); rt_sleep_ns(10*100000000ULL);
if (NFAPI_MODE!=NFAPI_MONOLITHIC) { if (NFAPI_MODE!=NFAPI_MONOLITHIC) {
LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
} }
if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF
#if defined(PRE_SCD_THREAD) #if defined(PRE_SCD_THREAD)
init_ru_vnf(); // ru pointer is necessary for pre_scd. init_ru_vnf(); // ru pointer is necessary for pre_scd.
#endif #endif
wait_nfapi_init("main?"); wait_nfapi_init("main?");
} }
LOG_I(ENB_APP,"START MAIN THREADS\n"); LOG_I(ENB_APP,"START MAIN THREADS\n");
// start the main threads // start the main threads
number_of_cards = 1; number_of_cards = 1;
printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst);
if (RC.nb_L1_inst > 0) { if (RC.nb_L1_inst > 0) {
printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
// for (inst=0;inst<RC.nb_L1_inst;inst++) // for (inst=0;inst<RC.nb_L1_inst;inst++)
// for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0); // for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0);
} }
printf("wait_eNBs()\n");
wait_eNBs(); // no need to wait: openair_rrc_eNB_configuration() is called earlier from this thread
printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); // openair_rrc_eNB_configuration()->init_SI()->rrc_mac_config_req_eNB ()->phy_config_request () sets the wait_eNBs() tested flag
// wait_eNBs();
// RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. // printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU);
// but RU thread deals with pre_scd and this is necessary in VNF and simulator.
// some initialization is necessary and init_ru_vnf do this. // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator.
if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { // but RU thread deals with pre_scd and this is necessary in VNF and simulator.
printf("Initializing RU threads\n"); // some initialization is necessary and init_ru_vnf do this.
if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) {
printf("Initializing RU threads\n");
init_RU(get_softmodem_params()->rf_config_file,get_softmodem_params()->clock_source,get_softmodem_params()->timing_source,get_softmodem_params()->send_dmrs_sync); init_RU(get_softmodem_params()->rf_config_file,get_softmodem_params()->clock_source,get_softmodem_params()->timing_source,get_softmodem_params()->send_dmrs_sync);
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
RC.ru[ru_id]->rf_map.card=0; RC.ru[ru_id]->rf_map.card=0;
RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
}
} }
config_sync_var=0; config_sync_var=0;
if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF
wait_nfapi_init("main?"); wait_nfapi_init("main?");
} }
printf("wait RUs\n"); printf("wait RUs\n");
// end of CI modifications // end of CI modifications
// fixme: very weird usage of bitmask // fixme: very weird usage of bitmask
...@@ -604,6 +699,7 @@ int main( int argc, char **argv ) { ...@@ -604,6 +699,7 @@ int main( int argc, char **argv ) {
pthread_mutex_unlock(&sync_mutex); pthread_mutex_unlock(&sync_mutex);
config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS); config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
} }
// wait for end of program // wait for end of program
LOG_UI(ENB_APP,"TYPE <CTRL-C> TO TERMINATE\n"); LOG_UI(ENB_APP,"TYPE <CTRL-C> TO TERMINATE\n");
// CI -- Flushing the std outputs for the previous marker to show on the eNB / DU / CU log file // CI -- Flushing the std outputs for the previous marker to show on the eNB / DU / CU log file
...@@ -648,17 +744,17 @@ int main( int argc, char **argv ) { ...@@ -648,17 +744,17 @@ int main( int argc, char **argv ) {
for(ru_id=0; ru_id<RC.nb_RU; ru_id++) { for(ru_id=0; ru_id<RC.nb_RU; ru_id++) {
if (RC.ru[ru_id]->rfdevice.trx_end_func) { if (RC.ru[ru_id]->rfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL; RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
} }
if (RC.ru[ru_id]->ifdevice.trx_end_func) { if (RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL; RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
} }
} }
} }
terminate_opt(); terminate_opt();
logClean(); logClean();
printf("Bye.\n"); printf("Bye.\n");
......
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