From 7a7b668e1694c0d96e0a7cbe4d4be4f4847ba669 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Tue, 1 Jun 2021 12:03:54 -0700 Subject: [PATCH] The pRACH is now only generated for slot 19. Several other changes in this commit include: - Setting the number of PDUS in the ul_config to be zero when we will it (inside of the get_ul_config() function.) - We reset the nprach flag to 0 for each slot. - We return out of the prach scheduler if mac->ul_config == NULL - Added error checking for array indexing - Created a dummy scheduler response function. - Allocated ul_config_req initially --- executables/nr-ue.c | 13 +++++++++---- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 9 +++++++++ openair1/SCHED_NR_UE/fapi_nr_ue_l1.h | 2 ++ openair2/LAYER2/NR_MAC_UE/config_ue.c | 5 +++++ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 15 +++++++++------ openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 5 ++++- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index c4d44ca7e8..298305814a 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -164,7 +164,7 @@ static void L1_nsa_prach_procedures(nfapi_nr_rach_indication_t *rach_ind, frame_ rach_ind->pdu_list[pdu_index].num_preamble = 1; const int num_p = rach_ind->pdu_list[pdu_index].num_preamble; rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t)); - rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = 0; + rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = 63; //Melissa, need to get this out of rrc_reconfig_msg rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0; rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff; @@ -203,16 +203,21 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) continue; } + mac->ra.generate_nr_prach = 0; frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot); int slot = NFAPI_SFNSLOT2SLOT(sfn_slot); + #if 0 int slots_per_frame = 2048; int slots_per_subframe = 2; int slot_ahead = 6; + ul_info.frame_tx = frame; //Melissa, hack. (slot > slots_per_frame - 1 - (slots_per_subframe*slot_ahead)) ? frame & 1023 : frame; + ul_info.slot_tx = slot; // Melissa hack. slot + slots_per_subframe*slot_ahead % slots_per_frame; + #endif nr_uplink_indication_t ul_info; ul_info.frame_rx = frame; ul_info.slot_rx = slot; - ul_info.frame_tx = (slot > slots_per_frame - 1 - (slots_per_subframe*slot_ahead)) ? frame & 1023 : frame; - ul_info.slot_tx = slot + slots_per_subframe*slot_ahead % slots_per_frame; + ul_info.frame_tx = frame; + ul_info.slot_tx = slot; if (is_nr_UL_slot(mac->scc, slot)) { LOG_I(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", slot, __FUNCTION__); nr_ue_ul_indication(&ul_info); @@ -232,7 +237,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) The UE is basically filling the rach and proxy will receive and think that it came from the gNB. The received rach in the proxy will trigger gNB to send back the RAR. RAR will go to proxy then goes to UE and the UE will get the DCI for RAR and the payload. have to handle receving the RAR once we get it. */ - LOG_I(NR_PHY, "Calling nr_Msg1_transmitted!!!\n"); + LOG_I(NR_PHY, "Calling nr_Msg1_transmitted for slot %d\n", slot); nr_Msg1_transmitted(mod_id, CC_id, frame, gNB_id); //This is called when phy layer has sent the prach } else if (nr_prach == 2) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index bdbfae58e3..1ffb6ef8b4 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -45,6 +45,15 @@ extern PHY_VARS_NR_UE ***PHY_vars_UE_g; const char *dl_pdu_type[]={"DCI", "DLSCH", "RA_DLSCH"}; const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"}; +int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { + /* Melissa, this is a hack. We are not calling nr_ue_scheduled_response + because it requires PHY_vars_UE_g. We are basically not using layer + one here so we are calling a stub version of this scheduled response. + The original scheduled_response sends downlink information for the DCIs. + The physical layer provides this information. We dont need this yet.*/ + return 0; +} + int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if(scheduled_response != NULL){ diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h index 9b7b87a18c..10e9659776 100755 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.h @@ -39,6 +39,8 @@ \param scheduled_response including transmission config(dl_config, ul_config) and data transmission (tx_req)*/ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response); +int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response); + /**\brief NR UE FAPI-like P5 message, physical configuration from L2 to configure L1 \param scheduled_response including transmission config(dl_config, ul_config) and data transmission (tx_req)*/ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index f6bd5436bc..b8b24f9b7c 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -531,6 +531,11 @@ int nr_rrc_mac_config_req_ue( if (cell_group_config->spCellConfig->reconfigurationWithSync) { ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { + num_slots++; + } + mac->ul_config_request = calloc(num_slots, sizeof(*mac->ul_config_request)); config_common_ue(mac,module_id,cc_idP); mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 1da6aea72c..51e9ad2442 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -138,9 +138,10 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl num_slots_per_tdd, num_slots_ul, index); + if(!mac->ul_config_request) return NULL; - + mac->ul_config_request[index].number_pdus = 0; return &mac->ul_config_request[index]; } @@ -1651,9 +1652,12 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); RA_config_t *ra = &mac->ra; + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); + if (!ul_config) { + LOG_E(NR_MAC, "mac->ul_config is null! \n"); + return; + } - //fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); - fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[0]; fapi_nr_ul_config_prach_pdu *prach_config_pdu; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_prach_config_t *prach_config = &cfg->prach_config; @@ -1686,10 +1690,9 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s format = prach_occasion_info_p->format; format0 = format & 0xff; // single PRACH format format1 = (format >> 8) & 0xff; // dual PRACH format - if (ul_config == NULL) - return; + AssertFatal(ul_config->number_pdus < FAPI_NR_UL_CONFIG_LIST_NUM, "Too many PDUs %d\n", ul_config->number_pdus); prach_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu; - memset(prach_config_pdu, 0, sizeof(fapi_nr_ul_config_prach_pdu)); + memset(prach_config_pdu, 0, sizeof(*prach_config_pdu)); ul_config->number_pdus += 1; LOG_D(PHY, "In %s: (%p) %d UL PDUs:\n", __FUNCTION__, ul_config, ul_config->number_pdus); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 26dd74d4ec..89640f825c 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -426,7 +426,10 @@ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id){ nr_ue_if_module_inst[module_id]->current_frame = 0; nr_ue_if_module_inst[module_id]->current_slot = 0; nr_ue_if_module_inst[module_id]->phy_config_request = nr_ue_phy_config_request; - nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response; + if (get_softmodem_params()->nsa) //Melissa, this is also a hack. Get a better flag. + nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response_stub; + else + nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response; nr_ue_if_module_inst[module_id]->dl_indication = nr_ue_dl_indication; nr_ue_if_module_inst[module_id]->ul_indication = nr_ue_ul_indication; }