diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 0007a3b4d109dd6b3e8ad97863e046d67f306049..1f350725526783da3723c121c89e8ed56d04eb6e 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -861,6 +861,7 @@ int main(int argc, char **argv) nr_l2_init_ue(NULL); UE_mac = get_mac_inst(0); + ue_init_config_request(UE_mac, mu); UE->if_inst = nr_ue_if_module_init(0); UE->if_inst->scheduled_response = nr_ue_scheduled_response; @@ -888,7 +889,8 @@ int main(int argc, char **argv) //Configure UE NR_BCCH_BCH_Message_t *mib = get_new_MIB_NR(scc); - nr_rrc_mac_config_req_ue(0, 0, 0, mib->message.choice.mib, NULL, NULL, secondaryCellGroup); + nr_rrc_mac_config_req_mib(0, 0, mib->message.choice.mib, false); + nr_rrc_mac_config_req_scg(0, 0, secondaryCellGroup); nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 6aaa79bb76e2c577d483ceee60de2f1f072a1a5c..4ee528a6fc1f0bec42a360cc19e37469f198cdcd 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -744,11 +744,8 @@ int main(int argc, char **argv) UE_mac->if_module = nr_ue_if_module_init(0); -// nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup); - nr_ue_phy_config_request(&UE_mac->phy_config); - unsigned char harq_pid = 0; NR_gNB_ULSCH_t *ulsch_gNB = &gNB->ulsch[UE_id]; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index fa70835d9ae49c0733a678318298c442fc9c8859..a3bb33868e08a5e4210ba536ce645349e1f60a43 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -693,145 +693,133 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } - -int nr_rrc_mac_config_req_ue(module_id_t module_id, - int cc_idP, - uint8_t gNB_index, - NR_MIB_t *mibP, - NR_ServingCellConfigCommonSIB_t *sccP, - NR_CellGroupConfig_t *cell_group_config, - NR_CellGroupConfig_t *scell_group_config) +void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs) { + int slots_per_frame = nr_slots_per_frame[scs]; + LOG_I(NR_MAC, "Initializing dl and ul config_request. num_slots = %d\n", slots_per_frame); + mac->dl_config_request = calloc(slots_per_frame, sizeof(*mac->dl_config_request)); + mac->ul_config_request = calloc(slots_per_frame, sizeof(*mac->ul_config_request)); + for (int i = 0; i < slots_per_frame; i++) + pthread_mutex_init(&(mac->ul_config_request[i].mutex_ul_config), NULL); +} +void nr_rrc_mac_config_req_mib(module_id_t module_id, + int cc_idP, + NR_MIB_t *mib, + bool sched_sib1) +{ NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - RA_config_t *ra = &mac->ra; - fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; - - if (mac->dl_config_request == NULL) // for SIB1 reception - mac->dl_config_request = calloc(NR_MAX_SLOTS_PER_FRAME, sizeof(*mac->dl_config_request)); + AssertFatal(mib, "MIB should not be NULL\n"); + // initialize dl and ul config_request upon first reception of MIB + mac->mib = mib; // update by every reception + mac->phy_config.Mod_id = module_id; + mac->phy_config.CC_id = cc_idP; + mac->get_sib1 = sched_sib1; +} - // TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc. +void nr_rrc_mac_config_req_sib1(module_id_t module_id, + int cc_idP, + NR_ServingCellConfigCommonSIB_t *scc) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + AssertFatal(scc, "SIB1 SCC should not be NULL\n"); + mac->scc_SIB = scc; + mac->nr_band = *scc->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list.array[0]->freqBandIndicatorNR; + config_common_ue_sa(mac, module_id, cc_idP); + configure_current_BWP(mac, scc, NULL); + + // Setup the SSB to Rach Occasionsif (cell_group_config->spCellConfig) { mapping according to the config + build_ssb_to_ro_map(mac); + if (!get_softmodem_params()->emulate_l1) + mac->if_module->phy_config_request(&mac->phy_config); + mac->phy_config_request_sent = true; +} - if(mibP != NULL){ - mac->mib = mibP; // update by every reception - mac->phy_config.Mod_id = module_id; - mac->phy_config.CC_id = cc_idP; - } - AssertFatal(scell_group_config == NULL || cell_group_config == NULL, - "both scell_group_config and cell_group_config cannot be non-NULL\n"); +void nr_rrc_mac_config_req_mcg(module_id_t module_id, + int cc_idP, + NR_CellGroupConfig_t *cell_group_config) +{ + LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); + AssertFatal(cell_group_config, "CellGroupConfig should not be NULL\n"); + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + mac->cg = cell_group_config; + if (cell_group_config->spCellConfig) + mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; + else + mac->servCellIndex = 0; - if (sccP != NULL) { + mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE; + LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", + module_id, + mac->scheduling_info.periodicBSR_SF, + mac->scheduling_info.retxBSR_SF); - mac->scc_SIB = sccP; - mac->nr_band = *sccP->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list.array[0]->freqBandIndicatorNR; - config_common_ue_sa(mac, module_id, cc_idP); - configure_current_BWP(mac, sccP, NULL); + configure_current_BWP(mac, NULL, cell_group_config); + config_control_ue(mac); - int num_slots_ul = nr_slots_per_frame[mac->mib->subCarrierSpacingCommon]; - if(cfg->cell_config.frame_duplex_type == TDD){ - num_slots_ul = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - if (mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { - num_slots_ul++; - } + RA_config_t *ra = &mac->ra; + if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { + LOG_A(NR_MAC, "Received the reconfigurationWithSync in %s\n", __FUNCTION__); + if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { + ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; } - LOG_I(NR_MAC, "Initializing ul_config_request. num_slots_ul = %d\n", num_slots_ul); - mac->ul_config_request = calloc(num_slots_ul, sizeof(*mac->ul_config_request)); - for (int i=0; i<num_slots_ul; i++) - pthread_mutex_init(&(mac->ul_config_request[i].mutex_ul_config), NULL); - - int num_slots_dl = nr_slots_per_frame[mac->mib->subCarrierSpacingCommon]; - if (cfg->cell_config.frame_duplex_type == TDD) { - num_slots_dl = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots; - if (mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols > 0) { - num_slots_dl++; - } + mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + mac->nr_band = *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + if (mac->scc_SIB) { + ASN_STRUCT_FREE(asn_DEF_NR_ServingCellConfigCommonSIB, mac->scc_SIB); + mac->scc_SIB = NULL; + } + mac->state = UE_NOT_SYNC; + mac->ra.ra_state = RA_UE_IDLE; + mac->physCellId = *mac->scc->physCellId; + if (!get_softmodem_params()->emulate_l1) { + mac->synch_request.Mod_id = module_id; + mac->synch_request.CC_id = cc_idP; + mac->synch_request.synch_req.target_Nid_cell = mac->physCellId; + mac->if_module->synch_request(&mac->synch_request); } - LOG_I(NR_MAC, "Initializing dl_config_request. num_slots_dl = %d\n", num_slots_dl); - mac->dl_config_request = realloc(mac->dl_config_request, num_slots_dl*sizeof(*mac->dl_config_request)); - memset(mac->dl_config_request, 0, num_slots_dl*sizeof(fapi_nr_dl_config_request_t)); + 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); - // Setup the SSB to Rach Occasionsif (cell_group_config->spCellConfig) { mapping according to the config - build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type); - if (!get_softmodem_params()->emulate_l1) + nr_ue_mac_default_configs(mac); + if (!get_softmodem_params()->emulate_l1) { mac->if_module->phy_config_request(&mac->phy_config); - mac->phy_config_request_sent = true; - } - if(scell_group_config != NULL ){ - mac->cg = scell_group_config; - mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; - if (scell_group_config->spCellConfig->reconfigurationWithSync) { - if (scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { - ra->rach_ConfigDedicated = scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; - } - mac->scc = scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; - mac->nr_band = *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - mac->physCellId = *mac->scc->physCellId; - config_common_ue(mac,module_id,cc_idP); - mac->crnti = scell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; - LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); + mac->phy_config_request_sent = true; } - configure_current_BWP(mac, NULL, scell_group_config); - config_control_ue(mac); + // Setup the SSB to Rach Occasions mapping according to the config build_ssb_to_ro_map(mac); + } +} - } else if (cell_group_config != NULL) { - LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); - mac->cg = cell_group_config; - if (cell_group_config->spCellConfig) - mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; - else - mac->servCellIndex = 0; - - mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; - mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; - mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE; - LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", - module_id, - mac->scheduling_info.periodicBSR_SF, - mac->scheduling_info.retxBSR_SF); - - configure_current_BWP(mac, NULL, cell_group_config); - config_control_ue(mac); - - if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { - LOG_A(NR_MAC, "Received the reconfigurationWithSync in %s\n", __FUNCTION__); - if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { - ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; - } - mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; - mac->nr_band = *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - if (mac->scc_SIB) { - free(mac->scc_SIB); - mac->scc_SIB = NULL; - } - int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { - num_slots++; - } - mac->state = UE_NOT_SYNC; - mac->ra.ra_state = RA_UE_IDLE; - mac->physCellId = *mac->scc->physCellId; - if (!get_softmodem_params()->emulate_l1) { - mac->synch_request.Mod_id = module_id; - mac->synch_request.CC_id = cc_idP; - mac->synch_request.synch_req.target_Nid_cell = mac->physCellId; - mac->if_module->synch_request(&mac->synch_request); - } - 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); - - nr_ue_mac_default_configs(mac); - if (!get_softmodem_params()->emulate_l1) { - mac->if_module->phy_config_request(&mac->phy_config); - mac->phy_config_request_sent = true; - } +void nr_rrc_mac_config_req_scg(module_id_t module_id, + int cc_idP, + NR_CellGroupConfig_t *scell_group_config) +{ + + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + RA_config_t *ra = &mac->ra; + + AssertFatal(scell_group_config, "scell_group_config cannot be NULL\n"); - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); + mac->cg = scell_group_config; + mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; + if (scell_group_config->spCellConfig->reconfigurationWithSync) { + if (scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { + ra->rach_ConfigDedicated = scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; } + mac->scc = scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + mac->nr_band = *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + mac->physCellId = *mac->scc->physCellId; + config_common_ue(mac,module_id,cc_idP); + mac->crnti = scell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; + LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); } - return 0; + configure_current_BWP(mac, NULL, scell_group_config); + config_control_ue(mac); + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index e5ffe9c35644cc7dce4b125730f38c13fde785b9..cc2f90280e1cfc391ff1dcea919ad04988fa6f82 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -399,7 +399,7 @@ typedef struct { long physCellId; //// MAC config int first_sync_frame; - bool sib1_decoded; + bool get_sib1; NR_DRX_Config_t *drx_Config; NR_SchedulingRequestConfig_t *schedulingRequestConfig; NR_BSR_Config_t *bsr_Config; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 76e33db385205efc108b499f22e0e8dc5d26828b..53888c0f1d1a401c0b99f53aaa3f4c8c846b8e65 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -95,22 +95,22 @@ int nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, long logicalChannelIdentity, bool status); -/**\brief primitive from RRC layer to MAC layer for configuration L1/L2, now supported 4 rrc messages: MIB, cell_group_config for MAC/PHY, spcell_config(serving cell config) - \param module_id module id - \param cc_id component carrier id - \param gNB_index gNB index - \param mibP pointer to RRC message MIB - \param sccP pointer to ServingCellConfigCommon structure, - \param spcell_configP pointer to RRC message serving cell config*/ -int nr_rrc_mac_config_req_ue( - module_id_t module_id, - int cc_idP, - uint8_t gNB_index, - NR_MIB_t *mibP, - NR_ServingCellConfigCommonSIB_t *sccP, - NR_CellGroupConfig_t *cell_group_config, - NR_CellGroupConfig_t *scell_group_config -); +void nr_rrc_mac_config_req_scg(module_id_t module_id, + int cc_idP, + NR_CellGroupConfig_t *scell_group_config); + +void nr_rrc_mac_config_req_mcg(module_id_t module_id, + int cc_idP, + NR_CellGroupConfig_t *scell_group_config); + +void nr_rrc_mac_config_req_mib(module_id_t module_id, + int cc_idP, + NR_MIB_t *mibP, + bool sched_sib1); + +void nr_rrc_mac_config_req_sib1(module_id_t module_id, + int cc_idP, + NR_ServingCellConfigCommonSIB_t *scc); /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst); @@ -425,6 +425,8 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); +void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs); + void configure_ss_coreset(NR_UE_MAC_INST_t *mac, NR_ServingCellConfig_t *scd, NR_BWP_Id_t dl_bwp_id); @@ -438,7 +440,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, dci_pdu_rel15_t *dci_pdu_rel15, int slot); -fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot); +fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot, int fb_time); fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot); void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 96a9a3e07233f257a5614fb2c9a0f50e3988322a..8899be18e6f225e68e76006e7a6bf8164b6ab363 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -56,9 +56,17 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { for (int j = 0; j < NB_NR_UE_MAC_INST; j++) nr_ue_init_mac(j); + int scs = get_softmodem_params()->sa ? + get_softmodem_params()->numerology : + rrc_inst ? + *rrc_inst->scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon->ssbSubcarrierSpacing : + - 1; + if (scs > -1) + ue_init_config_request(nr_ue_mac_inst, scs); + if (rrc_inst && rrc_inst->scell_group_config) { - nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,rrc_inst->scell_group_config); + nr_rrc_mac_config_req_scg(0, 0, rrc_inst->scell_group_config); AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); if (IS_SOFTMODEM_NOS1){ // get default noS1 configuration @@ -78,24 +86,9 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { // free memory free_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig); } - // Allocate memory for ul_config_request in the mac instance. This is now a pointer and will - // point to a list of structures (one for each UL slot) to store PUSCH scheduling parameters - // received from UL DCI. - if (nr_ue_mac_inst->scc) { - NR_TDD_UL_DL_ConfigCommon_t *tdd = nr_ue_mac_inst->scc->tdd_UL_DL_ConfigurationCommon; - int num_slots_ul = tdd ? tdd->pattern1.nrofUplinkSlots : nr_slots_per_frame[*nr_ue_mac_inst->scc->ssbSubcarrierSpacing]; - if (tdd && nr_ue_mac_inst->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { - num_slots_ul++; - } - LOG_D(NR_MAC, "In %s: Initializing ul_config_request. num_slots_ul = %d\n", __FUNCTION__, num_slots_ul); - nr_ue_mac_inst->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t)); - for (int i=0; i<num_slots_ul; i++) - pthread_mutex_init(&(nr_ue_mac_inst->ul_config_request[i].mutex_ul_config), NULL); - } } else { LOG_I(MAC,"Running without CellGroupConfig\n"); - nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,NULL); if(get_softmodem_params()->sa == 1) { AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 5aa4438af0373fa4f2cde4a734e9a40357232b53..6adaecef419f30720a46e80756c633eda8cf9e76 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -220,9 +220,8 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->rnti = SI_RNTI; // SI-RNTI - 3GPP TS 38.321 Table 7.1-1: RNTI values - if(mac->frequency_range == FR1) - rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; - else + rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; + if(mac->frequency_range == FR2) rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; break; case NR_RNTI_SFI: diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 465848bddc0055426ae59a5f1ca50cf8a89345bd..7326d187a48caa90c922e0f97660aa97eded2419 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -156,7 +156,7 @@ void nr_ue_init_mac(module_id_t module_idP) NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); nr_ue_mac_default_configs(mac); mac->first_sync_frame = -1; - mac->sib1_decoded = false; + mac->get_sib1 = false; mac->phy_config_request_sent = false; mac->state = UE_NOT_SYNC; } @@ -176,6 +176,12 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; mac->BSR_reporting_active = BSR_TRIGGER_NONE; + mac->first_sync_frame = -1; + mac->get_sib1 = false; + mac->phy_config_request_sent = false; + mac->state = UE_NOT_SYNC; + memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements)); + for (int i = 0; i < NR_MAX_NUM_LCID; i++) { LOG_D(NR_MAC, "Applying default logical channel config for LCGID %d\n", i); mac->scheduling_info.Bj[i] = -1; @@ -313,7 +319,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id, else ssb_sc_offset_norm = ssb_subcarrier_offset; - if (!mac->sib1_decoded) { + if (mac->get_sib1) { nr_ue_sib1_scheduler(module_id, cc_id, ssb_start_symbol, @@ -351,8 +357,6 @@ int8_t nr_ue_decode_BCCH_DL_SCH(module_id_t module_id, uint32_t pdu_len) { if(ack_nack) { LOG_D(NR_MAC, "Decoding NR-BCCH-DL-SCH-Message (SIB1 or SI)\n"); - NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - mac->sib1_decoded = true; nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len); } else @@ -503,7 +507,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (ret != -1){ // Get UL config request corresponding slot_tx - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, tda_info.k2); if (!ul_config) { LOG_W(MAC, "In %s: ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", __FUNCTION__, frame, slot); @@ -572,7 +576,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (ret != -1){ // Get UL config request corresponding slot_tx - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, tda_info.k2); if (!ul_config) { LOG_W(MAC, "In %s: ul_config request is NULL. Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n", __FUNCTION__, frame, slot); @@ -662,7 +666,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config = mac->type0_PDCCH_CSS_config; mux_pattern = type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern; dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_SI_DLSCH; + // in MIB SCS is signaled as 15or60 and 30or120 dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; + if(mac->frequency_range == FR2) + dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; if (pdsch_config) pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NULL; // For PDSCH with mapping type A, the UE shall assume dmrs-AdditionalPosition='pos2' } else { dlsch_config_pdu_1_0->SubcarrierSpacing = current_DL_BWP->scs; @@ -4121,7 +4128,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) if (ret != -1){ - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, tda_info.k2); uint16_t rnti = mac->crnti; if (!ul_config) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 80944a5a05498c15016a92f1f490c7d2e04701d2..086d80e4772bf8a2ced67e230d35008cc9aeda44 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -107,35 +107,19 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, * This function returns the UL config corresponding to a given UL slot * from MAC instance . */ -fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot) +fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot, int fb_time) { NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->scc==NULL ? mac->scc_SIB->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon; //Check if requested on the right slot - AssertFatal(is_nr_UL_slot(tdd_config, slot, mac->frame_type) != 0, "%s called at wrong slot %d\n", __func__, slot); + AssertFatal(is_nr_UL_slot(tdd_config, slot, mac->frame_type) != 0, "UL config_request called at wrong slot %d\n", slot); - // Calculate the index of the UL slot in mac->ul_config_request list. This is - // based on the TDD pattern (slot configuration period) and number of UL+mixed - // slots in the period. TS 38.213 Sec 11.1 int mu = mac->current_UL_BWP.scs; const int n = nr_slots_per_frame[mu]; - const int num_slots_per_tdd = tdd_config ? (n >> (7 - tdd_config->pattern1.dl_UL_TransmissionPeriodicity)) : n; - const int num_slots_ul = tdd_config ? (tdd_config->pattern1.nrofUplinkSlots + (tdd_config->pattern1.nrofUplinkSymbols != 0)) : n; - int index = slot % num_slots_ul; - - LOG_D(NR_MAC, "In %s slots per %s: %d, num_slots %d, index %d\n", - __FUNCTION__, - tdd_config ? "TDD" : "FDD", - num_slots_per_tdd, - num_slots_ul, - index); - - if (mac->ul_config_request) return &mac->ul_config_request[index]; - else { - LOG_E(NR_MAC, "mac->ul_config_request not set\n"); - return NULL; - } + AssertFatal(fb_time < n, "Cannot schedule to a slot more than 1 frame away, ul_config_request is not big enough\n"); + AssertFatal(mac->ul_config_request != NULL, "mac->ul_config_request not initialized, logic bug\n"); + return &mac->ul_config_request[slot]; } /* @@ -144,37 +128,8 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl */ fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot) { - int index; - if (!mac->scc && !mac->scc_SIB) - index = 0; - else { - NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->scc==NULL ? mac->scc_SIB->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon; - - //Check if requested on the right slot - AssertFatal(is_nr_DL_slot(tdd_config, slot) != 0, "%s called at wrong slot %d\n", __func__, slot); - - // Calculate the index of the DL slot in mac->ul_config_request list. This is - // based on the TDD pattern (slot configuration period) and number of DL+mixed - // slots in the period. TS 38.213 Sec 11.1 - int mu = mac->current_UL_BWP.scs; - const int n = nr_slots_per_frame[mu]; - const int num_slots_per_tdd = tdd_config ? (n >> (7 - tdd_config->pattern1.dl_UL_TransmissionPeriodicity)) : n; - const int num_slots_dl = tdd_config ? (tdd_config->pattern1.nrofDownlinkSlots + (tdd_config->pattern1.nrofDownlinkSymbols != 0)) : n; - - index = slot % num_slots_dl; - LOG_D(NR_MAC, "In %s slots per %s: %d, num_slots %d, index %d\n", - __FUNCTION__, - tdd_config ? "TDD" : "FDD", - num_slots_per_tdd, - num_slots_dl, - index); - } - - if (mac->dl_config_request) return &mac->dl_config_request[index]; - else { - LOG_E(NR_MAC, "mac->dl_config_request not set\n"); - return NULL; - } + AssertFatal(mac->dl_config_request != NULL, "mac->dl_config_request not initialized, logic bug\n"); + return &mac->dl_config_request[slot]; } void ul_layers_config(NR_UE_MAC_INST_t *mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, nr_dci_format_t dci_format) @@ -928,7 +883,7 @@ void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger } int sched_frame = frame + (slot + slot_offset >= n_slots_frame) % 1024; - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, sched_slot); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, sched_slot, slot_offset); fapi_nr_ul_config_srs_pdu *srs_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].srs_config_pdu; configure_srs_pdu(mac, srs_resource, srs_config_pdu, 0, 0); fill_ul_config(ul_config, sched_frame, sched_slot, FAPI_NR_UL_CONFIG_TYPE_SRS); @@ -981,7 +936,7 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo // Check if UE should transmit the SRS if((frame*n_slots_frame+slot-offset)%period == 0) { - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot, 0); fapi_nr_ul_config_srs_pdu *srs_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].srs_config_pdu; configure_srs_pdu(mac, srs_resource, srs_config_pdu, period, offset); @@ -1070,7 +1025,7 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); RA_config_t *ra = &mac->ra; - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx, 0); if (!ul_config) LOG_E(NR_MAC, "mac->ul_config is null!\n"); @@ -2238,7 +2193,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo if (num_res > 1) multiplex_pucch_resource(mac, pucch, num_res); - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP, 0); pthread_mutex_lock(&ul_config->mutex_ul_config); for (int j = 0; j < num_res; j++) { if (pucch[j].n_harq + pucch[j].n_sr + pucch[j].n_csi != 0) { @@ -2503,7 +2458,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s if(ra->ra_state != GENERATE_PREAMBLE) return; - fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); + fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP, 0); if (!ul_config) { LOG_E(NR_MAC, "mac->ul_config is null! \n"); return; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 187976753dc44eb4d07c6956baa9108d7c64a2e7..b9876b67731103a681b946180bcd324194edabbf 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1144,7 +1144,6 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) uint32_t ret_mask = 0x0; module_id_t module_id = dl_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, dl_info->slot); if ((!dl_info->dci_ind && !dl_info->rx_ind)) { // UL indication to schedule DCI reception @@ -1179,6 +1178,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) if (ret >= 0) { AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" ); AssertFatal( nr_ue_if_module_inst[module_id]->scheduled_response != NULL, "scheduled_response is NULL!\n" ); + fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, dl_info->slot); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot, dl_info->phy_data); nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 7ddc2da5d70237683c2c6b4a125ced869857bd96..0bffcfdc26d30ca708d3b79cd12e64252c6873e6 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -285,6 +285,9 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR NR_UE_rrc_inst[module_id].cell_group_config = cellGroupConfig; nr_rrc_ue_process_scg_config(module_id,cellGroupConfig); } + if (get_softmodem_params()->nsa) { + nr_rrc_mac_config_req_scg(0, 0, cellGroupConfig); + } } else nr_rrc_ue_decode_secondary_cellgroup_config(module_id, @@ -312,7 +315,6 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR default: break; } - //nr_rrc_mac_config_req_ue(); return 0; } @@ -340,10 +342,6 @@ int8_t nr_rrc_ue_process_scg_config(const module_id_t module_id, NR_CellGroupCon }else{ // maintain list if(cell_group_config->spCellConfig != NULL){ - if (get_softmodem_params()->nsa) { - nr_rrc_mac_config_req_ue(0, 0, 0, NULL, NULL, cell_group_config, NULL); - LOG_D(NR_RRC, "Filled scc now \n"); - } if(cell_group_config->spCellConfig->spCellConfigDedicated != NULL){ // process element of list to be add by RRC message if(cell_group_config->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList != NULL){ @@ -600,7 +598,10 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(const module_id_t module_id, const u NR_UE_rrc_inst[module_id].mib = bcch_message->message.choice.mib; bcch_message->message.choice.mib = NULL; - nr_rrc_mac_config_req_ue(0, 0, 0, NR_UE_rrc_inst[module_id].mib, NULL, NULL, NULL); + NR_SIB1_t *sib1 = NR_UE_rrc_inst[module_id].sib1[gNB_index]; + // if no sib1 because not acquired yet or expired, get a new one + bool get_sib1 = sib1 == NULL; + nr_rrc_mac_config_req_mib(module_id, 0, NR_UE_rrc_inst[module_id].mib, get_sib1); ret = 0; } ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, bcch_message); @@ -1210,8 +1211,8 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, } // take ServingCellConfigCommon and configure L1/L2 NR_UE_rrc_inst[module_id].servingCellConfigCommonSIB = sib1->servingCellConfigCommon; - nr_rrc_mac_config_req_ue(module_id,0,0,NULL,sib1->servingCellConfigCommon,NULL,NULL); - nr_rrc_ue_generate_ra_msg(module_id,gNB_index); + nr_rrc_mac_config_req_sib1(module_id, 0, sib1->servingCellConfigCommon); + nr_rrc_ue_generate_ra_msg(module_id, gNB_index); } else { LOG_E(NR_RRC, "SIB1 not decoded\n"); } @@ -1256,12 +1257,9 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, } //----------------------------------------------------------------------------- -void -nr_rrc_ue_process_masterCellGroup( - const protocol_ctxt_t *const ctxt_pP, - uint8_t gNB_index, - OCTET_STRING_t *masterCellGroup -) +void nr_rrc_ue_process_masterCellGroup(const protocol_ctxt_t *const ctxt_pP, + uint8_t gNB_index, + OCTET_STRING_t *masterCellGroup) //----------------------------------------------------------------------------- { NR_CellGroupConfig_t *cellGroupConfig=NULL; @@ -1342,23 +1340,23 @@ nr_rrc_ue_process_masterCellGroup( sizeof(struct NR_MAC_CellGroupConfig)); } - if( cellGroupConfig->sCellToReleaseList != NULL){ + if(cellGroupConfig->sCellToReleaseList != NULL) { //TODO (perform SCell release as specified in 5.3.5.5.8) } - if( cellGroupConfig->spCellConfig != NULL){ + if(cellGroupConfig->spCellConfig != NULL) { if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config && - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig) { + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig) { memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig,cellGroupConfig->spCellConfig, sizeof(struct NR_SpCellConfig)); } else { if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config) - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig = cellGroupConfig->spCellConfig; + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig = cellGroupConfig->spCellConfig; else - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = cellGroupConfig; + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = cellGroupConfig; } LOG_D(RRC,"Sending CellGroupConfig to MAC\n"); - nr_rrc_mac_config_req_ue(ctxt_pP->module_id,0,0,NULL,NULL,cellGroupConfig,NULL); + nr_rrc_mac_config_req_mcg(ctxt_pP->module_id, 0, cellGroupConfig); //TODO (configure the SpCell as specified in 5.3.5.5.7) } @@ -2136,12 +2134,9 @@ nr_rrc_ue_establish_srb2( } //----------------------------------------------------------------------------- - static void - rrc_ue_process_rrcReconfiguration( - const protocol_ctxt_t *const ctxt_pP, - NR_RRCReconfiguration_t *rrcReconfiguration, - uint8_t gNB_index - ) + static void rrc_ue_process_rrcReconfiguration(const protocol_ctxt_t *const ctxt_pP, + NR_RRCReconfiguration_t *rrcReconfiguration, + uint8_t gNB_index) //----------------------------------------------------------------------------- { LOG_I(NR_RRC, "[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCReconfiguration (gNB %d)\n",