diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 57c6589ca4ef928ed1e9fd5544e903cc276e03b1..0fe5315d4ecd5f3d74ff787b3e5108d411449f93 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -280,10 +280,9 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_UE_info_t *UE_info = RC.nrmac[module_id]->UE_info.list[0]; AssertFatal(RC.nrmac[module_id]->UE_info.list[1]==NULL, "can have only a single UE\n"); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; + NR_UE_DL_BWP_t *current_BWP = &UE_info->current_DL_BWP; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; - const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - sched_ctrl->search_space = get_searchspace(NULL, scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); uint8_t nr_of_candidates = 0; if (g_mcsIndex < 4) { find_aggregation_candidates(&sched_ctrl->aggregation_level, @@ -295,7 +294,6 @@ void nr_dlsim_preprocessor(module_id_t module_id, &nr_of_candidates, sched_ctrl->search_space,4); } - sched_ctrl->coreset = get_coreset(RC.nrmac[module_id], scc, sched_ctrl->active_bwp->bwp_Dedicated, sched_ctrl->search_space, target_ss); uint32_t Y = get_Y(sched_ctrl->search_space, slot, UE_info->rnti); int CCEIndex = find_pdcch_candidate(RC.nrmac[module_id], /* CC_id = */ 0, @@ -309,11 +307,8 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - nr_set_pdsch_semi_static(NULL, + nr_set_pdsch_semi_static(current_BWP, scc, - UE_info->CellGroup, - sched_ctrl->active_bwp, - NULL, /* tda = */ 0, g_nrOfLayers, sched_ctrl, @@ -325,10 +320,10 @@ void nr_dlsim_preprocessor(module_id_t module_id, sched_pdsch->mcs = g_mcsIndex; /* the following might override the table that is mandated by RRC * configuration */ - ps->mcsTableIdx = g_mcsTableIdx; + current_BWP->mcsTableIdx = g_mcsTableIdx; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, sched_pdsch->R, sched_pdsch->rbSize, @@ -356,7 +351,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, AssertFatal(sched_pdsch->rbStart >= 0, "invalid rbStart %d\n", sched_pdsch->rbStart); AssertFatal(sched_pdsch->rbSize > 0, "invalid rbSize %d\n", sched_pdsch->rbSize); AssertFatal(sched_pdsch->mcs >= 0, "invalid mcs %d\n", sched_pdsch->mcs); - AssertFatal(ps->mcsTableIdx >= 0 && ps->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", ps->mcsTableIdx); + AssertFatal(current_BWP->mcsTableIdx >= 0 && current_BWP->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", current_BWP->mcsTableIdx); } typedef struct { @@ -876,6 +871,8 @@ int main(int argc, char **argv) N_RB_DL = gNB->frame_parms.N_RB_DL; NR_UE_info_t *UE_info = RC.nrmac[0]->UE_info.list[0]; + configure_UE_BWP(RC.nrmac[0], scc, &UE_info->UE_sched_ctrl, NULL, UE_info); + // stub to configure frame_parms // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); // call MAC to configure common parameters diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index e2a7efcaa0559f5f15b10e5703455b9e1b8662cb..1855958879804ea7e88c64424d2af50c4a027b62 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4128,22 +4128,22 @@ uint16_t compute_pucch_prb_size(uint8_t format, } } -int get_bw_tbslbrm(NR_BWP_t *genericParameters, +int get_bw_tbslbrm(int scc_bwpsize, NR_CellGroupConfig_t *cg) { - int bw = 0; - if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { - struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; - for (int i=0; i<BWP_list->list.count; i++) { - genericParameters = &BWP_list->list.array[i]->bwp_Common->genericParameters; - int curr_bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - if (curr_bw > bw) - bw = curr_bw; + int bw = scc_bwpsize; + if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { + const NR_ServingCellConfig_t *servingCellConfig = cg->spCellConfig->spCellConfigDedicated; + if(servingCellConfig->downlinkBWP_ToAddModList) { + struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = servingCellConfig->downlinkBWP_ToAddModList; + for (int i=0; i<BWP_list->list.count; i++) { + NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; + int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (curr_bw > bw) + bw = curr_bw; + } } } - else - bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); return bw; } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 2b8d3c6652770bb5df056a1d3c77319f096d2b91..3b76faeef1a8ecca1e2788104b2d1f35978fe797 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -142,7 +142,7 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); -int get_bw_tbslbrm(NR_BWP_t *genericParameters, +int get_bw_tbslbrm(int scc_bwpsize, NR_CellGroupConfig_t *cg); uint32_t nr_compute_tbslbrm(uint16_t table, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 5d91e83069da6354d73fd9a9ea5209ca0ef68c89..0d9383eaf20c36ae175700e5f0620d7742dff728 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -964,7 +964,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (mac->scc || mac->scc_SIB || mac->cg) { NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - bw_tbslbrm = get_bw_tbslbrm(&genericParameters, mac->cg); + int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + bw_tbslbrm = get_bw_tbslbrm(BWPSize, mac->cg); } else bw_tbslbrm = dlsch_config_pdu_1_0->BWPSize; @@ -1404,7 +1405,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - int bw_tbslbrm = get_bw_tbslbrm(&genericParameters, mac->cg); + int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(BWPSize, mac->cg); dlsch_config_pdu_1_1->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_1->mcs_table, bw_tbslbrm, nl_tbslbrm); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index ef7c91151b607d191433c6869c503e195afe8679..745fc1ae2b0d7204f3fdee0ef18aafe31e3adea5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -398,7 +398,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot, - NR_ServingCellConfigCommon_t *scc, + int mu, NR_ServingCellConfigCommon_t *scc, frame_type_t frame_type, uint16_t monitoring_slot_period, uint16_t monitoring_offset,uint8_t beam_index, @@ -407,10 +407,9 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, // preferentially we schedule the msg2 in the mixed slot or in the last dl slot // if they are allowed by search space configuration - uint8_t mu = *scc->ssbSubcarrierSpacing; uint8_t response_window = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow; uint8_t slot_window; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int n_slots_frame = nr_slots_per_frame[mu]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; // number of mixed slot or of last dl slot if there is no mixed slot uint8_t last_dl_slot_period = n_slots_frame-1; @@ -516,7 +515,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, int16_t timing_offset){ uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL - NR_SearchSpace_t *ss; uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; @@ -567,20 +565,8 @@ void nr_initiate_ra_proc(module_id_t module_idP, else ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); - // This should be handled differently when we use the initialBWP for RA - ra->dl_bwp_id = 0;//TODO - ra->ul_bwp_id = 0; - NR_BWP_Downlink_t *bwp=NULL; - if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated) { - if (ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { - ra->dl_bwp_id = *ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id; - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id - 1]; - } - if (ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) - ra->ul_bwp_id = *ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; - } + // Configure RA BWP + configure_UE_BWP(nr_mac, scc, NULL, ra, NULL); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); @@ -611,37 +597,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->timing_offset = timing_offset; ra->preamble_slot = slotP; - NR_SearchSpaceId_t ra_SearchSpace = 0; - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; - NR_BWP_t *genericParameters = NULL; - if(bwp) { - commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ra_SearchSpace = *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - genericParameters = &bwp->bwp_Common->genericParameters; - } else { - commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } - AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); - - // Common SearchSpace list - for (int i = 0; i < commonSearchSpaceList->list.count; i++) { - ss = commonSearchSpaceList->list.array[i]; - if (ss->searchSpaceId == ra_SearchSpace) - ra->ra_ss = ss; - } - - AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); - - ra->coreset = get_coreset(nr_mac, scc, bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); - ra->sched_pdcch = set_pdcch_structure(nr_mac, - ra->ra_ss, - ra->coreset, - scc, - genericParameters, - &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); - // retrieving ra pdcch monitoring period and offset find_monitoring_periodicity_offset_common(ra->ra_ss, &monitoring_slot_period, &monitoring_offset); @@ -649,6 +604,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, slotP, &msg2_frame, &msg2_slot, + ra->DL_BWP.scs, scc, frame_type, monitoring_slot_period, @@ -656,7 +612,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, beam_index, cc->num_active_ssb, nr_mac->tdd_beam_association, - nr_mac->if_inst->sl_ahead); + nr_mac->if_inst->sl_ahead); ra->Msg2_frame = msg2_frame; ra->Msg2_slot = msg2_slot; @@ -738,22 +694,10 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + NR_UE_UL_BWP_t *ul_bwp = &ra->UL_BWP; - NR_BWP_Uplink_t *ubwp = NULL; - NR_BWP_UplinkDedicated_t *ubwpd = NULL; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - NR_BWP_t *genericParameters = NULL; - if(ra->CellGroup) { - ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id-1]; - ubwpd = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - genericParameters = &ubwp->bwp_Common->genericParameters; - pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else { - genericParameters = &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - pusch_TimeDomainAllocationList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - - int mu = genericParameters->subcarrierSpacing; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList; + int mu = ul_bwp->scs; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; @@ -763,7 +707,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t int16_t *tdd_beam_association = nr_mac->tdd_beam_association; if (*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257) { // FR2 - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int n_slots_frame = nr_slots_per_frame[mu]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd,"Dynamic TDD not handled yet\n"); uint8_t tdd_period_slot = n_slots_frame/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); @@ -775,12 +719,11 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t tdd_beam_association[num_tdd_period] = ra->beam_id; } - int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int fh = 0; - int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + int startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; int StartSymbolIndex, NrOfSymbols; SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); - int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; + int mappingtype = pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; @@ -821,7 +764,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t fill_msg3_pusch_pdu(pusch_pdu, scc, ra->msg3_round, startSymbolAndLength, - ra->rnti, scs, + ra->rnti, mu, BWPSize, BWPStart, mappingtype, fh, rbStart, ra->msg3_nb_rb); @@ -843,7 +786,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu_rel15 = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, false, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -883,26 +826,23 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t const NR_SIB1_t *sib1 = cc->sib1 ? cc->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; config_uldci(sib1, - ubwp, - ubwpd, scc, pusch_pdu, &uldci_payload, - NR_UL_DCI_FORMAT_0_0, ra->Msg3_tda_id, ra->msg3_TPC, - 0, // not used in format 0_0 - ra->ul_bwp_id); + &ra->UL_BWP); fill_dci_pdu_rel15(scc, ra->CellGroup, + &ra->DL_BWP, dci_pdu, &uldci_payload, NR_UL_DCI_FORMAT_0_0, NR_RNTI_TC, pusch_pdu->bwp_size, - ra->ul_bwp_id, - coresetid, + ul_bwp->bwp_id, + coreset, nr_mac->cset0_bwp_size); // Mark the corresponding RBs as used @@ -923,13 +863,11 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->Msg3_slot = sched_slot; } - } void nr_get_Msg3alloc(module_id_t module_id, int CC_id, NR_ServingCellConfigCommon_t *scc, - NR_BWP_Uplink_t *ubwp, sub_frame_t current_slot, frame_t current_frame, NR_RA_t *ra, @@ -938,21 +876,18 @@ void nr_get_Msg3alloc(module_id_t module_id, // msg3 is scheduled in mixed slot in the following TDD period uint16_t msg3_nb_rb = 8; // sdu has 6 or 8 bytes - frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type; - int mu = ubwp ? - ubwp->bwp_Common->genericParameters.subcarrierSpacing : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + NR_UE_UL_BWP_t *ul_bwp = &ra->UL_BWP; + + int mu = ul_bwp->scs; int StartSymbolIndex = 0; int NrOfSymbols = 0; int startSymbolAndLength = 0; int temp_slot = 0; ra->Msg3_tda_id = 16; // initialization to a value above limit - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList= ubwp ? - ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; const int n_slots_frame = nr_slots_per_frame[mu]; @@ -1016,10 +951,9 @@ void nr_get_Msg3alloc(module_id_t module_id, int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - if (ra->CellGroup) { - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id - 1]; - int act_bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int act_bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (bwpSize != ul_bwp->BWPSize || bwpStart != ul_bwp->BWPStart) { + int act_bwp_start = ul_bwp->BWPStart; + int act_bwp_size = ul_bwp->BWPSize; if (!((bwpStart >= act_bwp_start) && ((bwpStart+bwpSize) <= (act_bwp_start+act_bwp_size)))) bwpStart = act_bwp_start; } @@ -1054,7 +988,6 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, int mappingtype, int fh, int msg3_first_rb, int msg3_nb_rb) { - int start_symbol_index,nr_of_symbols; SLIV2SL(startSymbolAndLength, &start_symbol_index, &nr_of_symbols); @@ -1129,9 +1062,10 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra, uint8_t *RAR_pdu) { - gNB_MAC_INST *mac = RC.nrmac[module_idP]; - NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; - NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + gNB_MAC_INST *mac = RC.nrmac[module_idP]; + NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; + NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + NR_UE_UL_BWP_t *ul_bwp = &ra->UL_BWP; if (ra->state == RA_IDLE) { LOG_W(NR_MAC,"RA is not active for RA %X. skipping msg3 scheduling\n", ra->rnti); @@ -1164,20 +1098,11 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t nfapi_nr_pusch_pdu_t *pusch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pusch_pdu; memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); - int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - int fh = 0; - int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; - int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - - if (ra->CellGroup) { - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id - 1]; - - startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; - mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; - fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0; - } + const int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int scs = ul_bwp->scs; + const int fh = (ul_bwp->pusch_Config && ul_bwp->pusch_Config->frequencyHopping) ? 1 : 0; + const int startSymbolAndLength = ul_bwp->tdaList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + const int mappingtype = ul_bwp->tdaList->list.array[ra->Msg3_tda_id]->mappingType; LOG_D(NR_MAC, "Frame %d, Slot %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", frameP, @@ -1206,6 +1131,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; + NR_UE_DL_BWP_t *dl_bwp = &ra->DL_BWP; if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { @@ -1216,30 +1142,13 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - NR_BWP_Downlink_t *bwp = NULL; - NR_ControlResourceSet_t *coreset = NULL; - NR_BWP_t *genericParameters = NULL; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; - - if (ra->CellGroup && - ra->CellGroup->spCellConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]; - genericParameters = &bwp->bwp_Common->genericParameters; - pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - else { - genericParameters= &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = dl_bwp->tdaList; long BWPStart = 0; long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWPStart = dl_bwp->BWPStart; BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; @@ -1254,7 +1163,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n"); - coreset = ra->coreset; + NR_ControlResourceSet_t *coreset = ra->coreset; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg2\n"); @@ -1306,7 +1215,6 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them - const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { @@ -1316,7 +1224,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, false, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -1334,37 +1242,22 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // information to data and is reset every slot. const int pduindex = nr_mac->pdu_index[CC_id]++; - uint8_t mcsTableIdx = 0; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { - if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) - mcsTableIdx = 1; - else - mcsTableIdx = 2; - } - else mcsTableIdx = 0; + NR_PDSCH_Config_t *pdsch_Config = dl_bwp->pdsch_Config; + uint8_t mcsTableIdx = dl_bwp->mcsTableIdx; int dmrsConfigType=0; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) + if (pdsch_Config && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) dmrsConfigType = 1; - NR_PDSCH_Config_t *pdsch_config = bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pdsch_Config ? bwp->bwp_Dedicated->pdsch_Config->choice.setup : NULL; - pdsch_pdu_rel15->pduBitmap = 0; pdsch_pdu_rel15->rnti = ra->RA_rnti; pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = genericParameters->subcarrierSpacing; + pdsch_pdu_rel15->SubcarrierSpacing = dl_bwp->scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; @@ -1384,7 +1277,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->VRBtoPRBMapping = 0; pdsch_pdu_rel15->StartSymbolIndex = startSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = nrOfSymbols; - pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, + pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(pdsch_Config, nr_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex, @@ -1424,7 +1317,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->TBSize[0] = TBS; } - int bw_tbslbrm = get_bw_tbslbrm(genericParameters, ra->CellGroup); + int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1476,23 +1370,21 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra fill_dci_pdu_rel15(scc, ra->CellGroup, + dl_bwp, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, NR_RNTI_RA, BWPSize, - bwpid, - coresetid, + dl_bwp->bwp_id, + coreset, nr_mac->cset0_bwp_size); // DL TX request nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; // Program UL processing for Msg3 - NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1] : - NULL; - nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra, nr_mac->tdd_beam_association); + nr_get_Msg3alloc(module_idP, CC_id, scc, slotP, frameP, ra, nr_mac->tdd_beam_association); nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]); if(ra->cfra) { @@ -1530,6 +1422,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; + NR_UE_DL_BWP_t *dl_bwp = &ra->DL_BWP; if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) { @@ -1539,23 +1432,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - NR_BWP_Downlink_t *bwp = NULL; - NR_ControlResourceSet_t *coreset = NULL; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; - - if (ra->CellGroup && - ra->CellGroup->spCellConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]; - pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - else { - pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - - coreset = ra->coreset; + NR_ControlResourceSet_t *coreset = ra->coreset; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = dl_bwp->tdaList; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n"); @@ -1574,14 +1452,12 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_I(NR_MAC,"Generate msg4, rnti: %04x\n", ra->rnti); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_BWP_t *genericParameters = bwp ? & bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - long BWPStart = 0; long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + BWPStart = dl_bwp->BWPStart; + BWPSize = dl_bwp->BWPSize; } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1632,7 +1508,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } const int delta_PRI=0; - int r_pucch = nr_get_pucch_resource(coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); + int r_pucch = nr_get_pucch_resource(coreset, ra->UL_BWP.pucch_Config, CCEIndex); LOG_D(NR_MAC,"[RAPROC] Msg4 r_pucch %d (CCEIndex %d, nb_of_candidates %d, delta_PRI %d)\n", r_pucch, CCEIndex, nr_of_candidates, delta_PRI); @@ -1691,7 +1567,13 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra uint16_t N_DMRS_SLOT = get_num_dmrs(dlDmrsSymbPos); - long dmrsConfigType = bwp!=NULL ? (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; + NR_PDSCH_Config_t *pdsch_Config = dl_bwp->pdsch_Config; + int dmrsConfigType=0; + if (pdsch_Config && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) + dmrsConfigType = 1; nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData = 2; if (nrOfSymbols == 2) { @@ -1711,18 +1593,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra N_PRB_DMRS = nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 4; } - uint8_t mcsTableIdx = 0; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { - if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) - mcsTableIdx = 1; - else - mcsTableIdx = 2; - } - else mcsTableIdx = 0; + uint8_t mcsTableIdx = dl_bwp->mcsTableIdx; int rbStart = 0; int rbSize = 0; @@ -1767,7 +1638,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them - const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { @@ -1777,7 +1647,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, false, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -1799,7 +1669,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = genericParameters->subcarrierSpacing; + pdsch_pdu_rel15->SubcarrierSpacing = dl_bwp->scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); @@ -1828,7 +1698,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int x_Overhead = 0; nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling); - int bw_tbslbrm = get_bw_tbslbrm(genericParameters, ra->CellGroup); + int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1893,13 +1764,14 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra fill_dci_pdu_rel15(scc, ra->CellGroup, + dl_bwp, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, NR_RNTI_TC, pdsch_pdu_rel15->BWPSize, - bwpid, - coresetid, + dl_bwp->bwp_id, + coreset, nr_mac->cset0_bwp_size); // Add padding header and zero rest out if there is space left @@ -1965,19 +1837,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra harq->round = 0; harq->ndi ^= 1; - // Pause scheduling according to: - // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs - const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_idP]->common_channels[0]; - const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - common_channels->ServingCellConfigCommon, - sib1); - uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? - NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - - sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); - LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frameP, slotP, UE->rnti, delay_ms); + sched_ctrl->rrc_processing_timer = 1; // No need to wait at this point in time, setting it to 1 just to enter in function nr_mac_update_timers + LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frameP, slotP, UE->rnti, 1); // Reset uplink failure flags/counters/timers at MAC so gNB will resume again scheduling resources for this UE UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; @@ -2009,16 +1870,11 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram // Pause scheduling according to: // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs - const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_id]->common_channels[0]; - const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - common_channels->ServingCellConfigCommon, - sib1); uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); + sched_ctrl->rrc_processing_timer = (delay_ms << ra->DL_BWP.scs); LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frame, slot, UE->rnti, delay_ms); } else { LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index a05c782fb0635a5ca7571792abcbad25819e0c8e..a531a1c71c6438f2eba6bb62848c7e31bba758eb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -310,7 +310,6 @@ uint32_t schedule_control_sib1(module_id_t module_id, } gNB_mac->sched_ctrlCommon->pdsch_semi_static.time_domain_allocation = time_domain_allocation; - gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx = 0; gNB_mac->sched_ctrlCommon->sched_pdsch.mcs = 0; // starting from mcs 0 gNB_mac->sched_ctrlCommon->num_total_bytes = num_total_bytes; @@ -347,6 +346,7 @@ uint32_t schedule_control_sib1(module_id_t module_id, uint8_t N_PRB_DMRS = gNB_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 6; uint16_t dmrs_length = get_num_dmrs(dlDmrsSymbPos); LOG_D(MAC,"dlDmrsSymbPos %x\n",dlDmrsSymbPos); + int mcsTableIdx = 0; int rbSize = 0; uint32_t TBS = 0; do { @@ -358,8 +358,8 @@ uint32_t schedule_control_sib1(module_id_t module_id, else break; } - TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx), - nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx), + TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, mcsTableIdx), + nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, mcsTableIdx), rbSize, nrOfSymbols, N_PRB_DMRS * dmrs_length,0, 0,1) >> 3; } while (TBS < gNB_mac->sched_ctrlCommon->num_total_bytes); @@ -401,7 +401,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, gNB_MAC_INST *gNB_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = gNB_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - + int mcsTableIdx = 0; nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset((void*)dl_tti_pdcch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; @@ -410,7 +410,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; nr_configure_pdcch(pdcch_pdu_rel15, gNB_mac->sched_ctrlCommon->coreset, - NULL, + true, // sib1 &gNB_mac->sched_ctrlCommon->sched_pdcch); nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -452,9 +452,9 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->rbSize = gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize; pdsch_pdu_rel15->VRBtoPRBMapping = 0; pdsch_pdu_rel15->qamModOrder[0] = nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, - gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx); + mcsTableIdx); pdsch_pdu_rel15->TBSize[0] = TBS; - pdsch_pdu_rel15->mcsTable[0] = gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx; + pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; pdsch_pdu_rel15->dlDmrsSymbPos = dlDmrsSymbPos; @@ -503,6 +503,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, int rnti_type = NR_RNTI_SI; fill_dci_pdu_rel15(scc, + NULL, NULL, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, @@ -510,7 +511,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, rnti_type, pdsch_pdu_rel15->BWPSize, 0, - 0, + gNB_mac->sched_ctrlCommon->coreset, gNB_mac->cset0_bwp_size); LOG_D(MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 3517c124a57ee4b0ec4834b2fd06d8f85ac277ab..6aee81fa67237e4c6cb24e3c699fb630a034e13e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -388,8 +388,9 @@ bool allocate_dl_retransmission(module_id_t module_id, gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; - NR_CellGroupConfig_t *cg = UE->CellGroup; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; //TODO remove this and handle retransmission with old nrOfLayers @@ -402,26 +403,8 @@ bool allocate_dl_retransmission(module_id_t module_id, return false; } - NR_BWP_DownlinkDedicated_t *bwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated ? - cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - - NR_BWP_UplinkDedicated_t *ubwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); - - const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int coresetid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : dl_bwp->BWPSize; int rbStart = 0; // start wrt BWPstart int rbSize = 0; @@ -452,11 +435,8 @@ bool allocate_dl_retransmission(module_id_t module_id, /* check whether we need to switch the TDA allocation since the last * (re-)transmission */ if (ps->time_domain_allocation != tda) { - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(dl_bwp, scc, - cg, - sched_ctrl->active_bwp, - bwpd, tda, ps->nrOfLayers, sched_ctrl, @@ -467,11 +447,8 @@ bool allocate_dl_retransmission(module_id_t module_id, * that we have enough resources */ NR_pdsch_semi_static_t temp_ps = *ps; - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(dl_bwp, scc, - cg, - sched_ctrl->active_bwp, - bwpd, tda, ps->nrOfLayers, sched_ctrl, @@ -542,7 +519,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, ul_bwp->pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(MAC, @@ -602,6 +579,7 @@ void pf_dl(module_id_t module_id, continue; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *current_BWP = &UE->current_DL_BWP; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; @@ -641,15 +619,15 @@ void pf_dl(module_id_t module_id, /* Calculate coeff */ const NR_bler_options_t *bo = &mac->dl_bler; - const int max_mcs_table = ps->mcsTableIdx == 1 ? 27 : 28; + const int max_mcs_table = current_BWP->mcsTableIdx == 1 ? 27 : 28; const int max_mcs = min(sched_ctrl->dl_max_mcs, max_mcs_table); if (bo->harq_round_max == 1) sched_pdsch->mcs = max_mcs; else sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); UE->layers = set_dl_nrOfLayers(sched_ctrl); - const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); + const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); uint32_t tbs = nr_compute_tbs(Qm, R, 1, /* rbSize */ @@ -676,37 +654,16 @@ void pf_dl(module_id_t module_id, /* Loop UE_sched to find max coeff and allocate transmission */ while (remainUEs> 0 && n_rb_sched >= min_rbSize && iterator->UE != NULL) { - NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; - - NR_BWP_DownlinkDedicated_t *bwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated ? - cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - - NR_BWP_UplinkDedicated_t *ubwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; const uint16_t rnti = iterator->UE->rnti; - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? - RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : - NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); + NR_UE_DL_BWP_t *dl_bwp = &iterator->UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &iterator->UE->current_UL_BWP; - const int coresetid = (sched_ctrl->active_bwp||bwpd) ? - sched_ctrl->coreset->controlResourceSetId : - RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; + const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : - NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + dl_bwp->BWPSize; int rbStart = 0; // start wrt BWPstart if (sched_ctrl->available_dl_harq.head < 0) { @@ -746,7 +703,7 @@ void pf_dl(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, ul_bwp->pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, iterator->UE, frame, slot, r_pucch, 0); if (alloc<0) { @@ -773,11 +730,8 @@ void pf_dl(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; if (ps->nrOfLayers != iterator->UE->layers || ps->time_domain_allocation != tda ) { - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(dl_bwp, scc, - iterator->UE->CellGroup, - sched_ctrl->active_bwp, - bwpd, tda, iterator->UE->layers, sched_ctrl, @@ -795,8 +749,8 @@ void pf_dl(module_id_t module_id, while (rbStart + max_rbSize < bwpSize && (rballoc_mask[rbStart + max_rbSize] & slbitmap) == slbitmap) max_rbSize++; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); sched_pdsch->pucch_allocation = alloc; uint32_t TBS = 0; uint16_t rbSize; @@ -842,30 +796,18 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* This is temporary and it assumes all UEs have the same BWP and TDA*/ NR_UE_info_t *UE=UE_info->list[0]; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *current_BWP = &UE->current_DL_BWP; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ? - sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = current_BWP->tdaList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); - - NR_BWP_DownlinkDedicated_t *bwpd = - UE->CellGroup && - UE->CellGroup->spCellConfig && - UE->CellGroup->spCellConfig->spCellConfigDedicated ? - UE->CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - - const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; + const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : current_BWP->BWPSize; + const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : current_BWP->BWPStart; const uint16_t slbitmap = SL_to_bitmap(startSymbolIndex, nrOfSymbols); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; @@ -925,6 +867,7 @@ nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) { void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot) { + gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; if (!is_xlsch_in_slot(gNB_mac->dlsch_slot_bitmap[slot / 64], slot)) @@ -939,6 +882,7 @@ void nr_schedule_ue_spec(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *current_BWP = &UE->current_DL_BWP; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; @@ -946,12 +890,6 @@ void nr_schedule_ue_spec(module_id_t module_id, UE->mac_stats.dl.current_bytes = 0; NR_CellGroupConfig_t *cg = UE->CellGroup; - NR_BWP_DownlinkDedicated_t *bwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated ? - cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - /* update TA and set ta_apply every 10 frames. * Possible improvement: take the periodicity from input file. * If such UE is not scheduled now, it will be by the preprocessor later. @@ -1025,17 +963,9 @@ void nr_schedule_ue_spec(module_id_t module_id, pucch->ul_slot, sched_pdsch->pucch_allocation, sched_ctrl->tpc1); - NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; - - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); - - NR_SearchSpace_t *ss = (bwp||bwpd) ? sched_ctrl->search_space : gNB_mac->sched_ctrlCommon->search_space; - const int bwp_id = bwp ? bwp->bwp_Id : 0; - const int coresetid = (bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; + const int bwp_id = current_BWP->bwp_id; + const int coresetid = sched_ctrl->coreset->controlResourceSetId; /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it */ nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][coresetid]; @@ -1049,8 +979,8 @@ void nr_schedule_ue_spec(module_id_t module_id, dl_req->nPDUs += 1; pdcch_pdu = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %04x, bwp %d, cs %d\n", UE->rnti, bwp_id, coresetid); - NR_ControlResourceSet_t *coreset = (bwp||bwpd)? sched_ctrl->coreset:gNB_mac->sched_ctrlCommon->coreset; - nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); + NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; + nr_configure_pdcch(pdcch_pdu, coreset, false, &sched_ctrl->sched_pdcch); gNB_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu; } @@ -1072,19 +1002,19 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->BWPSize = gNB_mac->cset0_bwp_size; pdsch_pdu->BWPStart = gNB_mac->cset0_bwp_start; } else { - pdsch_pdu->BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pdsch_pdu->BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + pdsch_pdu->BWPSize = current_BWP->BWPSize; + pdsch_pdu->BWPStart = current_BWP->BWPStart; } - pdsch_pdu->SubcarrierSpacing = genericParameters->subcarrierSpacing; - pdsch_pdu->CyclicPrefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; + pdsch_pdu->SubcarrierSpacing = current_BWP->scs; + pdsch_pdu->CyclicPrefix = current_BWP->cyclicprefix ? *current_BWP->cyclicprefix : 0; // Codeword information pdsch_pdu->NrOfCodewords = 1; //number of information bits per 1024 coded bits expressed in 0.1 bit units pdsch_pdu->targetCodeRate[0] = R; pdsch_pdu->qamModOrder[0] = Qm; pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; - pdsch_pdu->mcsTable[0] = ps->mcsTableIdx; + pdsch_pdu->mcsTable[0] = current_BWP->mcsTableIdx; AssertFatal(harq!=NULL,"harq is null\n"); AssertFatal(harq->round<gNB_mac->dl_bler.harq_round_max,"%d",harq->round); pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round%4]; @@ -1121,21 +1051,17 @@ void nr_schedule_ue_spec(module_id_t module_id, csi_report->codebook_mode); } // TBS_LBRM according to section 5.4.2.1 of 38.212 - long maxMIMO_Layers = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated ? *cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers : 1; - int nl_tbslbrm = maxMIMO_Layers < 4 ? maxMIMO_Layers : 4; + long *maxMIMO_Layers = current_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers; + AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); + int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; // Maximum number of PRBs across all configured DL BWPs - int bw_tbslbrm = get_bw_tbslbrm(genericParameters, cg); - pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(ps->mcsTableIdx, + int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, cg); + pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcsTableIdx, bw_tbslbrm, nl_tbslbrm); - NR_PDSCH_Config_t *pdsch_Config=NULL; - - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup) - pdsch_Config = bwp->bwp_Dedicated->pdsch_Config->choice.setup; + NR_PDSCH_Config_t *pdsch_Config = current_BWP->pdsch_Config; /* Check and validate PTRS values */ struct NR_SetupRelease_PTRS_DownlinkConfig *phaseTrackingRS = @@ -1182,14 +1108,11 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_pdu_rel15_t dci_payload; memset(&dci_payload, 0, sizeof(dci_pdu_rel15_t)); // bwp indicator - const int n_dl_bwp = bwp ? cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count : 0; - AssertFatal(n_dl_bwp <= NR_MAX_NUM_BWP, "downlinkBWP_ToAddModList has %d BWP!\n", n_dl_bwp); - // as per table 7.3.1.1.2-1 in 38.212 - dci_payload.bwp_indicator.val = bwp ? (n_dl_bwp < 4 ? bwp->bwp_Id : bwp->bwp_Id - 1) : 0; + dci_payload.bwp_indicator.val = current_BWP->n_dl_bwp < 4 ? bwp_id : bwp_id - 1; - if (bwp) AssertFatal(bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, - "Only frequency resource allocation type 1 is currently supported\n"); + AssertFatal(pdsch_Config->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, + "Only frequency resource allocation type 1 is currently supported\n"); dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu->rbSize, pdsch_pdu->rbStart, @@ -1225,19 +1148,17 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.tpc, pucch->timing_indicator); - int dci_format = ss && ss->searchSpaceType && ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? - NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; - const int rnti_type = NR_RNTI_C; fill_dci_pdu_rel15(scc, cg, + current_BWP, dci_pdu, &dci_payload, - dci_format, + current_BWP->dci_format, rnti_type, pdsch_pdu->BWPSize, - bwp ? bwp->bwp_Id : 0, - coresetid, + bwp_id, + sched_ctrl->coreset, gNB_mac->cset0_bwp_size); LOG_D(NR_MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 808fc613f1a854d7b410b7a5e28b82ea05aeaa3f..e474315de780568549570a1eff7e5f53acaa908a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -195,17 +195,18 @@ void nr_preprocessor_phytest(module_id_t module_id, NR_UE_info_t *UE = RC.nrmac[module_id]->UE_info.list[0]; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; const int CC_id = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) - nr_set_pdsch_semi_static(NULL, scc, UE->CellGroup, sched_ctrl->active_bwp, NULL, tda, target_dl_Nl,sched_ctrl , ps); + nr_set_pdsch_semi_static(dl_bwp, scc, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ - const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int bwpSize = dl_bwp->BWPSize; + const int BWPStart = dl_bwp->BWPStart; int rbStart = 0; int rbSize = 0; @@ -278,7 +279,7 @@ void nr_preprocessor_phytest(module_id_t module_id, __func__, UE->rnti); - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, UE->current_UL_BWP.pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc < 0) { LOG_D(MAC, @@ -308,9 +309,9 @@ void nr_preprocessor_phytest(module_id_t module_id, sched_pdsch->rbSize = rbSize; sched_pdsch->mcs = target_dl_mcs; + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); sched_ctrl->dl_bler_stats.mcs = target_dl_mcs; /* for logging output */ - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, sched_pdsch->R, sched_pdsch->rbSize, @@ -340,7 +341,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - const int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; NR_UE_info_t *UE = nr_mac->UE_info.list[0]; AssertFatal(nr_mac->UE_info.list[1] == NULL, @@ -351,9 +351,10 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int mu = ul_bwp->scs; - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = - sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = ul_bwp->tdaList; const int temp_tda = get_ul_tda(nr_mac, scc, slot); if (temp_tda < 0) return false; @@ -361,7 +362,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ "time domain assignment %d >= %d\n", temp_tda, tdaList->list.count); - int K2 = get_K2(scc,NULL,sched_ctrl->active_ubwp, temp_tda, mu); + int K2 = get_K2(ul_bwp->tdaList, temp_tda, mu); const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_slot); @@ -377,33 +378,19 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ if (!is_xlsch_in_slot(ulsch_slot_bitmap, sched_slot)) return false; - const long f = (sched_ctrl->active_bwp && sched_ctrl->search_space && - sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? - sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; - const int dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; - uint8_t num_dmrs_cdm_grps_no_data = 1; - if ((target_ul_Nl==4)||(target_ul_Nl==3)) - num_dmrs_cdm_grps_no_data = 2; - /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or + * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format - || ps->nrOfLayers != target_ul_Nl - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(NULL, scc, sched_ctrl->active_ubwp, NULL,dci_format, tda, num_dmrs_cdm_grps_no_data,target_ul_Nl,ps); + || ps->nrOfLayers != target_ul_Nl) + nr_set_pusch_semi_static(ul_bwp, scc, tda, target_ul_Nl,ps); uint16_t rbStart = 0; uint16_t rbSize; - const int bw = NRRIV2BW(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int bw = ul_bwp->BWPSize; + const int BWPStart = ul_bwp->BWPStart; if (target_ul_bw>bw) rbSize = bw; @@ -466,10 +453,10 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ /* Calculate TBS from MCS */ ps->nrOfLayers = target_ul_Nl; - sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table); - sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table); - if (ps->pusch_Config->tp_pi2BPSK - && ((ps->mcs_table == 3 && mcs < 2) || (ps->mcs_table == 4 && mcs < 6))) { + sched_pusch->R = nr_get_code_rate_ul(mcs, ul_bwp->mcs_table); + sched_pusch->Qm = nr_get_Qm_ul(mcs, ul_bwp->mcs_table); + if (ul_bwp->pusch_Config->tp_pi2BPSK + && ((ul_bwp->mcs_table == 3 && mcs < 2) || (ul_bwp->mcs_table == 4 && mcs < 6))) { sched_pusch->R >>= 1; sched_pusch->Qm <<= 1; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 4023c4ed4e1cd0c6b46fa23c8d761489e8cd3964..a737e66c403d2ec875d38bbbc9b2ba9ac91b7ffe 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -245,54 +245,12 @@ void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { } } -NR_BWP_t *get_dl_bwp_genericParameters(NR_BWP_Downlink_t *active_bwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1) { - NR_BWP_t *genericParameters = NULL; - if (active_bwp) { - genericParameters = &active_bwp->bwp_Common->genericParameters; - } else if (ServingCellConfigCommon) { - genericParameters = &ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } else { - genericParameters = &sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - } - return genericParameters; -} - -NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1) { - NR_BWP_t *genericParameters = NULL; - if (active_ubwp) { - genericParameters = &active_ubwp->bwp_Common->genericParameters; - } else if (ServingCellConfigCommon) { - genericParameters = &ServingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP->genericParameters; - } else { - genericParameters = &sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.genericParameters; - } - return genericParameters; -} - -NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, - const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1) { - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if (active_bwp) { - tdaList = active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else if (ServingCellConfigCommon) { - tdaList = ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else { - tdaList = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - return tdaList; -} - - NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, void *bwp, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type) { + NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId; if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { // common search space @@ -324,29 +282,22 @@ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, } } -NR_SearchSpace_t *get_searchspace(const NR_SIB1_t *sib1, - NR_ServingCellConfigCommon_t *scc, +NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_SearchSpace__searchSpaceType_PR target_ss) { int n = 0; - if(bwp_Dedicated) { + if(bwp_Dedicated) n = bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count; - } else if(scc) { + else n = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.count; - } else { - n = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.count; - } for (int i=0;i<n;i++) { NR_SearchSpace_t *ss = NULL; - if(bwp_Dedicated) { + if(bwp_Dedicated) ss = bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - } else if(scc) { + else ss = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.array[i]; - } else { - ss = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.array[i]; - } AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); if (ss->searchSpaceType->present == target_ss) { @@ -557,11 +508,8 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *dl_bwp, const NR_ServingCellConfigCommon_t *scc, - const NR_CellGroupConfig_t *secondaryCellGroup, - const NR_BWP_Downlink_t *bwp, - const NR_BWP_DownlinkDedicated_t *bwpd0, int tda, uint8_t layers, NR_UE_sched_ctrl_t *sched_ctrl, @@ -569,39 +517,11 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, { bool reset_dmrs = false; - NR_BWP_DownlinkDedicated_t *bwpd = NULL; - if (bwp && bwp->bwp_Dedicated) { - bwpd = bwp->bwp_Dedicated; - } else { - bwpd = (NR_BWP_DownlinkDedicated_t*)bwpd0; - } - - // Prevent gNB to enable 256QAM table while the RRCProcessing timer is running. - // For example, after the RRC created RRC Reconfiguration message we need to prevent gNB to apply another MCS table - // before the RRC Reconfiguration being received by the UE, otherwise UE will not be able to decode PDSCH - // and the connection will drop. - if (sched_ctrl->rrc_processing_timer == 0) { - if (bwpd && - bwpd->pdsch_Config && - bwpd->pdsch_Config->choice.setup && - bwpd->pdsch_Config->choice.setup->mcs_Table) { - if (*bwpd->pdsch_Config->choice.setup->mcs_Table == 0) { - ps->mcsTableIdx = 1; - } else { - ps->mcsTableIdx = 2; - } - } else { - ps->mcsTableIdx = 0; - } - } - LOG_D(NR_MAC,"MCS Table Index: %d\n",ps->mcsTableIdx); - - NR_PDSCH_Config_t *pdsch_Config = NULL; - if (bwpd && bwpd->pdsch_Config) pdsch_Config = bwpd->pdsch_Config->choice.setup; + NR_PDSCH_Config_t *pdsch_Config = dl_bwp->pdsch_Config; LOG_D(NR_MAC,"tda %d, ps->time_domain_allocation %d,layers %d, ps->nrOfLayers %d, pdsch_config %p\n",tda,ps->time_domain_allocation,layers,ps->nrOfLayers,pdsch_Config); reset_dmrs = true; ps->time_domain_allocation = tda; - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = get_pdsch_TimeDomainAllocationList(bwp, scc, sib1); + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = dl_bwp->tdaList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); ps->mapping_type = tdaList->list.array[tda]->mappingType; if (pdsch_Config) { @@ -615,19 +535,7 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); - const long f = ((bwp || bwpd) && - sched_ctrl->search_space && - sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? - sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; - - int dci_format; - if (sched_ctrl->search_space) { - dci_format = f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; - } - else { - dci_format = NR_DL_DCI_FORMAT_1_0; - } - if (dci_format == NR_DL_DCI_FORMAT_1_0) { + if (dl_bwp->dci_format == NR_DL_DCI_FORMAT_1_0) { if (ps->nrOfSymbols == 2) ps->numDmrsCdmGrpsNoData = 1; else @@ -648,72 +556,38 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, ps->N_PRB_DMRS = ps->numDmrsCdmGrpsNoData * (ps->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4); if (reset_dmrs) { - ps->dl_dmrs_symb_pos = fill_dmrs_mask(bwpd ? bwpd->pdsch_Config->choice.setup : NULL, scc ? scc->dmrs_TypeA_Position : 0, ps->nrOfSymbols, ps->startSymbolIndex, ps->mapping_type, ps->frontloaded_symb); + ps->dl_dmrs_symb_pos = fill_dmrs_mask(pdsch_Config, scc ? scc->dmrs_TypeA_Position : 0, ps->nrOfSymbols, ps->startSymbolIndex, ps->mapping_type, ps->frontloaded_symb); ps->N_DMRS_SLOT = get_num_dmrs(ps->dl_dmrs_symb_pos); } - LOG_D(NR_MAC,"bwpd0 %p, bwpd %p : Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",bwpd0,bwpd,ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); + LOG_D(NR_MAC,"Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); } -void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *ul_bwp, const NR_ServingCellConfigCommon_t *scc, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, - long dci_format, int tda, - uint8_t num_dmrs_cdm_grps_no_data, uint8_t nrOfLayers, NR_pusch_semi_static_t *ps) { - ps->dci_format = dci_format; ps->time_domain_allocation = tda; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if(ubwp) { - tdaList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else if(scc) { - tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else { - tdaList = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + const int startSymbolAndLength = ul_bwp->tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); - ps->pusch_Config = ubwp && ubwp->bwp_Dedicated && ubwp->bwp_Dedicated->pusch_Config ? - ubwp->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd ? ubwpd->pusch_Config->choice.setup : NULL); - if (ps->pusch_Config == NULL || !ps->pusch_Config->transformPrecoder) - ps->transform_precoding = !scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder; - else - ps->transform_precoding = *ps->pusch_Config->transformPrecoder; - const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - if (ps->transform_precoding) - ps->mcs_table = get_pusch_mcs_table(ps->pusch_Config ? ps->pusch_Config->mcs_Table : NULL, - 0, - ps->dci_format, - NR_RNTI_C, - target_ss, - false); - else { - ps->mcs_table = get_pusch_mcs_table(ps->pusch_Config ? ps->pusch_Config->mcs_TableTransformPrecoder : NULL, - 1, - ps->dci_format, - NR_RNTI_C, - target_ss, - false); - num_dmrs_cdm_grps_no_data = 2; // in case of transform precoding - no Data sent in DMRS symbol - } - ps->nrOfLayers = nrOfLayers; - ps->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + // TODO setting of cdm groups with no data to be redone for MIMO + if (ul_bwp->transform_precoding || nrOfLayers<3) + ps->num_dmrs_cdm_grps_no_data = (ul_bwp->dci_format == NR_UL_DCI_FORMAT_0_1) ? 1 : (ps->nrOfSymbols == 2 ? 1 : 2); + else + ps->num_dmrs_cdm_grps_no_data = 2; /* DMRS calculations */ - ps->mapping_type = tdaList->list.array[tda]->mappingType; - ps->NR_DMRS_UplinkConfig = ps->pusch_Config ? + ps->mapping_type = ul_bwp->tdaList->list.array[tda]->mappingType; + ps->NR_DMRS_UplinkConfig = ul_bwp->pusch_Config ? (ps->mapping_type == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA ? - ps->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : - ps->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup) : NULL; + ul_bwp->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : + ul_bwp->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup) : NULL; ps->dmrs_config_type = ps->NR_DMRS_UplinkConfig ? ((ps->NR_DMRS_UplinkConfig->dmrs_Type == NULL ? 0 : 1)) : 0; const pusch_dmrs_AdditionalPosition_t additional_pos = ps->NR_DMRS_UplinkConfig ? (ps->NR_DMRS_UplinkConfig->dmrs_AdditionalPosition == NULL @@ -735,8 +609,8 @@ void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, num_dmrs_symb += (ps->ul_dmrs_symb_pos >> i) & 1; ps->num_dmrs_symb = num_dmrs_symb; ps->N_PRB_DMRS = ps->dmrs_config_type == 0 - ? num_dmrs_cdm_grps_no_data * 6 - : num_dmrs_cdm_grps_no_data * 4; + ? ps->num_dmrs_cdm_grps_no_data * 6 + : ps->num_dmrs_cdm_grps_no_data * 4; } #define BLER_UPDATE_FRAME 10 @@ -1003,25 +877,18 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } void config_uldci(const NR_SIB1_t *sib1, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, - int dci_format, int time_domain_assignment, uint8_t tpc, - int n_ubwp, - int bwp_id) { - - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters((NR_BWP_Uplink_t *)ubwp, - (NR_ServingCellConfigCommon_t *)scc, - (NR_SIB1_t *)sib1); + NR_UE_UL_BWP_t *ul_bwp) { - const int bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int bwp_id = ul_bwp->bwp_id; + nr_dci_format_t dci_format = ul_bwp->dci_format; dci_pdu_rel15->frequency_domain_assignment.val = - PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, bw); + PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, ul_bwp->BWPSize); dci_pdu_rel15->time_domain_assignment.val = time_domain_assignment; dci_pdu_rel15->frequency_hopping_flag.val = pusch_pdu->frequency_hopping; dci_pdu_rel15->mcs = pusch_pdu->mcs_index; @@ -1029,9 +896,9 @@ void config_uldci(const NR_SIB1_t *sib1, dci_pdu_rel15->rv = pusch_pdu->pusch_data.rv_index; dci_pdu_rel15->harq_pid = pusch_pdu->pusch_data.harq_process_id; dci_pdu_rel15->tpc = tpc; - const NR_BWP_UplinkDedicated_t *ubwpd2 = (ubwp) ? ubwp->bwp_Dedicated : ubwpd; + NR_PUSCH_Config_t *pusch_Config = ul_bwp->pusch_Config; - if (ubwpd2) AssertFatal(ubwpd2->pusch_Config->choice.setup->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, + if (pusch_Config) AssertFatal(pusch_Config->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, "Only frequency resource allocation type 1 is currently supported\n"); switch (dci_format) { case NR_UL_DCI_FORMAT_0_0: @@ -1041,13 +908,11 @@ void config_uldci(const NR_SIB1_t *sib1, LOG_D(NR_MAC,"Configuring DCI Format 0_1\n"); dci_pdu_rel15->dai[0].val = 0; //TODO // bwp indicator as per table 7.3.1.1.2-1 in 38.212 - dci_pdu_rel15->bwp_indicator.val = n_ubwp < 4 ? bwp_id : bwp_id - 1; + dci_pdu_rel15->bwp_indicator.val = ul_bwp->n_ul_bwp < 4 ? bwp_id : bwp_id - 1; // SRS resource indicator - if (ubwpd2 && - ubwpd2->pusch_Config && - ubwpd2->pusch_Config->choice.setup && - ubwpd2->pusch_Config->choice.setup->txConfig != NULL) { - AssertFatal(*ubwpd2->pusch_Config->choice.setup->txConfig == NR_PUSCH_Config__txConfig_codebook, + if (pusch_Config && + pusch_Config->txConfig != NULL) { + AssertFatal(*pusch_Config->txConfig == NR_PUSCH_Config__txConfig_codebook, "Non Codebook configuration non supported\n"); dci_pdu_rel15->srs_resource_indicator.val = 0; // taking resource 0 for SRS } @@ -1098,7 +963,7 @@ int nr_get_default_pucch_res(int pucch_ResourceCommon) { void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_ControlResourceSet_t *coreset, - NR_BWP_t *bwp, + bool is_sib1, NR_sched_pdcch_t *pdcch) { @@ -1122,7 +987,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, pdcch_pdu->ShiftIndex = pdcch->ShiftIndex; if(coreset->controlResourceSetId == 0) { - if(bwp == NULL) + if(is_sib1) pdcch_pdu->CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1; else pdcch_pdu->CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG_CSET_0; @@ -1135,11 +1000,10 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, } int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, - NR_BWP_Uplink_t *bwp, - NR_BWP_UplinkDedicated_t *bwpd, + NR_PUCCH_Config_t *pucch_Config, int CCEIndex) { int r_pucch = -1; - if(bwp == NULL && bwpd == NULL) { + if(pucch_Config == NULL) { int n_rb,rb_offset; get_coreset_rballoc(coreset->frequencyDomainResources.buf,&n_rb,&rb_offset); const uint16_t N_cce = n_rb * coreset->duration / NR_NB_REG_PER_CCE; @@ -1150,24 +1014,20 @@ int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, } // This function configures pucch pdu fapi structure -void nr_configure_pucch(const NR_SIB1_t *sib1, - nfapi_nr_pucch_pdu_t* pucch_pdu, +void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, - NR_CellGroupConfig_t *CellGroup, - NR_BWP_Uplink_t *bwp, - NR_BWP_UplinkDedicated_t *bwpd, - uint16_t rnti, + NR_UE_info_t* UE, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, uint8_t O_sr, int r_pucch) { - NR_PUCCH_Config_t *pucch_Config; NR_PUCCH_Resource_t *pucchres; NR_PUCCH_ResourceSet_t *pucchresset; NR_PUCCH_FormatConfig_t *pucchfmt; NR_PUCCH_ResourceId_t *resource_id = NULL; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; long *id0 = NULL; int n_list, n_set; @@ -1179,12 +1039,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, uint16_t O_uci = O_csi + O_ack; - NR_PUSCH_Config_t *pusch_Config = NULL; - if(bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pusch_Config) { - pusch_Config = bwp->bwp_Dedicated->pusch_Config->choice.setup; - } else if(bwpd && bwpd->pusch_Config) { - pusch_Config = bwpd->pusch_Config->choice.setup; - } + NR_PUSCH_Config_t *pusch_Config = current_BWP->pusch_Config; long *pusch_id = pusch_Config ? pusch_Config->dataScramblingIdentityPUSCH : NULL; @@ -1194,14 +1049,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; else id0 = scc->physCellId; - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = NULL; - if(bwp) { - pucch_ConfigCommon = bwp->bwp_Common->pucch_ConfigCommon->choice.setup; - } else if(scc) { - pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; - } else { - pucch_ConfigCommon = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup; - } + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = current_BWP->pucch_ConfigCommon; // hop flags and hopping id are valid for any BWP switch (pucch_ConfigCommon->pucch_GroupHopping){ @@ -1229,18 +1077,14 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, else pucch_pdu->hopping_id = *scc->physCellId; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(bwp,scc, sib1); + pucch_pdu->bwp_size = current_BWP->BWPSize; + pucch_pdu->bwp_start = current_BWP->BWPStart; + pucch_pdu->subcarrier_spacing = current_BWP->scs; + pucch_pdu->cyclic_prefix = (current_BWP->cyclicprefix==NULL) ? 0 : *current_BWP->cyclicprefix; - pucch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pucch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - pucch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; - pucch_pdu->cyclic_prefix = (genericParameters->cyclicPrefix==NULL) ? 0 : *genericParameters->cyclicPrefix; - if (r_pucch<0 || bwp ){ + NR_PUCCH_Config_t *pucch_Config = current_BWP->pucch_Config; + if (r_pucch<0 || pucch_Config){ LOG_D(NR_MAC,"pucch_acknak: Filling dedicated configuration for PUCCH\n"); - // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP - AssertFatal(bwp!=NULL || bwpd!=NULL,"We need one dedicated configuration for a BWP (neither additional or initial BWP has a dedicated configuration)\n"); - pucch_Config = bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pucch_Config ? - bwp->bwp_Dedicated->pucch_Config->choice.setup : bwpd->pucch_Config->choice.setup; AssertFatal(pucch_Config->resourceSetToAddModList!=NULL, "PUCCH resourceSetToAddModList is null\n"); @@ -1293,7 +1137,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, if (pucchres->pucch_ResourceId == *resource_id) { res_found = 1; pucch_pdu->prb_start = pucchres->startingPRB; - pucch_pdu->rnti = rnti; + pucch_pdu->rnti = UE->rnti; // FIXME why there is only one frequency hopping flag // what about inter slot frequency hopping? pucch_pdu->freq_hop_flag = pucchres->intraSlotFrequencyHopping!= NULL ? 1 : 0; @@ -1382,8 +1226,8 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, LOG_D(NR_MAC,"Configure pucch: pucch_pdu->format_type %d pucch_pdu->bit_len_harq %d, pucch->pdu->bit_len_csi %d\n",pucch_pdu->format_type,pucch_pdu->bit_len_harq,pucch_pdu->bit_len_csi_part1); } else { // this is the default PUCCH configuration, PUCCH format 0 or 1 - LOG_D(NR_MAC,"pucch_acknak: Filling default PUCCH configuration from Tables (r_pucch %d, bwp %p)\n",r_pucch,bwp); - int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; + LOG_D(NR_MAC,"pucch_acknak: Filling default PUCCH configuration from Tables (r_pucch %d, pucch_Config %p)\n",r_pucch,pucch_Config); + int rsetindex = *pucch_ConfigCommon->pucch_ResourceCommon; int prb_start, second_hop_prb, nr_of_symb, start_symb; set_r_pucch_parms(rsetindex, r_pucch, @@ -1394,7 +1238,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, &start_symb); pucch_pdu->prb_start = prb_start; - pucch_pdu->rnti = rnti; + pucch_pdu->rnti = UE->rnti; pucch_pdu->freq_hop_flag = 1; pucch_pdu->second_hop_prb = second_hop_prb; pucch_pdu->format_type = default_pucch_fmt[rsetindex]; @@ -1437,25 +1281,14 @@ void set_r_pucch_parms(int rsetindex, } void prepare_dci(const NR_CellGroupConfig_t *CellGroup, + const NR_UE_DL_BWP_t *current_BWP, + const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, - nr_dci_format_t format, - int bwp_id) { + nr_dci_format_t format) { AssertFatal(CellGroup!=NULL,"CellGroup shouldn't be null here\n"); - const NR_BWP_DownlinkDedicated_t *bwpd = NULL; - const NR_PDSCH_Config_t *pdsch_Config = NULL; - const NR_PDCCH_Config_t *pdcch_Config = NULL; - - if (bwp_id>0) { - bwpd=CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; - } - else { - bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - } - pdsch_Config = (bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; - pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; - + const NR_PDSCH_Config_t *pdsch_Config = current_BWP ? current_BWP->pdsch_Config : NULL; switch(format) { case NR_UL_DCI_FORMAT_0_1: @@ -1493,7 +1326,7 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, if (pdsch_Config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL) AssertFatal(1==0,"Aperiodic ZP CSI-RS currently not supported\n"); // transmission configuration indication - if (pdcch_Config->controlResourceSetToAddModList->list.array[0]->tci_PresentInDCI != NULL) + if (coreset->tci_PresentInDCI != NULL) AssertFatal(1==0,"TCI in DCI currently not supported\n"); //srs resource set if (CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching!=NULL) { @@ -1517,9 +1350,8 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, else dci_pdu_rel15->srs_request.val = 0; // CBGTI and CBGFI - if (CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup && - CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) + if (current_BWP->pdsch_servingcellconfig && + current_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) AssertFatal(1==0,"CBG transmission currently not supported\n"); break; default : @@ -1530,23 +1362,28 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *CellGroup, + const NR_UE_DL_BWP_t *current_BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, int rnti_type, int N_RB, int bwp_id, - NR_ControlResourceSetId_t coreset_id, + NR_ControlResourceSet_t *coreset, uint16_t cset0_bwp_size) { uint8_t fsize = 0, pos = 0; uint64_t *dci_pdu = (uint64_t *)pdcch_dci_pdu->Payload; *dci_pdu=0; - int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP,scc->uplinkConfigCommon->initialUplinkBWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, N_RB, bwp_id, coreset_id, cset0_bwp_size); + NR_ControlResourceSetId_t coreset_id = coreset->controlResourceSetId; + int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, + scc->uplinkConfigCommon->initialUplinkBWP, + CellGroup, dci_pdu_rel15, dci_format, + rnti_type, N_RB, bwp_id, coreset_id, cset0_bwp_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); if (dci_format == NR_DL_DCI_FORMAT_1_1 || dci_format == NR_UL_DCI_FORMAT_0_1) - prepare_dci(CellGroup, dci_pdu_rel15, dci_format, bwp_id); + prepare_dci(CellGroup, current_BWP, coreset, dci_pdu_rel15, dci_format); /// Payload generation switch (dci_format) { @@ -2294,24 +2131,6 @@ int get_nrofHARQ_ProcessesForPDSCH(e_NR_PDSCH_ServingCellConfig__nrofHARQ_Proces } } -int get_dl_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) -{ - if (servingCellConfig->firstActiveDownlinkBWP_Id) - return *servingCellConfig->firstActiveDownlinkBWP_Id; - else if (servingCellConfig->defaultDownlinkBWP_Id) - return *servingCellConfig->defaultDownlinkBWP_Id; - else - return 1; -} - -int get_ul_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) -{ - if (servingCellConfig->uplinkConfig && servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) - return *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; - else - return 1; -} - /* hack data to remove UE in the phy */ int rnti_to_remove[10]; volatile int rnti_to_remove_count; @@ -2355,6 +2174,253 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) } } +// main function to configure parameters of current BWP +void configure_UE_BWP(gNB_MAC_INST *nr_mac, + NR_ServingCellConfigCommon_t *scc, + NR_UE_sched_ctrl_t *sched_ctrl, + NR_RA_t *ra, + NR_UE_info_t *UE) { + + AssertFatal((ra != NULL && UE == NULL) || (ra == NULL && UE != NULL), "RA and UE structures are mutually exlusive in BWP configuration\n"); + + NR_CellGroupConfig_t *CellGroup; + NR_UE_DL_BWP_t *DL_BWP; + NR_UE_UL_BWP_t *UL_BWP; + + if (ra) { + DL_BWP = &ra->DL_BWP; + UL_BWP = &ra->UL_BWP; + CellGroup = ra->CellGroup; + } + else { + DL_BWP = &UE->current_DL_BWP; + UL_BWP = &UE->current_UL_BWP; + CellGroup = UE->CellGroup; + } + NR_BWP_Downlink_t *dl_bwp = NULL; + NR_BWP_Uplink_t *ul_bwp = NULL; + NR_BWP_DownlinkDedicated_t *bwpd = NULL; + NR_BWP_UplinkDedicated_t *ubwpd = NULL; + DL_BWP->n_dl_bwp = 1; + UL_BWP->n_ul_bwp = 1; + int old_dl_bwp_id = DL_BWP->bwp_id; + int old_ul_bwp_id = UL_BWP->bwp_id; + + int target_ss; + + if (CellGroup && + CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated) { + + const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + DL_BWP->pdsch_servingcellconfig = servingCellConfig->pdsch_ServingCellConfig? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + + if(UE && UE->Msg3_dcch_dtch) { + // switching to initial BWP + DL_BWP->bwp_id = 0; + UL_BWP->bwp_id = 0; + UE->Msg3_dcch_dtch = false; + } + else { + // (re)configuring BWP + // TODO BWP switching not via RRC reconfiguration + // via RRC if firstActiveXlinkBWP_Id is NULL, MAC stays on the same BWP as before + if (servingCellConfig->firstActiveDownlinkBWP_Id) + DL_BWP->bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; + if (servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) + UL_BWP->bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + } + + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; + if(bwpList) + DL_BWP->n_dl_bwp = bwpList->list.count; + if (DL_BWP->bwp_id>0) { + for (int i=0; i<bwpList->list.count; i++) { + dl_bwp = bwpList->list.array[i]; + if(dl_bwp->bwp_Id == DL_BWP->bwp_id) + break; + } + AssertFatal(dl_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",DL_BWP->bwp_id); + } + + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; + if(ubwpList) + UL_BWP->n_ul_bwp = ubwpList->list.count; + if (UL_BWP->bwp_id>0) { + for (int i=0; i<ubwpList->list.count; i++) { + ul_bwp = ubwpList->list.array[i]; + if(ul_bwp->bwp_Id == UL_BWP->bwp_id) + break; + } + AssertFatal(ul_bwp!=NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); + } + + // selection of dedicated BWPs + if(dl_bwp) + bwpd = dl_bwp->bwp_Dedicated; + else + bwpd = servingCellConfig->initialDownlinkBWP; + if(ul_bwp) + ubwpd = ul_bwp->bwp_Dedicated; + else + ubwpd = servingCellConfig->uplinkConfig->initialUplinkBWP; + + DL_BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; + UL_BWP->pusch_Config = ubwpd->pusch_Config->choice.setup; + UL_BWP->pucch_Config = ubwpd->pucch_Config->choice.setup; + UL_BWP->srs_Config = ubwpd->srs_Config->choice.setup; + UL_BWP->csi_MeasConfig = servingCellConfig->csi_MeasConfig ? servingCellConfig->csi_MeasConfig->choice.setup : NULL; + } + else { + DL_BWP->bwp_id = 0; + DL_BWP->bwp_id = 0; + target_ss = NR_SearchSpace__searchSpaceType_PR_common; + DL_BWP->pdsch_Config = NULL; + UL_BWP->pusch_Config = NULL; + UL_BWP->pucch_Config = NULL; + UL_BWP->csi_MeasConfig = NULL; + } + + if (old_dl_bwp_id != DL_BWP->bwp_id) + LOG_I(NR_MAC, "Switching to DL-BWP %li\n", DL_BWP->bwp_id); + if (old_ul_bwp_id != UL_BWP->bwp_id) + LOG_I(NR_MAC, "Switching to UL-BWP %li\n", UL_BWP->bwp_id); + + // TDA lists + if (DL_BWP->bwp_id>0) + DL_BWP->tdaList = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + else + DL_BWP->tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + + if(UL_BWP->bwp_id>0) + UL_BWP->tdaList = ul_bwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + else + UL_BWP->tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + + // setting generic parameters + NR_BWP_t dl_genericParameters = (DL_BWP->bwp_id>0 && dl_bwp) ? + dl_bwp->bwp_Common->genericParameters: + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + + DL_BWP->scs = dl_genericParameters.subcarrierSpacing; + DL_BWP->cyclicprefix = dl_genericParameters.cyclicPrefix; + DL_BWP->BWPSize = NRRIV2BW(dl_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + DL_BWP->BWPStart = NRRIV2PRBOFFSET(dl_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + + NR_BWP_t ul_genericParameters = (UL_BWP->bwp_id>0 && ul_bwp) ? + ul_bwp->bwp_Common->genericParameters: + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + + UL_BWP->scs = ul_genericParameters.subcarrierSpacing; + UL_BWP->cyclicprefix = ul_genericParameters.cyclicPrefix; + UL_BWP->BWPSize = NRRIV2BW(ul_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + UL_BWP->BWPStart = NRRIV2PRBOFFSET(ul_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + + // Set downlink MCS table + if (DL_BWP->pdsch_Config && + DL_BWP->pdsch_Config->mcs_Table) { + if (*DL_BWP->pdsch_Config->mcs_Table == 0) + DL_BWP->mcsTableIdx = 1; + else + DL_BWP->mcsTableIdx = 2; + } else + DL_BWP->mcsTableIdx = 0; + LOG_D(NR_MAC,"DL MCS Table Index: %d\n",DL_BWP->mcsTableIdx); + + if (UL_BWP->pusch_Config == NULL || !UL_BWP->pusch_Config->transformPrecoder) + UL_BWP->transform_precoding = !scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder; + else + UL_BWP->transform_precoding = *UL_BWP->pusch_Config->transformPrecoder; + + if(UL_BWP->bwp_id>0) + UL_BWP->pucch_ConfigCommon = ul_bwp->bwp_Common->pucch_ConfigCommon->choice.setup; + else + UL_BWP->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; + + + if(UE) { + // setting PDCCH related structures for sched_ctrl + sched_ctrl->search_space = get_searchspace(scc, + bwpd, + target_ss); + sched_ctrl->coreset = get_coreset(nr_mac, + scc, + bwpd, + sched_ctrl->search_space, + target_ss); + + sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, + sched_ctrl->search_space, + sched_ctrl->coreset, + scc, + &dl_genericParameters, + nr_mac->type0_PDCCH_CSS_config); + + // set DL DCI format + DL_BWP->dci_format = (sched_ctrl->search_space->searchSpaceType && + sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + (sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 ? + NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0) : + NR_DL_DCI_FORMAT_1_0; + // set UL DCI format + UL_BWP->dci_format = (sched_ctrl->search_space->searchSpaceType && + sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + (sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 ? + NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : + NR_UL_DCI_FORMAT_0_0; + + if (UL_BWP->csi_MeasConfig) + compute_csi_bitlen (UL_BWP->csi_MeasConfig, UE->csi_report_template); + + } + + if(ra) { + // setting PDCCH related structures for RA + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; + NR_SearchSpaceId_t ra_SearchSpace = 0; + if(dl_bwp) { + commonSearchSpaceList = dl_bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *dl_bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + } else { + commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + } + AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); + for (int i = 0; i < commonSearchSpaceList->list.count; i++) { + NR_SearchSpace_t * ss = commonSearchSpaceList->list.array[i]; + if (ss->searchSpaceId == ra_SearchSpace) + ra->ra_ss = ss; + } + AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); + + ra->coreset = get_coreset(nr_mac, scc, dl_bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); + ra->sched_pdcch = set_pdcch_structure(nr_mac, + ra->ra_ss, + ra->coreset, + scc, + &dl_genericParameters, + &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); + + UL_BWP->dci_format = NR_UL_DCI_FORMAT_0_0; + DL_BWP->dci_format = NR_DL_DCI_FORMAT_1_0; + } + + // Set uplink MCS table + long *mcs_Table = NULL; + if (UL_BWP->pusch_Config) + mcs_Table = UL_BWP->transform_precoding ? + UL_BWP->pusch_Config->mcs_Table : + UL_BWP->pusch_Config->mcs_TableTransformPrecoder; + + UL_BWP->mcs_table = get_pusch_mcs_table(mcs_Table, + UL_BWP->transform_precoding ? 0 : 1, + UL_BWP->dci_format, + NR_RNTI_C, + target_ss, + false); +} + //------------------------------------------------------------------------------ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup) { @@ -2380,91 +2446,50 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf else UE->Msg4_ACKed = false; - if (CellGroup && - CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && - CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen(CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE->csi_report_template); - } - - NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - memset(sched_ctrl, 0, sizeof(*sched_ctrl)); - sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ - sched_ctrl->set_pmi = false; - sched_ctrl->ta_frame = 0; - sched_ctrl->ta_update = 31; - sched_ctrl->ta_apply = false; - sched_ctrl->ul_rssi = 0; - sched_ctrl->pucch_consecutive_dtx_cnt = 0; - sched_ctrl->pusch_consecutive_dtx_cnt = 0; - sched_ctrl->ul_failure = 0; - sched_ctrl->sched_srs.frame = -1; - sched_ctrl->sched_srs.slot = -1; - sched_ctrl->sched_srs.srs_scheduled = false; - - /* set illegal time domain allocation to force recomputation of all fields */ - sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; - sched_ctrl->pusch_semi_static.time_domain_allocation = -1; - const NR_ServingCellConfig_t *servingCellConfig = CellGroup && CellGroup->spCellConfig ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + memset(sched_ctrl, 0, sizeof(*sched_ctrl)); + sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ + sched_ctrl->ta_update = 31; + sched_ctrl->sched_srs.frame = -1; + sched_ctrl->sched_srs.slot = -1; + + // initialize UE BWP information + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + memset(dl_bwp, 0, sizeof(*dl_bwp)); + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + memset(ul_bwp, 0, sizeof(*ul_bwp)); + configure_UE_BWP(nr_mac, scc, sched_ctrl, NULL, UE); + + /* set illegal time domain allocation to force recomputation of all fields */ + sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; + sched_ctrl->pusch_semi_static.time_domain_allocation = -1; /* Set default BWPs */ - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; - - const int bwp_id = servingCellConfig ? *servingCellConfig->firstActiveDownlinkBWP_Id : 0; - sched_ctrl->active_bwp = bwpList && bwp_id > 0 ? bwpList->list.array[bwp_id - 1] : NULL; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; - const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - sched_ctrl->search_space = get_searchspace(sib1, - scc, - sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, - target_ss); - sched_ctrl->coreset = get_coreset(nr_mac, - scc, - sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, - sched_ctrl->search_space, - target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, - sched_ctrl->search_space, - sched_ctrl->coreset, - scc, - genericParameters, - NULL); - sched_ctrl->next_dl_bwp_id = -1; - sched_ctrl->next_ul_bwp_id = -1; - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; - AssertFatal(ubwpList == NULL || ubwpList->list.count <= NR_MAX_NUM_BWP, - "uplinkBWP_ToAddModList has %d BWP!\n", - ubwpList->list.count); - const int ul_bwp_id = servingCellConfig ? *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id : 0; - sched_ctrl->active_ubwp = ubwpList && ul_bwp_id > 0 ? ubwpList->list.array[ul_bwp_id - 1] : NULL; - - /* get Number of HARQ processes for this UE */ - AssertFatal(servingCellConfig == NULL - || servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, - "no pdsch-ServingCellConfig found for UE %04x\n", - UE->rnti); - const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; - // pdsch == NULL in SA -> will create default (8) number of HARQ processes - create_dl_harq_list(sched_ctrl, pdsch); - // add all available UL HARQ processes for this UE - // nb of ul harq processes not configurable - create_nr_list(&sched_ctrl->available_ul_harq, 16); - for (int harq = 0; harq < 16; harq++) - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); - create_nr_list(&sched_ctrl->feedback_ul_harq, 16); - create_nr_list(&sched_ctrl->retrans_ul_harq, 16); + sched_ctrl->next_dl_bwp_id = -1; + sched_ctrl->next_ul_bwp_id = -1; + AssertFatal(ul_bwp->n_ul_bwp <= NR_MAX_NUM_BWP, + "uplinkBWP_ToAddModList has %d BWP!\n", + ul_bwp->n_ul_bwp); + + /* get Number of HARQ processes for this UE */ + // pdsch_servingcellconfig == NULL in SA -> will create default (8) number of HARQ processes + create_dl_harq_list(sched_ctrl, dl_bwp->pdsch_servingcellconfig); + // add all available UL HARQ processes for this UE + // nb of ul harq processes not configurable + create_nr_list(&sched_ctrl->available_ul_harq, 16); + for (int harq = 0; harq < 16; harq++) + add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); + create_nr_list(&sched_ctrl->feedback_ul_harq, 16); + create_nr_list(&sched_ctrl->retrans_ul_harq, 16); pthread_mutex_lock(&UE_info->mutex); int i; - for(i=0; i<MAX_MOBILES_PER_GNB; i++) + for(i=0; i<MAX_MOBILES_PER_GNB; i++) { if (UE_info->list[i] == NULL) { UE_info->list[i] = UE; break; } + } if (i == MAX_MOBILES_PER_GNB) { LOG_E(NR_MAC,"Try to add UE %04x but the list is full\n", rntiP); delete_nr_ue_data(UE, nr_mac->common_channels); @@ -2595,46 +2620,12 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { } -void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, - int bwp_id, - NR_SearchSpace__searchSpaceType_PR ss_type, +void get_pdsch_to_harq_feedback(NR_PUCCH_Config_t *pucch_Config, + nr_dci_format_t dci_format, int *max_fb_time, uint8_t *pdsch_to_harq_feedback) { - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - NR_BWP_DownlinkDedicated_t *bwpd=NULL; - NR_BWP_UplinkDedicated_t *ubwpd=NULL; - - if (ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { - AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE %04x\n",UE->rnti); - AssertFatal(CellGroup->spCellConfig!=NULL,"Cellgroup->spCellConfig is null\n"); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated!=NULL,"CellGroup->spCellConfig->spCellConfigDedicated is null\n"); - } - if (bwp_id>0) { - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList is null\n"); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList is null\n"); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count >= bwp_id, - "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count %d < bwp_id %d\n", - CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count,bwp_id); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count >= bwp_id, - "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count %d < bwp_id %d\n", - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count,bwp_id); - - bwpd = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; - ubwpd = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; - } - else if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { // this is an initialBWP - AssertFatal((bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP is null\n"); - AssertFatal((ubwpd=CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP)!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->uplnikConfig->initialUplinkBWP is null\n"); - } - NR_SearchSpace_t *ss=NULL; - - // common search type uses DCI format 1_0 - if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { + if (dci_format == NR_DL_DCI_FORMAT_1_0) { for (int i=0; i<8; i++) { pdsch_to_harq_feedback[i] = i+1; if(pdsch_to_harq_feedback[i]>*max_fb_time) @@ -2642,42 +2633,16 @@ void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, } } else { - - // searching for a ue specific search space - int found=0; - AssertFatal(bwpd->pdcch_Config!=NULL,"bwpd->pdcch_Config is null\n"); - AssertFatal(bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL, - "bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList is null\n"); - for (int i=0;i<bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { - ss=bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); - AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); - if (ss->searchSpaceType->present == ss_type) { - found=1; - break; - } - } - AssertFatal(found==1,"Couldn't find a ue specific searchspace\n"); - - if (ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0) { + AssertFatal(pucch_Config!=NULL,"pucch_Config shouldn't be null here\n"); + if(pucch_Config->dl_DataToUL_ACK != NULL) { for (int i=0; i<8; i++) { - pdsch_to_harq_feedback[i] = i+1; + pdsch_to_harq_feedback[i] = *pucch_Config->dl_DataToUL_ACK->list.array[i]; if(pdsch_to_harq_feedback[i]>*max_fb_time) *max_fb_time = pdsch_to_harq_feedback[i]; } } - else { - AssertFatal(ubwpd!=NULL,"ubwpd shouldn't be null here\n"); - if(ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK != NULL) { - for (int i=0; i<8; i++) { - pdsch_to_harq_feedback[i] = *ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[i]; - if(pdsch_to_harq_feedback[i]>*max_fb_time) - *max_fb_time = pdsch_to_harq_feedback[i]; - } - } - else - AssertFatal(0==1,"There is no allocated dl_DataToUL_ACK for pdsch to harq feedback\n"); - } + else + AssertFatal(0==1,"There is no allocated dl_DataToUL_ACK for pdsch to harq feedback\n"); } } @@ -2699,12 +2664,13 @@ void nr_csirs_scheduling(int Mod_idP, if (sched_ctrl->rrc_processing_timer > 0) { continue; } - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || - !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + + if (!ul_bwp->csi_MeasConfig) continue; - NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_CSI_MeasConfig_t *csi_measconfig = ul_bwp->csi_MeasConfig; if (csi_measconfig->nzp_CSI_RS_ResourceToAddModList != NULL) { @@ -2712,9 +2678,6 @@ void nr_csirs_scheduling(int Mod_idP, int period, offset; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters : - &gNB_mac->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; @@ -2733,22 +2696,20 @@ void nr_csirs_scheduling(int Mod_idP, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csirs_pdu_rel15 = &dl_tti_csirs_pdu->csi_rs_pdu.csi_rs_pdu_rel15; - csirs_pdu_rel15->subcarrier_spacing = genericParameters->subcarrierSpacing; - if (genericParameters->cyclicPrefix) - csirs_pdu_rel15->cyclic_prefix = *genericParameters->cyclicPrefix; + csirs_pdu_rel15->subcarrier_spacing = dl_bwp->scs; + if (dl_bwp->cyclicprefix) + csirs_pdu_rel15->cyclic_prefix = *dl_bwp->cyclicprefix; else csirs_pdu_rel15->cyclic_prefix = 0; // According to last paragraph of TS 38.214 5.2.2.3.1 - uint16_t BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - uint16_t BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - if (resourceMapping.freqBand.startingRB < BWPStart) { - csirs_pdu_rel15->start_rb = BWPStart; + if (resourceMapping.freqBand.startingRB < dl_bwp->BWPStart) { + csirs_pdu_rel15->start_rb = dl_bwp->BWPStart; } else { csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; } - if (resourceMapping.freqBand.nrofRBs > (BWPStart + BWPSize - csirs_pdu_rel15->start_rb)) { - csirs_pdu_rel15->nr_of_rbs = BWPStart + BWPSize - csirs_pdu_rel15->start_rb; + if (resourceMapping.freqBand.nrofRBs > (dl_bwp->BWPStart + dl_bwp->BWPSize - csirs_pdu_rel15->start_rb)) { + csirs_pdu_rel15->nr_of_rbs = dl_bwp->BWPStart + dl_bwp->BWPSize - csirs_pdu_rel15->start_rb; } else { csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; } @@ -2903,8 +2864,8 @@ void nr_csirs_scheduling(int Mod_idP, void nr_mac_update_timers(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->rrc_processing_timer > 0) { @@ -2912,8 +2873,6 @@ void nr_mac_update_timers(module_id_t module_id, if (sched_ctrl->rrc_processing_timer == 0) { LOG_I(NR_MAC, "(%d.%d) De-activating RRC processing timer for UE %04x\n", frame, slot, UE->rnti); - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_CellGroupConfig_t *cg = NULL; uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, //might be added prefix later @@ -2927,138 +2886,37 @@ void nr_mac_update_timers(module_id_t module_id, } NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - const NR_ServingCellConfig_t *spCellConfigDedicated = cg && cg->spCellConfig ? cg->spCellConfig->spCellConfigDedicated : NULL; LOG_I(NR_MAC,"Modified rnti %04x with CellGroup\n", UE->rnti); process_CellGroup(cg,&UE->UE_sched_ctrl); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - const NR_PDSCH_ServingCellConfig_t *pdsch = spCellConfigDedicated ? spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup : NULL; + configure_UE_BWP(RC.nrmac[module_id], scc, sched_ctrl, NULL, UE); + if (get_softmodem_params()->sa) { // add all available DL HARQ processes for this UE in SA - create_dl_harq_list(sched_ctrl, pdsch); - } - - // If needed, update the Dedicated BWP - const int current_bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - const int current_ubwp_id = sched_ctrl->active_ubwp ? sched_ctrl->active_ubwp->bwp_Id : 0; - if (UE->Msg3_dcch_dtch) { - // 3GPP TS 38.321 Section 5.15 Bandwidth Part (BWP) operation - // Currently there are no PRACH occasions configured for any Dedicated BWP, so UE will switch to the initialDownlinkBWP - sched_ctrl->active_bwp = NULL; - if (current_bwp_id != 0) { - LOG_I(NR_MAC, "(%d.%d) Switching to initialDownlinkBWP\n", frame, slot); - } - // 3GPP TS 38.321 Section 5.15 Bandwidth Part (BWP) operation - // Currently there are no PRACH occasions configured for any Dedicated BWP, so UE will switch to the initialUplinkBWP - sched_ctrl->active_ubwp = NULL; - if (current_ubwp_id != 0) { - LOG_I(NR_MAC, "(%d.%d) Switching to initialUplinkBWP\n", frame, slot); - } - UE->Msg3_dcch_dtch = false; - - // Schedule BWP switching to the first active BWP (previous active BWP before RA with Msg3 carrying DCCH or DTCH message) - sched_ctrl->next_dl_bwp_id = current_bwp_id; - sched_ctrl->next_ul_bwp_id = current_ubwp_id; - } else if (spCellConfigDedicated && - spCellConfigDedicated->downlinkBWP_ToAddModList && - spCellConfigDedicated->uplinkConfig && - spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { - sched_ctrl->active_bwp = spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[*spCellConfigDedicated->firstActiveDownlinkBWP_Id - 1]; - if (*spCellConfigDedicated->firstActiveDownlinkBWP_Id != current_bwp_id) { - LOG_I(NR_MAC, "(%d.%d) Switching to DL-BWP %li\n", frame, slot, sched_ctrl->active_bwp->bwp_Id); - } - sched_ctrl->active_ubwp = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id - 1]; - if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != current_ubwp_id) { - LOG_I(NR_MAC, "(%d.%d) Switching to UL-BWP %li\n", frame, slot, sched_ctrl->active_ubwp->bwp_Id); - } - - // Update next_dl_bwp_id to not trigger BWP switching, UE should be already on active_bwp - sched_ctrl->next_dl_bwp_id = sched_ctrl->active_bwp->bwp_Id; - // Update next_ul_bwp_id to not trigger BWP switching, UE should be already on active_ubwp - sched_ctrl->next_ul_bwp_id = sched_ctrl->active_ubwp->bwp_Id; - } else { - sched_ctrl->active_bwp = NULL; - sched_ctrl->active_ubwp = NULL; - - // Update next_dl_bwp_id to not trigger BWP switching, UE should be already on Initial BWP - sched_ctrl->next_dl_bwp_id = 0; - // Update next_ul_bwp_id to not trigger BWP switching, UE should be already on Initial BWP - sched_ctrl->next_ul_bwp_id = 0; - } - - // Update coreset/searchspace - NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; - NR_BWP_DownlinkDedicated_t *bwpd = NULL; - NR_BWP_t *genericParameters = NULL; - int target_ss = NR_SearchSpace__searchSpaceType_PR_common; - if (bwp) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - bwpd = sched_ctrl->active_bwp->bwp_Dedicated; - genericParameters = &sched_ctrl->active_bwp->bwp_Common->genericParameters; - } else if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - (cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - bwpd = cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } - sched_ctrl->search_space = get_searchspace(sib1, scc, (void*)bwpd, target_ss); - sched_ctrl->coreset = get_coreset(RC.nrmac[module_id], scc, (void*)bwpd, sched_ctrl->search_space, target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[module_id], - sched_ctrl->search_space, - sched_ctrl->coreset, - scc, - genericParameters, - RC.nrmac[module_id]->type0_PDCCH_CSS_config); - sched_ctrl->maxL = 2; - if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig && - cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen (cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE->csi_report_template); + create_dl_harq_list(sched_ctrl, UE->current_DL_BWP.pdsch_servingcellconfig); } NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; const uint8_t layers = set_dl_nrOfLayers(sched_ctrl); const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(&UE->current_DL_BWP, scc, - cg, - bwp, - bwpd, tda, layers, sched_ctrl, ps); - NR_BWP_Uplink_t *ubwp = sched_ctrl->active_ubwp; - NR_BWP_UplinkDedicated_t *ubwpd = NULL; - if (ubwp) { - ubwpd = sched_ctrl->active_ubwp->bwp_Dedicated; - } else if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - (cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { - ubwpd = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - } NR_pusch_semi_static_t *ups = &sched_ctrl->pusch_semi_static; - int dci_format = get_dci_format(sched_ctrl); - const uint8_t num_dmrs_cdm_grps_no_data = (ubwp || ubwpd) ? 1 : 2; const uint8_t nrOfLayers = 1; const int utda = get_ul_tda(RC.nrmac[module_id], scc, slot); - nr_set_pusch_semi_static(sib1, + nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, - ubwp, - ubwpd, - dci_format, utda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ups); } @@ -3078,21 +2936,23 @@ void schedule_nr_bwp_switch(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; if (sched_ctrl->rrc_processing_timer == 0 && UE->Msg4_ACKed && sched_ctrl->next_dl_bwp_id >= 0) { int schedule_bwp_switching = false; - if (sched_ctrl->active_bwp == NULL) { + if (dl_bwp->bwp_id == 0) { // Switching from Initial BWP to Dedicated BWP if (sched_ctrl->next_dl_bwp_id > 0 && sched_ctrl->next_ul_bwp_id > 0) { schedule_bwp_switching = true; LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from Initial DL BWP to %ld and from Initial UL BWP to %ld\n", frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); } - } else if (sched_ctrl->active_bwp->bwp_Id != sched_ctrl->next_dl_bwp_id && sched_ctrl->active_ubwp->bwp_Id != sched_ctrl->next_ul_bwp_id) { + } else if (dl_bwp->bwp_id != sched_ctrl->next_dl_bwp_id && ul_bwp->bwp_id != sched_ctrl->next_ul_bwp_id) { // Switching between Dedicated BWPs schedule_bwp_switching = true; LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", - frame, slot, UE->rnti, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->next_dl_bwp_id, sched_ctrl->active_ubwp->bwp_Id, sched_ctrl->next_ul_bwp_id); + frame, slot, UE->rnti, dl_bwp->bwp_id, sched_ctrl->next_dl_bwp_id, ul_bwp->bwp_id, sched_ctrl->next_ul_bwp_id); } if (schedule_bwp_switching) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index 4be176714eccbba1e5ae9fe28b7c16bea0cc49cf..97e5f75e340ed248d35f3afc6513e9dd3240f65c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -36,20 +36,13 @@ extern RAN_CONTEXT_t RC; void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id,NR_UE_info_t* UE, NR_SRS_Resource_t *srs_resource) { - gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - - const NR_SIB1_t *sib1 = nrmac->common_channels[0].sib1 ? nrmac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; srs_pdu->rnti = UE->rnti; srs_pdu->handle = 0; - srs_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);; - srs_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);; - srs_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; + srs_pdu->bwp_size = current_BWP->BWPSize; + srs_pdu->bwp_start = current_BWP->BWPStart; + srs_pdu->subcarrier_spacing = current_BWP->scs; srs_pdu->cyclic_prefix = 0; srs_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; srs_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols; @@ -115,9 +108,8 @@ void nr_schedule_srs(int module_id, frame_t frame) { UE_iterator(UE_info->list, UE) { const int CC_id = 0; - NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; - NR_CellGroupConfig_t *cg = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; @@ -128,23 +120,9 @@ void nr_schedule_srs(int module_id, frame_t frame) { continue; } - NR_SRS_Config_t *srs_config = NULL; - if (sched_ctrl->active_ubwp) { - if (sched_ctrl->active_ubwp->bwp_Dedicated && - sched_ctrl->active_ubwp->bwp_Dedicated->srs_Config) { - srs_config = sched_ctrl->active_ubwp->bwp_Dedicated->srs_Config->choice.setup; - } - } else if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - srs_config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; - } - - if (!srs_config) { + NR_SRS_Config_t *srs_config = current_BWP->srs_Config; + if (!srs_config) continue; - } for(int rs = 0; rs < srs_config->srs_ResourceSetToAddModList->list.count; rs++) { @@ -172,15 +150,9 @@ void nr_schedule_srs(int module_id, frame_t frame) { continue; } - const NR_SIB1_t *sib1 = nrmac->common_channels[0].sib1 ? nrmac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); - uint16_t period = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present]; uint16_t offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); - - const int n_slots_frame = nr_slots_per_frame[genericParameters->subcarrierSpacing]; + int n_slots_frame = nr_slots_per_frame[current_BWP->scs]; // Check if UE will transmit the SRS in this frame if ( ((frame - offset/n_slots_frame)*n_slots_frame)%period == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 0db821dd883e64bc1ede035a387ebff4b9e3e991..68900cda354cc4e71275ba181d82e7e1a1847c81 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -80,23 +80,13 @@ static void nr_fill_nfapi_pucch(gNB_MAC_INST *nrmac, pucch->resource_indicator); NR_COMMON_channels_t * common_ch=nrmac->common_channels; NR_ServingCellConfigCommon_t *scc = common_ch->ServingCellConfigCommon; - NR_CellGroupConfig_t *cg=UE->CellGroup; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + LOG_D(NR_MAC,"%4d.%2d Calling nr_configure_pucch (pucch_Config %p,r_pucch %d) pucch to be scheduled in %4d.%2d\n", + frame,slot,UE->current_UL_BWP.pucch_Config,pucch->r_pucch,pucch->frame,pucch->ul_slot); - LOG_D(NR_MAC,"%4d.%2d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch to be scheduled in %4d.%2d\n", - frame,slot,ubwpd,pucch->r_pucch,pucch->frame,pucch->ul_slot); - - const NR_SIB1_t *sib1 = common_ch->sib1 ? common_ch->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - nr_configure_pucch(sib1, - pucch_pdu, + nr_configure_pucch(pucch_pdu, scc, - UE->CellGroup, - UE->UE_sched_ctrl.active_ubwp, - ubwpd, - UE->rnti, + UE, pucch->resource_indicator, pucch->csi_bits, pucch->dai_c, @@ -173,31 +163,18 @@ void nr_csi_meas_reporting(int Mod_idP, frame_t frame, sub_frame_t slot) { - NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { - const NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { continue; } - if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || - !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; - const NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + const NR_CSI_MeasConfig_t *csi_measconfig = ul_bwp->csi_MeasConfig; + if (!csi_measconfig) continue; AssertFatal(csi_measconfig->csi_ReportConfigToAddModList->list.count > 0, "NO CSI report configuration available"); - NR_PUCCH_Config_t *pucch_Config = NULL; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (CellGroup && - CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } + NR_PUCCH_Config_t *pucch_Config = ul_bwp->pucch_Config; for (int csi_report_id = 0; csi_report_id < csi_measconfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ NR_CSI_ReportConfig_t *csirep = csi_measconfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; @@ -237,12 +214,7 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->resource_indicator = res_index; curr_pucch->csi_bits += nr_get_csi_bitlen(UE->csi_report_template, csi_report_id); - const NR_SIB1_t *sib1 = RC.nrmac[Mod_idP]->common_channels[0].sib1 ? RC.nrmac[Mod_idP]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); - - int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + int bwp_start = ul_bwp->BWPStart; // going through the list of PUCCH resources to find the one indexed by resource_id uint16_t *vrb_map_UL = &RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; @@ -310,13 +282,13 @@ static void handle_dl_harq(NR_UE_info_t * UE, } int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, NR_UE_info_t * UE) { - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; + + const NR_PDSCH_Config_t *pdsch_Config = UE->current_DL_BWP.pdsch_Config; + int nb_tci_states = pdsch_Config ? pdsch_Config->tci_StatesToAddModList->list.count : 0; NR_TCI_State_t *tci =NULL; - int i; - for(i=0; i<nb_tci_states && i<64; i++) { - tci = (NR_TCI_State_t *)CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.array[i]; + for(int i=0; i<nb_tci_states && i<64; i++) { + tci = (NR_TCI_State_t *)pdsch_Config->tci_StatesToAddModList->list.array[i]; if(tci != NULL) { if(tci->qcl_Type1.referenceSignal.present == NR_QCL_Info__referenceSignal_PR_ssb) { @@ -336,18 +308,17 @@ int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, NR_UE_info_t * } int checkTargetSSBInTCIStates_pdcchConfig(int ssb_index_t, NR_UE_info_t *UE) { - NR_CellGroupConfig_t *CellGroup = UE->CellGroup ; - int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; + NR_TCI_State_t *tci =NULL; NR_TCI_StateId_t *tci_id = NULL; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; - int i; int flag = 0; int tci_stateID = -1; - - for(i=0; i<nb_tci_states && i<128; i++) { - tci = (NR_TCI_State_t *)CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.array[i]; + const NR_PDSCH_Config_t *pdsch_Config = UE->current_DL_BWP.pdsch_Config; + int nb_tci_states = pdsch_Config ? pdsch_Config->tci_StatesToAddModList->list.count : 0; + for(int i=0; i<nb_tci_states && i<128; i++) { + tci = (NR_TCI_State_t *)pdsch_Config->tci_StatesToAddModList->list.array[i]; if(tci != NULL && tci->qcl_Type1.referenceSignal.present == NR_QCL_Info__referenceSignal_PR_ssb) { if(tci->qcl_Type1.referenceSignal.choice.ssb == ssb_index_t) { @@ -403,21 +374,12 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { uint8_t target_ssb_beam_index = curr_ssb_beam_index; uint8_t is_triggering_ssb_beam_switch =0; uint8_t ssb_idx = 0; - int pdsch_bwp_id =0; + int pdsch_bwp_id = 0; int ssb_index[MAX_NUM_SSB] = {0}; int ssb_rsrp[MAX_NUM_SSB] = {0}; uint8_t idx = 0; - + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - - //bwp indicator - int n_dl_bwp=0; - if (CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) - n_dl_bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; uint8_t nr_ssbri_cri = 0; uint8_t nb_of_csi_ssb_report = UE->csi_report_template[cqi_idx].nb_of_csi_ssb_report; @@ -425,6 +387,9 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { uint8_t diff_rsrp_idx = 0; uint8_t i, j; + //bwp indicator + int n_dl_bwp = dl_bwp->n_dl_bwp; + const int bwp_id = dl_bwp->bwp_id; if (n_dl_bwp < 4) pdsch_bwp_id = bwp_id; else @@ -686,9 +651,11 @@ void evaluate_cqi_report(uint8_t *payload, nr_csi_report_t *csi_report, int cumul_bits, uint8_t ri, - NR_UE_sched_ctrl_t *sched_ctrl, + NR_UE_info_t *UE, long *cqi_Table){ + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + //TODO sub-band CQI report not yet implemented int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[ri]; @@ -711,7 +678,7 @@ void evaluate_cqi_report(uint8_t *payload, // TODO for wideband case and multiple TB const int cqi_idx = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb; - const int mcs_table = sched_ctrl->pdsch_semi_static.mcsTableIdx; + const int mcs_table = UE->current_DL_BWP.mcsTableIdx; const int cqi_table = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.cqi_table; sched_ctrl->dl_max_mcs = get_mcs_from_cqi(mcs_table, cqi_table, cqi_idx); } @@ -786,11 +753,12 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_ServingCellConfigCommon_t *scc) { /** From Table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel */ - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; uint8_t *payload = uci_pdu->csi_part1.csi_part1_payload; uint16_t bitlen = uci_pdu->csi_part1.csi_part1_bit_len; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type = NR_CSI_ReportConfig__reportQuantity_PR_NOTHING; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; int cumul_bits = 0; int r_index = -1; for (int csi_report_id = 0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++ ) { @@ -825,7 +793,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, cumul_bits += ri_bitlen; if (r_index != -1) skip_zero_padding(&cumul_bits,csi_report,r_index,bitlen); - evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); + evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,UE,csirep->cqi_Table); break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI: cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; @@ -841,7 +809,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, pmi_bitlen = evaluate_pmi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl); sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id = csi_report_id; cumul_bits += pmi_bitlen; - evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); + evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,UE,csirep->cqi_Table); break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI: cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; @@ -859,7 +827,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, pmi_bitlen = evaluate_pmi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl); sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id = csi_report_id; cumul_bits += pmi_bitlen; - evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); + evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,UE,csirep->cqi_Table); break; default: AssertFatal(1==0, "Invalid or not supported CSI measurement report\n"); @@ -969,15 +937,10 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->rnti); return; } - AssertFatal(UE->CellGroup,"Cellgroup is null for UE %04x\n", uci_234->rnti); - AssertFatal(UE->CellGroup->spCellConfig, - "Cellgroup->spCellConfig is null for UE %04x\n", uci_234->rnti); - AssertFatal(UE->CellGroup->spCellConfig->spCellConfigDedicated, - "Cellgroup->spCellConfig->spCellConfigDedicated is null for UE %04x\n", uci_234->rnti); - if ( UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig==NULL) - return; - NR_CSI_MeasConfig_t *csi_MeasConfig = UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_CSI_MeasConfig_t *csi_MeasConfig = UE->current_UL_BWP.csi_MeasConfig; + if (csi_MeasConfig==NULL) + return; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; // tpc (power control) @@ -1079,7 +1042,8 @@ int nr_acknack_scheduling(int mod_id, const int CC_id = 0; const int minfbtime = RC.nrmac[mod_id]->minRXTXTIMEpdsch; const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels[CC_id].ServingCellConfigCommon; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd || RC.nrmac[mod_id]->common_channels[CC_id].frame_type == FDD, "Dynamic TDD not handled yet\n"); const int nr_slots_period = tdd ? n_slots_frame / get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity) : n_slots_frame; @@ -1094,23 +1058,10 @@ int nr_acknack_scheduling(int mod_id, * later) * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_CellGroupConfig_t *cg = UE->CellGroup; - - NR_PUCCH_Config_t *pucch_Config = NULL; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - pucch_Config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? - &sched_ctrl->active_ubwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - int bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + NR_PUCCH_Config_t *pucch_Config = ul_bwp->pucch_Config; + + int bwp_start = ul_bwp->BWPStart; + int bwp_size = ul_bwp->BWPSize; NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; LOG_D(NR_MAC, "In %s: %4d.%2d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c); @@ -1165,22 +1116,13 @@ int nr_acknack_scheduling(int mod_id, LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame, slot, pucch->frame, pucch->ul_slot, pucch->dai_c); - // this is hardcoded for now as ue specific only if we are not on the initialBWP (to be fixed to allow ue_Specific also on initialBWP - NR_BWP_UplinkDedicated_t *ubwpd=NULL; - - if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) - ubwpd = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; + nr_dci_format_t dci_format = NR_DL_DCI_FORMAT_1_0; + if(is_common == 0) + dci_format = UE->current_DL_BWP.dci_format; - NR_SearchSpace__searchSpaceType_PR ss_type = (is_common==0 && (sched_ctrl->active_bwp || ubwpd)) ? NR_SearchSpace__searchSpaceType_PR_ue_Specific: NR_SearchSpace__searchSpaceType_PR_common; uint8_t pdsch_to_harq_feedback[8]; - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - int max_fb_time = 0; - get_pdsch_to_harq_feedback(UE, bwp_id, ss_type, &max_fb_time, pdsch_to_harq_feedback); + get_pdsch_to_harq_feedback(pucch_Config, dci_format, &max_fb_time, pdsch_to_harq_feedback); LOG_D(NR_MAC, "In %s: 1b. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); /* there is a HARQ. Check whether we can use it for this ACKNACK */ @@ -1201,7 +1143,6 @@ int nr_acknack_scheduling(int mod_id, // we cannot reach this timing anymore, allocate and try again const int f = pucch->frame; const int s = pucch->ul_slot; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; LOG_D(NR_MAC, "In %s: %4d.%2d DAI > 0, cannot reach timing for pucch in %4d.%2d, advancing slot by 1 and trying again\n", __FUNCTION__, frame, slot, f, s); if (!(csi_pucch && csi_pucch->csi_bits > 0 && @@ -1362,30 +1303,20 @@ void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) { if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slot / 64], slot)) return; - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + UE_iterator(nrmac->UE_info.list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; if (sched_ctrl->ul_failure==1 || sched_ctrl->rrc_processing_timer>0) continue; - NR_PUCCH_Config_t *pucch_Config = NULL; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (UE->CellGroup && - UE->CellGroup->spCellConfig && - UE->CellGroup->spCellConfig->spCellConfigDedicated && - UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } - else continue; - if (!pucch_Config->schedulingRequestResourceToAddModList) - continue; + NR_PUCCH_Config_t *pucch_Config = ul_bwp->pucch_Config; + + if (!pucch_Config || !pucch_Config->schedulingRequestResourceToAddModList) + continue; AssertFatal(pucch_Config->schedulingRequestResourceToAddModList->list.count>0,"NO SR configuration available"); - for (int SR_resource_id =0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { + for (int SR_resource_id = 0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { NR_SchedulingRequestResourceConfig_t *SchedulingRequestResourceConfig = pucch_Config->schedulingRequestResourceToAddModList->list.array[SR_resource_id]; int SR_period; int SR_offset; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 63defe39629e05586968dd229adbdbef6d66b437..27af724c203d0c2ad0d14e4b31c69488df3b5446 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -36,19 +36,9 @@ #include <openair2/UTIL/OPT/opt.h> #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" -extern void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); //#define SRS_IND_DEBUG -int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl) { - - int dci_format = sched_ctrl->search_space && sched_ctrl->search_space->searchSpaceType && - sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? - NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; - - return(dci_format); -} - const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot) { /* there is a mixed slot only when in TDD */ @@ -816,23 +806,14 @@ void handle_nr_srs_measurements(const module_id_t module_id, } } -long get_K2(NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfigCommonSIB_t *scc_sib1, - NR_BWP_Uplink_t *ubwp, +long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu) { - NR_PUSCH_TimeDomainResourceAllocation_t *tda_list = NULL; - if(ubwp) { - tda_list = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; - } else if(scc) { - tda_list = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; - } else if(scc_sib1) { - tda_list = scc_sib1->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; - } + NR_PUSCH_TimeDomainResourceAllocation_t *tda = tdaList->list.array[time_domain_assignment]; - if (tda_list->k2) - return *tda_list->k2; + if (tda->k2) + return *tda->k2; else if (mu < 2) return 1; else if (mu == 2) @@ -894,40 +875,22 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; - NR_CellGroupConfig_t *cg = UE->CellGroup; - - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - (NR_ServingCellConfigCommon_t *)scc, - sib1); int rbStart = 0; // wrt BWP start - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = UE->current_UL_BWP.BWPSize; const uint8_t nrOfLayers = 1; - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); - LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); + LOG_D(NR_MAC,"tbs %d\n",retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { /* check whether we need to switch the TDA allocation since tha last * (re-)transmission */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; - int dci_format = get_dci_format(sched_ctrl); - if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format - || ps->nrOfLayers != nrOfLayers - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { - nr_set_pusch_semi_static(sib1, + || ps->nrOfLayers != nrOfLayers) { + nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, - dci_format, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ps); } @@ -943,14 +906,9 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, LOG_D(NR_MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); } else { NR_pusch_semi_static_t temp_ps; - int dci_format = get_dci_format(sched_ctrl); - nr_set_pusch_semi_static(sib1, + nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, - dci_format, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, &temp_ps); /* the retransmission will use a different time domain allocation, check @@ -1045,13 +1003,13 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, return true; } -void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_pusch_semi_static_t *ps) -{ +void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_PUSCH_Config_t *pusch_Config, const int mcs_table) { + const int mcs = sched_pusch->mcs; - sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table); - sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table); + sched_pusch->R = nr_get_code_rate_ul(mcs, mcs_table); + sched_pusch->Qm = nr_get_Qm_ul(mcs, mcs_table); - if (ps->pusch_Config && ps->pusch_Config->tp_pi2BPSK && ((ps->mcs_table == 3 && mcs < 2) || (ps->mcs_table == 4 && mcs < 6))) { + if (pusch_Config && pusch_Config->tp_pi2BPSK && ((mcs_table == 3 && mcs < 2) || (mcs_table == 4 && mcs < 6))) { sched_pusch->R >>= 1; sched_pusch->Qm <<= 1; } @@ -1094,18 +1052,11 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %04x\n",UE->rnti); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; int rbStart = 0; // wrt BWP start - NR_CellGroupConfig_t *cg = UE->CellGroup; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = current_BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; const NR_mac_dir_stats_t *stats = &UE->mac_stats.ul; @@ -1192,23 +1143,15 @@ void pf_ul(module_id_t module_id, /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or + * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ const uint8_t nrOfLayers = 1; - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; - int dci_format = get_dci_format(sched_ctrl); const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format - || ps->nrOfLayers != nrOfLayers - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { - nr_set_pusch_semi_static(sib1, + || ps->nrOfLayers != nrOfLayers) { + nr_set_pusch_semi_static(current_BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, - dci_format, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ps); } @@ -1233,7 +1176,7 @@ void pf_ul(module_id_t module_id, NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = min(nrmac->min_grant_mcs, sched_pusch->mcs); - update_ul_ue_R_Qm(sched_pusch, ps); + update_ul_ue_R_Qm(sched_pusch, current_BWP->pusch_Config, current_BWP->mcs_table); sched_pusch->rbStart = rbStart; sched_pusch->rbSize = min_rb; sched_pusch->tb_size = nr_compute_tbs(sched_pusch->Qm, @@ -1256,7 +1199,7 @@ void pf_ul(module_id_t module_id, /* Create UE_sched for UEs eligibale for new data transmission*/ /* Calculate coefficient*/ - const uint32_t tbs = ul_pf_tbs[ps->mcs_table][sched_pusch->mcs]; + const uint32_t tbs = ul_pf_tbs[current_BWP->mcs_table][sched_pusch->mcs]; float coeff_ue = (float) tbs / UE->ul_thr_ue; LOG_D(NR_MAC,"rnti %04x b %d, ul_thr_ue %f, tbs %d, coeff_ue %f\n", UE->rnti, b, UE->ul_thr_ue, tbs, coeff_ue); @@ -1299,44 +1242,29 @@ void pf_ul(module_id_t module_id, } else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, iterator->UE->rnti); - NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated - && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); + NR_UE_UL_BWP_t *current_BWP = &iterator->UE->current_UL_BWP; - int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = current_BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or + * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ const uint8_t nrOfLayers = 1; - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; - int dci_format = get_dci_format(sched_ctrl); const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format - || ps->nrOfLayers != nrOfLayers - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { - nr_set_pusch_semi_static(sib1, + || ps->nrOfLayers != nrOfLayers) { + nr_set_pusch_semi_static(current_BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, - dci_format, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ps); } - update_ul_ue_R_Qm(sched_pusch, ps); + update_ul_ue_R_Qm(sched_pusch, current_BWP->pusch_Config, current_BWP->mcs_table); + int rbStart = 0; const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; @@ -1402,9 +1330,6 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t AssertFatal(scc!=NULL || scc_sib1!=NULL,"We need one serving cell config common\n"); - const int mu = scc ? scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing : - scc_sib1->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; - // no UEs if (nr_mac->UE_info.list[0] == NULL) return false; @@ -1416,14 +1341,16 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * TDAs yet). If the TDA is negative, it means that there is no UL slot to * schedule now (slot + k2 is not UL slot) */ NR_UE_sched_ctrl_t *sched_ctrl = &nr_mac->UE_info.list[0]->UE_sched_ctrl; + NR_UE_UL_BWP_t *current_BWP = &nr_mac->UE_info.list[0]->current_UL_BWP; + int mu = current_BWP->scs; const int temp_tda = get_ul_tda(nr_mac, scc, slot); - int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); + int K2 = get_K2(current_BWP->tdaList, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_slot); if (tda < 0) return false; - DevAssert(K2 == get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, tda, mu)); + DevAssert(K2 == get_K2(current_BWP->tdaList, tda, mu)); if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; @@ -1437,7 +1364,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot); // FIXME: Avoid mixed slots for initialUplinkBWP - if (sched_ctrl->active_ubwp==NULL && is_mixed_slot) + if (current_BWP->bwp_id==0 && is_mixed_slot) return false; // Avoid slots with the SRS @@ -1452,8 +1379,9 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->sched_pusch.frame = sched_frame; UE_iterator(nr_mac->UE_info.list, UE2) { NR_UE_sched_ctrl_t *sched_ctrl = &UE2->UE_sched_ctrl; - AssertFatal(K2 == get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), - "Different K2, %d(UE%d) != %ld(UE%04x)\n", K2, 0, get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), UE2->rnti); + AssertFatal(K2 == get_K2(current_BWP->tdaList, tda, mu), + "Different K2, %d(UE%d) != %ld(UE%04x)\n", + K2, 0, get_K2(current_BWP->tdaList, tda, mu), UE2->rnti); sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; } @@ -1464,24 +1392,10 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); - - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - const uint16_t bwpStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + const uint16_t bwpSize = current_BWP->BWPSize; + const uint16_t bwpStart = current_BWP->BWPStart; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if (sched_ctrl->active_ubwp) { - tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else if (scc) { - tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else { - NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1; - tdaList = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + const int startSymbolAndLength = current_BWP->tdaList->list.array[tda]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); const uint16_t symb = SL_to_bitmap(startSymbolIndex, nrOfSymbols); @@ -1581,10 +1495,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) if (sched_ctrl->ul_failure == 1 && get_softmodem_params()->phy_test==0) continue; NR_CellGroupConfig_t *cg = UE->CellGroup; - - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; UE->mac_stats.ul.current_bytes = 0; @@ -1710,23 +1621,20 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->handle = 0; //not yet used /* FAPI: BWP */ - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); - pusch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pusch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pusch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; + pusch_pdu->bwp_size = current_BWP->BWPSize; + pusch_pdu->bwp_start = current_BWP->BWPStart; + pusch_pdu->subcarrier_spacing = current_BWP->scs; pusch_pdu->cyclic_prefix = 0; /* FAPI: PUSCH information always included */ pusch_pdu->target_code_rate = sched_pusch->R; pusch_pdu->qam_mod_order = sched_pusch->Qm; pusch_pdu->mcs_index = sched_pusch->mcs; - pusch_pdu->mcs_table = ps->mcs_table; - pusch_pdu->transform_precoding = ps->transform_precoding; - if (ps->pusch_Config && ps->pusch_Config->dataScramblingIdentityPUSCH) - pusch_pdu->data_scrambling_id = *ps->pusch_Config->dataScramblingIdentityPUSCH; + pusch_pdu->mcs_table = current_BWP->mcs_table; + pusch_pdu->transform_precoding = current_BWP->transform_precoding; + if (current_BWP->pusch_Config && current_BWP->pusch_Config->dataScramblingIdentityPUSCH) + pusch_pdu->data_scrambling_id = *current_BWP->pusch_Config->dataScramblingIdentityPUSCH; else pusch_pdu->data_scrambling_id = *scc->physCellId; pusch_pdu->nrOfLayers = ps->nrOfLayers; @@ -1762,7 +1670,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->rb_start = sched_pusch->rbStart; pusch_pdu->rb_size = sched_pusch->rbSize; pusch_pdu->vrb_to_prb_mapping = 0; - if (ps->pusch_Config==NULL || ps->pusch_Config->frequencyHopping==NULL) + if (current_BWP->pusch_Config==NULL || current_BWP->pusch_Config->frequencyHopping==NULL) pusch_pdu->frequency_hopping = 0; else pusch_pdu->frequency_hopping = 1; @@ -1796,7 +1704,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) else AssertFatal(1==0,"SequenceGroupHopping or sequenceHopping are NOT Supported\n"); - LOG_D(NR_MAC,"TRANSFORM PRECODING IS ENABLED. CDM groups: %d, U: %d MCS table: %d\n", pusch_pdu->num_dmrs_cdm_grps_no_data, pusch_pdu->dfts_ofdm.low_papr_group_number, ps->mcs_table); + LOG_D(NR_MAC,"TRANSFORM PRECODING IS ENABLED. CDM groups: %d, U: %d MCS table: %d\n", pusch_pdu->num_dmrs_cdm_grps_no_data, pusch_pdu->dfts_ofdm.low_papr_group_number, current_BWP->mcs_table); } /*-----------------------------------------------------------------------------*/ @@ -1820,9 +1728,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* look up the PDCCH PDU for this BWP and CORESET. If it does not exist, * create it */ - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - NR_SearchSpace_t *ss = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->search_space: RC.nrmac[module_id]->sched_ctrlCommon->search_space; - NR_ControlResourceSet_t *coreset = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->coreset: RC.nrmac[module_id]->sched_ctrlCommon->coreset; + NR_SearchSpace_t *ss = sched_ctrl->search_space; + NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = pdcch_pdu_coreset[coresetid]; if (!pdcch_pdu) { @@ -1832,7 +1739,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); + nr_configure_pdcch(pdcch_pdu, coreset, false, &sched_ctrl->sched_pdcch); pdcch_pdu_coreset[coresetid] = pdcch_pdu; } @@ -1857,35 +1764,24 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) dci_pdu_rel15_t uldci_payload; memset(&uldci_payload, 0, sizeof(uldci_payload)); - int n_ubwp=1; - if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { - n_ubwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; - } config_uldci(sib1, - sched_ctrl->active_ubwp, - ubwpd, scc, pusch_pdu, &uldci_payload, - ps->dci_format, ps->time_domain_allocation, UE->UE_sched_ctrl.tpc0, - n_ubwp, - bwp_id); + current_BWP); fill_dci_pdu_rel15(scc, cg, + &UE->current_DL_BWP, dci_pdu, &uldci_payload, - ps->dci_format, + current_BWP->dci_format, rnti_types[0], pusch_pdu->bwp_size, - bwp_id, - coresetid, + current_BWP->bwp_id, + coreset, nr_mac->cset0_bwp_size); memset(sched_pusch, 0, sizeof(*sched_pusch)); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 75902ca60a6f1b892b0c8a975e9ba8ae2ef99ad9..fe5affbf38fd8540cd14eb8cf1e1f085d272e121 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -38,8 +38,6 @@ void set_cset_offset(uint16_t); void mac_top_init_gNB(void); -void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); - void config_common(int Mod_idP, int pdsch_AntennaPorts, int pusch_AntennaPorts, @@ -132,7 +130,6 @@ int nr_allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t slo void nr_get_Msg3alloc(module_id_t module_id, int CC_id, NR_ServingCellConfigCommon_t *scc, - NR_BWP_Uplink_t *ubwp, sub_frame_t current_subframe, frame_t current_frame, NR_RA_t *ra, @@ -190,16 +187,12 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, void config_uldci(const NR_SIB1_t *sib1, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, - int dci_format, int time_domain_assignment, uint8_t tpc, - int n_ubwp, - int bwp_id); + NR_UE_UL_BWP_t *ul_bwp); void nr_schedule_pucch(gNB_MAC_INST *nrmac, frame_t frameP, @@ -223,9 +216,8 @@ int nr_acknack_scheduling(int Mod_idP, int r_pucch, int do_common); -void get_pdsch_to_harq_feedback(NR_UE_info_t *, - int bwp_id, - NR_SearchSpace__searchSpaceType_PR ss_type, +void get_pdsch_to_harq_feedback(NR_PUCCH_Config_t *pucch_Config, + nr_dci_format_t dci_format, int *max_fb_time, uint8_t *pdsch_to_harq_feedback); @@ -249,17 +241,12 @@ int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space, */ int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, - NR_BWP_Uplink_t *bwp, - NR_BWP_UplinkDedicated_t *bwpd, + NR_PUCCH_Config_t *pucch_Config, int CCEIndex); -void nr_configure_pucch(const NR_SIB1_t *sib1, - nfapi_nr_pucch_pdu_t* pucch_pdu, +void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, - NR_CellGroupConfig_t *CellGroup, - NR_BWP_Uplink_t *bwp, - NR_BWP_UplinkDedicated_t *bwpd, - uint16_t rnti, + NR_UE_info_t* UE, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, @@ -272,7 +259,7 @@ void find_search_space(int ss_type, void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_ControlResourceSet_t *coreset, - NR_BWP_t *bwp, + bool is_sib1, NR_sched_pdcch_t *pdcch); NR_sched_pdcch_t set_pdcch_structure(gNB_MAC_INST *gNB_mac, @@ -298,19 +285,21 @@ void fill_pdcch_vrb_map(gNB_MAC_INST *mac, void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *CellGroup, + const NR_UE_DL_BWP_t *dl_bwp, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_formats, int rnti_types, int N_RB, int bwp_id, - NR_ControlResourceSetId_t coreset_id, + NR_ControlResourceSet_t *coreset, uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, + const NR_UE_DL_BWP_t *dl_bwp, + const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, - nr_dci_format_t format, - int bwp_id); + nr_dci_format_t format); void set_r_pucch_parms(int rsetindex, int r_pucch, @@ -320,18 +309,6 @@ void set_r_pucch_parms(int rsetindex, int *nr_of_symbols, int *start_symbol_index); -NR_BWP_t *get_dl_bwp_genericParameters(NR_BWP_Downlink_t *active_bwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1); - -NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1); - -NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, - const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1); - /* find coreset within the search space */ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, @@ -340,34 +317,24 @@ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_SearchSpace__searchSpaceType_PR ss_type); /* find a search space within a BWP */ -NR_SearchSpace_t *get_searchspace(const NR_SIB1_t *sib1, - NR_ServingCellConfigCommon_t *scc, +NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_SearchSpace__searchSpaceType_PR target_ss); -long get_K2(NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfigCommonSIB_t *scc_sib1, - NR_BWP_Uplink_t *ubwp, +long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu); -void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *dl_bwp, const NR_ServingCellConfigCommon_t *scc, - const NR_CellGroupConfig_t *secondaryCellGroup, - const NR_BWP_Downlink_t *bwp, - const NR_BWP_DownlinkDedicated_t *bwpd0, int tda, uint8_t layers, NR_UE_sched_ctrl_t *sched_ctrl, NR_pdsch_semi_static_t *ps); -void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *ul_bwp, const NR_ServingCellConfigCommon_t *scc, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, - long dci_format, int tda, - uint8_t num_dmrs_cdm_grps_no_data, uint8_t nrOfLayers, NR_pusch_semi_static_t *ps); @@ -402,7 +369,13 @@ NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP); int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); -NR_UE_info_t*add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); +void configure_UE_BWP(gNB_MAC_INST *nr_mac, + NR_ServingCellConfigCommon_t *scc, + NR_UE_sched_ctrl_t *sched_ctrl, + NR_RA_t *ra, + NR_UE_info_t *UE); + +NR_UE_info_t* add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti); @@ -499,7 +472,6 @@ uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx); uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); -int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl); const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 3ec0de57e48bb9a763f543e1514d9760642a7fc5..67da0035bff3bae64ef6aac0425ca443f039d976 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -90,6 +90,37 @@ typedef struct { int len; } NR_list_t; +typedef struct NR_UE_DL_BWP { + NR_BWP_Id_t bwp_id; + int n_dl_bwp; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PDSCH_Config_t *pdsch_Config; + NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig; + uint8_t mcsTableIdx; + nr_dci_format_t dci_format; +} NR_UE_DL_BWP_t; + +typedef struct NR_UE_UL_BWP { + NR_BWP_Id_t bwp_id; + int n_ul_bwp; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PUSCH_Config_t *pusch_Config; + NR_PUCCH_Config_t *pucch_Config; + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; + NR_CSI_MeasConfig_t *csi_MeasConfig; + NR_SRS_Config_t *srs_Config; + uint8_t transform_precoding; + uint8_t mcs_table; + nr_dci_format_t dci_format; +} NR_UE_UL_BWP_t; typedef enum { RA_IDLE = 0, @@ -123,10 +154,6 @@ typedef struct NR_sched_pdcch { typedef struct { /// Flag to indicate this process is active RA_gNB_state_t state; - /// DL BWP id of RA process - int dl_bwp_id; - /// UL BWP id of RA process - int ul_bwp_id; /// CORESET0 configured flag int coreset0_configured; /// Slot where preamble was received @@ -198,6 +225,9 @@ typedef struct { rnti_t crnti; /// CFRA flag bool cfra; + // BWP for RA + NR_UE_DL_BWP_t DL_BWP; + NR_UE_UL_BWP_t UL_BWP; } NR_RA_t; /*! \brief gNB common channels */ @@ -345,18 +375,11 @@ typedef struct NR_sched_pucch { * recalculate all S/L, MCS table, or DMRS-related parameters over and over * again. Hence, we store them in this struct for easy reference. */ typedef struct NR_pusch_semi_static_t { - int dci_format; int time_domain_allocation; uint8_t nrOfLayers; uint8_t num_dmrs_cdm_grps_no_data; - int startSymbolIndex; int nrOfSymbols; - - NR_PUSCH_Config_t *pusch_Config; - uint8_t transform_precoding; - uint8_t mcs_table; - long mapping_type; NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig; uint16_t dmrs_config_type; @@ -408,7 +431,6 @@ typedef struct NR_pdsch_semi_static { int startSymbolIndex; int nrOfSymbols; uint8_t nrOfLayers; - uint8_t mcsTableIdx; uint8_t dmrs_ports_id; uint8_t N_PRB_DMRS; uint8_t N_DMRS_SLOT; @@ -534,11 +556,6 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ #define MAX_CSI_REPORTS 48 typedef struct { - /// the currently active BWP in DL - NR_BWP_Downlink_t *active_bwp; - /// the currently active BWP in UL - NR_BWP_Uplink_t *active_ubwp; - /// the next active BWP ID in DL NR_BWP_Id_t next_dl_bwp_id; /// the next active BWP ID in UL @@ -553,8 +570,6 @@ typedef struct { /// corresponding to the sched_pusch/sched_pdsch structures below int cce_index; uint8_t aggregation_level; - /// maximum aggregation level for UE, can be used to select level - int maxL; /// PUCCH scheduling information. Array of two: HARQ+SR in the first field, /// CSI in second. This order is important for nr_acknack_scheduling()! NR_sched_pucch_t sched_pucch[2]; @@ -676,12 +691,12 @@ typedef struct { /// scheduling control info nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; NR_UE_sched_ctrl_t UE_sched_ctrl; + NR_UE_DL_BWP_t current_DL_BWP; + NR_UE_UL_BWP_t current_UL_BWP; NR_mac_stats_t mac_stats; NR_CellGroupConfig_t *CellGroup; char cg_buf[32768]; /* arbitrary size */ asn_enc_rval_t enc_rval; - /// CCE indexing - int m; // UE selected beam index uint8_t UE_beam_index; bool Msg3_dcch_dtch; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 687784cafc82229b996d6beaa7b52ec6f57c33b0..3dadeda2ae46df572f780c7ab38473570ac6be30 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -306,10 +306,10 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { return((enc_rval.encoded+7)/8); } -uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *configuration) { +uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, + gNB_RrcConfigurationReq *configuration) { asn_enc_rval_t enc_rval; - NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); carrier->siblock1 = sib1_message; sib1_message->message.present = NR_BCCH_DL_SCH_MessageType_PR_c1;