From 1fdbf2906f6baf4678703ee699fdcf3f32b9196e Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Fri, 14 Mar 2025 09:59:01 +0000 Subject: [PATCH 1/6] feat(NR PHY simulators): add a SIGINT handler to some PHY simulators When using T2 virtual functions, it is important to properly stop DPDK and free the device. Otherwise the virtual functions may be blocked and a restart of the admin application is necessary. Up to now, SIGINT was shutting down the PHY simulators without freeing the device. This commit adds a signal handler to handle SIGINT in a way that allow to properly free the device. This feature is first added to the PHY simulators that use the T2 which are `nr_ulsim`, `nr_dlsim`, `nr_ulschsim` and `nr_dlschsim`. --- openair1/SIMULATION/NR_PHY/dlschsim.c | 8 ++++++-- openair1/SIMULATION/NR_PHY/dlsim.c | 10 +++++++--- openair1/SIMULATION/NR_PHY/nr_dummy_functions.c | 10 ++++++++++ openair1/SIMULATION/NR_PHY/nr_unitary_defs.h | 11 +++++++++++ openair1/SIMULATION/NR_PHY/ulschsim.c | 8 ++++++-- openair1/SIMULATION/NR_PHY/ulsim.c | 10 +++++++--- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 977970c9f7..14adffad9b 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -100,6 +100,10 @@ configmodule_interface_t *uniqCfg = NULL; int main(int argc, char **argv) { + stop = false; + __attribute__((unused)) struct sigaction oldaction; + sigaction(SIGINT, &sigint_action, &oldaction); + int i; double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; double snr_step = 0.1; @@ -519,11 +523,11 @@ int main(int argc, char **argv) nr_dlsch_encoding(gNB, &msgDataTx, frame, slot, frame_parms, output, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - for (SNR = snr0; SNR < snr1; SNR += snr_step) { + for (SNR = snr0; SNR < snr1 && !stop; SNR += snr_step) { n_errors = 0; n_false_positive = 0; - for (trial = 0; trial < n_trials; trial++) { + for (trial = 0; trial < n_trials && !stop; trial++) { for (i = 0; i < available_bits; i++) { #ifdef DEBUG_CODER if ((i&0xf)==0) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 76c8881945..95c32bdb94 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -266,6 +266,10 @@ int NB_UE_INST = 1; configmodule_interface_t *uniqCfg = NULL; int main(int argc, char **argv) { + stop = false; + __attribute__((unused)) struct sigaction oldaction; + sigaction(SIGINT, &sigint_action, &oldaction); + FILE *csv_file = NULL; char *filename_csv = NULL; setbuf(stdout, NULL); @@ -955,7 +959,7 @@ printf("%d\n", slot); fprintf(csv_file,"avg_round,eff_rate,eff_throughput,TBS\n"); } //--------------- - for (SNR = snr0; SNR < snr1; SNR += .2) { + for (SNR = snr0; SNR < snr1 && !stop; SNR += .2) { varArray_t *table_tx=initVarArray(1000,sizeof(double)); reset_meas(&gNB->phy_proc_tx); @@ -985,7 +989,7 @@ printf("%d\n", slot); n_false_positive = 0; if (n_trials== 1) num_rounds = 1; - for (trial = 0; trial < n_trials; trial++) { + for (trial = 0; trial < n_trials && !stop; trial++) { errors_bit = 0; //multipath channel @@ -1016,7 +1020,7 @@ printf("%d\n", slot); memset(Sched_INFO, 0, sizeof(*Sched_INFO)); Sched_INFO->sched_response_id = -1; - while (round < num_rounds && !UE_harq_process->decodeResult) { + while (round < num_rounds && !UE_harq_process->decodeResult && !stop) { round_trials[round]++; clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot, &Sched_INFO->DL_req, &Sched_INFO->TX_req, &Sched_INFO->UL_dci_req); diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 973aa60930..355c6ad280 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -5,6 +5,16 @@ #include "openair1/PHY/defs_nr_UE.h" #include "position_interface.h" +// Define signal handler to attempt graceful termination +bool stop = false; + +void sigint_handler(int arg) { + static const char msg[] = "\nCaught SIGINT, shutting down\nPress again CTRL+C to force shutdown\n"; + __attribute__((unused)) int unused = write(STDOUT_FILENO, msg, sizeof(msg) - 1); + + stop = true; +} + int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return (0); } int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req) { return (0); } int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req) { return (0); } diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index 504b6a8ed5..38e8df8425 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -36,6 +36,17 @@ #include "NR_ServingCellConfigCommon.h" #include "NR_ServingCellConfig.h" +// Define signal handler to attempt graceful termination +extern bool stop; + +void sigint_handler(int arg); + +const struct sigaction sigint_action = { + .sa_handler = sigint_handler, + // restore handler to default upon entry to the signal handler + .sa_flags = SA_RESETHAND +}; + int oai_exit=0; void exit_function(const char* file, const char* function, const int line, const char *s, const int assert) { diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index fcc986e92c..3027ceff58 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -99,6 +99,10 @@ nrUE_params_t *get_nrUE_params(void) { configmodule_interface_t *uniqCfg = NULL; int main(int argc, char **argv) { + stop = false; + __attribute__((unused)) struct sigaction oldaction; + sigaction(SIGINT, &sigint_action, &oldaction); + int i; double SNR, snr0 = -2.0, snr1 = 2.0, SNR_lin; double snr_step = 0.1; @@ -521,11 +525,11 @@ int main(int argc, char **argv) /////////// //////////////////////////////////////////////////////////////////// - for (SNR = snr0; SNR < snr1; SNR += snr_step) { + for (SNR = snr0; SNR < snr1 && !stop; SNR += snr_step) { n_errors = 0; n_false_positive = 0; - for (trial = 0; trial < n_trials; trial++) { + for (trial = 0; trial < n_trials && !stop; trial++) { errors_bit_uncoded = 0; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 4013951cab..051f452ef1 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -166,6 +166,10 @@ int NB_UE_INST = 1; configmodule_interface_t *uniqCfg = NULL; int main(int argc, char *argv[]) { + stop = false; + __attribute__((unused)) struct sigaction oldaction; + sigaction(SIGINT, &sigint_action, &oldaction); + FILE *csv_file = NULL; char *filename_csv = NULL; int i; @@ -973,7 +977,7 @@ int main(int argc, char *argv[]) //--------------- int ret = 1; int srs_ret = do_SRS; - for (SNR = snr0; SNR <= snr1; SNR += snr_step) { + for (SNR = snr0; SNR <= snr1 && !stop; SNR += snr_step) { varArray_t *table_rx=initVarArray(1000,sizeof(double)); int error_flag = 0; @@ -1012,13 +1016,13 @@ int main(int argc, char *argv[]) int64_t sum_srs_snr = 0; int srs_snr_count = 0; - for (trial = 0; trial < n_trials; trial++) { + for (trial = 0; trial < n_trials && !stop; trial++) { uint8_t round = 0; crc_status = 1; errors_decoding = 0; - while (round < max_rounds && crc_status) { + while (round < max_rounds && crc_status && !stop) { round_trials[round]++; rv_index = nr_get_rv(round % 4); From 0033da561101f7d83d5bf564972b2c8060288cda Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Fri, 14 Mar 2025 15:04:55 +0000 Subject: [PATCH 2/6] fix(nr_ulschsim): make nr_ulschsim functional There was two issues that were making nr_ulschsim non functional: 1. The channel output was not copied to decoder input (llr array) 2. The test on decoding successful outcome was wrong The result was that nr_ulschsim was succesfull whatever were its arguments. This commit fixes the two issues so that nr_ulschsim is now functional. --- openair1/SIMULATION/NR_PHY/ulschsim.c | 30 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 3027ceff58..6e157ac57e 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -448,6 +448,7 @@ int main(int argc, char **argv) NR_gNB_ULSCH_t *ulsch_gNB = &gNB->ulsch[UE_id]; NR_UL_gNB_HARQ_t *harq_process_gNB = ulsch_gNB->harq_process; nfapi_nr_pusch_pdu_t *rel15_ul = &harq_process_gNB->ulsch_pdu; + NR_gNB_PUSCH *pusch_vars = &gNB->pusch_vars[UE_id]; nr_phy_data_tx_t phy_data = {0}; NR_UE_ULSCH_t *ulsch_ue = &phy_data.ulsch; @@ -475,7 +476,6 @@ int main(int argc, char **argv) /////////////////////////////////////////////////// double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc - short channel_output_fixed[16 * 68 * 384]; short channel_output_uncoded[16 * 68 * 384]; unsigned int errors_bit_uncoded = 0; @@ -526,12 +526,13 @@ int main(int argc, char **argv) //////////////////////////////////////////////////////////////////// for (SNR = snr0; SNR < snr1 && !stop; SNR += snr_step) { + errors_bit_uncoded = 0; n_errors = 0; n_false_positive = 0; for (trial = 0; trial < n_trials && !stop; trial++) { - - errors_bit_uncoded = 0; + memset(pusch_vars->llr, 0, (8 * ((3 * 8 * 6144) + 12)) * sizeof(int16_t)); + harq_process_gNB->harq_to_be_cleared = true; for (i = 0; i < available_bits; i++) { @@ -555,16 +556,16 @@ int main(int argc, char **argv) #if 1 SNR_lin = pow(10, SNR / 10.0); sigma = 1.0 / sqrt(2 * SNR_lin); - channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, - modulated_input[i] + sigma * gaussdouble(0.0, 1.0), - qbits); + pusch_vars->llr[i] = (int16_t) quantize(sigma / 4.0 / 4.0, + modulated_input[i] + sigma * gaussdouble(0.0, 1.0), + qbits); #else - channel_output_fixed[i] = (short) quantize(0.01, modulated_input[i], qbits); + pusch_vars->llr[i] = (int16_t) quantize(0.01, modulated_input[i], qbits); #endif - //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); + //printf("pusch_vars->llr[%d]: %d\n", i, pusch_vars->llr[i]); //Uncoded BER - if (channel_output_fixed[i] < 0) + if (pusch_vars->llr[i] < 0) channel_output_uncoded[i] = 1; //QPSK demod else channel_output_uncoded[i] = 0; @@ -581,14 +582,19 @@ int main(int argc, char **argv) exit(-1); #endif nr_ulsch_decoding(gNB, frame_parms, frame, subframe, &G, &UE_id, 1); - bool crc_valid = check_crc(harq_process_gNB->b, lenWithCrc(1, (harq_process_gNB->TBS) << 3), crcType(1, (harq_process_gNB->TBS) << 3)); - if (!crc_valid) { + if (harq_process_gNB->processedSegments == harq_process_gNB->C) { + bool crc_valid = check_crc(harq_process_gNB->b, lenWithCrc(1, (harq_process_gNB->TBS) << 3), crcType(1, (harq_process_gNB->TBS) << 3)); + if (!crc_valid) { + n_false_positive++; + } + } else { n_errors++; } } printf("*****************************************\n"); - printf("SNR %f, BLER %f (false positive %f)\n", SNR, + printf("SNR %f, uncoded BER %f, BLER %f (false positive %f)\n", SNR, + (float) errors_bit_uncoded / (float) available_bits / (float) n_trials, (float) n_errors / (float) n_trials, (float) n_false_positive / (float) n_trials); printf("*****************************************\n"); From 4971b1e62c2d8c4a36b7ddc11716eb8ba9094d68 Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Mon, 17 Mar 2025 10:57:55 +0000 Subject: [PATCH 3/6] feat(NR PHY simulators): Add a SIGINT handler to other NR PHY simulators Even though the remaining NR PHY simulators do not use the T2, we may still feature them with a SIGINT handler for proper termination on SIGINT and for a matter of completeness. The remaining NR PHY simulators are: * nr_pbchsim * nr_prachsim * nr_psbchsim * nr_pucchsim --- openair1/SIMULATION/NR_PHY/pbchsim.c | 8 ++++++-- openair1/SIMULATION/NR_PHY/prachsim.c | 10 +++++++--- openair1/SIMULATION/NR_PHY/psbchsim.c | 16 +++++++--------- openair1/SIMULATION/NR_PHY/pucchsim.c | 8 ++++++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index b8ebf2bb30..d032a9d53c 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -126,6 +126,10 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, configmodule_interface_t *uniqCfg = NULL; int main(int argc, char **argv) { + stop = false; + __attribute__((unused)) struct sigaction oldaction; + sigaction(SIGINT, &sigint_action, &oldaction); + int i,aa,start_symbol; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; double cfo=0; @@ -623,12 +627,12 @@ int main(int argc, char **argv) printf("txlev %d (%f)\n",txlev,10*log10(txlev));*/ - for (SNR=snr0; SNRnb_antennas_tx; aa++) { diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index eb3537650b..0776a6768e 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -129,6 +129,10 @@ int NB_UE_INST = 1; configmodule_interface_t *uniqCfg = NULL; int main(int argc, char **argv){ + stop = false; + __attribute__((unused)) struct sigaction oldaction; + sigaction(SIGINT, &sigint_action, &oldaction); + get_softmodem_params()->sl_mode = 0; double sigma2, sigma2_dB = 0, SNR, snr0 = -2.0, snr1 = 0.0, ue_speed0 = 0.0, ue_speed1 = 0.0; double **s_re, **s_im, **r_re, **r_im, iqim = 0.0, delay_avg = 0, ue_speed = 0, fs=-1, bw; @@ -716,15 +720,15 @@ int main(int argc, char **argv){ uint16_t preamble_rx, preamble_energy; - for (SNR=snr0; SNRmax_Doppler = 1.9076e9*(ue_speed/3.6)/3e8; printf("n_frames %d SNR %f\n",n_frames,SNR); prach_errors=0; - for (trial=0; trial= snr1; SNR -= 1) { - for (int trial = 0; trial < n_trials; trial++) { + for (SNR = snr0; SNR >= snr1 && !stop; SNR -= 1) { + for (int trial = 0; trial < n_trials && !stop; trial++) { for (int i = 0; i < frame_length_complex_samples; i++) { for (int aa = 0; aa < frame_parms->nb_antennas_tx; aa++) { struct complex16 *txdata_ptr = (struct complex16 *)&UE_TX->common_vars.txData[aa][i]; diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index bc022d5bc1..2d97a6a536 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -95,6 +95,10 @@ nrUE_params_t *get_nrUE_params(void) { configmodule_interface_t *uniqCfg = NULL; int main(int argc, char **argv) { + stop = false; + __attribute__((unused)) struct sigaction oldaction; + sigaction(SIGINT, &sigint_action, &oldaction); + int i;//,l; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; double cfo=0; @@ -546,12 +550,12 @@ int main(int argc, char **argv) pucch_GroupHopping_t PUCCH_GroupHopping = pucch_tx_pdu.group_hop_flag + (pucch_tx_pdu.sequence_hop_flag<<1); double tx_level_fp = 100.0; c16_t **rxdataF = gNB->common_vars.rxdataF[0]; - for(SNR = snr0; SNR <= snr1; SNR += 1) { + for(SNR = snr0; SNR <= snr1 && !stop; SNR += 1) { ack_nack_errors=0; sr_errors = 0; n_errors = 0; c16_t **txdataF = gNB->common_vars.txdataF[0]; - for (trial=0; trialofdm_symbol_size*sizeof(int)); if(format==0 && do_DTX==0){ From e68123e06d78e27c7834f6fa6c7fffc6bc6ac93a Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Fri, 21 Mar 2025 10:28:04 +0000 Subject: [PATCH 4/6] fix(NR PHY simulators): Naming coherence & NR PHY simulators common functions object 1. Change the name of `openair1/SIMULATION/NR_PHY/nr_dummy_functions.c` into `openair1/SIMULATION/NR_PHY/nr_unitary_common.c` for naming coherence after adding the SIGINT handler which is not a dummy function. 2. Instead of being built once for every NR PHY simulators, the common functions source file is built once as an object and linked to each simulator. --- CMakeLists.txt | 44 +++++++------------ ..._dummy_functions.c => nr_unitary_common.c} | 0 2 files changed, 15 insertions(+), 29 deletions(-) rename openair1/SIMULATION/NR_PHY/{nr_dummy_functions.c => nr_unitary_common.c} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d608d99c53..e906942632 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1971,29 +1971,25 @@ target_link_libraries(ldpctest PRIVATE -Wl,--whole-archive crc_byte -Wl,--no-whole-archive ) -add_executable(nr_dlschsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c - ) +add_library(physim_common OBJECT ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_unitary_common.c) +target_link_libraries(physim_common PRIVATE UTIL) + +add_executable(nr_dlschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c) target_link_libraries(nr_dlschsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader + m pthread ${T_LIB} ITTI dl shlib_loader physim_common ) target_link_libraries(nr_dlschsim PRIVATE asn1_nr_rrc_hdrs) -add_executable(nr_pbchsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c - ) +add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c) target_link_libraries(nr_pbchsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader + m pthread ${T_LIB} ITTI dl shlib_loader physim_common ) target_link_libraries(nr_pbchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_psbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/psbchsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c @@ -2002,24 +1998,19 @@ add_executable(nr_psbchsim ) target_link_libraries(nr_psbchsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON CONFIG_LIB L2_NR -lz -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader + m pthread ${T_LIB} ITTI dl shlib_loader physim_common ) target_link_libraries(nr_psbchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) -#PUCCH ---> Prashanth -add_executable(nr_pucchsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c - ) +add_executable(nr_pucchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c) target_link_libraries(nr_pucchsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader + m pthread ${T_LIB} ITTI dl shlib_loader physim_common ) target_link_libraries(nr_pucchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_dlsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c @@ -2028,33 +2019,28 @@ add_executable(nr_dlsim ) target_link_libraries(nr_dlsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader nr_ue_phy_meas + m pthread ${T_LIB} ITTI dl shlib_loader nr_ue_phy_meas physim_common ) target_link_libraries(nr_dlsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) -add_executable(nr_prachsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/prachsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c -) +add_executable(nr_prachsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/prachsim.c) target_link_libraries(nr_prachsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB CONFIG_LIB -lz -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader) + m pthread ${T_LIB} ITTI dl shlib_loader physim_common) target_link_libraries(nr_prachsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${PHY_INTERFACE_DIR}/queue_t.c ) target_link_libraries(nr_ulschsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader + m pthread ${T_LIB} ITTI dl shlib_loader physim_common ) target_link_libraries(nr_ulschsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_ulsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/nr_dummy_functions.c ${OPENAIR_DIR}/executables/softmodem-common.c ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c @@ -2064,7 +2050,7 @@ add_executable(nr_ulsim target_link_libraries(nr_ulsim PRIVATE -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_UE_NR MAC_NR_COMMON nr_rrc CONFIG_LIB L2_NR HASHTABLE x2ap SECURITY ngap -lz -Wl,--end-group - m pthread ${T_LIB} ITTI dl shlib_loader nr_ue_phy_meas + m pthread ${T_LIB} ITTI dl shlib_loader nr_ue_phy_meas physim_common ) target_link_libraries(nr_ulsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_unitary_common.c similarity index 100% rename from openair1/SIMULATION/NR_PHY/nr_dummy_functions.c rename to openair1/SIMULATION/NR_PHY/nr_unitary_common.c From a2d13f755ca29735ef99d89a02f13778484c6bdf Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Fri, 21 Mar 2025 10:31:30 +0000 Subject: [PATCH 5/6] feat(nr_unitary_common): Add banner and apply clang-format to openair1/SIMULATION/NR_PHY/nr_unitary_common.c --- .../SIMULATION/NR_PHY/nr_unitary_common.c | 173 ++++++++++++++---- 1 file changed, 140 insertions(+), 33 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_common.c b/openair1/SIMULATION/NR_PHY/nr_unitary_common.c index 355c6ad280..6e23a67d25 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_common.c +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_common.c @@ -1,3 +1,28 @@ +/* + * 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 + */ + +/*!\file openair1/SIMULATION/NR_PHY/nr_unitary_common.c + * \brief common functions to NR PHY unitary tests + * \company EURECOM + */ #include "nfapi/oai_integration/vendor_ext.h" #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h" #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" @@ -8,52 +33,131 @@ // Define signal handler to attempt graceful termination bool stop = false; -void sigint_handler(int arg) { +void sigint_handler(int arg) +{ static const char msg[] = "\nCaught SIGINT, shutting down\nPress again CTRL+C to force shutdown\n"; __attribute__((unused)) int unused = write(STDOUT_FILENO, msg, sizeof(msg) - 1); stop = true; } -int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return (0); } -int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req) { return (0); } -int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req) { return (0); } -int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req) { return (0); } -int oai_nfapi_nr_crc_indication(nfapi_nr_crc_indication_t *ind) { return (0); } -int oai_nfapi_nr_srs_indication(nfapi_nr_srs_indication_t *ind) { return (0); } -int oai_nfapi_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { return (0); } -int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind) { return (0); } -int oai_nfapi_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind) { return 0; } +int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) +{ + return (0); +} +int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req) +{ + return (0); +} +int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req) +{ + return (0); +} +int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req) +{ + return (0); +} +int oai_nfapi_nr_crc_indication(nfapi_nr_crc_indication_t *ind) +{ + return (0); +} +int oai_nfapi_nr_srs_indication(nfapi_nr_srs_indication_t *ind) +{ + return (0); +} +int oai_nfapi_nr_uci_indication(nfapi_nr_uci_indication_t *ind) +{ + return (0); +} +int oai_nfapi_nr_rach_indication(nfapi_nr_rach_indication_t *ind) +{ + return (0); +} +int oai_nfapi_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind) +{ + return 0; +} -void handle_nr_slot_ind(uint16_t sfn, uint16_t slot) { } +void handle_nr_slot_ind(uint16_t sfn, uint16_t slot) +{ +} -int pack_nr_srs_beamforming_report(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen) { return 0; } -int unpack_nr_srs_beamforming_report(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen) { return 0; } -int pack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen) { return 0; } -int unpack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen) { return 0; } -void get_position_coordinates(int Mod_id, position_t *position) {} -int32_t get_uldl_offset(int nr_bandP) { return (0); } +int pack_nr_srs_beamforming_report(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen) +{ + return 0; +} +int unpack_nr_srs_beamforming_report(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen) +{ + return 0; +} +int pack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen) +{ + return 0; +} +int unpack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, + uint32_t messageBufLen, + void *pUnpackedBuf, + uint32_t unpackedBufLen) +{ + return 0; +} +void get_position_coordinates(int Mod_id, position_t *position) +{ +} +int32_t get_uldl_offset(int nr_bandP) +{ + return (0); +} -void configure_nr_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) {} -void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) {} -int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config) { return 0; } -int nfapi_nr_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config) { return 0; } -int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t *config) { return 0; } +void configure_nr_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) +{ +} +void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) +{ +} +int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t *config) +{ + return 0; +} +int nfapi_nr_p7_message_unpack(void *pMessageBuf, + uint32_t messageBufLen, + void *pUnpackedBuf, + uint32_t unpackedBufLen, + nfapi_p7_codec_config_t *config) +{ + return 0; +} +int nfapi_p7_message_header_unpack(void *pMessageBuf, + uint32_t messageBufLen, + void *pUnpackedBuf, + uint32_t unpackedBufLen, + nfapi_p7_codec_config_t *config) +{ + return 0; +} -void nr_mac_rrc_sync_ind(const module_id_t module_id, - const frame_t frame, - const bool in_sync) {} +void nr_mac_rrc_sync_ind(const module_id_t module_id, const frame_t frame, const bool in_sync) +{ +} -void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti, int gnb_id) {} +void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti, int gnb_id) +{ +} -void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success) {} +void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success) +{ +} -void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) {} +void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) +{ +} void rrc_data_ind(const protocol_ctxt_t *const ctxt_pP, - const rb_id_t Srb_id, - const sdu_size_t sdu_sizeP, - const uint8_t *const buffer_pP) { } + const rb_id_t Srb_id, + const sdu_size_t sdu_sizeP, + const uint8_t *const buffer_pP) +{ +} typedef uint32_t channel_t; int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, @@ -65,8 +169,11 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const uint32_t cellid, const long arfcn, const channel_t channel, - const uint8_t* pduP, - const sdu_size_t pdu_len) { return 0; } + const uint8_t *pduP, + const sdu_size_t pdu_len) +{ + return 0; +} void *rrc_nrue(void *notUsed) { return NULL; From 60b04f0c8256e1523578bd590042d52577c57c7a Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Fri, 21 Mar 2025 10:36:03 +0000 Subject: [PATCH 6/6] feat(nr_unitary_defs): Apply clang-format to openair1/SIMULATION/NR_PHY/nr_unitary_defs.h --- openair1/SIMULATION/NR_PHY/nr_unitary_defs.h | 43 ++++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index 38e8df8425..74fbf1051b 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -28,7 +28,7 @@ * \email turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #ifndef __NR_UNITARY_DEFS__H__ #define __NR_UNITARY_DEFS__H__ @@ -41,21 +41,21 @@ extern bool stop; void sigint_handler(int arg); -const struct sigaction sigint_action = { - .sa_handler = sigint_handler, - // restore handler to default upon entry to the signal handler - .sa_flags = SA_RESETHAND -}; +const struct sigaction sigint_action = {.sa_handler = sigint_handler, + // restore handler to default upon entry to the signal handler + .sa_flags = SA_RESETHAND}; -int oai_exit=0; +int oai_exit = 0; -void exit_function(const char* file, const char* function, const int line, const char *s, const int assert) { - const char * msg= s==NULL ? "no comment": s; +void exit_function(const char *file, const char *function, const int line, const char *s, const int assert) +{ + const char *msg = s == NULL ? "no comment" : s; printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); exit(-1); } -signed char quantize(double D, double x, unsigned char B) { +signed char quantize(double D, double x, unsigned char B) +{ double qxd; short maxlev; qxd = floor(x / D); @@ -66,18 +66,27 @@ signed char quantize(double D, double x, unsigned char B) { else if (qxd >= maxlev) qxd = maxlev - 1; - return ((char) qxd); + return ((char)qxd); } -int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) {return(0);} -//NR_IF_Module_t *NR_IF_Module_init(int Mod_id){return(NULL);} -int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { return(0); } +int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) +{ + return (0); +} +// NR_IF_Module_t *NR_IF_Module_init(int Mod_id){return(NULL);} +int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) +{ + return (0); +} -void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_RB_DL,int N_RB_UL,int mu_dl,int mu_ul); -void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap); +void fill_scc_sim(NR_ServingCellConfigCommon_t *scc, uint64_t *ssb_bitmap, int N_RB_DL, int N_RB_UL, int mu_dl, int mu_ul); +void fix_scc(NR_ServingCellConfigCommon_t *scc, uint64_t ssbmap); void prepare_scc(NR_ServingCellConfigCommon_t *scc); void prepare_msgA_scc(NR_ServingCellConfigCommon_t *scc); void prepare_scd(NR_ServingCellConfig_t *scd); -uint32_t ngap_generate_gNB_id(void) {return 0;} +uint32_t ngap_generate_gNB_id(void) +{ + return 0; +} #endif