diff --git a/ci-scripts/ci_ueinfra.yaml b/ci-scripts/ci_ueinfra.yaml index deef3718ec..2636c7413a 100644 --- a/ci-scripts/ci_ueinfra.yaml +++ b/ci-scripts/ci_ueinfra.yaml @@ -119,6 +119,48 @@ amarisoft_ue_10: NetworkScript: ip netns exec ue10 ip a show dev pdn0 CmdPrefix: ip netns exec ue10 MTU: 1500 +amarisoft_ue_11: + Host: amariue + AttachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_on","ue_id":11}' + DetachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_off","ue_id":11}' + NetworkScript: ip netns exec ue11 ip a show dev pdn0 + CmdPrefix: ip netns exec ue11 + MTU: 1500 +amarisoft_ue_12: + Host: amariue + AttachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_on","ue_id":12}' + DetachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_off","ue_id":12}' + NetworkScript: ip netns exec ue12 ip a show dev pdn0 + CmdPrefix: ip netns exec ue12 + MTU: 1500 +amarisoft_ue_13: + Host: amariue + AttachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_on","ue_id":13}' + DetachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_off","ue_id":13}' + NetworkScript: ip netns exec ue13 ip a show dev pdn0 + CmdPrefix: ip netns exec ue13 + MTU: 1500 +amarisoft_ue_14: + Host: amariue + AttachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_on","ue_id":14}' + DetachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_off","ue_id":14}' + NetworkScript: ip netns exec ue14 ip a show dev pdn0 + CmdPrefix: ip netns exec ue14 + MTU: 1500 +amarisoft_ue_15: + Host: amariue + AttachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_on","ue_id":15}' + DetachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_off","ue_id":15}' + NetworkScript: ip netns exec ue15 ip a show dev pdn0 + CmdPrefix: ip netns exec ue15 + MTU: 1500 +amarisoft_ue_16: + Host: amariue + AttachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_on","ue_id":16}' + DetachScript: /root/2023-10-27/libs/ws.js 127.0.0.1:9002 '{"message":"power_off","ue_id":16}' + NetworkScript: ip netns exec ue16 ip a show dev pdn0 + CmdPrefix: ip netns exec ue16 + MTU: 1500 oai_ue_caracal: Host: caracal diff --git a/ci-scripts/xml_files/container_sa_aw2s_asue.xml b/ci-scripts/xml_files/container_sa_aw2s_asue.xml index 4d81b123e6..10170885f0 100644 --- a/ci-scripts/xml_files/container_sa_aw2s_asue.xml +++ b/ci-scripts/xml_files/container_sa_aw2s_asue.xml @@ -40,9 +40,15 @@ 002008 002009 002010 + 002011 + 002012 + 002013 + 002014 + 002015 000100 000010 000020 + 002016 000200 003000 004000 @@ -132,12 +138,42 @@ amarisoft_ue_10 + + Attach_UE + Attach UE + amarisoft_ue_11 + + + + Attach_UE + Attach UE + amarisoft_ue_12 + + + + Attach_UE + Attach UE + amarisoft_ue_13 + + + + Attach_UE + Attach UE + amarisoft_ue_14 + + + + Attach_UE + Attach UE + amarisoft_ue_15 + + Iperf iperf (DL/7Mbps/UDP)(30 sec)(multi-ue profile) -u -b 70M -t 30 -i 1 -R IPERF3 - amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 + amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 amarisoft_ue_11 amarisoft_ue_12 amarisoft_ue_13 amarisoft_ue_14 amarisoft_ue_15 25 80 balanced @@ -148,7 +184,7 @@ iperf (UL/3.6Mbps/UDP)(30 sec)(multi-ue profile) -u -b 36M -t 30 -i 1 IPERF3 - amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 + amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 amarisoft_ue_11 amarisoft_ue_12 amarisoft_ue_13 amarisoft_ue_14 amarisoft_ue_15 25 80 balanced @@ -157,17 +193,23 @@ Ping Ping: 20pings in 20sec, multi-ue - amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 + amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 amarisoft_ue_11 amarisoft_ue_12 amarisoft_ue_13 amarisoft_ue_14 amarisoft_ue_15 -c 20 %cn_ip% 1 25 + + Attach_UE + Attach UE + amarisoft_ue_16 + + Ping - Ping: 100pings in 20sec, multi-ue - amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 - -c 100 -i 0.2 %cn_ip% + Ping: 50pings in 10sec, multi-ue + amarisoft_ue_16 + -c 50 -i 0.2 %cn_ip% 1 30 @@ -175,7 +217,7 @@ Detach_UE Detach UE - amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 + amarisoft_ue_1 amarisoft_ue_2 amarisoft_ue_3 amarisoft_ue_4 amarisoft_ue_5 amarisoft_ue_6 amarisoft_ue_7 amarisoft_ue_8 amarisoft_ue_9 amarisoft_ue_10 amarisoft_ue_11 amarisoft_ue_12 amarisoft_ue_13 amarisoft_ue_14 amarisoft_ue_15 amarisoft_ue_16 diff --git a/common/openairinterface5g_limits.h b/common/openairinterface5g_limits.h index d9e49e26a7..d2f44a6195 100644 --- a/common/openairinterface5g_limits.h +++ b/common/openairinterface5g_limits.h @@ -12,8 +12,6 @@ # define NUMBER_OF_SRS_MAX 16 # define NUMBER_OF_SCH_STATS_MAX 16 -#define NUMBER_FRAMES_PHY_UE_INACTIVE 10 - #define MAX_MANAGED_ENB_PER_MOBILE 2 #define MAX_MANAGED_GNB_PER_MOBILE 2 diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 3d9c02f5e4..04b66237dc 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -679,9 +679,6 @@ int main( int argc, char **argv ) { AssertFatal(ret == 0, "cannot create ITTI tasks\n"); } - // init UE_PF_PO and mutex lock - pthread_mutex_init(&ue_pf_po_mutex, NULL); - memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); mlockall(MCL_CURRENT | MCL_FUTURE); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); @@ -823,7 +820,6 @@ int main( int argc, char **argv ) { pthread_mutex_destroy(&sync_mutex); pthread_cond_destroy(&nfapi_sync_cond); pthread_mutex_destroy(&nfapi_sync_mutex); - pthread_mutex_destroy(&ue_pf_po_mutex); // *** Handle per CC_id openair0 diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index de1c97a07b..a0ea170aa5 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -567,9 +567,6 @@ int main(int argc, char **argv) } init_openair0(); - // init UE_PF_PO and mutex lock - pthread_mutex_init(&ue_pf_po_mutex, NULL); - memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); set_latency_target(); if(IS_SOFTMODEM_DOSCOPE_QT) { diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 3214d3a5ac..2f4fad4257 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -77,8 +77,11 @@ NR_gNB_PHY_STATS_t *get_phy_stats(PHY_VARS_gNB *gNB, uint16_t rnti) else if (!stats->active && first_free == -1) first_free = i; } + + if (first_free < 0) + return NULL; + // new stats - AssertFatal(first_free >= 0, "PHY statistics list is full\n"); stats = &gNB->phy_stats[first_free]; stats->active = true; stats->rnti = rnti; @@ -130,6 +133,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB) load_LDPClib(NULL, &ldpc_interface); + pthread_mutex_init(&gNB->UL_INFO.crc_rx_mutex, NULL); + if (gNB->ldpc_offload_flag) load_LDPClib("_t2", &ldpc_interface_offload); gNB->max_nb_pdsch = MAX_MOBILES_PER_GNB; @@ -326,6 +331,8 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) const int max_ul_mimo_layers = 4; // taken from phy_init_nr_gNB() const int n_buf = Prx * max_ul_mimo_layers; + pthread_mutex_destroy(&gNB->UL_INFO.crc_rx_mutex); + PHY_MEASUREMENTS_gNB *meas = &gNB->measurements; free_and_zero(meas->n0_subband_power); free_and_zero(meas->n0_subband_power_dB); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index 7e7562ff22..bc3046c578 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -34,7 +34,7 @@ #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" -NR_gNB_ULSCH_t *find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid) +static NR_gNB_ULSCH_t *find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid) { int16_t first_free_index = -1; AssertFatal(gNB != NULL, "gNB is null\n"); @@ -62,7 +62,10 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, int frame, int slot, nfapi_nr_pusch_pdu_t { int harq_pid = ulsch_pdu->pusch_data.harq_process_id; NR_gNB_ULSCH_t *ulsch = find_nr_ulsch(gNB, ulsch_pdu->rnti, harq_pid); - AssertFatal(ulsch, "No ulsch_id found for rnti %04x\n", ulsch_pdu->rnti); + if (ulsch == NULL) { + LOG_E(NR_PHY, "No ulsch_id found for rnti %04x\n", ulsch_pdu->rnti); + return; + } ulsch->rnti = ulsch_pdu->rnti; ulsch->harq_pid = harq_pid; diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index ec7f6cae69..fa7d085ed0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -30,9 +30,14 @@ * \warning */ +#ifndef NR_ULSCH_H_ +#define NR_ULSCH_H_ + #include "PHY/defs_gNB.h" #include "common/utils/threadPool/thread-pool.h" +#define NUMBER_FRAMES_PHY_UE_INACTIVE 10 + void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch, uint16_t N_RB_UL); NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL); @@ -71,10 +76,10 @@ void nr_ulsch_unscrambling(int16_t* llr, uint32_t size, uint32_t Nid, uint32_t n void nr_ulsch_layer_demapping(int16_t *llr_cw, uint8_t Nl, uint8_t mod_order, uint32_t length, int16_t **llr_layers); -NR_gNB_ULSCH_t *find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid); - void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB); void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB); NR_gNB_SCH_STATS_t *get_ulsch_stats(PHY_VARS_gNB *gNB,NR_gNB_ULSCH_t *ulsch); + +#endif /* NR_ULSCH_H_ */ diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index e930a46a08..7ffb5af0e7 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -162,10 +162,15 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, pucch_pdu->bit_len_harq, pucch_pdu->sr_flag); + /* it might be that the stats list is full: In this case, we will simply + * write to some memory on the stack instead of the UE's UCI stats */ + NR_gNB_UCI_STATS_t stack_uci_stats = {0}; + NR_gNB_UCI_STATS_t *uci_stats = &stack_uci_stats; NR_gNB_PHY_STATS_t *phy_stats = get_phy_stats(gNB, pucch_pdu->rnti); - AssertFatal(phy_stats != NULL, "phy_stats shouldn't be NULL\n"); - phy_stats->frame = frame; - NR_gNB_UCI_STATS_t *uci_stats = &phy_stats->uci_stats; + if (phy_stats != NULL) { + phy_stats->frame = frame; + uci_stats = &phy_stats->uci_stats; + } int nr_sequences; const uint8_t *mcs; @@ -350,9 +355,14 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, #endif index=maxpos; - uci_stats->pucch0_n00 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]]; - uci_stats->pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]; - LOG_D(PHY,"n00[%d] = %d, n01[%d] = %d\n",prb_offset[0],uci_stats->pucch0_n00,prb_offset[1],uci_stats->pucch0_n01); + int pucch0_n00 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]]; + int pucch0_n01 = gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]; + LOG_D(PHY, "n00[%d] = %d, n01[%d] = %d\n", prb_offset[0], pucch0_n00, prb_offset[1], pucch0_n01); + + uci_stats->pucch0_n00 = pucch0_n00; + uci_stats->pucch0_n01 = pucch0_n01; + uci_stats->pucch0_thres = gNB->pucch0_thres; + // estimate CQI for MAC (from antenna port 0 only) int max_n0 = max(gNB->measurements.n0_subband_power_tot_dB[prb_offset[0]], gNB->measurements.n0_subband_power_tot_dB[prb_offset[1]]); @@ -365,7 +375,6 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, else cqi = (640 + SNRtimes10) / 5; - uci_stats->pucch0_thres = gNB->pucch0_thres; /* + (10*max_n0);*/ bool no_conf=false; if (nr_sequences>1) { if (/*xrtmag_dBtimes10 < (30+xrtmag_next_dBtimes10) ||*/ SNRtimes10 < gNB->pucch0_thres) { @@ -374,7 +383,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, "%d.%d PUCCH bad confidence: %d threshold, %d, %d, %d\n", frame, slot, - uci_stats->pucch0_thres, + gNB->pucch0_thres, SNRtimes10, xrtmag_dBtimes10, xrtmag_next_dBtimes10); @@ -390,7 +399,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_pdu->rssi = 1280 - (10 * dB_fixed(32767 * 32767)) - dB_fixed_times10(signal_energy_ant0); if (pucch_pdu->bit_len_harq==0) { - uci_pdu->sr.sr_confidence_level = SNRtimes10 < uci_stats->pucch0_thres; + uci_pdu->sr.sr_confidence_level = SNRtimes10 < gNB->pucch0_thres; uci_stats->pucch0_sr_trials++; if (xrtmag_dBtimes10>(10*max_n0+100)) { uci_pdu->sr.sr_indication = 1; @@ -417,9 +426,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, xrtmag_next_dBtimes10, pucch_power_dBtimes10, max_n0, - uci_stats->pucch0_n00, - uci_stats->pucch0_n01, - uci_stats->pucch0_thres, + pucch0_n00, + pucch0_n01, + gNB->pucch0_thres, cqi, SNRtimes10, 10 * log10((double)signal_energy_ant0)); @@ -452,9 +461,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, xrtmag_next_dBtimes10, pucch_power_dBtimes10, max_n0, - uci_stats->pucch0_n00, - uci_stats->pucch0_n01, - uci_stats->pucch0_thres, + pucch0_n00, + pucch0_n01, + gNB->pucch0_thres, cqi, SNRtimes10); if (pucch_pdu->sr_flag == 1) { diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 79ac95ef73..f9abcf211b 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -614,8 +614,8 @@ static void pucchIQ (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { static void puschThroughtput (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { // PUSCH Throughput /* - float tput_time_enb[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; - float tput_enb[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; + float tput_time_enb[MAX_MOBILES_PER_GNB][TPUT_WINDOW_LENGTH] = {{0}}; + float tput_enb[MAX_MOBILES_PER_GNB][TPUT_WINDOW_LENGTH] = {{0}}; 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) ); @@ -725,7 +725,7 @@ static void *scope_thread_gNB(void *arg) { int fl_argc=1; char *name="5G-gNB-scope"; fl_initialize (&fl_argc, &name, NULL, 0, 0); - int nb_ue=min(NUMBER_OF_UE_MAX, scope_enb_num_ue); + int nb_ue=min(MAX_MOBILES_PER_GNB, scope_enb_num_ue); OAI_phy_scope_t *form_gnb = create_phy_scope_gnb(); while (!oai_exit) { @@ -985,9 +985,9 @@ static void uePdschIQ (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_ } static void uePdschThroughput (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { /* - 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}; + float tput_time_ue[MAX_MOBILES_PER_GNB][TPUT_WINDOW_LENGTH] = {{0}}; + float tput_ue[MAX_MOBILES_PER_GNB][TPUT_WINDOW_LENGTH] = {{0}}; + float tput_ue_max[MAX_MOBILES_PER_GNB] = {0}; // PDSCH Throughput @@ -1178,7 +1178,7 @@ static void reset_stats_gNB(FL_OBJECT *button, int i,k; //PHY_VARS_gNB *phy_vars_gNB = RC.gNB[0][0]; - for (i=0; idlsch[i][0]->Mlimit; j++) { phy_vars_gNB->UE_stats[i].dlsch_NAK[k][j]=0; diff --git a/openair1/PHY/phy_vars.h b/openair1/PHY/phy_vars.h index 89063c5be2..85d2d2a59f 100644 --- a/openair1/PHY/phy_vars.h +++ b/openair1/PHY/phy_vars.h @@ -30,8 +30,6 @@ PHY_VARS_UE ***PHY_vars_UE_g; UL_RCC_IND_t UL_RCC_INFO; -NR_UL_IND_t UL_INFO; - unsigned char NB_RU=0; int number_of_cards; uint8_t max_turbo_iterations=4; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 0062875fb3..87cdff15ab 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -467,75 +467,13 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, else if (SNRtimes10 > 635) cqi=255; else cqi=(640+SNRtimes10)/5; - - if (0/*pusch_pdu->mcs_index == 9*/) { - __attribute__((unused)) - int off = ((pusch_pdu->rb_size&1) == 1)? 4:0; - - LOG_M("rxsigF0.m", - "rxsF0", - &gNB->common_vars - .rxdataF[0][(slot_rx % RU_RX_SLOT_DEPTH) * gNB->frame_parms.ofdm_symbol_size * gNB->frame_parms.symbols_per_slot], - gNB->frame_parms.ofdm_symbol_size * gNB->frame_parms.symbols_per_slot, - 1, - 1); - LOG_M("chestF0.m", - "chF0", - &gNB->pusch_vars[0].ul_ch_estimates[0][pusch_pdu->start_symbol_index * gNB->frame_parms.ofdm_symbol_size], - gNB->frame_parms.ofdm_symbol_size, - 1, - 1); - LOG_M("chestF0_ext.m", - "chF0_ext", - &gNB->pusch_vars[0] - .ul_ch_estimates_ext[0][(pusch_pdu->start_symbol_index + 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (pusch_pdu->nr_of_symbols - 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), - 1, - 1); - LOG_M("rxsigF0_comp.m", - "rxsF0_comp", - &gNB->pusch_vars[0].rxdataF_comp[0][pusch_pdu->start_symbol_index * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - pusch_pdu->nr_of_symbols * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), - 1, - 1); - LOG_M("rxsigF0_llr.m", - "rxsF0_llr", - &gNB->pusch_vars[0].llr[0], - (pusch_pdu->nr_of_symbols - 1) * NR_NB_SC_PER_RB * pusch_pdu->rb_size * pusch_pdu->qam_mod_order, - 1, - 0); - if (gNB->frame_parms.nb_antennas_rx > 1) { - LOG_M( - "rxsigF1.m", - "rxsF1", - &gNB->common_vars - .rxdataF[1][(slot_rx % RU_RX_SLOT_DEPTH) * gNB->frame_parms.ofdm_symbol_size * gNB->frame_parms.symbols_per_slot], - gNB->frame_parms.ofdm_symbol_size * gNB->frame_parms.symbols_per_slot, - 1, - 1); - LOG_M("chestF1.m", - "chF1", - &gNB->pusch_vars[0].ul_ch_estimates[1][pusch_pdu->start_symbol_index * gNB->frame_parms.ofdm_symbol_size], - gNB->frame_parms.ofdm_symbol_size, - 1, - 1); - LOG_M("chestF1_ext.m", - "chF1_ext", - &gNB->pusch_vars[0] - .ul_ch_estimates_ext[1][(pusch_pdu->start_symbol_index + 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (pusch_pdu->nr_of_symbols - 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), - 1, - 1); - LOG_M("rxsigF1_comp.m", - "rxsF1_comp", - &gNB->pusch_vars[0].rxdataF_comp[1][pusch_pdu->start_symbol_index * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - pusch_pdu->nr_of_symbols * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), - 1, - 1); - } - exit(-1); - - } + // multiple threads might call this function at the same time, or while the + // L2 reads the messages. Hence, if not protected, crc and rx indications + // might not appear pairwise (in the same order) in the same slot, or even in + // separate slots. The L2 does not support this; hence, use the crc_rx_mutex + // to ensure that messages are pairwise. + int rc = pthread_mutex_lock(&gNB->UL_INFO.crc_rx_mutex); + DevAssert(rc == 0); // crc indication uint16_t num_crc = gNB->UL_INFO.crc_ind.number_crcs; @@ -573,8 +511,10 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, gNB->rx_pdu_list[num_rx].pdu_length = harq_process->TBS; gNB->rx_pdu_list[num_rx].pdu = harq_process->b; } - gNB->UL_INFO.rx_ind.number_of_pdus++; + + rc = pthread_mutex_unlock(&gNB->UL_INFO.crc_rx_mutex); + DevAssert(rc == 0); } // Function to fill UL RB mask to be used for N0 measurements diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index f4f6e891b2..b252f1cdd4 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -136,7 +136,7 @@ nrUE_params_t *get_nrUE_params(void) { uint16_t n_rnti = 0x1234; openair0_config_t openair0_cfg[MAX_CARDS]; -channel_desc_t *UE2gNB[NUMBER_OF_UE_MAX][NUMBER_OF_gNB_MAX]; +channel_desc_t *UE2gNB[MAX_MOBILES_PER_GNB][NUMBER_OF_gNB_MAX]; int NB_UE_INST = 1; configmodule_interface_t *uniqCfg = NULL; diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 37bedddf46..8494a56492 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -177,6 +177,9 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) } if (UL_info->rx_ind.number_of_pdus > 0 && UL_info->crc_ind.number_crcs > 0) { + // see nr_fill_indication about why this mutex is necessary + int rc = pthread_mutex_lock(&UL_info->crc_rx_mutex); + DevAssert(rc == 0); AssertFatal(UL_info->rx_ind.number_of_pdus == UL_info->crc_ind.number_crcs, "number_of_pdus %d, number_crcs %d\n", UL_info->rx_ind.number_of_pdus, UL_info->crc_ind.number_crcs); @@ -210,9 +213,11 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) rx->rssi); handle_nr_ul_harq(UL_info->CC_id, UL_info->module_id, UL_info->frame, UL_info->slot, crc); } + UL_info->rx_ind.number_of_pdus = 0; + UL_info->crc_ind.number_crcs = 0; + rc = pthread_mutex_unlock(&UL_info->crc_rx_mutex); + DevAssert(rc == 0); } - UL_info->rx_ind.number_of_pdus = 0; - UL_info->crc_ind.number_crcs = 0; } void handle_nr_srs(NR_UL_IND_t *UL_info) { diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h index e7cbb331bc..82ccdb782f 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h @@ -63,6 +63,11 @@ typedef struct { /// crc indication list nfapi_nr_crc_indication_t crc_ind; + /// RX indication + nfapi_nr_rx_data_indication_t rx_ind; + /// mutex to protect concurrent access to crc_ind and rx_ind, which the L2 + /// needs to be pairwise + pthread_mutex_t crc_rx_mutex; /// RACH indication list nfapi_nr_rach_indication_t rach_ind; @@ -70,9 +75,6 @@ typedef struct { /// SRS indication list nfapi_nr_srs_indication_t srs_ind; - /// RX indication - nfapi_nr_rx_data_indication_t rx_ind; - /// UCI indication nfapi_nr_uci_indication_t uci_ind; diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index d85bedf79e..06e5f75442 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -608,25 +608,27 @@ static struct NR_SRS_Resource__resourceType__periodic *configure_periodic_srs(co return periodic_srs; } -static void config_srs(const NR_ServingCellConfigCommon_t *scc, - NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, - const NR_UE_NR_Capability_t *uecap, - const int curr_bwp, - const int uid, - const int res_id, - const long maxMIMO_Layers, - const int do_srs) +static NR_SetupRelease_SRS_Config_t *get_config_srs(const NR_ServingCellConfigCommon_t *scc, + const NR_UE_NR_Capability_t *uecap, + const int curr_bwp, + const int uid, + const int res_id, + const long maxMIMO_Layers, + int do_srs) { - setup_release_srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; - - NR_SRS_Config_t *srs_Config; - if (setup_release_srs_Config->choice.setup) { - srs_Config = setup_release_srs_Config->choice.setup; - ASN_STRUCT_FREE(asn_DEF_NR_SRS_Config, srs_Config); + // if in the future NUMBER_OF_gNB_MAX is increased, it will be necessary to improve the allocation of SRS resources, + // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. + static_assert(NUMBER_OF_gNB_MAX <= 32, + "SRS can only handle up to 30 UEs (additional ones are handled gracefully, but don't have SRS enabled\n"); + if (do_srs && (uid < 0 || uid > 29)) { + LOG_E(NR_RRC, "gNB cannot allocate SRS resources for UID %d: available resources exceeded\n", uid); + do_srs = 0; } + NR_SetupRelease_SRS_Config_t *setup_release_srs_Config = calloc(1,sizeof(*setup_release_srs_Config)); + setup_release_srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup; setup_release_srs_Config->choice.setup = calloc(1,sizeof(*setup_release_srs_Config->choice.setup)); - srs_Config = setup_release_srs_Config->choice.setup; + NR_SRS_Config_t *srs_Config = setup_release_srs_Config->choice.setup; srs_Config->srs_ResourceSetToReleaseList = NULL; @@ -733,6 +735,8 @@ static void config_srs(const NR_ServingCellConfigCommon_t *scc, srs_res0->spatialRelationInfo->referenceSignal.present = NR_SRS_SpatialRelationInfo__referenceSignal_PR_ssb_Index; srs_res0->spatialRelationInfo->referenceSignal.choice.ssb_Index = 0; asn1cSeqAdd(&srs_Config->srs_ResourceToAddModList->list,srs_res0); + + return setup_release_srs_Config; } void prepare_sim_uecap(NR_UE_NR_Capability_t *cap, @@ -1443,15 +1447,7 @@ static void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, && servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers ? *servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers : 1; - ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); - config_srs(scc, - ubwp->bwp_Dedicated->srs_Config, - NULL, - curr_bwp, - uid, - bwp_loop+1, - maxMIMO_Layers, - configuration->do_SRS); + ubwp->bwp_Dedicated->srs_Config = get_config_srs(scc, NULL, curr_bwp, uid, bwp_loop + 1, maxMIMO_Layers, configuration->do_SRS); ubwp->bwp_Dedicated->configuredGrantConfig = NULL; ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; @@ -2227,8 +2223,7 @@ static NR_SpCellConfig_t *get_initial_SpCellConfig(int uid, : 1; // We are using do_srs = 0 here because the periodic SRS will only be enabled in update_cellGroupConfig() if do_srs == 1 - initialUplinkBWP->srs_Config = calloc(1, sizeof(*initialUplinkBWP->srs_Config)); - config_srs(scc, initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, maxMIMO_Layers, 0); + initialUplinkBWP->srs_Config = get_config_srs(scc, NULL, curr_bwp, uid, 0, maxMIMO_Layers, 0); scheduling_request_config(scc, pucch_Config, scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing); @@ -2525,17 +2520,8 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, // UL and SRS configuration if (configuration->do_SRS && uplinkConfig && uplinkConfig->initialUplinkBWP) { - if (!uplinkConfig->initialUplinkBWP->srs_Config) { - uplinkConfig->initialUplinkBWP->srs_Config = calloc(1, sizeof(*uplinkConfig->initialUplinkBWP->srs_Config)); - } - config_srs(scc, - SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config, - uecap, - curr_bwp, - uid, - 0, - maxMIMO_Layers, - configuration->do_SRS); + ASN_STRUCT_FREE(asn_DEF_NR_SetupRelease_SRS_Config, uplinkConfig->initialUplinkBWP->srs_Config); + uplinkConfig->initialUplinkBWP->srs_Config = get_config_srs(scc, uecap, curr_bwp, uid, 0, maxMIMO_Layers, configuration->do_SRS); } // Set DL MCS table @@ -2570,7 +2556,9 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, } *pusch_Config->maxRank = ul_max_layers; } - config_srs(scc, ul_bwp->bwp_Dedicated->srs_Config, uecap, bwp_size, uid, i + 1, maxMIMO_Layers, configuration->do_SRS); + + ASN_STRUCT_FREE(asn_DEF_NR_SetupRelease_SRS_Config, ul_bwp->bwp_Dedicated->srs_Config); + ul_bwp->bwp_Dedicated->srs_Config = get_config_srs(scc, uecap, bwp_size, uid, i + 1, maxMIMO_Layers, configuration->do_SRS); } } update_cqitables(bwp_Dedicated->pdsch_Config, SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup); @@ -2648,11 +2636,6 @@ NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigC if (uecap == NULL) LOG_E(RRC, "No UE Capabilities available when programming default CellGroup in NSA\n"); - // This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4. - // However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources, - // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. - AssertFatal(uid >= 0 && uid < 30, "gNB cannot allocate the SRS resources\n"); - uint64_t bitmap = get_ssb_bitmap(servingcellconfigcommon); // See comment at the end of this function regarding ServingCellConfig fix_servingcellconfigdedicated(servingcellconfigdedicated); @@ -2772,8 +2755,7 @@ NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigC int curr_bwp = NRRIV2BW(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - initialUplinkBWP->srs_Config = calloc(1, sizeof(*initialUplinkBWP->srs_Config)); - config_srs(servingcellconfigcommon, initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, maxMIMO_Layers, configuration->do_SRS); + initialUplinkBWP->srs_Config = get_config_srs(servingcellconfigcommon, NULL, curr_bwp, uid, 0, maxMIMO_Layers, configuration->do_SRS); // Downlink BWPs int n_dl_bwp = 1; diff --git a/openair2/RRC/NR/nr_rrc_extern.h b/openair2/RRC/NR/nr_rrc_extern.h index 64e6095dcd..66483214a7 100644 --- a/openair2/RRC/NR/nr_rrc_extern.h +++ b/openair2/RRC/NR/nr_rrc_extern.h @@ -34,25 +34,5 @@ #include "COMMON/mac_rrc_primitives.h" #include "LAYER2/RLC/rlc.h" #include "openair2/RRC/common.h" - void openair_rrc_gNB_configuration(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration); - -extern UE_RRC_INST *UE_rrc_inst; - -extern uint8_t DRB2LCHAN[8]; - -extern int NB_UE_INST; -extern void* bigphys_malloc(int); - - -//uint8_t RACH_TIME_ALLOC; -extern uint16_t RACH_FREQ_ALLOC; -// uint8_t NB_RACH; -extern MAC_MEAS_T BCCH_MEAS_TRIGGER,CCCH_MEAS_TRIGGER,DCCH_MEAS_TRIGGER,DTCH_MEAS_TRIGGER; -extern MAC_AVG_T BCCH_MEAS_AVG,CCCH_MEAS_AVG,DCCH_MEAS_AVG, DTCH_MEAS_AVG; - -extern UE_PF_PO_t UE_PF_PO[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; - -extern pthread_mutex_t ue_pf_po_mutex; - #endif diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 513e874073..f0df5996a3 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -317,7 +317,7 @@ static void rrc_gNB_CU_DU_init(gNB_RRC_INST *rrc) void openair_rrc_gNB_configuration(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration) { AssertFatal(rrc != NULL, "RC.nrrrc not initialized!"); - AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); + AssertFatal(MAX_MOBILES_PER_GNB < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); AssertFatal(configuration!=NULL,"configuration input is null\n"); rrc->module_id = 0; rrc_gNB_CU_DU_init(rrc); @@ -2698,14 +2698,12 @@ rrc_gNB_generate_RRCRelease( int rrc_gNB_generate_pcch_msg(sctp_assoc_t assoc_id, const NR_SIB1_t *sib1, uint32_t tmsi, uint8_t paging_drx) { instance_t instance = 0; - uint8_t CC_id = 0; const unsigned int Ttab[4] = {32,64,128,256}; uint8_t Tc; uint8_t Tue; uint32_t pfoffset; uint32_t N; /* N: min(T,nB). total count of PF in one DRX cycle */ uint32_t Ns = 0; /* Ns: max(1,nB/T) */ - uint8_t i_s; /* i_s = floor(UE_ID/N) mod Ns */ uint32_t T; /* DRX cycle */ uint32_t length; uint8_t buffer[RRC_BUF_SIZE]; @@ -2767,44 +2765,9 @@ int rrc_gNB_generate_pcch_msg(sctp_assoc_t assoc_id, const NR_SIB1_t *sib1, uint return (-1); } - /* insert data to UE_PF_PO or update data in UE_PF_PO */ - pthread_mutex_lock(&ue_pf_po_mutex); - uint8_t i = 0; - - for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if ((UE_PF_PO[CC_id][i].enable_flag == true && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(tmsi%1024)) - || (UE_PF_PO[CC_id][i].enable_flag != true)) { - /* set T = min(Tc,Tue) */ - UE_PF_PO[CC_id][i].T = T; - /* set UE_ID */ - UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)(tmsi%1024); - /* calculate PF and PO */ - /* set PF_min and PF_offset: (SFN + PF_offset) mod T = (T div N)*(UE_ID mod N) */ - UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N); - UE_PF_PO[CC_id][i].PF_offset = pfoffset; - /* set i_s */ - /* i_s = floor(UE_ID/N) mod Ns */ - i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns); - UE_PF_PO[CC_id][i].i_s = i_s; - - // TODO,set PO - - if (UE_PF_PO[CC_id][i].enable_flag == true) { - //paging exist UE log - LOG_D(NR_RRC,"[gNB %ld] CC_id %d In rrc_gNB_generate_pcch_msg: Update exist UE %d, T %d, N %d, PF %d, i_s %d, PF_offset %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, - T, N, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].i_s, UE_PF_PO[CC_id][i].PF_offset); - } else { - /* set enable_flag */ - UE_PF_PO[CC_id][i].enable_flag = true; - //paging new UE log - LOG_D(NR_RRC,"[gNB %ld] CC_id %d In rrc_gNB_generate_pcch_msg: Insert a new UE %d, T %d, N %d, PF %d, i_s %d, PF_offset %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, - T, N, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].i_s, UE_PF_PO[CC_id][i].PF_offset); - } - break; - } - } - - pthread_mutex_unlock(&ue_pf_po_mutex); + (void) N; /* not used, suppress warning */ + (void) Ns; /* not used, suppress warning */ + (void) pfoffset; /* not used, suppress warning */ /* Create message for PDCP (DLInformationTransfer_t) */ length = do_NR_Paging (instance,