From 2be7cc59bfbb5119b7ff4a7a4ecb0f94a6ad659b Mon Sep 17 00:00:00 2001 From: "kn.raju" Date: Tue, 18 Aug 2020 19:26:07 +0530 Subject: [PATCH] Addition of multi-user rach --- openair1/PHY/NR_TRANSPORT/nr_prach.c | 19 ++-------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 33 +++++++++------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 18 ++++----- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 3 +- openair2/RRC/NR/rrc_gNB_reconfig.c | 38 ++++++++++++++++--- 6 files changed, 68 insertions(+), 45 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index aee0eac1ff..dcf7aab89a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -65,13 +65,11 @@ int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame, int slot, find_type_t type) { if((type == SEARCH_EXIST_OR_FREE) && (gNB->prach_vars.list[i].frame == -1) && (gNB->prach_vars.list[i].slot == -1)) { - LOG_I(PHY, "Providing free prach index %d\n",i); return i; } else if ((type == SEARCH_EXIST) && (gNB->prach_vars.list[i].frame == frame) && (gNB->prach_vars.list[i].slot == slot)) { - LOG_I(PHY, "Providing existing prach index %d\n",i); return i; } } @@ -113,14 +111,12 @@ int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type) { if((type == SEARCH_EXIST_OR_FREE) && (ru->prach_list[i].frame == -1) && (ru->prach_list[i].slot == -1)) { - LOG_I(PHY, "Providing free prach index %d in ru\n",i); pthread_mutex_unlock(&ru->prach_list_mutex); return i; } else if ((type == SEARCH_EXIST) && (ru->prach_list[i].frame == frame) && (ru->prach_list[i].slot == slot)) { - LOG_I(PHY, "Providing existing prach index %d in ru\n",i); pthread_mutex_unlock(&ru->prach_list_mutex); return i; } @@ -184,7 +180,6 @@ void rx_nr_prach_ru(RU_t *ru, for (int aa=0; aanb_rx; aa++){ if (prach_sequence_length == 0) slot2=(slot/fp->slots_per_subframe)*fp->slots_per_subframe; prach[aa] = (int16_t*)&ru->common.rxdata[aa][(slot2*fp->get_samples_per_slot(slot,fp))-ru->N_TA_offset]; - LOG_I(PHY,"GES printing received signal %d\n",*prach[aa]); } @@ -290,8 +285,6 @@ void rx_nr_prach_ru(RU_t *ru, k*=K; k+=kbar; - LOG_I(PHY,"GES printing frequency domain k value %d fp->N_RB_UL %d n_ra_prb %d kbar %d\n",k,fp->N_RB_UL,n_ra_prb,kbar); - int reps=1; for (int aa=0; aanb_rx; aa++) { @@ -360,7 +353,6 @@ void rx_nr_prach_ru(RU_t *ru, } else { // threequarter sampling // 40 MHz @ 46.08 Ms/s prach2 = prach[aa] + (3*Ncp); // 46.08 is 1.5 * 30.72, times 2 for I/Q - LOG_I(PHY,"GES printing prach2 %p prach[aa] %p Ncp %d\n",prach2,prach[aa],Ncp); if (prach_sequence_length == 0) { AssertFatal(fp->N_RB_UL <= 107,"cannot do 108..136 PRBs with 3/4 sampling\n"); if (prachFormat == 0 || prachFormat == 1 || prachFormat == 2) { @@ -540,7 +532,6 @@ void rx_nr_prach_ru(RU_t *ru, if (k2==(dftlen<<1)) k2=0; rxsigF_tmp[j] = rxsigF2[k2]; for (int i=1;i60) LOG_D(PHY,"frame %d, subframe %d : Trying preamble %d \n",frame,subframe,preamble_index); } @@ -719,14 +709,13 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, } // Compute DFT of RX signal (conjugate input, results in conjugate output) for each new rootSequenceIndex -// if (LOG_DEBUGFLAG(PRACH)) { - if(1) { + if (LOG_DEBUGFLAG(PRACH)) { int en = dB_fixed(signal_energy((int32_t*)&rxsigF[0][0],840)); if (en>60) LOG_I(PHY,"frame %d, subframe %d : preamble index %d, NCS %d, N_ZC/NCS %d: offset %d, preamble shift %d , en %d)\n", frame,subframe,preamble_index,NCS,N_ZC/NCS,preamble_offset,preamble_shift,en); } - LOG_I(PHY,"PRACH RX preamble_index %d, preamble_offset %d\n",preamble_index,preamble_offset); + LOG_D(PHY,"PRACH RX preamble_index %d, preamble_offset %d\n",preamble_index,preamble_offset); if (new_dft == 1) { @@ -734,7 +723,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, Xu=(int16_t*)gNB->X_u[preamble_offset-first_nonzero_root_idx]; - LOG_I(PHY,"PRACH RX new dft preamble_offset-first_nonzero_root_idx %d\n",preamble_offset-first_nonzero_root_idx); + LOG_D(PHY,"PRACH RX new dft preamble_offset-first_nonzero_root_idx %d\n",preamble_offset-first_nonzero_root_idx); memset(prach_ifft,0,((N_ZC==839) ? 2048 : 256)*sizeof(int32_t)); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 0b7c1de3ea..2960c36a04 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -442,7 +442,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, */ // This schedules MIB - + if((slot_txP == 0) && (frame_txP & 7) == 0) schedule_nr_mib(module_idP, frame_txP, slot_txP); if (get_softmodem_params()->phy_test == 0) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 173fdf7db6..be3e569480 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -373,12 +373,8 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, // computing start of next period uint8_t start_next_period = (rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot)%nr_slots_per_frame_mac[mu]; - //scheduling msg2 based on identified active SSB from RO - for(int i = 0;i <= last_dl_slot_period;i++) { - if (index == ( (start_next_period + i ) % num_active_ssb )) - *msg2_slot = start_next_period + i; - } -// *msg2_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot + + *msg2_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot *msg2_frame = (*msg2_slot>(rach_slot))? rach_frame : (rach_frame +1); switch(response_window){ @@ -448,7 +444,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_RA_t *ra = &cc->ra[0]; // if the preamble received correspond to one of the listed // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries @@ -467,6 +462,9 @@ void nr_initiate_ra_proc(module_id_t module_idP, return; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc } + for (int i = 0; i < NB_RA_PROC_MAX; i++) { + NR_RA_t *ra = &cc->ra[i]; + // This should be handled differently when we use the initialBWP for RA ra->bwp_id=1; NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; @@ -523,6 +521,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, abort(); } + UE_id = find_nr_UE_id(module_idP, ra->rnti); ra->RA_rnti = ra_rnti; ra->preamble_index = preamble_index; UE_list->tc_rnti[UE_id] = ra->rnti; @@ -543,6 +542,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, return; } + } LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: CC_id %d Frame %d initiating RA procedure for preamble index %d\n", module_idP, CC_id, frameP, preamble_index); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); @@ -554,15 +554,17 @@ void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ int CC_id = 0; gNB_MAC_INST *mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; - NR_RA_t *ra = &cc->ra[0]; start_meas(&mac->schedule_ra); + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { + + NR_RA_t *ra = &cc->ra[i]; - //for (i = 0; i < NR_NB_RA_PROC_MAX; i++) { LOG_D(MAC,"RA[state:%d]\n",ra->state); switch (ra->state){ case Msg2: - nr_generate_Msg2(module_idP, CC_id, frameP, slotP); + nr_generate_Msg2(module_idP, CC_id, frameP, slotP,ra); break; case Msg4: //generate_Msg4(module_idP, CC_id, frameP, slotP, ra); @@ -573,7 +575,8 @@ void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ default: break; } - //} + } + } stop_meas(&mac->schedule_ra); } @@ -744,13 +747,14 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, - sub_frame_t slotP){ + sub_frame_t slotP, + NR_RA_t *ra){ int UE_id = 0, dci_formats[2], rnti_types[2], mcsIndex; int startSymbolAndLength = 0, StartSymbolIndex = -1, NrOfSymbols = 14, StartSymbolIndex_tmp, NrOfSymbols_tmp, x_Overhead, time_domain_assignment; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; - NR_COMMON_channels_t *cc = &nr_mac->common_channels[0]; - NR_RA_t *ra = &cc->ra[0]; + NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; +// NR_RA_t *ra = &cc->ra[0]; NR_UE_list_t *UE_list = &nr_mac->UE_list; NR_SearchSpace_t *ss = ra->ra_ss; @@ -923,6 +927,7 @@ void nr_generate_Msg2(module_id_t module_idP, } void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP){ + NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[0]; LOG_D(MAC,"[gNB %d][RAPROC] CC_id %d Frame %d Clear Random access information rnti %x\n", module_idP, CC_id, frameP, ra->rnti); ra->state = IDLE; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 64f48f58bf..5215f3f999 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -67,8 +67,8 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ int mib_sdu_length; int CC_id; -// AssertFatal(slotP == 0, "Subframe must be 0\n"); -// AssertFatal((frameP & 7) == 0, "Frame must be a multiple of 8\n"); + AssertFatal(slotP == 0, "Subframe must be 0\n"); + AssertFatal((frameP & 7) == 0, "Frame must be a multiple of 8\n"); for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { @@ -76,7 +76,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ dl_tti_request = &gNB->DL_req[CC_id]; dl_req = &dl_tti_request->dl_tti_request_body; cc = &gNB->common_channels[CC_id]; - +#if 0 //SSB is transmitted based on SSB periodicity if((frameP % cfg->ssb_table.ssb_period.value) == 0) { uint64_t L_ssb = (((uint64_t) cfg->ssb_table.ssb_mask_list[0].ssb_mask.value)<<32) | cfg->ssb_table.ssb_mask_list[1].ssb_mask.value ; @@ -84,7 +84,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ for (int i=0; i<2; i++) { // max two SSB per slot ssb_index = i + SSB_Table[slotP]; // computing the ssb_index if ((ssb_index<64) && ((L_ssb >> (63-ssb_index)) & 0x01)) { // generating the ssb only if the bit of L_ssb at current ssb index is 1 - +#endif mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); // not used in this case @@ -106,7 +106,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ AssertFatal(cc->ServingCellConfigCommon->physCellId!=NULL,"cc->ServingCellConfigCommon->physCellId is null\n"); dl_config_pdu->ssb_pdu.ssb_pdu_rel15.PhysCellId = *cc->ServingCellConfigCommon->physCellId; dl_config_pdu->ssb_pdu.ssb_pdu_rel15.BetaPss = 0; - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = ssb_index ;//SSB index for each SSB + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0;//ssb_index ;//SSB index for each SSB AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon!=NULL,"scc->downlinkConfigCommonL is null\n"); AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL is null\n"); AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB is null\n"); @@ -143,14 +143,14 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ AssertFatal(1==0,"SCS %ld not allowed for SSB \n", *cc->ServingCellConfigCommon->ssbSubcarrierSpacing); } dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset = cfg->ssb_table.ssb_subcarrier_offset.value; //kSSB - dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA = /*cfg->ssb_table.ssb_offset_point_a.value;*/ssb_offset0/(ratio*12) - 10; // absoluteFrequencySSB is the center of SSB + dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA = ssb_offset0/(ratio*12) - 10;/*cfg->ssb_table.ssb_offset_point_a.value;*/ // absoluteFrequencySSB is the center of SSB dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag = 1; dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload = (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1); dl_req->nPDUs++; } - } - } - } +// } +// } +// } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index bfecc7b60e..8a75bf65df 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -284,7 +284,8 @@ void config_nr_mib(int Mod_idP, void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, - sub_frame_t slotP); + sub_frame_t slotP, + NR_RA_t *ra); void nr_schedule_reception_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP); diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 129881d3d4..6f77ed9a3e 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -157,12 +157,40 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb = calloc(1,sizeof(struct NR_CFRA__resources__ssb)); secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ra_ssb_OccasionMaskIndex = 0; struct NR_CFRA_SSB_Resource *ssbElem[8]; - for(int i = 0; i < 8; i++) { - ssbElem[i] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); - ssbElem[i]->ssb = i; - ssbElem[i]->ra_PreambleIndex = 63; + ssbElem[0] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[0]->ssb = 0; + ssbElem[0]->ra_PreambleIndex = 63; + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[0]); +#if 1 + ssbElem[1] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[1]->ssb = 1; + ssbElem[1]->ra_PreambleIndex = 62; + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[1]); + ssbElem[2] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[2]->ssb = 2; + ssbElem[2]->ra_PreambleIndex = 63; + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[2]); + ssbElem[3] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[3]->ssb = 3; + ssbElem[3]->ra_PreambleIndex = 63; + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[3]); + ssbElem[4] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[4]->ssb = 4; + ssbElem[4]->ra_PreambleIndex = 63; + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[4]); + ssbElem[5] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[5]->ssb = 5; + ssbElem[5]->ra_PreambleIndex = 63; ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[i]); - } + ssbElem[6] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[6]->ssb = i; + ssbElem[6]->ra_PreambleIndex = 63; + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[6]); + ssbElem[7] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); + ssbElem[7]->ssb = 7; + ssbElem[7]->ra_PreambleIndex = 63; + ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[7]); +#endif secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->ext1 = NULL; secondaryCellGroup->spCellConfig->rlf_TimersAndConstants = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants)); secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup;