From 6d69a1069f2dfcf550c18949e29be0a77d97b60a Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 6 Sep 2019 18:12:13 +0200 Subject: [PATCH] adding PHY side of FAPI UL handling --- executables/nr-gnb.c | 4 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 4 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c | 34 ++++++---- openair1/PHY/defs_gNB.h | 5 +- openair1/SCHED_NR/fapi_nr_l1.c | 6 ++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 68 +++++++++++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 1 - 8 files changed, 73 insertions(+), 51 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index f96c6f27a9..8c8681b497 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -924,7 +924,8 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { gNB->if_inst->NR_Schedule_response = nr_schedule_response; gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO)); - memset((void *)&gNB->Sched_INFO,0,sizeof(gNB->Sched_INFO)); + memset((void *)&gNB->UL_tti_req,0,sizeof(nfapi_nr_ul_tti_request_t)); + //memset((void *)&gNB->Sched_INFO,0,sizeof(gNB->Sched_INFO)); LOG_I(PHY,"Setting indication lists\n"); gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list = gNB->rx_pdu_list; gNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = gNB->crc_pdu_list; @@ -932,6 +933,7 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list; + gNB->prach_energy_counter = 0; } } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index ab3cf4af9b..b48299b691 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -155,7 +155,7 @@ void nr_pdcch_scrambling(uint32_t *in, } } -uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, +uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, uint32_t **gold_pdcch_dmrs, int32_t *txdataF, int16_t amp, @@ -170,8 +170,6 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, nr_cce_t cce; nr_reg_t reg; nr_reg_t reg_mapping_list[NR_MAX_PDCCH_AGG_LEVEL*NR_NB_REG_PER_CCE]; - /*First iteration: single DCI*/ - NR_gNB_DCI_ALLOC_t dci_alloc = pdcch_vars.dci_alloc[0]; nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params = dci_alloc.pdcch_params; /*The coreset is initialised diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index f246eaf18e..10865ca4be 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -30,7 +30,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, uint16_t N_RB, nfapi_nr_config_request_t *config); -uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, +uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, uint32_t **gold_pdcch_dmrs, int32_t *txdataF, int16_t amp, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c index 22aa927e41..e188ddcfb4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c @@ -316,28 +316,34 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, nfapi_nr_pusch_pdu_t *ulsch_pdu) { - int ulsch_id = find_nr_dlsch(ulsch_pdu->rnti,gNB,SEARCH_EXIST); + int ulsch_id = find_nr_ulsch(ulsch_pdu->rnti,gNB,SEARCH_EXIST); AssertFatal( (ulsch_id>=0) && (ulsch_idrnti,ulsch_id); + NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ulsch_id][0]; - NR_UL_gNB_HARQ_t **harq = ulsch->harq_processes; int harq_pid = ulsch_pdu->pusch_data.harq_process_id; - nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &harq[harq_pid]->ulsch_pdu; + ulsch->rnti = ulsch_pdu->rnti; + //ulsch->rnti_type; + ulsch->harq_mask |= 1<harq_process_id[slot] = harq_pid; + + nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch->harq_processes[harq_pid]->ulsch_pdu; LOG_I(PHY,"Initializing nFAPI for ULSCH, UE %d, harq_pid %d\n",ulsch_id,harq_pid); - + + //FK this is still a bad hack. We need to replace the L1 FAPI structures with the new scf ones as well. rel15_ul->rnti = ulsch_pdu->rnti; - rel15_ul->ulsch_pdu_rel15.start_rb = ulsch_pdu->rb_start; - rel15_ul->ulsch_pdu_rel15.number_rbs = ulsch_pdu->rb_size; - rel15_ul->ulsch_pdu_rel15.start_symbol = ulsch_pdu->start_symbol_index; - rel15_ul->ulsch_pdu_rel15.number_symbols = ulsch_pdu->nr_of_symbols; - rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = 6; //where should this come from? - rel15_ul->ulsch_pdu_rel15.length_dmrs = 1; //where should this come from? - rel15_ul->ulsch_pdu_rel15.Qm = ulsch_pdu->qam_mod_order; - rel15_ul->ulsch_pdu_rel15.mcs = ulsch_pdu->mcs_index; - rel15_ul->ulsch_pdu_rel15.rv = ulsch_pdu->pusch_data.rv_index; - rel15_ul->ulsch_pdu_rel15.n_layers = ulsch_pdu->nrOfLayers; + rel15_ul->ulsch_pdu_rel15.start_rb = ulsch_pdu->rb_start; + rel15_ul->ulsch_pdu_rel15.number_rbs = ulsch_pdu->rb_size; + rel15_ul->ulsch_pdu_rel15.start_symbol = ulsch_pdu->start_symbol_index; + rel15_ul->ulsch_pdu_rel15.number_symbols = ulsch_pdu->nr_of_symbols; + rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = 6; //where should this come from? + rel15_ul->ulsch_pdu_rel15.length_dmrs = 1; //where should this come from? + rel15_ul->ulsch_pdu_rel15.Qm = ulsch_pdu->qam_mod_order; + rel15_ul->ulsch_pdu_rel15.mcs = ulsch_pdu->mcs_index; + rel15_ul->ulsch_pdu_rel15.rv = ulsch_pdu->pusch_data.rv_index; + rel15_ul->ulsch_pdu_rel15.n_layers = ulsch_pdu->nrOfLayers; } diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 0ced3e1dac..b170ebd875 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -614,6 +614,7 @@ typedef struct PHY_VARS_gNB_s { NR_IF_Module_t *if_inst; NR_UL_IND_t UL_INFO; pthread_mutex_t UL_INFO_mutex; + /// NFAPI RX ULSCH information nfapi_rx_indication_pdu_t rx_pdu_list[NFAPI_RX_IND_MAX_PDU]; /// NFAPI RX ULSCH CRC information @@ -629,7 +630,9 @@ typedef struct PHY_VARS_gNB_s { /// NFAPI PRACH information nfapi_preamble_pdu_t preamble_list[MAX_NUM_RX_PRACH_PREAMBLES]; - Sched_Rsp_t Sched_INFO; + //Sched_Rsp_t Sched_INFO; + nfapi_nr_ul_tti_request_t UL_tti_req; + NR_gNB_PDCCH pdcch_vars; NR_gNB_PBCH pbch; // LTE_eNB_PHICH phich_vars[2]; diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 51d5d20d9d..3eeeafc6b5 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -30,6 +30,7 @@ * \warning */ #include "fapi_nr_l1.h" +#include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_dci.h" @@ -158,7 +159,11 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ } } } + + memcpy(&gNB->UL_tti_req,UL_tti_req,sizeof(nfapi_nr_ul_tti_request_t)); + /* + // this is done in phy_procedures_gNB_uespec_RX now for (i=0;ipdus_list[i].pdu_type); switch (UL_tti_req->pdus_list[i].pdu_type) { @@ -169,6 +174,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ } } } + */ if (nfapi_mode && do_oai && !dont_send) { oai_nfapi_tx_req(Sched_INFO->TX_req); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 41e360aa4e..9c230ecab3 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -181,28 +181,27 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, num_dci = gNB->pdcch_vars.num_dci; num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti; - if (num_dci) { + for (int i=0; iMod_id, frame, slot, num_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1); - if (nfapi_mode == 0 || nfapi_mode == 1) { - nr_generate_dci_top(gNB->pdcch_vars, - gNB->nr_gold_pdcch_dmrs[slot], - gNB->common_vars.txdataF[0], - AMP, *fp, *cfg); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0); - if (num_pdsch_rnti) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1); - LOG_D(PHY, "PDSCH generation started (%d)\n", num_pdsch_rnti); - nr_generate_pdsch(gNB->dlsch[0][0], - &gNB->pdcch_vars.dci_alloc[0], - gNB->nr_gold_pdsch_dmrs[slot], - gNB->common_vars.txdataF, - AMP, frame, slot, fp, cfg); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0); - } - } + nr_generate_dci_top(gNB->pdcch_vars.dci_alloc[i], + gNB->nr_gold_pdcch_dmrs[slot], + gNB->common_vars.txdataF[0], + AMP, *fp, *cfg); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0); + } + + for (int i=0; idlsch[i][0], + &gNB->pdcch_vars.dci_alloc[i], + gNB->nr_gold_pdsch_dmrs[slot], + gNB->common_vars.txdataF, + AMP, frame, slot, fp, cfg); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0); @@ -212,7 +211,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id, uint8_t harq_pid) { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; - nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->ulsch_pdu; + nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->ulsch_pdu; nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &rel15_ul->ulsch_pdu_rel15; //uint8_t ret; @@ -344,19 +343,28 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) } - void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, uint8_t symbol_start, uint8_t symbol_end) { - - uint8_t UE_id; - uint8_t symbol; - uint8_t harq_pid = 0; // [hna] Previously in LTE, the harq_pid was obtained from the subframe number (Synchronous HARQ) - // In NR, this should be signaled through uplink scheduling dci (i.e, DCI 0_0, 0_1) (Asynchronous HARQ) - for (UE_id = 0; UE_id < 1; UE_id++) { // temporary set to 1 untill list of connected UEs is implemented - for(symbol = symbol_start; symbol < symbol_end; symbol++) { - nr_rx_pusch(gNB, UE_id, frame_rx, slot_rx, symbol, harq_pid); + nfapi_nr_ul_tti_request_t *UL_tti_req = &gNB->UL_tti_req; + int num_pusch_pdu = UL_tti_req->n_pdus; + + for (int i = 0; i < num_pusch_pdu; i++) { + + switch (UL_tti_req->pdus_list[i].pdu_type) { + case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE: + { + nfapi_nr_pusch_pdu_t *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu; + nr_fill_ulsch(gNB,frame_rx,slot_rx,pusch_pdu); + + uint8_t UE_id = find_nr_ulsch(pusch_pdu->rnti,gNB,SEARCH_EXIST); + uint8_t harq_pid = pusch_pdu->pusch_data.harq_process_id; + + for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) { + nr_rx_pusch(gNB, UE_id, frame_rx, slot_rx, symbol, harq_pid); + } + nr_ulsch_procedures(gNB, frame_rx, slot_rx, UE_id, harq_pid); + nr_fill_rx_indication(gNB, frame_rx, slot_rx, UE_id, harq_pid); // indicate SDU to MAC + } } - nr_ulsch_procedures(gNB, frame_rx, slot_rx, UE_id, harq_pid); - nr_fill_rx_indication(gNB, frame_rx, slot_rx, UE_id, harq_pid); // indicate SDU to MAC } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 4b52963988..8cfd6e7964 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -183,7 +183,6 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; //NR_COMMON_channels_t *cc = nr_mac->common_channels; nfapi_nr_dl_config_request_body_t *dl_req; - nfapi_nr_pusch_pdu_t *ul_req; nfapi_nr_dl_config_request_pdu_t *dl_config_dci_pdu; nfapi_nr_dl_config_request_pdu_t *dl_config_dlsch_pdu; nfapi_tx_request_pdu_t *TX_req;