make multiple config instead of one implicit global

This commit is contained in:
Laurent THOMAS
2023-11-10 10:23:11 +01:00
parent 82597e7e8f
commit f50d5f5a9b
74 changed files with 1316 additions and 1118 deletions
+1 -1
View File
@@ -2889,7 +2889,7 @@ RU_t **RCconfig_RU(int nb_RU,int nb_L1_inst,PHY_VARS_eNB ***eNB,uint64_t *ru_mas
int i = 0;
paramdef_t RUParams[] = RUPARAMS_DESC;
paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0};
config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL);
config_getlist(config_get_if(), &RUParamList, RUParams, sizeofArray(RUParams), NULL);
RU_t **ru=NULL;
if ( RUParamList.numelt > 0) {
ru = (RU_t **)malloc(nb_RU*sizeof(RU_t *));
+7 -11
View File
@@ -289,10 +289,10 @@ void exit_function(const char *file, const char *function, const int line, const
}
}
static void get_options(void) {
static void get_options(configmodule_interface_t *cfg)
{
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
get_common_options(SOFTMODEM_ENB_BIT );
get_common_options(cfg, SOFTMODEM_ENB_BIT);
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) {
@@ -313,10 +313,6 @@ static void get_options(void) {
}
}
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
int CC_id;
@@ -438,7 +434,7 @@ static void wait_nfapi_init(char *thread_name) {
pthread_mutex_unlock(&nfapi_sync_mutex);
printf( "NFAPI: got sync (%s)\n", thread_name);
}
configmodule_interface_t *uniqCfg = NULL;
int main ( int argc, char **argv )
{
int CC_id = 0;
@@ -446,7 +442,7 @@ int main ( int argc, char **argv )
start_background_system();
if ( load_configmodule(argc,argv,0) == NULL) {
if ((uniqCfg = load_configmodule(argc, argv, 0)) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
@@ -454,7 +450,7 @@ int main ( int argc, char **argv )
logInit();
set_latency_target();
printf("Reading in command-line options\n");
get_options ();
get_options(uniqCfg);
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
@@ -617,7 +613,7 @@ int main ( int argc, char **argv )
create_tasks_mbms(1);
sleep(1);
config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
config_check_unknown_cmdlineopt(uniqCfg, CONFIG_CHECKALLSECTIONS);
// wait for end of program
LOG_UI(ENB_APP,"TYPE <CTRL-C> TO TERMINATE\n");
+10 -10
View File
@@ -270,7 +270,8 @@ void exit_function(const char *file, const char *function, const int line, const
extern int16_t dlsch_demod_shift;
uint16_t node_number;
static void get_options(void) {
static void get_options(configmodule_interface_t *cfg)
{
int CC_id=0;
int tddflag=0;
int dumpframe=0;
@@ -281,11 +282,11 @@ static void get_options(void) {
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
/* unknown parameters on command line will be checked in main
after all init have been performed */
get_common_options(SOFTMODEM_4GUE_BIT );
get_common_options(cfg, SOFTMODEM_4GUE_BIT);
paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC;
paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC;
config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL);
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
config_process_cmdline(cfg, cmdline_uemodeparams, sizeofArray(cmdline_uemodeparams), NULL);
config_process_cmdline(cfg, cmdline_ueparams, sizeofArray(cmdline_ueparams), NULL);
nfapi_setmode(nfapi_mode);
get_softmodem_params()->hw_timing_advance = timingadv;
@@ -356,7 +357,6 @@ static void get_options(void) {
}
}
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
int CC_id;
@@ -518,6 +518,7 @@ AssertFatal(false,"");
}
int NB_UE_INST = 1;
configmodule_interface_t *uniqCfg = NULL;
int main( int argc, char **argv ) {
@@ -525,11 +526,10 @@ int main( int argc, char **argv ) {
uint8_t abstraction_flag=0;
// Default value for the number of UEs. It will hold,
// if not changed from the command line option --num-ues
configmodule_interface_t *config_mod;
start_background_system();
config_mod = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY);
uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY);
if (config_mod == NULL) {
if (uniqCfg == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
@@ -541,7 +541,7 @@ int main( int argc, char **argv ) {
for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23;
get_options ();
get_options(uniqCfg);
if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
sf_ahead = 1;
@@ -680,7 +680,7 @@ int main( int argc, char **argv ) {
if(IS_SOFTMODEM_DOSCOPE)
load_softscope("ue",NULL);
config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
config_check_unknown_cmdlineopt(uniqCfg, CONFIG_CHECKALLSECTIONS);
printf("Sending sync to all threads (%p,%p,%p)\n",&sync_var,&sync_cond,&sync_mutex);
pthread_mutex_lock(&sync_mutex);
sync_var=0;
+10 -15
View File
@@ -115,20 +115,15 @@ void exit_function(const char *file, const char *function, const int line, const
}
}
static void get_options(void) {
static void get_options(configmodule_interface_t *cfg)
{
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
get_common_options(SOFTMODEM_ENB_BIT );
get_common_options(cfg, SOFTMODEM_ENB_BIT);
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
//RCConfig();
// RCConfig();
}
extern void phy_free_RU(RU_t *);
nfapi_mode_t nfapi_getmode(void) {
@@ -144,17 +139,17 @@ void wait_eNBs(void){ return; }
uint64_t downlink_frequency[MAX_NUM_CCs][4];
configmodule_interface_t *uniqCfg = NULL;
int main ( int argc, char **argv )
{
if ( load_configmodule(argc,argv,0) == NULL) {
if ((uniqCfg = load_configmodule(argc, argv, 0)) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
logInit();
printf("Reading in command-line options\n");
get_options ();
get_options(uniqCfg);
if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
fprintf(stderr,"Getting configuration failed\n");
@@ -180,7 +175,7 @@ int main ( int argc, char **argv )
paramdef_t RUParams[] = RUPARAMS_DESC;
paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0};
config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL);
config_getlist(config_get_if(), &RUParamList, RUParams, sizeofArray(RUParams), NULL);
int j=0;
uint64_t ru_mask=1;
@@ -366,8 +361,8 @@ int main ( int argc, char **argv )
phy_free_RU(ru);
free_lte_top();
end_configmodule();
end_configmodule(uniqCfg);
if (ru->rfdevice.trx_end_func) {
ru->rfdevice.trx_end_func(&ru->rfdevice);
ru->rfdevice.trx_end_func = NULL;
+2 -2
View File
@@ -111,11 +111,11 @@ f1ap_cudu_inst_t *getCxt(instance_t instanceP)
fake.gtpInst = e1inst->gtpInstF1U;
return &fake;
}
configmodule_interface_t *uniqCfg = NULL;
int main(int argc, char **argv)
{
/// static configuration for NR at the moment
if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == NULL) {
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
logInit();
+8 -11
View File
@@ -94,16 +94,13 @@ extern void nr_phy_config_request(NR_PHY_Config_t *gNB);
//extern PARALLEL_CONF_t get_thread_parallel_conf(void);
//extern WORKER_CONF_t get_thread_worker_conf(void);
void init_NR_RU(char *);
void start_NR_RU();
void stop_RU(int nb_ru);
void configure_ru(int idx, void *arg);
void configure_rru(int idx, void *arg);
int attach_rru(RU_t *ru);
int connect_rau(RU_t *ru);
static void NRRCconfig_RU(void);
static void NRRCconfig_RU(configmodule_interface_t *cfg);
extern int emulate_rf;
extern int numerology;
@@ -1784,7 +1781,8 @@ void set_function_spec_param(RU_t *ru) {
} // switch on interface type
}
void init_NR_RU(char *rf_config_file) {
void init_NR_RU(configmodule_interface_t *cfg, char *rf_config_file)
{
int ru_id;
RU_t *ru;
PHY_VARS_gNB *gNB_RC;
@@ -1797,7 +1795,7 @@ void init_NR_RU(char *rf_config_file) {
pthread_cond_init(&RC.ru_cond,NULL);
// read in configuration file)
printf("configuring RU from file\n");
NRRCconfig_RU();
NRRCconfig_RU(cfg);
LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",RC.nb_nr_L1_inst,RC.nb_RU,get_nprocs());
LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU);
@@ -1884,7 +1882,6 @@ void start_NR_RU()
start_RU_proc(ru);
}
void stop_RU(int nb_ru) {
for (int inst = 0; inst < nb_ru; inst++) {
LOG_I(PHY, "Stopping RU %d processing threads\n", inst);
@@ -1895,19 +1892,19 @@ void stop_RU(int nb_ru) {
/* --------------------------------------------------------*/
/* from here function to use configuration module */
static void NRRCconfig_RU(void)
static void NRRCconfig_RU(configmodule_interface_t *cfg)
{
paramdef_t RUParams[] = RUPARAMS_DESC;
paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0};
config_getlist(&RUParamList, RUParams, sizeof(RUParams)/sizeof(paramdef_t), NULL);
config_getlist(cfg, &RUParamList, RUParams, sizeofArray(RUParams), NULL);
paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
paramdef_t GNBParams[] = GNBPARAMS_DESC;
paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST, NULL, 0};
config_get(GNBSParams, sizeof(GNBSParams) / sizeof(paramdef_t), NULL);
config_get(cfg, GNBSParams, sizeofArray(GNBSParams), NULL);
int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt;
AssertFatal(num_gnbs > 0, "Failed to parse config file no gnbs %s \n", GNB_CONFIG_STRING_ACTIVE_GNBS);
config_getlist(&GNBParamList, GNBParams, sizeof(GNBParams) / sizeof(paramdef_t), NULL);
config_getlist(cfg, &GNBParamList, GNBParams, sizeofArray(GNBParams), NULL);
int N1 = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_N1_IDX].iptr;
int N2 = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_N2_IDX].iptr;
int XP = *GNBParamList.paramarray[0][GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr;
+15 -14
View File
@@ -288,7 +288,7 @@ void exit_function(const char *file, const char *function, const int line, const
}
}
static int create_gNB_tasks(ngran_node_t node_type)
static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cfg)
{
uint32_t gnb_nb = RC.nb_nr_inst;
uint32_t gnb_id_start = 0;
@@ -297,12 +297,13 @@ static int create_gNB_tasks(ngran_node_t node_type)
itti_wait_ready(1);
LOG_I(PHY, "%s() Task ready initialize structures\n", __FUNCTION__);
RCconfig_verify(node_type);
RCconfig_verify(cfg, node_type);
RCconfig_NR_L1();
RCconfig_nr_prs();
if (RC.nb_nr_macrlc_inst>0) RCconfig_nr_macrlc();
if (RC.nb_nr_macrlc_inst > 0)
RCconfig_nr_macrlc(cfg);
LOG_I(PHY, "%s() RC.nb_nr_L1_inst:%d\n", __FUNCTION__, RC.nb_nr_L1_inst);
@@ -367,8 +368,8 @@ static int create_gNB_tasks(ngran_node_t node_type)
paramdef_t NETParams[] = GNBNETPARAMS_DESC;
char aprefix[MAX_OPTNAME_SIZE*2 + 8];
sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
config_get(cfg, NETParams, sizeofArray(NETParams), aprefix);
for(int i = GNB_INTERFACE_NAME_FOR_NG_AMF_IDX; i <= GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX; i++) {
if( NETParams[i].strptr == NULL) {
LOG_E(NGAP, "No AMF configuration in the file.\n");
@@ -426,12 +427,12 @@ static int create_gNB_tasks(ngran_node_t node_type)
return 0;
}
static void get_options(void) {
static void get_options(configmodule_interface_t *cfg)
{
paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC_GNB ;
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
get_common_options(SOFTMODEM_GNB_BIT );
config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
get_common_options(cfg, SOFTMODEM_GNB_BIT);
config_process_cmdline(cfg, cmdline_params, sizeofArray(cmdline_params), NULL);
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) {
@@ -448,7 +449,6 @@ static void get_options(void) {
if(worker_config != NULL) set_worker_conf(worker_config);
}
void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs],
NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
@@ -570,12 +570,13 @@ void init_pdcp(void) {
}
}
configmodule_interface_t *uniqCfg = NULL;
int main( int argc, char **argv ) {
int ru_id, CC_id = 0;
start_background_system();
///static configuration for NR at the moment
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
@@ -590,7 +591,7 @@ int main( int argc, char **argv ) {
logInit();
set_latency_target();
printf("Reading in command-line options\n");
get_options ();
get_options(uniqCfg);
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
@@ -639,7 +640,7 @@ int main( int argc, char **argv ) {
// don't create if node doesn't connect to RRC/S1/GTP
const ngran_node_t node_type = get_node_type();
if (NFAPI_MODE != NFAPI_MODE_PNF) {
int ret = create_gNB_tasks(node_type);
int ret = create_gNB_tasks(node_type, uniqCfg);
AssertFatal(ret == 0, "cannot create ITTI tasks\n");
}
@@ -673,7 +674,7 @@ int main( int argc, char **argv ) {
int sl_ahead=6;
if (RC.nb_RU >0) {
printf("Initializing RU threads\n");
init_NR_RU(get_softmodem_params()->rf_config_file);
init_NR_RU(uniqCfg, get_softmodem_params()->rf_config_file);
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
RC.ru[ru_id]->rf_map.card=0;
+1 -1
View File
@@ -52,7 +52,7 @@ extern void stop_gNB(int);
extern void kill_gNB_proc(int inst);
// In nr-ru.c
extern void init_NR_RU(char *);
extern void init_NR_RU(configmodule_interface_t *cfg, char *);
extern void init_RU_proc(RU_t *ru);
extern void start_NR_RU(void);
extern void stop_RU(int nb_ru);
+13 -12
View File
@@ -258,12 +258,11 @@ uint64_t set_nrUE_optmask(uint64_t bitmask) {
nrUE_params_t *get_nrUE_params(void) {
return &nrUE_params;
}
static void get_options(void) {
static void get_options(configmodule_interface_t *cfg)
{
paramdef_t cmdline_params[] =CMDLINE_NRUEPARAMS_DESC ;
int numparams = sizeof(cmdline_params)/sizeof(paramdef_t);
config_get(cmdline_params,numparams,NULL);
int numparams = sizeofArray(cmdline_params);
config_get(cfg, cmdline_params, numparams, NULL);
AssertFatal(rrc_config_path == NULL, "the option \"rrc_config_path\" is deprecated. Please use --reconfig-file and --rbconfig-file separately to point to files reconfig.raw and rbconfig.raw\n");
@@ -414,9 +413,10 @@ static void trigger_deregistration(int sig)
}
}
static void get_channel_model_mode() {
static void get_channel_model_mode(configmodule_interface_t *cfg)
{
paramdef_t GNBParams[] = GNBPARAMS_DESC;
config_get(GNBParams, sizeof(GNBParams)/sizeof(paramdef_t), NULL);
config_get(cfg, GNBParams, sizeofArray(GNBParams), NULL);
int num_xp_antennas = *GNBParams[GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr;
if (num_xp_antennas == 2)
@@ -426,6 +426,7 @@ static void get_channel_model_mode() {
}
int NB_UE_INST = 1;
configmodule_interface_t *uniqCfg = NULL;
int main( int argc, char **argv ) {
int set_exe_prio = 1;
@@ -440,7 +441,7 @@ int main( int argc, char **argv ) {
PHY_VARS_NR_UE *UE[MAX_NUM_CCs];
start_background_system();
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
//set_softmodem_sighandler();
@@ -451,9 +452,9 @@ int main( int argc, char **argv ) {
logInit();
// get options and fill parameters from configuration file
get_options (); //Command-line options specific for NRUE
get_options(uniqCfg); // Command-line options specific for NRUE
get_common_options(SOFTMODEM_5GUE_BIT);
get_common_options(uniqCfg, SOFTMODEM_5GUE_BIT);
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
#if T_TRACER
T_Config_Init();
@@ -496,7 +497,7 @@ int main( int argc, char **argv ) {
PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE *)*MAX_NUM_CCs);
if (get_softmodem_params()->emulate_l1) {
RCconfig_nr_ue_macrlc();
get_channel_model_mode();
get_channel_model_mode(uniqCfg);
}
if (get_softmodem_params()->do_ra)
@@ -568,7 +569,7 @@ int main( int argc, char **argv ) {
// Sleep a while before checking all parameters have been used
// Some are used directly in external threads, asynchronously
sleep(2);
config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
config_check_unknown_cmdlineopt(uniqCfg, CONFIG_CHECKALLSECTIONS);
// wait for end of program
printf("Entering ITTI signals handler\n");
+6 -5
View File
@@ -91,7 +91,8 @@ char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr) {
return "???";
}
void get_common_options(uint32_t execmask) {
void get_common_options(configmodule_interface_t *cfg, uint32_t execmask)
{
int32_t stats_disabled = 0;
uint32_t online_log_messages=0;
uint32_t glog_level=0 ;
@@ -107,16 +108,16 @@ void get_common_options(uint32_t execmask) {
checkedparam_t cmdline_CheckParams[] = CMDLINE_PARAMS_CHECK_DESC;
int numparams = sizeofArray(cmdline_params);
config_set_checkfunctions(cmdline_params, cmdline_CheckParams, numparams);
config_get(cmdline_params, numparams, NULL);
config_get(cfg, cmdline_params, numparams, NULL);
nfapi_index = config_paramidx_fromname(cmdline_params, numparams, "nfapi");
AssertFatal(nfapi_index >= 0,"Index for nfapi config option not found!");
nfapi_mode = config_get_processedint(&cmdline_params[nfapi_index]);
nfapi_mode = config_get_processedint(cfg, &cmdline_params[nfapi_index]);
paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ;
checkedparam_t cmdline_log_CheckParams[] = CMDLINE_LOGPARAMS_CHECK_DESC;
int numlogparams = sizeof(cmdline_logparams) / sizeof(paramdef_t);
int numlogparams = sizeofArray(cmdline_logparams);
config_set_checkfunctions(cmdline_logparams, cmdline_log_CheckParams, numlogparams);
config_get(cmdline_logparams, numlogparams, NULL);
config_get(cfg, cmdline_logparams, numlogparams, NULL);
if(config_isparamset(cmdline_logparams,config_paramidx_fromname(cmdline_logparams,numparams, CONFIG_FLOG_OPT))) {
set_glog_onlinelog(online_log_messages);
+1 -1
View File
@@ -359,7 +359,7 @@ extern uint64_t get_softmodem_optmask(void);
extern uint64_t set_softmodem_optmask(uint64_t bitmask);
extern uint64_t clear_softmodem_optmask(uint64_t bitmask);
extern softmodem_params_t *get_softmodem_params(void);
extern void get_common_options(uint32_t execmask);
extern void get_common_options(configmodule_interface_t *cfg, uint32_t execmask);
extern char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr);
#define SOFTMODEM_RTSIGNAL (SIGRTMIN+1)
extern void set_softmodem_sighandler(void);