From 999f5d67e336be2af2e8a0d2c8262145549db619 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 4 May 2022 11:03:26 +0200 Subject: [PATCH] bugfixes and improvements in handling dci candidates --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 1 - openair1/SIMULATION/NR_PHY/dlsim.c | 2 -- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 13 +++++++++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 ++ openair2/LAYER2/NR_MAC_UE/config_ue.c | 3 +- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 1 - openair2/LAYER2/NR_MAC_UE/mac_proto.h | 7 ++--- .../NR_MAC_UE/nr_ue_dci_configuration.c | 28 ++++++++++++++----- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 4 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 -- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 -- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 -- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 27 ++---------------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 -- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- openair2/RRC/NR/rrc_gNB_reconfig.c | 2 +- 16 files changed, 47 insertions(+), 53 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index ba7e539429..22556747d3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -82,7 +82,6 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, int rb_offset; int n_rb; - // compute rb_offset and n_prb based on frequency allocation nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL]; nr_fill_cce_list(cce_list,0,pdcch_pdu_rel15); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 1de8d6ced4..f39629e592 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -1100,8 +1100,6 @@ int main(int argc, char **argv) UE_info->UE_sched_ctrl[0].harq_processes[harq_pid].round = round; - for (int i=0; ipdcch_cand[i] = 0; if (css_flag == 0) { nr_schedule_ue_spec(0, frame, slot); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index b25efbb5d8..edbf35ae6a 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3467,6 +3467,19 @@ void csi_period_offset(NR_CSI_ReportConfig_t *csirep, } } +uint16_t get_Y(int cid, int slot, rnti_t rnti) { + + const int A[3] = {39827, 39829, 39839}; + const int D = 65537; + int Y; + + Y = (A[cid] * rnti) % D; + + for (int s = 0; s < slot; s++) + Y = (A[cid] * Y) % D; + + return Y; +} void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, frame_t frameP, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 0f2cb42b88..0ea9cebb75 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -37,6 +37,8 @@ #include "nr_mac.h" #include "openair1/PHY/impl_defs_nr.h" +uint16_t get_Y(int cid, int slot, rnti_t rnti); + uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 3b10167e03..9603871232 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -474,7 +474,7 @@ void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format */ void config_control_ue(NR_UE_MAC_INST_t *mac){ - uint8_t coreset_id = 1, ss_id; + uint8_t ss_id; NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; @@ -520,6 +520,7 @@ void config_control_ue(NR_UE_MAC_INST_t *mac){ } // check pdcch_Config, pdcch_ConfigCommon and DL BWP mac->DLbwp[0] = dl_bwp_id>0?scd->downlinkBWP_ToAddModList->list.array[dl_bwp_id - 1]:NULL; + int coreset_id = controlResourceSetToAddModList->list.array[0]->controlResourceSetId; mac->coreset[dl_bwp_id][coreset_id - 1] = controlResourceSetToAddModList->list.array[0]; // Check dedicated UL BWP and pass to MAC diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index fc2c2d2c8b..ddb2012715 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -558,7 +558,6 @@ typedef struct ssb_list_info { } ssb_list_info_t; void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 7ed99b92b5..8586e81e7e 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -243,10 +243,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, uint16_t *crnti, NR_BSR_SHORT *truncated_bsr, NR_BSR_SHORT *short_bsr, - NR_BSR_LONG *long_bsr - ); - -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); + NR_BSR_LONG *long_bsr); void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); @@ -446,7 +443,7 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p uint16_t riv); void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); +void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, int slot, int rnti); void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 0ee6f5501c..586a4dc60f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -49,7 +49,9 @@ //#define DEBUG_DCI -void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { +void fill_dci_search_candidates(NR_SearchSpace_t *ss, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + int slot, int rnti) { LOG_D(NR_MAC,"Filling search candidates for DCI\n"); @@ -57,6 +59,9 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd uint8_t number_of_candidates=0; rel15->number_of_candidates=0; int i=0; + int Y = 0; + if (slot >= 0) + Y = get_Y(*ss->controlResourceSetId, slot, rnti); for (int maxL=16;maxL>0;maxL>>=1) { find_aggregation_candidates(&aggregation, &number_of_candidates, @@ -65,8 +70,17 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd if (number_of_candidates>0) { LOG_D(NR_MAC,"L %d, number of candidates %d, aggregation %d\n",maxL,number_of_candidates,aggregation); rel15->number_of_candidates += number_of_candidates; + int N_cce_sym = 0; // nb of rbs of coreset per symbol + for (int i=0;i<6;i++) { + for (int t=0;t<8;t++) { + N_cce_sym+=((rel15->coreset.frequency_domain_resource[i]>>t)&1); + } + } + int N_cces = N_cce_sym*rel15->coreset.duration; for (int j=0; jCCE[i] = j*aggregation; + int first_cce = aggregation * (( Y + CEILIDIV((j*N_cces),(aggregation*number_of_candidates)) + 0 ) % CEILIDIV(N_cces,aggregation)); + LOG_D(NR_MAC,"Candidate %d of %d first_cce %d (L %d N_cces %d Y %d)\n", j, number_of_candidates, first_cce, aggregation, N_cces, Y); + rel15->CCE[i] = first_cce; rel15->L[i] = aggregation; } } @@ -308,14 +322,14 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl } else { config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id); } - fill_dci_search_candidates(ss, rel15); + fill_dci_search_candidates(ss, rel15, -1, -1); break; case WAIT_CONTENTION_RESOLUTION: LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg4)\n"); rel15->num_dci_options = 1; rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_TC, -1); - fill_dci_search_candidates(ss, rel15); + fill_dci_search_candidates(ss, rel15, -1, -1); break; default: break; @@ -387,7 +401,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); - fill_dci_search_candidates(ss, rel15); + fill_dci_search_candidates(ss, rel15, slot, mac->crnti); //#ifdef DEBUG_DCI LOG_D(NR_MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", @@ -439,7 +453,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl rel15->num_dci_options = 1; rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1); - fill_dci_search_candidates(ss0, rel15); + fill_dci_search_candidates(ss0, rel15, -1, -1); } } } @@ -450,7 +464,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl rel15->num_dci_options = 1; rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C , -1); - fill_dci_search_candidates(ss0, rel15); + fill_dci_search_candidates(ss0, rel15, -1, -1); dl_config->number_pdus = 1; } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 8f61d66333..fd33c1aaec 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1087,7 +1087,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in if (mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; // msg3 retransmission config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , mac->ra.ss->searchSpaceId); - fill_dci_search_candidates(mac->ra.ss, rel15); + fill_dci_search_candidates(mac->ra.ss, rel15, -1 , -1); dl_config->number_pdus = 1; LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->thread_id, dl_info->phy_data); @@ -2750,7 +2750,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, rel15->num_dci_options = 1; rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1); - fill_dci_search_candidates(mac->search_space_zero, rel15); + fill_dci_search_candidates(mac->search_space_zero, rel15, -1, -1); if(mac->type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern == 1){ // same frame as ssb diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 540198a22a..379752e6d8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -307,8 +307,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_rrc_trigger(&ctxt, 0 /*CC_id*/, frame, slot >> *scc->ssbSubcarrierSpacing); } - for (int i=0; ipdcch_cand[i] = 0; for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { //mbsfn_status[CC_id] = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 5aace1d0dc..336ada079e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -680,7 +680,6 @@ bool allocate_dl_retransmission(module_id_t module_id, UE_info->rnti[UE_id], frame, slot); - RC.nrmac[module_id]->pdcch_cand[cid]--; return false; } @@ -871,7 +870,6 @@ void pf_dl(module_id_t module_id, rnti, frame, slot); - mac->pdcch_cand[cid]--; continue; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 338fc7dcd5..c41a001d17 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -367,7 +367,6 @@ void nr_preprocessor_phytest(module_id_t module_id, rnti, frame, slot); - RC.nrmac[module_id]->pdcch_cand[cid]--; return; } @@ -522,7 +521,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ if (CCEIndex < 0) { LOG_E(MAC, "%s(): CCE list not empty, couldn't schedule PUSCH\n", __func__); - nr_mac->pdcch_cand[cid]--; return false; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 6f17556c91..f3b5ec1cf1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -443,14 +443,8 @@ int find_pdcch_candidate(gNB_MAC_INST *mac, uint16_t Y){ uint16_t *vrb_map = mac->common_channels[cc_id].vrb_map; - const int next_cand = mac->pdcch_cand[coreset->controlResourceSetId]; const int N_ci = 0; - if(next_cand>=nr_of_candidates) { - LOG_D(NR_MAC,"No more available candidates for this coreset\n"); - return -1; - } - const int N_rb = pdcch->n_rb; // nb of rbs of coreset per symbol const int N_symb = coreset->duration; // nb of coreset symbols const int N_regs = N_rb*N_symb; // nb of REGs per coreset @@ -462,9 +456,10 @@ int find_pdcch_candidate(gNB_MAC_INST *mac, // loop over all the available candidates // this implements TS 38.211 Sec. 7.3.2.2 - for(int m=next_cand; mShiftIndex, C, L, N_regs); @@ -476,10 +471,8 @@ int find_pdcch_candidate(gNB_MAC_INST *mac, } } } - if(!taken){ - mac->pdcch_cand[coreset->controlResourceSetId] = m++; // using candidate m, next available is m+1 + if(!taken) return first_cce; - } } return -1; } @@ -2204,20 +2197,6 @@ int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP) return -1; } -uint16_t get_Y(int cid, int slot, rnti_t rnti) { - - const int A[3] = {39827, 39829, 39839}; - const int D = 65537; - int Y; - - Y = (A[cid] * rnti) % D; - - for (int s = 0; s < slot; s++) - Y = (A[cid] * Y) % D; - - return Y; -} - int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP) { //------------------------------------------------------------------------------ int RA_id; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 399033abd0..5f8fc540e8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -359,8 +359,6 @@ void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, uint8_t num_dmrs_cdm_grps_no_data, NR_pusch_semi_static_t *ps); -uint16_t get_Y(int cid, int slot, rnti_t rnti); - uint8_t nr_get_tpc(int target, uint8_t cqi, int incr); int get_spf(nfapi_nr_config_request_scf_t *cfg); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 0f538131dd..dc90b820f6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -755,7 +755,7 @@ typedef struct gNB_MAC_INST_s { nfapi_nr_ul_dci_request_t UL_dci_req[NFAPI_CC_MAX]; /// NFAPI DL PDU structure nfapi_nr_tx_data_request_t TX_req[NFAPI_CC_MAX]; - int pdcch_cand[MAX_NUM_CORESET]; + NR_UE_info_t UE_info; /// UL handle diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 0349f5004a..cb66a3cf72 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -466,7 +466,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco ss2->searchSpaceId=2; ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId)); - *ss2->controlResourceSetId=1; + *ss2->controlResourceSetId=coreset->controlResourceSetId; ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset)); ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1; ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0;