From b0dd59193285ae9e4576d0b3941b155eb12b6732 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 6 Dec 2023 14:29:50 +0100 Subject: [PATCH] fixes after CI run --- openair1/SIMULATION/NR_PHY/dlsim.c | 34 ++++--- openair2/GNB_APP/gnb_config.c | 4 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 94 +++++++++++++++---- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 2 +- .../LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c | 3 +- .../LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h | 3 +- openair2/RRC/NR/nr_rrc_config.c | 15 ++- 7 files changed, 113 insertions(+), 42 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 20aabed512..6c5c0e4702 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -54,15 +54,13 @@ #include "NR_UE_PHY_INTERFACE/NR_IF_Module.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" -//#include "LAYER2/NR_MAC_gNB/mac_proto.h" -//#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" +#include "LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "NR_asn_constant.h" #include "RRC/NR/nr_rrc_config.h" #include "openair1/SIMULATION/RF/rf.h" #include "openair1/SIMULATION/TOOLS/sim.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" -//#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "PHY/NR_REFSIG/ptrs_nr.h" #include "NR_RRCReconfiguration.h" #define inMicroS(a) (((double)(a))/(get_cpu_freq_GHz()*1000.0)) @@ -138,14 +136,6 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_UE_DL_BWP_t *current_BWP = &UE_info->current_DL_BWP; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; - //TODO better implementation needed - //for now artificially set candidates for the required aggregation levels - sched_ctrl->search_space->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - sched_ctrl->search_space->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; - sched_ctrl->search_space->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; - sched_ctrl->search_space->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n1; - sched_ctrl->search_space->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; - uint8_t nr_of_candidates = 0; if (g_mcsIndex < 4) { find_aggregation_candidates(&sched_ctrl->aggregation_level, @@ -614,6 +604,7 @@ int main(int argc, char **argv) InitSinLUT(); get_softmodem_params()->phy_test = 1; + get_softmodem_params()->usim_test = 1; get_softmodem_params()->do_ra = 0; set_softmodem_optmask(SOFTMODEM_DLSIM_BIT); @@ -879,10 +870,13 @@ int main(int argc, char **argv) // generate signal AssertFatal(input_fd==NULL,"Not ready for input signal file\n"); + // clone CellGroup to have a separate copy at UE + NR_CellGroupConfig_t *UE_CellGroup = clone_CellGroupConfig(secondaryCellGroup); + //Configure UE NR_BCCH_BCH_Message_t *mib = get_new_MIB_NR(scc); nr_rrc_mac_config_req_mib(0, 0, mib->message.choice.mib, false); - nr_rrc_mac_config_req_cg(0, 0, secondaryCellGroup); + nr_rrc_mac_config_req_cg(0, 0, UE_CellGroup); UE_mac->state = UE_CONNECTED; UE_mac->ra.ra_state = RA_SUCCEEDED; @@ -1409,7 +1403,7 @@ void update_dmrs_config(NR_CellGroupConfig_t *scg, int8_t* dmrs_arg) } /* Additional DMRS positions 0 ,1 ,2 and 3 */ - if(dmrs_arg[1] >= 0 && dmrs_arg[1] <4 ) { + if(dmrs_arg[1] >= 0 && dmrs_arg[1] < 4) { add_pos = dmrs_arg[1]; } else { AssertFatal(1==0,"Incorrect Additional Position, valid options 0-pos1, 1-pos1, 2-pos2, 3-pos3\n"); @@ -1468,7 +1462,19 @@ void update_dmrs_config(NR_CellGroupConfig_t *scg, int8_t* dmrs_arg) if (dmrs_config->dmrs_AdditionalPosition == NULL) { dmrs_config->dmrs_AdditionalPosition = calloc(1,sizeof(*dmrs_MappingtypeA->choice.setup->dmrs_AdditionalPosition)); } - *dmrs_config->dmrs_AdditionalPosition = add_pos; + switch (add_pos) { + case 0 : + *dmrs_config->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0; + break; + case 1 : + *dmrs_config->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; + break; + case 3 : + *dmrs_config->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos3; + break; + default : + AssertFatal(false, "DMRS additional position %d not valid\n", add_pos); + } } else { // if NULL, Value pos2 free(dmrs_config->dmrs_AdditionalPosition); dmrs_config->dmrs_AdditionalPosition = NULL; diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index de0373e37a..9bf6736c33 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -278,7 +278,7 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0; scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=mu_dl; scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_DL; - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=275*(N_RB_DL-1); + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(N_RB_DL, 0); scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing=mu_dl;//NR_SubcarrierSpacing_kHz30; *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=12; *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero=0; @@ -298,7 +298,7 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=mu_ul; scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_UL; *scc->uplinkConfigCommon->frequencyInfoUL->p_Max=20; - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=275*(N_RB_UL-1); + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth = PRBalloc_to_locationandbandwidth(N_RB_UL, 0); scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing=mu_ul;//NR_SubcarrierSpacing_kHz30; scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex=98; scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM=NR_RACH_ConfigGeneric__msg1_FDM_one; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 8fc4fe1ac5..5fc1d938da 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -605,8 +605,9 @@ void modlist_coreset(NR_ControlResourceSet_t *source, NR_ControlResourceSet_t *t { target->controlResourceSetId = source->controlResourceSetId; target->frequencyDomainResources.size = source->frequencyDomainResources.size; - target->frequencyDomainResources.buf = calloc(target->frequencyDomainResources.size, - sizeof(*target->frequencyDomainResources.buf)); + if (!target->frequencyDomainResources.buf) + target->frequencyDomainResources.buf = calloc(target->frequencyDomainResources.size, + sizeof(*target->frequencyDomainResources.buf)); for (int i = 0; i < source->frequencyDomainResources.size; i++) target->frequencyDomainResources.buf[i] = source->frequencyDomainResources.buf[i]; target->duration = source->duration; @@ -649,9 +650,19 @@ void modlist_coreset(NR_ControlResourceSet_t *source, NR_ControlResourceSet_t *t } } if (source->tci_StatesPDCCH_ToAddList) { - if (target->tci_StatesPDCCH_ToAddList) - for (int i = 0; source->tci_StatesPDCCH_ToAddList->list.count; i++) - ASN_SEQUENCE_ADD(&target->tci_StatesPDCCH_ToAddList->list, source->tci_StatesPDCCH_ToAddList->list.array[i]); + if (target->tci_StatesPDCCH_ToAddList) { + for (int i = 0; i < source->tci_StatesPDCCH_ToAddList->list.count; i++) { + long id = *source->tci_StatesPDCCH_ToAddList->list.array[i]; + int j; + for (j = 0; j < target->tci_StatesPDCCH_ToAddList->list.count; j++) { + if(id == *target->tci_StatesPDCCH_ToAddList->list.array[j]) + break; + } + if (j == target->tci_StatesPDCCH_ToAddList->list.count) + ASN_SEQUENCE_ADD(&target->tci_StatesPDCCH_ToAddList->list, + source->tci_StatesPDCCH_ToAddList->list.array[i]); + } + } else updateMACie(target->tci_StatesPDCCH_ToAddList, source->tci_StatesPDCCH_ToAddList, @@ -845,8 +856,11 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, AssertFatal(1 == 0, "The logical id %d is not a valid SRB id %li\n", lc_identity, srb_id); } } else { /* DRB */ - mac_lc_config = rlc_bearer->mac_LogicalChannelConfig; - AssertFatal(mac_lc_config != NULL, "For DRB, it should be mandatorily present\n"); + AssertFatal(rlc_bearer->mac_LogicalChannelConfig, + "When establishing a DRB, LogicalChannelConfig should be mandatorily present\n"); + updateMACie(mac_lc_config, + rlc_bearer->mac_LogicalChannelConfig, + NR_LogicalChannelConfig_t); } } else { /* LC is already established, reconfiguring the LC */ @@ -855,13 +869,12 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, updateMACie(mac_lc_config, rlc_bearer->mac_LogicalChannelConfig, NR_LogicalChannelConfig_t); - } else { - /* Need M - Maintains current value */ - continue; } } - mac->lc_ordered_info[i].logicalChannelConfig_ordered = mac_lc_config; - nr_configure_mac_config_logicalChannelBearer(module_id, lc_identity, mac_lc_config); + if (mac_lc_config) { + mac->lc_ordered_info[i].logicalChannelConfig_ordered = mac_lc_config; + nr_configure_mac_config_logicalChannelBearer(module_id, lc_identity, mac_lc_config); + } } // reorder the logical channels as per its priority @@ -1773,11 +1786,6 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, if (!get_softmodem_params()->emulate_l1) mac->if_module->phy_config_request(&mac->phy_config); mac->phy_config_request_sent = true; - - ASN_STRUCT_FREE(asn_DEF_NR_SI_SchedulingInfo, - si_SchedulingInfo); - ASN_STRUCT_FREE(asn_DEF_NR_ServingCellConfigCommonSIB, - scc); } void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, @@ -1903,6 +1911,56 @@ void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroupConfig_ } } +static void configure_csi_resourcemapping(NR_CSI_RS_ResourceMapping_t *target, + NR_CSI_RS_ResourceMapping_t *source) +{ + target->frequencyDomainAllocation.present = source->frequencyDomainAllocation.present; + switch (source->frequencyDomainAllocation.present) { + case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1 : + target->frequencyDomainAllocation.choice.row1.size = source->frequencyDomainAllocation.choice.row1.size; + target->frequencyDomainAllocation.choice.row1.bits_unused = source->frequencyDomainAllocation.choice.row1.bits_unused; + if (!target->frequencyDomainAllocation.choice.row1.buf) + target->frequencyDomainAllocation.choice.row1.buf = calloc(target->frequencyDomainAllocation.choice.row1.size, sizeof(uint8_t)); + for (int i = 0; i < target->frequencyDomainAllocation.choice.row1.size; i++) + target->frequencyDomainAllocation.choice.row1.buf[i] = source->frequencyDomainAllocation.choice.row1.buf[i]; + break; + case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2 : + target->frequencyDomainAllocation.choice.row2.size = source->frequencyDomainAllocation.choice.row2.size; + target->frequencyDomainAllocation.choice.row2.bits_unused = source->frequencyDomainAllocation.choice.row2.bits_unused; + if (!target->frequencyDomainAllocation.choice.row2.buf) + target->frequencyDomainAllocation.choice.row2.buf = calloc(target->frequencyDomainAllocation.choice.row2.size, sizeof(uint8_t)); + for (int i = 0; i < target->frequencyDomainAllocation.choice.row2.size; i++) + target->frequencyDomainAllocation.choice.row2.buf[i] = source->frequencyDomainAllocation.choice.row2.buf[i]; + break; + case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row4 : + target->frequencyDomainAllocation.choice.row4.size = source->frequencyDomainAllocation.choice.row4.size; + target->frequencyDomainAllocation.choice.row4.bits_unused = source->frequencyDomainAllocation.choice.row4.bits_unused; + if (!target->frequencyDomainAllocation.choice.row4.buf) + target->frequencyDomainAllocation.choice.row4.buf = calloc(target->frequencyDomainAllocation.choice.row4.size, sizeof(uint8_t)); + for (int i = 0; i < target->frequencyDomainAllocation.choice.row4.size; i++) + target->frequencyDomainAllocation.choice.row4.buf[i] = source->frequencyDomainAllocation.choice.row4.buf[i]; + break; + case NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other : + target->frequencyDomainAllocation.choice.other.size = source->frequencyDomainAllocation.choice.other.size; + target->frequencyDomainAllocation.choice.other.bits_unused = source->frequencyDomainAllocation.choice.other.bits_unused; + if (!target->frequencyDomainAllocation.choice.other.buf) + target->frequencyDomainAllocation.choice.other.buf = calloc(target->frequencyDomainAllocation.choice.other.size, sizeof(uint8_t)); + for (int i = 0; i < target->frequencyDomainAllocation.choice.other.size; i++) + target->frequencyDomainAllocation.choice.other.buf[i] = source->frequencyDomainAllocation.choice.other.buf[i]; + break; + default: + AssertFatal(false , "Invalid entry\n"); + } + target->nrofPorts = source->nrofPorts; + target->firstOFDMSymbolInTimeDomain = source->firstOFDMSymbolInTimeDomain; + updateMACie(target->firstOFDMSymbolInTimeDomain2, + source->firstOFDMSymbolInTimeDomain2, + long); + target->cdm_Type = source->cdm_Type; + target->density = source->density; + target->freqBand = source->freqBand; +} + static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, struct NR_SetupRelease_CSI_MeasConfig *csi_MeasConfig_sr) { @@ -1963,7 +2021,7 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, } if (j < target->nzp_CSI_RS_ResourceToAddModList->list.count) { // modify NR_NZP_CSI_RS_Resource_t *mac_res = target->nzp_CSI_RS_ResourceToAddModList->list.array[j]; - mac_res->resourceMapping = res->resourceMapping; + configure_csi_resourcemapping(&mac_res->resourceMapping, &res->resourceMapping); mac_res->powerControlOffset = res->powerControlOffset; updateMACie(mac_res->powerControlOffsetSS, res->powerControlOffsetSS, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 25f2c80512..4dfea6d4c2 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -116,7 +116,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl //Check if requested on the right slot AssertFatal(is_nr_UL_slot(tdd_config, slot, mac->frame_type) != 0, "UL config_request called at wrong slot %d\n", slot); - int mu = mac->current_UL_BWP->scs; + int mu = mac->current_UL_BWP ? mac->current_UL_BWP->scs : get_softmodem_params()->numerology; const int n = nr_slots_per_frame[mu]; 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"); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c index c1313a495e..ab7977d4dc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c @@ -24,7 +24,6 @@ #include "mac_proto.h" #include "openair2/F1AP/f1ap_ids.h" #include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" -#include "openair2/RRC/NR/MESSAGES/asn1_msg.h" #include "F1AP_CauseRadioNetwork.h" #include "uper_decoder.h" @@ -225,7 +224,7 @@ static NR_UE_NR_Capability_t *get_ue_nr_cap(int rnti, uint8_t *buf, uint32_t len return cap; } -static NR_CellGroupConfig_t *clone_CellGroupConfig(const NR_CellGroupConfig_t *orig) +NR_CellGroupConfig_t *clone_CellGroupConfig(const NR_CellGroupConfig_t *orig) { uint8_t buf[16636]; asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, orig, buf, sizeof(buf)); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h index 32759b304f..c91f07e623 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.h @@ -24,10 +24,11 @@ #include "platform_types.h" #include "f1ap_messages_types.h" +#include "openair2/RRC/NR/MESSAGES/asn1_msg.h" void f1_setup_response(const f1ap_setup_resp_t *resp); void f1_setup_failure(const f1ap_setup_failure_t *failure); - +NR_CellGroupConfig_t *clone_CellGroupConfig(const NR_CellGroupConfig_t *orig); void ue_context_setup_request(const f1ap_ue_context_setup_t *req); void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req); void ue_context_modification_confirm(const f1ap_ue_context_modif_confirm_t *confirm); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index c7de394f79..2e5dcec3f9 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -171,15 +171,22 @@ NR_SearchSpace_t *rrc_searchspace_config(bool is_common, int searchspaceid, int ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates)); // TODO temporary hardcoded implementation ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0; - if (is_common) { + if (get_softmodem_params()->usim_test) { ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n1; } else { - ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; - ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n0; + if (is_common) { + ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0; + ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1; + } + else { + ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n2; + ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n0; + } + ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; } - ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0; ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0; ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType)); if (is_common) {