From 17a1a554b7909c89cb842548339abc55ea198367 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 2 Jun 2020 16:14:49 +0200 Subject: [PATCH 1/7] separation of dl and ul clear fapi information --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 28 +++++++++++++++------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 13 ++++++---- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 2 +- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 758d37e6bb..a3ea1ce6b8 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -745,7 +745,7 @@ int main(int argc, char **argv) while ((roundharq_ack.ack==0)) { memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int)); memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int)); - clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot); + clear_nr_nfapi_information_dl(RC.nrmac[0], 0, frame, slot); UE_list->UE_sched_ctrl[0].harq_processes[0].ndi = !(trial&1); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 08fcf5bbaa..300f8f853a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -62,13 +62,12 @@ const uint8_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160}; uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; -void clear_nr_nfapi_information(gNB_MAC_INST * gNB, - int CC_idP, - frame_t frameP, - sub_frame_t slotP){ +void clear_nr_nfapi_information_dl(gNB_MAC_INST * gNB, + int CC_idP, + frame_t frameP, + sub_frame_t slotP){ nfapi_nr_dl_tti_request_t *DL_req = &gNB->DL_req[0]; - nfapi_nr_ul_tti_request_t *UL_tti_req = &gNB->UL_tti_req[0]; nfapi_nr_ul_dci_request_t *UL_dci_req = &gNB->UL_dci_req[0]; nfapi_nr_tx_data_request_t *TX_req = &gNB->TX_req[0]; @@ -86,17 +85,28 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, UL_dci_req[CC_idP].Slot = slotP; UL_dci_req[CC_idP].numPdus = 0; + TX_req[CC_idP].Number_of_PDUs = 0; + + } +} + +void clear_nr_nfapi_information_ul(gNB_MAC_INST * gNB, + int CC_idP, + frame_t frameP, + sub_frame_t slotP){ + + nfapi_nr_ul_tti_request_t *UL_tti_req = &gNB->UL_tti_req[0]; + + if (nfapi_mode==0 || nfapi_mode == 1) { // monolithic or PNF UL_tti_req[CC_idP].SFN = frameP; UL_tti_req[CC_idP].Slot = slotP; UL_tti_req[CC_idP].n_pdus = 0; UL_tti_req[CC_idP].n_ulsch = 0; UL_tti_req[CC_idP].n_ulcch = 0; UL_tti_req[CC_idP].n_group = 0; - - TX_req[CC_idP].Number_of_PDUs = 0; - } } + /* void check_nr_ul_failure(module_id_t module_idP, int CC_id, @@ -419,7 +429,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, memset(cc[CC_id].vrb_map, 0, 100); memset(cc[CC_id].vrb_map_UL, 0, 100); - clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame_txP, slot_txP); + clear_nr_nfapi_information_dl(RC.nrmac[module_idP], CC_id, frame_txP, slot_txP); } // refresh UE list based on UEs dropped by PHY in previous subframe diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 4e29adf978..980b26bdbb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -56,10 +56,15 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, NR_CellGroupConfig_t *secondaryCellGroup ); -void clear_nr_nfapi_information(gNB_MAC_INST * gNB, - int CC_idP, - frame_t frameP, - sub_frame_t subframeP); +void clear_nr_nfapi_information_dl(gNB_MAC_INST * gNB, + int CC_idP, + frame_t frameP, + sub_frame_t subframeP); + +void clear_nr_nfapi_information_ul(gNB_MAC_INST * gNB, + int CC_idP, + frame_t frameP, + sub_frame_t subframeP); void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame_txP, sub_frame_t slot_txP, diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 2b8dc0ec02..578a47df4f 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -225,7 +225,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { } // clear DL/UL info for new scheduling round - clear_nr_nfapi_information(mac,CC_id,UL_info->frame,UL_info->slot); + clear_nr_nfapi_information_ul(mac,CC_id,UL_info->frame,UL_info->slot); handle_nr_rach(UL_info); handle_nr_uci(UL_info, &mac->UE_list.UE_sched_ctrl[0]); // clear HI prior to handling ULSCH From c359a05351fbf9eefa41fc87f34292d18c093a8e Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Tue, 2 Jun 2020 18:31:09 +0200 Subject: [PATCH 2/7] Revert "separation of dl and ul clear fapi information" This reverts commit 17a1a554b7909c89cb842548339abc55ea198367. --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 28 +++++++--------------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 13 ++++------ openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 2 +- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index a3ea1ce6b8..758d37e6bb 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -745,7 +745,7 @@ int main(int argc, char **argv) while ((roundharq_ack.ack==0)) { memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int)); memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int)); - clear_nr_nfapi_information_dl(RC.nrmac[0], 0, frame, slot); + clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot); UE_list->UE_sched_ctrl[0].harq_processes[0].ndi = !(trial&1); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 300f8f853a..08fcf5bbaa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -62,12 +62,13 @@ const uint8_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160}; uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; -void clear_nr_nfapi_information_dl(gNB_MAC_INST * gNB, - int CC_idP, - frame_t frameP, - sub_frame_t slotP){ +void clear_nr_nfapi_information(gNB_MAC_INST * gNB, + int CC_idP, + frame_t frameP, + sub_frame_t slotP){ nfapi_nr_dl_tti_request_t *DL_req = &gNB->DL_req[0]; + nfapi_nr_ul_tti_request_t *UL_tti_req = &gNB->UL_tti_req[0]; nfapi_nr_ul_dci_request_t *UL_dci_req = &gNB->UL_dci_req[0]; nfapi_nr_tx_data_request_t *TX_req = &gNB->TX_req[0]; @@ -85,28 +86,17 @@ void clear_nr_nfapi_information_dl(gNB_MAC_INST * gNB, UL_dci_req[CC_idP].Slot = slotP; UL_dci_req[CC_idP].numPdus = 0; - TX_req[CC_idP].Number_of_PDUs = 0; - - } -} - -void clear_nr_nfapi_information_ul(gNB_MAC_INST * gNB, - int CC_idP, - frame_t frameP, - sub_frame_t slotP){ - - nfapi_nr_ul_tti_request_t *UL_tti_req = &gNB->UL_tti_req[0]; - - if (nfapi_mode==0 || nfapi_mode == 1) { // monolithic or PNF UL_tti_req[CC_idP].SFN = frameP; UL_tti_req[CC_idP].Slot = slotP; UL_tti_req[CC_idP].n_pdus = 0; UL_tti_req[CC_idP].n_ulsch = 0; UL_tti_req[CC_idP].n_ulcch = 0; UL_tti_req[CC_idP].n_group = 0; + + TX_req[CC_idP].Number_of_PDUs = 0; + } } - /* void check_nr_ul_failure(module_id_t module_idP, int CC_id, @@ -429,7 +419,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, memset(cc[CC_id].vrb_map, 0, 100); memset(cc[CC_id].vrb_map_UL, 0, 100); - clear_nr_nfapi_information_dl(RC.nrmac[module_idP], CC_id, frame_txP, slot_txP); + clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame_txP, slot_txP); } // refresh UE list based on UEs dropped by PHY in previous subframe diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 980b26bdbb..4e29adf978 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -56,15 +56,10 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, NR_CellGroupConfig_t *secondaryCellGroup ); -void clear_nr_nfapi_information_dl(gNB_MAC_INST * gNB, - int CC_idP, - frame_t frameP, - sub_frame_t subframeP); - -void clear_nr_nfapi_information_ul(gNB_MAC_INST * gNB, - int CC_idP, - frame_t frameP, - sub_frame_t subframeP); +void clear_nr_nfapi_information(gNB_MAC_INST * gNB, + int CC_idP, + frame_t frameP, + sub_frame_t subframeP); void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame_txP, sub_frame_t slot_txP, diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 578a47df4f..2b8dc0ec02 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -225,7 +225,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { } // clear DL/UL info for new scheduling round - clear_nr_nfapi_information_ul(mac,CC_id,UL_info->frame,UL_info->slot); + clear_nr_nfapi_information(mac,CC_id,UL_info->frame,UL_info->slot); handle_nr_rach(UL_info); handle_nr_uci(UL_info, &mac->UE_list.UE_sched_ctrl[0]); // clear HI prior to handling ULSCH From f6b83fd9254102bd5236df15dd8353c9a96ef21a Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 3 Jun 2020 11:51:58 +0200 Subject: [PATCH 3/7] adding frequency offset to prachsim --- openair1/SIMULATION/NR_PHY/prachsim.c | 44 +++++++++++++++------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 18939b33f2..797118b382 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -88,7 +88,7 @@ int main(int argc, char **argv){ double **s_re, **s_im, **r_re, **r_im, iqim = 0.0, delay_avg = 0, ue_speed = 0, fs, bw; int i, aa, aarx, **txdata, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1; int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0; - uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format; + uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0; uint8_t frame = 1, subframe = 9, slot=19, slot_gNB=19, config_index = 98, prach_sequence_length = 1, num_root_sequences = 16, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format, format0, format1; uint32_t tx_lev = 10000, prach_errors = 0, samp_count; //,tx_lev_dB; @@ -131,6 +131,10 @@ int main(int argc, char **argv){ config_index = atoi(optarg); break; + case 'r': + msg1_frequencystart = atoi(optarg); + break; + case 'd': delay = atoi(optarg); break; @@ -401,15 +405,15 @@ int main(int argc, char **argv){ if (format1 != 0xff) { switch(format0) { - case 0xa1: - prach_format = 9; - break; - case 0xa2: - prach_format = 10; - break; - case 0xa3: - prach_format = 11; - break; + case 0xa1: + prach_format = 9; + break; + case 0xa2: + prach_format = 10; + break; + case 0xa3: + prach_format = 11; + break; default: AssertFatal(1==0, "Only formats A1/B1 A2/B2 A3/B3 are valid for dual format"); } @@ -459,6 +463,8 @@ int main(int argc, char **argv){ } } + printf("PRACH format %d\n",prach_format); + prach_config->num_prach_fd_occasions_list[fd_occasion].prach_root_sequence_index.value = rootSequenceIndex; prach_config->num_prach_fd_occasions_list[fd_occasion].k1.value = msg1_frequencystart; prach_config->restricted_set_config.value = restrictedSetConfig; @@ -578,16 +584,14 @@ int main(int argc, char **argv){ /* tx_lev_dB not used later, no need to set */ //tx_lev_dB = (unsigned int) dB_fixed(tx_lev); - if (mu == 0) - samp_count = frame_parms->samples_per_subframe; - else - samp_count = ((slot)%(frame_parms->slots_per_subframe/2)) ? frame_parms->samples_per_slotN0 : frame_parms->samples_per_slot0; - - prach_start = slot*samp_count - UE->N_TA_offset; + samp_count=0; + for (int s=0; sget_samples_per_slot(s,frame_parms); + + prach_start = samp_count - UE->N_TA_offset; #ifdef NR_PRACH_DEBUG - LOG_M("txsig0.m", "txs0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1); - //LOG_M("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); + LOG_M("txsig0.m", "txs0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1); + LOG_M("txsig0_frame.m","txs0", txdata[0],frame_parms->samples_per_frame,1,1); #endif // multipath channel @@ -628,7 +632,7 @@ int main(int argc, char **argv){ ue_speed1 = ue_speed0 + 50; } - rx_prach_start = slot*frame_parms->get_samples_per_slot(slot,frame_parms); + rx_prach_start = subframe*frame_parms->samples_per_subframe; if (n_frames==1) printf("slot %d, rx_prach_start %d\n",slot,rx_prach_start); uint16_t preamble_rx, preamble_energy, N_ZC; N_ZC = prach_sequence_length == 0 ? 839 : 139; @@ -688,7 +692,7 @@ int main(int argc, char **argv){ if (n_frames==1) { printf("preamble %d (tx %d) : energy %d, delay %d\n",preamble_rx,preamble_tx,preamble_energy,preamble_delay); #ifdef NR_PRACH_DEBUG - LOG_M("prach0.m","prach0", &txdata[0][prach_start], samp_count, 1, 1); + LOG_M("prach0.m","prach0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1); LOG_M("prachF0.m","prachF0", &gNB->prach_vars.prachF[0], N_ZC, 1, 1); LOG_M("rxsig0.m","rxs0", &gNB->common_vars.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1); //LOG_M("ru_rxsig0.m","rxs0", &ru->common.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1); From 7948d26f8ca3d6ec2495f6412e5d2bdb403bbd42 Mon Sep 17 00:00:00 2001 From: Francesco Mani Date: Wed, 3 Jun 2020 15:45:00 +0200 Subject: [PATCH 4/7] Revert "scheduling dl in both half frames" This reverts commit cf5bc231ec2c1ad348c9bb840935b4f7679248a1. --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 28 +++++++++++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 1 + .../NR_MAC_gNB/gNB_scheduler_primitives.c | 19 ++----------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 08fcf5bbaa..8652d7fce6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -291,8 +291,7 @@ void copy_nr_ulreq(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) void nr_schedule_pucch(int Mod_idP, int UE_id, frame_t frameP, - sub_frame_t slotP, - int num_slots_per_tdd) { + sub_frame_t slotP) { uint16_t O_uci; uint16_t O_ack; @@ -307,13 +306,12 @@ void nr_schedule_pucch(int Mod_idP, nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0]; NR_sched_pucch *curr_pucch; - int p = slotP/num_slots_per_tdd; int nr_ulmix_slots = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0) nr_ulmix_slots++; for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[p][k]; + curr_pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[k]; if ((curr_pucch->dai_c > 0) && (frameP == curr_pucch->frame) && (slotP == curr_pucch->ul_slot)) { UL_tti_req->SFN = frameP; UL_tti_req->Slot = slotP; @@ -335,9 +333,7 @@ void nr_schedule_pucch(int Mod_idP, O_ack, SR_flag); - memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pucch[p][k], - 0, - sizeof(NR_sched_pucch)); + curr_pucch->dai_c = 0; } } } @@ -381,6 +377,14 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0) nr_ulmix_slots++; + if (slot_txP== 0 && (UE_list->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) { + for (int k=0; kUE_sched_ctrl[UE_id].sched_pucch[k], + 0, + sizeof(NR_sched_pucch)); + } + } + start_meas(&RC.nrmac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); @@ -393,11 +397,12 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, dlsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].dlsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains dlsch ulsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch + // hardcoding dlsch to be in slot 1 if (!(slot_txP%num_slots_per_tdd)) { if(slot_txP==0) *dlsch_in_slot_bitmap = 0x7e; else - *dlsch_in_slot_bitmap = 0x7e; + *dlsch_in_slot_bitmap = 0x00; } // hardcoding ulsch to be in slot 8 @@ -464,8 +469,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (UE_list->fiveG_connected[UE_id] && (is_xlsch_in_slot(*dlsch_in_slot_bitmap,slot_txP%num_slots_per_tdd))) { ue_sched_ctl->current_harq_pid = slot_txP % num_slots_per_tdd; nr_update_pucch_scheduling(module_idP, UE_id, frame_txP, slot_txP, num_slots_per_tdd,&pucch_sched); - nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP, - &UE_list->UE_sched_ctrl[UE_id].sched_pucch[slot_txP/num_slots_per_tdd][pucch_sched], NULL); + nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP, &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL); // resetting ta flag gNB->ta_len = 0; } @@ -482,12 +486,12 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if (get_softmodem_params()->phy_test == 0) { if (UE_list->fiveG_connected[UE_id]) - nr_schedule_pucch(module_idP, UE_id, frame_rxP, slot_rxP, num_slots_per_tdd); + nr_schedule_pucch(module_idP, UE_id, frame_rxP, slot_rxP); schedule_nr_prach(module_idP, (frame_rxP+1)&1023, slot_rxP); nr_schedule_reception_msg3(module_idP, 0, frame_rxP, slot_rxP); } if (get_softmodem_params()->phy_test){ - nr_schedule_pucch(module_idP, UE_id, frame_rxP, slot_rxP, num_slots_per_tdd); + nr_schedule_pucch(module_idP, UE_id, frame_rxP, slot_rxP); if (is_xlsch_in_slot(*ulsch_in_slot_bitmap,slot_rxP%num_slots_per_tdd)){ nr_schedule_uss_ulsch_phytest(module_idP, frame_rxP, slot_rxP); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index f9e43dfeb3..0167a5579b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -370,6 +370,7 @@ int configure_fapi_dl_pdu(int Mod_idP, dci_pdu_rel15[0].ndi = UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi; // DAI dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3; + // TPC for PUCCH dci_pdu_rel15[0].tpc = 1; // table 7.2.1-1 in 38.213 // PUCCH resource indicator diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5c84d779df..fa1e860c57 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1328,13 +1328,11 @@ int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ int UE_id; - int i,p; + int i; NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list; NR_COMMON_channels_t *cc = RC.nrmac[mod_idP]->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; int num_slots_ul = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - int nb_periods = 1<<(7-scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols>0) num_slots_ul++; LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n", @@ -1355,17 +1353,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){ memset((void *) &UE_list->UE_sched_ctrl[UE_id], 0, sizeof(NR_UE_sched_ctrl_t)); - - UE_list->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch **)malloc(nb_periods*sizeof(NR_sched_pucch *)); - for (p=0; pUE_sched_ctrl[UE_id].sched_pucch[p] = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch)); - for (p=0; pUE_sched_ctrl[UE_id].sched_pucch[p][k], - 0, sizeof(NR_sched_pucch)); - } - } - + UE_list->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch)); LOG_I(MAC, "gNB %d] Add NR UE_id %d : rnti %x\n", mod_idP, UE_id, @@ -1443,7 +1431,6 @@ void nr_update_pucch_scheduling(int Mod_idP, NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; NR_sched_pucch *curr_pucch; - int tdd_index = slotP/slots_per_tdd; int first_ul_slot_tdd,k,i; uint8_t pdsch_to_harq_feedback[8]; int found = 0; @@ -1457,7 +1444,7 @@ void nr_update_pucch_scheduling(int Mod_idP, // for each possible ul or mixed slot for (k=0; kUE_sched_ctrl[UE_id].sched_pucch[tdd_index][k]; + curr_pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[k]; // if there is free room in current pucch structure if (curr_pucch->dai_cframe = frameP; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 666ca64132..0125535071 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -198,7 +198,7 @@ typedef struct NR_UE_harq { typedef struct { uint64_t dlsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains dlsch uint64_t ulsch_in_slot_bitmap; // static bitmap signaling which slot in a tdd period contains ulsch - NR_sched_pucch **sched_pucch; + NR_sched_pucch *sched_pucch; uint16_t ta_timer; int16_t ta_update; uint8_t current_harq_pid; From 91fd14bf995e194054f7b8e3f0ebbab7a9a264e5 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 5 Jun 2020 17:35:25 +0200 Subject: [PATCH 5/7] UE harq bugfixes --- executables/nr-ue.c | 9 +-- .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 3 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 6 +- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 63 ++++++++++--------- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 30ce657edb..db0af31a65 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -374,7 +374,7 @@ void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_scheduled_response_t scheduled_response; // program PUSCH. this should actually be done by the MAC upon reception of an UL DCI - if (proc->nr_tti_tx == 8 || proc->nr_tti_tx == 19 || UE->frame_parms.frame_type == FDD){ + if (proc->nr_tti_tx == 8 || proc->nr_tti_tx == 7 || UE->frame_parms.frame_type == FDD){ mod_id = UE->Mod_id; @@ -420,7 +420,7 @@ void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_ue_scheduled_response(&scheduled_response); if (UE->mode != loop_through_memory) { - uint8_t thread_id = PHY_vars_UE_g[mod_id][0]->current_thread_id[proc->nr_tti_tx]; + uint8_t thread_id = PHY_vars_UE_g[mod_id][0]->current_thread_id[proc->nr_tti_rx]; phy_procedures_nrUE_TX(UE,proc,0,thread_id); } } @@ -860,8 +860,9 @@ void *UE_thread(void *arg) { usleep(200); } - if ( decoded_frame_rx != curMsg->proc.frame_rx && - ((decoded_frame_rx+1) % MAX_FRAME_NUMBER) != curMsg->proc.frame_rx ) + if ( (decoded_frame_rx != curMsg->proc.frame_rx) && + (((decoded_frame_rx+1) % MAX_FRAME_NUMBER) != curMsg->proc.frame_rx) && + (((decoded_frame_rx+2) % MAX_FRAME_NUMBER) != curMsg->proc.frame_rx)) LOG_D(PHY,"Decoded frame index (%d) is not compatible with current context (%d), UE should go back to synch mode\n", decoded_frame_rx, curMsg->proc.frame_rx ); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 0dffb66c15..5c2221805f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -32,6 +32,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "PHY/defs_nr_UE.h" +#include "SCHED_NR_UE/harq_nr.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/CODING/coding_extern.h" #include "PHY/CODING/coding_defs.h" @@ -132,6 +133,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint memset(dlsch,0,sizeof(NR_UE_DLSCH_t)); dlsch->Kmimo = Kmimo; dlsch->Mdlharq = Mdlharq; + dlsch->number_harq_processes_for_pdsch = Mdlharq; dlsch->Nsoft = Nsoft; dlsch->Mlimit = 4; dlsch->max_ldpc_iterations = max_ldpc_iterations; @@ -142,6 +144,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint if (dlsch->harq_processes[i]) { memset(dlsch->harq_processes[i],0,sizeof(NR_DL_UE_HARQ_t)); + init_downlink_harq_status(dlsch->harq_processes[i]); dlsch->harq_processes[i]->first_tx=1; dlsch->harq_processes[i]->b = (uint8_t*)malloc16(dlsch_bytes); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 1a562c04c8..d05dde4667 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -44,6 +44,7 @@ #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" //#include "PHY/extern.h" #include "SCHED_NR_UE/defs.h" +#include "SCHED_NR_UE/pucch_uci_ue_nr.h" #include "SCHED_NR/extern.h" #include "SCHED_NR_UE/phy_sch_processing_time.h" //#include @@ -4032,8 +4033,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; NR_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id]; fapi_nr_config_request_t *cfg = &ue->nrUE_config; - uint8_t harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid; - NR_DL_UE_HARQ_t *dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; + uint8_t *harq_pid = &ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid; + NR_DL_UE_HARQ_t *dlsch0_harq = dlsch[0]->harq_processes[*harq_pid]; uint16_t nb_symb_sch = dlsch0_harq->nb_symbols; uint16_t start_symb_sch = dlsch0_harq->start_symbol; uint8_t nb_symb_pdcch = pdcch_vars->nb_search_space > 0 ? pdcch_vars->pdcch_config[0].coreset.duration : 0; @@ -4144,6 +4145,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if (dci_cnt > 0){ LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); //to update from pdsch config + dlsch0_harq = dlsch[0]->harq_processes[*harq_pid]; start_symb_sch = dlsch0_harq->start_symbol; int symb_dmrs=-1; for (int i=0;i<4;i++) if (((1<dlDmrsSymbPos) > 0) {symb_dmrs=i;break;} diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index a2452248b8..de6605b08d 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -718,41 +718,44 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t for (int dl_harq_pid = 0; dl_harq_pid < number_pid_dl; dl_harq_pid++) { - harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid]->harq_ack; + for (int thread_idx = 0; thread_idx < RX_NB_TH; thread_idx++) { - /* check if current tx slot should transmit downlink acknowlegment */ - if (harq_status->slot_for_feedback_ack == proc->nr_tti_tx) { + harq_status = &ue->dlsch[thread_idx][gNB_id][code_word]->harq_processes[dl_harq_pid]->harq_ack; - if (harq_status->ack == DL_ACKNACK_NO_SET) { - LOG_E(PHY,"PUCCH Downlink acknowledgment has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return (0); - } - else if (harq_status->vDAI_DL == DL_DAI_NO_SET) { - LOG_E(PHY,"PUCCH Downlink DAI has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return (0); - } - else if (harq_status->vDAI_DL > NR_DL_MAX_DAI) { - LOG_E(PHY,"PUCCH Downlink DAI has an invalid value : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return (0); - } - else if (harq_status->send_harq_status == 0) { - LOG_E(PHY,"PUCCH Downlink ack can not be transmitted : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return(0); - } - else { + /* check if current tx slot should transmit downlink acknowlegment */ + if (harq_status->slot_for_feedback_ack == proc->nr_tti_tx) { - dai_current = harq_status->vDAI_DL; - - if (dai_current == 0) { - LOG_E(PHY,"PUCCH Downlink dai is invalid : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - return(0); - } else if (dai_current > dai_max) { - dai_max = dai_current; + if (harq_status->ack == DL_ACKNACK_NO_SET) { + LOG_E(PHY,"PUCCH Downlink acknowledgment has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + return (0); } + else if (harq_status->vDAI_DL == DL_DAI_NO_SET) { + LOG_E(PHY,"PUCCH Downlink DAI has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + return (0); + } + else if (harq_status->vDAI_DL > NR_DL_MAX_DAI) { + LOG_E(PHY,"PUCCH Downlink DAI has an invalid value : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + return (0); + } + else if (harq_status->send_harq_status == 0) { + LOG_E(PHY,"PUCCH Downlink ack can not be transmitted : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + return(0); + } + else { - number_harq_feedback++; - ack_data[code_word][dai_current - 1] = harq_status->ack; - dai[code_word][dai_current - 1] = dai_current; + dai_current = harq_status->vDAI_DL; + + if (dai_current == 0) { + LOG_E(PHY,"PUCCH Downlink dai is invalid : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + return(0); + } else if (dai_current > dai_max) { + dai_max = dai_current; + } + + number_harq_feedback++; + ack_data[code_word][dai_current - 1] = harq_status->ack; + dai[code_word][dai_current - 1] = dai_current; + } } } if (do_reset == TRUE) { From 06ee95f40e546c6e3587f0b4d7cfa3be5ef8f418 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 5 Jun 2020 17:35:46 +0200 Subject: [PATCH 6/7] UE sync fix --- openair1/PHY/MODULATION/slot_fep_nr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 7ff735cb71..0a3047a56d 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -338,7 +338,7 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, #endif - dft(dftsize,(int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + dft(dftsize,(int16_t *) &common_vars->rxdata[aa][rx_offset], (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); #if UE_TIMING_TRACE stop_meas(&ue->rx_dft_stats); @@ -362,7 +362,7 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, dft(dftsize,(int16_t *)tmp_dft_in, (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); } else { // use dft input from RX buffer directly - dft(dftsize,(int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + dft(dftsize,(int16_t *) &common_vars->rxdata[aa][rx_offset], (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); } #if UE_TIMING_TRACE From 0124e5378c910ea5fe0f745d59b7d43214c330e7 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Sat, 6 Jun 2020 22:55:13 +0200 Subject: [PATCH 7/7] adding possibility to read rx signal from file --- openair1/SIMULATION/NR_PHY/prachsim.c | 31 ++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 797118b382..c420ca41fa 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -99,7 +99,9 @@ int main(int argc, char **argv){ // double prach_sinr; // uint32_t nsymb; // uint16_t preamble_max, preamble_energy_max; - + FILE *input_fd=NULL; + char* input_file=NULL; + int n_bytes=0; NR_DL_FRAME_PARMS *frame_parms; NR_PRACH_RESOURCES_t prach_resources; @@ -292,6 +294,14 @@ int main(int argc, char **argv){ break; case 'F': + input_fd = fopen(optarg,"r"); + input_file = optarg; + + if (input_fd==NULL) { + printf("Problem with filename %s\n",optarg); + exit(-1); + } + break; default: @@ -647,7 +657,7 @@ int main(int argc, char **argv){ for (trial=0; trialcommon.rxdata[aa][rx_prach_start])[2*i+1] = (short) (.167*(r_im[aa][i] + (iqim*r_re[aa][i]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); } } + } else { + n_bytes = fread(&ru->common.rxdata[0][rx_prach_start+frame_parms->samples_per_subframe/2],sizeof(int32_t),frame_parms->samples_per_subframe/2,input_fd); + printf("fread %d bytes from file %s\n",n_bytes,input_file); + if (n_bytes!=frame_parms->samples_per_subframe/2) { + printf("expected %d bytes\n",frame_parms->samples_per_subframe/2); + exit(-1); + } + } + rx_nr_prach_ru(ru, prach_format, numRA, prachStartSymbol, frame, slot); @@ -695,7 +714,7 @@ int main(int argc, char **argv){ LOG_M("prach0.m","prach0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1); LOG_M("prachF0.m","prachF0", &gNB->prach_vars.prachF[0], N_ZC, 1, 1); LOG_M("rxsig0.m","rxs0", &gNB->common_vars.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1); - //LOG_M("ru_rxsig0.m","rxs0", &ru->common.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1); + LOG_M("ru_rxsig0.m","rxs0", &ru->common.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1); LOG_M("rxsigF0.m","rxsF0", gNB->prach_vars.rxsigF[0], N_ZC, 1, 1); LOG_M("prach_preamble.m","prachp", &gNB->X_u[0], N_ZC, 1, 1); LOG_M("ue_prach_preamble.m","prachp", &UE->X_u[0], N_ZC, 1, 1); @@ -703,6 +722,8 @@ int main(int argc, char **argv){ } } printf("SNR %f dB, UE Speed %f km/h: errors %d/%d (delay %f)\n", SNR, ue_speed, prach_errors, n_frames, delay_avg/(double)(n_frames-prach_errors)); + if (input_fd) + break; if (prach_errors) break; } // UE Speed loop @@ -710,6 +731,8 @@ int main(int argc, char **argv){ printf("PRACH test OK\n"); break; } + if (input_fd) + break; } //SNR loop for (i=0; i<2; i++) { @@ -724,5 +747,7 @@ int main(int argc, char **argv){ free(r_re); free(r_im); + if (input_fd) fclose(input_fd); + return(0); }