From b9ae5db874bf591a9102ab6ff98acd277a2ffb35 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 25 Feb 2022 12:09:42 +0100 Subject: [PATCH] gold init improvement at ue for dl channels --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 3 +- openair1/PHY/NR_REFSIG/nr_gold_ue.c | 31 +++++------ openair1/PHY/NR_REFSIG/refsig_defs_ue.h | 3 +- .../nr_dl_channel_estimation.c | 22 ++++---- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 3 ++ .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 9 ++-- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 2 + openair1/PHY/defs_nr_UE.h | 2 +- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 + openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 3 ++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 51 ++++++++++++++----- 11 files changed, 82 insertions(+), 49 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 3b429a5e84..ce43e23c15 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -464,7 +464,8 @@ typedef struct { uint8_t nEpreRatioOfPDSCHToPTRS; /// MCS table for this DLSCH uint8_t mcs_table; - + uint8_t nscid; + uint16_t dlDmrsScramblingId; uint16_t pduBitmap; } fapi_nr_dl_config_dlsch_pdu_rel15_t; diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index 623b86edfb..6c48cf1b73 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -75,33 +75,28 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue, } void nr_gold_pdsch(PHY_VARS_NR_UE* ue, - unsigned short *n_idDMRS) + int nscid, + uint32_t nid) { - unsigned char l; - unsigned int n,x1,x2,x2tmp0,ns; - int nscid; - unsigned int nid; + + unsigned int x1,x2,x2tmp0; uint8_t reset; /// to be updated from higher layer //unsigned short lbar = 0; - for (nscid=0; nscid<2; nscid++) { - for (ns=0; nsframe_parms.slots_per_frame; ns++) { + for (int ns=0; nsframe_parms.slots_per_frame; ns++) { - nid = n_idDMRS[nscid]; + for (int l=0; lframe_parms.symbols_per_slot; l++) { - for (l=0; lframe_parms.symbols_per_slot; l++) { + reset = 1; + x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; + x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31); //cinit + LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid); - reset = 1; - x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; - x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31); //cinit - LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid); - - for (n=0; nnr_gold_pdsch[0][ns][l][nscid][n] = lte_gold_generic(&x1, &x2, reset); - reset = 0; - } + for (int n=0; nnr_gold_pdsch[0][ns][l][nscid][n] = lte_gold_generic(&x1, &x2, reset); + reset = 0; } } } diff --git a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h index 1fca2be2a1..db0cb674f7 100644 --- a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h +++ b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h @@ -61,7 +61,8 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue, unsigned short n_idDMRS); void nr_gold_pdsch(PHY_VARS_NR_UE* ue, - unsigned short *n_idDMRS); + int nscid, + uint32_t nid); void nr_init_pusch_dmrs(PHY_VARS_NR_UE* ue, uint16_t *N_n_scid, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 30eae2d30f..2387ae35ea 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -466,6 +466,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t gNB_id, unsigned char Ns, unsigned char symbol, + unsigned short scrambling_id, unsigned short coreset_start_subcarrier, unsigned short nb_rb_coreset) { @@ -493,13 +494,11 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, fm = filt16a_m1; fr = filt16a_r1; - // checking if re-initialization of scrambling IDs is needed (should be done here but scrambling ID for PDCCH is not taken from RRC) -/* if (( != ue->scramblingID_pdcch){ - ue->scramblingID_pdcch=; - nr_gold_pdsch(ue,ue->scramblingID_pdcch); - }*/ - + if (scrambling_id != ue->scramblingID_pdcch){ + ue->scramblingID_pdcch = scrambling_id; + nr_gold_pdcch(ue,ue->scramblingID_pdcch); + } // generate pilot int pilot[nb_rb_coreset * 3] __attribute__((aligned(16))); @@ -641,6 +640,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned char Ns, unsigned short p, unsigned char symbol, + unsigned char nscid, + unsigned short scrambling_id, unsigned short BWPStart, unsigned short bwp_start_subcarrier, unsigned short nb_rb_pdsch) @@ -682,11 +683,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, int8_t delta = get_delta(p, config_type); // checking if re-initialization of scrambling IDs is needed - /*if ((XXX.scramblingID0 != ue->scramblingID[0]) || (XXX.scramblingID1 != ue->scramblingID[1])){ - ue->scramblingID[0] = XXX.scramblingID0; - ue->scramblingID[1] = XXX.scramblingID1; - nr_gold_pdsch(ue,ue->scramblingID); - }*/ + if (scrambling_id != ue->scramblingID_dlsch[nscid]){ + ue->scramblingID_dlsch[nscid] = scrambling_id; + nr_gold_pdsch(ue, nscid, scrambling_id); + } nr_pdsch_dmrs_rx(ue, Ns, ue->nr_gold_pdsch[gNB_id][Ns][symbol][0], &pilot[0], 1000+p, 0, nb_rb_pdsch+rb_offset, config_type); diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index c5330ce2f2..06394eb029 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -44,6 +44,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint8_t gNB_id, unsigned char Ns, unsigned char symbol, + unsigned short scrambling_id, unsigned short coreset_start_subcarrier, unsigned short nb_rb_coreset); @@ -71,6 +72,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, unsigned char Ns, unsigned short p, unsigned char symbol, + unsigned char nscid, + unsigned short scrambling_id, unsigned short BWPStart, unsigned short bwp_start_subcarrier, unsigned short nb_rb_pdsch); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 203be1bd24..dd7a2144e0 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -310,10 +310,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, nr_gold_pdcch(ue,fp->Nid_cell); // compute the scrambling IDs for PDSCH DMRS - for (int i=0; i<2; i++) - ue->scramblingID[i]=fp->Nid_cell; - - nr_gold_pdsch(ue,ue->scramblingID); + for (int i=0; i<2; i++) { + ue->scramblingID_dlsch[i]=fp->Nid_cell; + nr_gold_pdsch(ue, i, ue->scramblingID_dlsch[i]); + } // initialize the pusch dmrs uint16_t N_n_scid[2] = {fp->Nid_cell,fp->Nid_cell}; @@ -509,6 +509,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, 0, pdcch_vars->slot, l, + fp->Nid_cell, fp->first_carrier_offset+(pdcch_vars->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12, coreset_nb_rb); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 9b9f1add6e..0cd2f33b0c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -303,6 +303,8 @@ typedef struct { uint16_t ptrs_symbols; // PTRS symbol index, to be updated every PTRS symbol within a slot. uint8_t ptrs_symbol_index; + uint8_t nscid; + uint16_t dlDmrsScramblingId; /// PDU BITMAP uint16_t pduBitmap; } NR_DL_UE_HARQ_t; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index bca956bf75..b0568ebff5 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -859,7 +859,7 @@ typedef struct { uint32_t ****nr_gold_pdsch[NUMBER_OF_CONNECTED_eNB_MAX]; // Scrambling IDs used in PDSCH DMRS - uint16_t scramblingID[2]; + uint16_t scramblingID_dlsch[2]; /// PDCCH DMRS uint32_t ***nr_gold_pdcch[NUMBER_OF_CONNECTED_eNB_MAX]; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 4f4757ec5a..2326b3518a 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -286,6 +286,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ dlsch0_harq->n_dmrs_cdm_groups = dlsch_config_pdu->n_dmrs_cdm_groups; dlsch0_harq->mcs = dlsch_config_pdu->mcs; dlsch0_harq->rvidx = dlsch_config_pdu->rv; + dlsch0_harq->nscid = dlsch_config_pdu->nscid; + dlsch0_harq->dlDmrsScramblingId = dlsch_config_pdu->dlDmrsScramblingId; dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; //get nrOfLayers from DCI info uint8_t Nl = 0; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 97a7e2e489..d35fbf3b97 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -574,6 +574,8 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ nr_slot_rx, aatx /*p*/, m, + dlsch0_harq->nscid, + dlsch0_harq->dlDmrsScramblingId, BWPStart, ue->frame_parms.first_carrier_offset+(BWPStart + pdsch_start_rb)*12, pdsch_nb_rb); @@ -1470,6 +1472,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, gNB_id, nr_slot_rx, l, + pdcch_vars->pdcch_config[n_ss].coreset.pdcch_dmrs_scrambling_id, fp->first_carrier_offset+(pdcch_vars->pdcch_config[n_ss].BWPStart + coreset_start_rb)*12, coreset_nb_rb); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 85bb10290a..d0f5c38d66 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -281,7 +281,6 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){ LOG_D(MAC, "In %s: returning rnti_type %s \n", __FUNCTION__, rnti_types[rnti_type]); return rnti_type; - } @@ -866,6 +865,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } int mappingtype = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType : ((dlsch_config_pdu_1_0->start_symbol <= 3)? typeA: typeB); + struct NR_DMRS_DownlinkConfig *dl_dmrs_config = (mappingtype == typeA) ? + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + + dlsch_config_pdu_1_0->nscid = 0; + if(mac->DLbwp[0] && dl_dmrs_config->scramblingID0) + dlsch_config_pdu_1_0->dlDmrsScramblingId = *dl_dmrs_config->scramblingID0; + else + dlsch_config_pdu_1_0->dlDmrsScramblingId = mac->physCellId; + /* dmrs symbol positions*/ dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, (get_softmodem_params()->nsa) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position, @@ -873,7 +882,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_0->start_symbol, mappingtype); dlsch_config_pdu_1_0->dmrsConfigType = (mac->DLbwp[0] != NULL) ? - (mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; + (dl_dmrs_config->dmrs_Type == NULL ? 0 : 1) : 0; /* number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214 version 15.9.0 Release 15 */ if (dlsch_config_pdu_1_0->number_symbols == 2) dlsch_config_pdu_1_0->n_dmrs_cdm_groups = 1; @@ -1062,6 +1071,29 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr int mappingtype = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType : ((dlsch_config_pdu_1_1->start_symbol <= 3)? typeA: typeB); + struct NR_DMRS_DownlinkConfig *dl_dmrs_config = (mappingtype == typeA) ? + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + + switch (dci->dmrs_sequence_initialization.val) { + case 0: + dlsch_config_pdu_1_1->nscid = 0; + if(dl_dmrs_config->scramblingID0) + dlsch_config_pdu_1_1->dlDmrsScramblingId = *dl_dmrs_config->scramblingID0; + else + dlsch_config_pdu_1_1->dlDmrsScramblingId = mac->physCellId; + break; + case 1: + dlsch_config_pdu_1_1->nscid = 1; + if(dl_dmrs_config->scramblingID1) + dlsch_config_pdu_1_1->dlDmrsScramblingId = *dl_dmrs_config->scramblingID1; + else + dlsch_config_pdu_1_1->dlDmrsScramblingId = mac->physCellId; + break; + default: + AssertFatal(1==0,"Invalid dmrs sequence initialization value\n"); + } + /* dmrs symbol positions*/ dlsch_config_pdu_1_1->dlDmrsSymbPos = fill_dmrs_mask(pdsch_Config, mac->scc? mac->scc->dmrs_TypeA_Position:mac->mib->dmrs_TypeA_Position, @@ -1069,7 +1101,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_1->start_symbol, mappingtype); - dlsch_config_pdu_1_1->dmrsConfigType = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? NFAPI_NR_DMRS_TYPE1 : NFAPI_NR_DMRS_TYPE2; + dlsch_config_pdu_1_1->dmrsConfigType = dl_dmrs_config->dmrs_Type == NULL ? NFAPI_NR_DMRS_TYPE1 : NFAPI_NR_DMRS_TYPE2; /* TODO: fix number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214, using tables 7.3.1.2.2-1, 7.3.1.2.2-2, 7.3.1.2.2-3, 7.3.1.2.2-4 of 3GPP TS 38.212 */ @@ -1130,16 +1162,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* ANTENNA_PORTS */ uint8_t n_codewords = 1; // FIXME!!! - long *max_length = NULL; - long *dmrs_type = NULL; - if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA) { - max_length = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength; - dmrs_type = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type; - } - if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB) { - max_length = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->maxLength; - dmrs_type = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type; - } + long *max_length = dl_dmrs_config->maxLength; + long *dmrs_type = dl_dmrs_config->dmrs_Type; + if ((dmrs_type == NULL) && (max_length == NULL)){ // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1 dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_1[dci->antenna_ports.val][0];