From 5d2a1ace17a524287aec5572c1bfba0752e0a164 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 22 Oct 2024 10:32:35 +0200 Subject: [PATCH] nr-{ue,}softmodem: Check for correct modes THere are four possibilities, for the three options (phy_test, do_ra, nsa): - None is set -> SA - Only one is set of each -> corresponding mode Introduce a function softmodem_verify_mode() to check for these. --- executables/nr-softmodem.c | 6 +----- executables/nr-uesoftmodem.c | 9 +++------ executables/softmodem-common.c | 18 ++++++++++++++++++ executables/softmodem-common.h | 1 + 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index e952a525a4..c402b0ed08 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -605,11 +605,7 @@ int main( int argc, char **argv ) { LOG_W(UTIL, "no SYS_NICE capability: cannot set thread priority and affinity, consider running with sudo for optimum performance\n"); - if (get_softmodem_params()->do_ra) - AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); - - if (get_softmodem_params()->sa) - AssertFatal(get_softmodem_params()->phy_test == 0,"Standalone mode and phy_test are mutually exclusive\n"); + softmodem_verify_mode(get_softmodem_params()); #if T_TRACER T_Config_Init(); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 51520d031f..519c7ffbc4 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -407,6 +407,9 @@ int main(int argc, char **argv) get_common_options(uniqCfg, SOFTMODEM_5GUE_BIT); CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); + + softmodem_verify_mode(get_softmodem_params()); + #if T_TRACER T_Config_Init(); #endif @@ -461,12 +464,6 @@ int main(int argc, char **argv) get_channel_model_mode(uniqCfg); } - if (get_softmodem_params()->do_ra) - AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); - - if (get_softmodem_params()->sa) - AssertFatal(get_softmodem_params()->phy_test == 0,"Standalone mode and phy_test are mutually exclusive\n"); - if (!get_softmodem_params()->nsa && get_softmodem_params()->emulate_l1) start_oai_nrue_threads(); diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index d566767902..394235e8f0 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -174,6 +174,24 @@ void get_common_options(configmodule_interface_t *cfg, uint32_t execmask) if (stats_disabled) set_softmodem_optmask(SOFTMODEM_NOSTATS_BIT); } + +void softmodem_verify_mode(const softmodem_params_t *p) +{ + if (IS_SA_MODE(p)) { + LOG_I(UTIL, "running in SA mode (no --phy-test, --do-ra, --nsa option present)\n"); + return; + } + + if (p->phy_test) + LOG_I(UTIL, "running in phy-test mode (--phy-test)\n"); + if (p->do_ra) + LOG_I(UTIL, "running in do-ra mode (--do-ra)\n"); + if (p->nsa) + LOG_I(UTIL, "running in NSA mode (--nsa)\n"); + int num_modes = p->phy_test + p->do_ra + p->nsa; + AssertFatal(num_modes == 1, "--phy-test, --do-ra, and --nsa are mutually exclusive\n"); +} + void softmodem_printresources(int sig, telnet_printfunc_t pf) { struct rusage usage; struct timespec stop; diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index ee2339b85c..6707e38c2e 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -330,6 +330,7 @@ typedef struct { } softmodem_params_t; #define IS_SA_MODE(sM_params) (!(sM_params)->phy_test && !(sM_params)->do_ra && !(sM_params)->nsa) +void softmodem_verify_mode(const softmodem_params_t *p); uint64_t get_softmodem_optmask(void); uint64_t set_softmodem_optmask(uint64_t bitmask);