Commit 889a5007 authored by Roberto Louro Magueta's avatar Roberto Louro Magueta

Implementation of resynchronization procedures for a gNB with a given Nid_cell

parent dcdf057d
......@@ -157,6 +157,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
ue->mac_enabled = 1;
ue->if_inst = nr_ue_if_module_init(0);
ue->dci_thres = 0;
ue->target_Nid_cell = -1;
// initialize all signal buffers
init_nr_ue_signal(ue, nb_connected_gNB);
......@@ -413,7 +414,11 @@ static void UE_synch(void *arg) {
*/
}
LOG_W(PHY, "Starting sync detection\n");
if (UE->target_Nid_cell != -1) {
LOG_W(NR_PHY, "Starting re-sync detection for target Nid_cell %i\n", UE->target_Nid_cell);
} else {
LOG_W(NR_PHY, "Starting sync detection\n");
}
switch (sync_mode) {
/*
......@@ -597,6 +602,17 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) {
nr_phy_data_t phy_data = {0};
if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) {
// Start synchronization with a target gNB
if (UE->synch_request.received_synch_request == 1 && UE->target_Nid_cell == -1) {
UE->is_synchronized = 0;
UE->target_Nid_cell = UE->synch_request.synch_req.target_Nid_cell;
clean_UE_ulsch(UE, proc->gNB_id);
} else if (UE->synch_request.received_synch_request == 1 && UE->target_Nid_cell != -1) {
UE->synch_request.received_synch_request = 0;
UE->target_Nid_cell = -1;
}
/* send tick to RLC and PDCP every ms */
if (proc->nr_slot_rx % UE->frame_parms.slots_per_subframe == 0) {
void nr_rlc_tick(int frame, int subframe);
......@@ -815,13 +831,13 @@ void *UE_thread(void *arg) {
if (!UE->is_synchronized) {
readFrame(UE, &timestamp, false);
notifiedFIFO_elt_t *Msg=newNotifiedFIFO_elt(sizeof(syncData_t),0,&nf,UE_synch);
syncData_t *syncMsg=(syncData_t *)NotifiedFifoData(Msg);
syncMsg->UE=UE;
notifiedFIFO_elt_t *Msg = newNotifiedFIFO_elt(sizeof(syncData_t), 0, &nf, UE_synch);
syncData_t *syncMsg = (syncData_t *)NotifiedFifoData(Msg);
syncMsg->UE = UE;
memset(&syncMsg->proc, 0, sizeof(syncMsg->proc));
pushTpool(&(get_nrUE_params()->Tpool), Msg);
trashed_frames=0;
syncRunning=true;
trashed_frames = 0;
syncRunning = true;
continue;
}
......
......@@ -654,6 +654,10 @@ typedef struct
} fapi_nr_prach_config_t;
typedef struct {
uint16_t target_Nid_cell;
} fapi_nr_synch_request_t;
typedef struct {
uint32_t config_mask;
......
......@@ -126,12 +126,7 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue);
void free_context_pss_nr(void);
int set_pss_nr(int ofdm_symbol_size);
int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change);
int pss_search_time_nr(c16_t **rxdata, ///rx data in time domain
NR_DL_FRAME_PARMS *frame_parms,
int fo_flag,
int is,
int *eNB_id,
int *f_off);
int pss_search_time_nr(c16_t **rxdata, PHY_VARS_NR_UE *ue, int fo_flag, int is);
#endif
#undef EXTERN
......
......@@ -300,11 +300,11 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
/* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */
/* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
for(int i=0; i<4;i++)
for (int i = 0; i < NR_N_SYMBOLS_SSB; i++)
nr_slot_fep_init_sync(ue,
proc,
i,
is*fp->samples_per_frame+ue->ssb_offset,
is * fp->samples_per_frame + ue->ssb_offset,
false,
rxdataF);
......@@ -522,6 +522,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
}
if (ue->target_Nid_cell != -1) {
return ret;
}
// if stand alone and sync on ssb do sib1 detection as part of initial sync
if (sa==1 && ret==0) {
nr_ue_dlsch_init(phy_data.dlsch, 1, ue->max_ldpc_iterations);
......
......@@ -251,6 +251,8 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
NR_DL_FRAME_PARMS *frame_parms,
uint8_t Nl);
int8_t clean_UE_ulsch(PHY_VARS_NR_UE *UE, uint8_t gNB_id);
void nr_dlsch_unscrambling(int16_t* llr,
uint32_t size,
uint8_t q,
......@@ -313,7 +315,7 @@ int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, char* bu
@param mode current running mode
*/
int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
PHY_VARS_NR_UE *phy_vars_ue,
PHY_VARS_NR_UE *phy_vars_ue,
int n_frames,
int sa);
......
......@@ -662,3 +662,15 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
////////////////////////////////////////////////////
return 0;
}
int8_t clean_UE_ulsch(PHY_VARS_NR_UE *UE, uint8_t gNB_id)
{
for (int harq_pid = 0; harq_pid < NR_MAX_ULSCH_HARQ_PROCESSES; harq_pid++) {
NR_UL_UE_HARQ_t *ul_harq_process = &UE->ul_harq_processes[harq_pid];
ul_harq_process->tx_status = NEW_TRANSMISSION_HARQ;
ul_harq_process->status = SCH_IDLE;
ul_harq_process->round = 0;
ul_harq_process->first_tx = 1;
}
return 0;
}
......@@ -555,12 +555,8 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change)
#endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PSS_SEARCH_TIME_NR, VCD_FUNCTION_IN);
synchro_position = pss_search_time_nr(rxdata,
frame_parms,
fo_flag,
is,
(int *)&PHY_vars_UE->common_vars.eNb_id,
(int *)&PHY_vars_UE->common_vars.freq_offset);
synchro_position = pss_search_time_nr(rxdata, PHY_vars_UE, fo_flag, is);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PSS_SEARCH_TIME_NR, VCD_FUNCTION_OUT);
......@@ -605,7 +601,7 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change)
*
* NAME : pss_search_time_nr
*
* PARAMETERS : received buffer
* PARAMETERS : received buffer in time domain
* frame parameters
*
* RETURN : position of detected pss
......@@ -651,17 +647,15 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change)
*
*********************************************************************/
int pss_search_time_nr(c16_t **rxdata, ///rx data in time domain
NR_DL_FRAME_PARMS *frame_parms,
int fo_flag,
int is,
int *eNB_id,
int *f_off)
int pss_search_time_nr(c16_t **rxdata, PHY_VARS_NR_UE *ue, int fo_flag, int is)
{
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
int *eNB_id = (int *)&ue->common_vars.eNb_id;
int *f_off = (int *)&ue->common_vars.freq_offset;
unsigned int n, ar, peak_position, pss_source;
int64_t peak_value;
int64_t avg[NUMBER_PSS_SEQUENCE]={0};
double ffo_est=0;
int64_t avg[NUMBER_PSS_SEQUENCE] = {0};
double ffo_est = 0;
// performing the correlation on a frame length plus one symbol for the first of the two frame
// to take into account the possibility of PSS in between the two frames
......@@ -692,7 +686,14 @@ int pss_search_time_nr(c16_t **rxdata, ///rx data in time domain
/* This is required by SIMD (single instruction Multiple Data) Extensions of Intel processors. */
/* Correlation computation is based on a a dot product which is realized thank to SIMS extensions */
for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) {
uint16_t pss_index_start = 0;
uint16_t pss_index_end = NUMBER_PSS_SEQUENCE;
if (ue->target_Nid_cell != -1) {
pss_index_start = GET_NID2(ue->target_Nid_cell);
pss_index_end = pss_index_start + 1;
}
for (int pss_index = pss_index_start; pss_index < pss_index_end; pss_index++) {
for (n = 0; n < length; n += 8) { //
int64_t pss_corr_ue=0;
......@@ -748,10 +749,10 @@ int pss_search_time_nr(c16_t **rxdata, ///rx data in time domain
}
// computing absolute value of frequency offset
*f_off = ffo_est*frame_parms->subcarrier_spacing;
*f_off = ffo_est*frame_parms->subcarrier_spacing;
for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++)
avg[pss_index]/=(length/4);
for (int pss_index = pss_index_start; pss_index < pss_index_end; pss_index++)
avg[pss_index] /= (length / 4);
*eNB_id = pss_source;
......@@ -776,6 +777,6 @@ int pss_search_time_nr(c16_t **rxdata, ///rx data in time domain
#endif
return(peak_position);
return peak_position;
}
......@@ -511,9 +511,15 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric,
/* cosinus cos(x + y) = cos(x)cos(y) - sin(x)sin(y) */
/* sinus sin(x + y) = sin(x)cos(y) + cos(x)sin(y) */
for (Nid1 = 0 ; Nid1 < N_ID_1_NUMBER; Nid1++) { // all possible Nid1 values
for (phase=0; phase < PHASE_HYPOTHESIS_NUMBER; phase++) { // phase offset between PSS and SSS
uint16_t Nid1_start = 0;
uint16_t Nid1_end = N_ID_1_NUMBER;
if (ue->target_Nid_cell != -1) {
Nid1_start = GET_NID1(ue->target_Nid_cell);
Nid1_end = Nid1_start + 1;
}
for (Nid1 = Nid1_start; Nid1 < Nid1_end; Nid1++) { // all possible Nid1 values
for (phase = 0; phase < PHASE_HYPOTHESIS_NUMBER; phase++) { // phase offset between PSS and SSS
metric = 0;
metric_re = 0;
......@@ -523,7 +529,6 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t *tot_metric,
// This is the inner product using one particular value of each unknown parameter
for (i=0; i < LENGTH_SSS_NR; i++) {
metric_re += d[i]*(((phase_re_nr[phase]*sss[2*i])>>SCALING_METRIC_SSS_NR) - ((phase_im_nr[phase]*sss[2*i+1])>>SCALING_METRIC_SSS_NR));
#if 0
......
......@@ -400,6 +400,8 @@ typedef struct {
int if_freq_off;
/// \brief Indicator that UE is synchronized to a gNB
int is_synchronized;
/// \brief Target gNB Nid_cell when UE is resynchronizing
int target_Nid_cell;
/// \brief Indicator that UE lost frame synchronization
int lost_sync;
/// Data structure for UE process scheduling
......@@ -440,6 +442,7 @@ typedef struct {
nr_ue_if_module_t *if_inst;
fapi_nr_config_request_t nrUE_config;
nr_synch_request_t synch_request;
NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_PRACH *prach_vars[NUMBER_OF_CONNECTED_gNB_MAX];
......
......@@ -548,3 +548,11 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config)
memcpy(nrUE_config,&phy_config->config_req,sizeof(fapi_nr_config_request_t));
return 0;
}
void nr_ue_synch_request(nr_synch_request_t *synch_request)
{
fapi_nr_synch_request_t *synch_req = &PHY_vars_UE_g[synch_request->Mod_id][synch_request->CC_id]->synch_request.synch_req;
memcpy(synch_req, &synch_request->synch_req, sizeof(fapi_nr_synch_request_t));
PHY_vars_UE_g[synch_request->Mod_id][synch_request->CC_id]->synch_request.received_synch_request = 1;
}
......@@ -47,6 +47,10 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
\param scheduled_response including transmission config(dl_config, ul_config) and data transmission (tx_req)*/
int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config);
/**\brief NR UE FAPI message to schedule a synchronization with target gNB
\param synch_request including target_Nid_cell*/
void nr_ue_synch_request(nr_synch_request_t *synch_request);
void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nack);
#endif
......@@ -120,6 +120,10 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
return 0;
}
int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index) {
return 0;
}
int nr_derive_key(int alg_type, uint8_t alg_id,
const uint8_t key[32], uint8_t **out)
{
......
......@@ -106,6 +106,10 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
return 0;
}
int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index) {
return 0;
}
int nr_derive_key(int alg_type, uint8_t alg_id,
const uint8_t key[32], uint8_t **out)
{
......
......@@ -116,6 +116,10 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
return 0;
}
int8_t nr_rrc_RA_succeeded(const module_id_t mod_id, const uint8_t gNB_index) {
return 0;
}
int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP,
int CC_idP,
int UE_id,
......
......@@ -752,8 +752,8 @@ int nr_rrc_mac_config_req_ue(module_id_t module_id,
config_control_ue(mac);
// Setup the SSB to Rach Occasions mapping according to the config
build_ssb_to_ro_map(mac);
}
else if (cell_group_config != NULL ){
} else if (cell_group_config != NULL) {
LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n");
mac->cg = cell_group_config;
if (cell_group_config->spCellConfig)
......@@ -772,20 +772,38 @@ int nr_rrc_mac_config_req_ue(module_id_t module_id,
configure_current_BWP(mac, NULL, cell_group_config);
config_control_ue(mac);
if (get_softmodem_params()->nsa) {
if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) {
if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
}
mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) {
num_slots++;
}
mac->ul_config_request = calloc(num_slots, sizeof(*mac->ul_config_request));
config_common_ue(mac,module_id,cc_idP);
mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) {
LOG_A(NR_MAC, "Received the reconfigurationWithSync in %s\n", __FUNCTION__);
if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
}
mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
if (mac->scc_SIB) {
free(mac->scc_SIB);
mac->scc_SIB = NULL;
}
int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) {
num_slots++;
}
mac->state = UE_NOT_SYNC;
mac->ra.ra_state = RA_UE_IDLE;
mac->physCellId = *mac->scc->physCellId;
if (!get_softmodem_params()->emulate_l1) {
mac->synch_request.Mod_id = module_id;
mac->synch_request.CC_id = cc_idP;
mac->synch_request.synch_req.target_Nid_cell = mac->physCellId;
mac->if_module->synch_request(&mac->synch_request);
}
mac->ul_config_request = calloc(num_slots, sizeof(*mac->ul_config_request));
config_common_ue(mac, module_id, cc_idP);
mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
LOG_I(MAC, "Configuring CRNTI %x\n", mac->crnti);
nr_ue_init_mac(module_id);
if (!get_softmodem_params()->emulate_l1) {
mac->if_module->phy_config_request(&mac->phy_config);
mac->phy_config_request_sent = true;
}
// Setup the SSB to Rach Occasions mapping according to the config
......
......@@ -446,6 +446,7 @@ typedef struct {
/// Interface module instances
nr_ue_if_module_t *if_module;
nr_phy_config_t phy_config;
nr_synch_request_t synch_request;
/// BSR report flag management
uint8_t BSR_reporting_active;
......
......@@ -886,7 +886,7 @@ uint8_t nr_ue_get_rach(module_id_t mod_id,
if(ra->cfra) {
// Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213)
nr_ra_succeeded(mod_id, frame, nr_slot_tx);
nr_ra_succeeded(mod_id, gNB_id, frame, nr_slot_tx);
}
} else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) {
......@@ -1001,13 +1001,14 @@ void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame
// according to section 5 of 3GPP TS 38.321 version 16.2.1 Release 16
// todo:
// - complete handling of received contention-based RA preamble
void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
void nr_ra_succeeded(const module_id_t mod_id, const uint8_t gNB_index, const frame_t frame, const int slot)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra;
if (ra->cfra) {
LOG_I(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CF-RA: RAR successfully received.\n", mod_id, frame, slot);
nr_rrc_RA_succeeded(mod_id, gNB_index);
mac->state = UE_CONNECTED;
ra->RA_window_cnt = -1;
} else {
......
......@@ -269,7 +269,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
uint8_t bwp_id = mac->current_DL_BWP.bwp_id;
//NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
NR_BWP_DownlinkDedicated_t *bwpd = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Dedicated : (mac->cg ? mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL);
NR_BWP_DownlinkCommon_t *bwp_Common = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Common : &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP;
NR_BWP_DownlinkCommon_t *bwp_Common = get_bwp_downlink_common(mac, bwp_id);
LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti);
......
......@@ -686,7 +686,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
/* dmrs symbol positions*/
dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config,
NR_DL_DCI_FORMAT_1_0,
(get_softmodem_params()->nsa) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position,
mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position,
dlsch_config_pdu_1_0->number_symbols,
dlsch_config_pdu_1_0->start_symbol,
tda_info.mapping_type,
......@@ -2421,6 +2421,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
switch(dci_format) {
case NR_DL_DCI_FORMAT_1_0:
switch(rnti_type) {
case NR_RNTI_RA:
// Freq domain assignment
......
......@@ -495,7 +495,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
#ifdef DEBUG_MSG3
LOG_D(NR_MAC, "In %s BWP assignment (BWP (start %d, size %d) \n", __FUNCTION__, pusch_config_pdu->bwp_start, pusch_config_pdu->bwp_size);
#endif
#endif
// MCS
pusch_config_pdu->mcs_index = rar_grant->mcs;
......@@ -1399,6 +1399,8 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t curren
case 3:
delta = 6;
break;
default:
AssertFatal(1 == 0, "Invalid numerology %i\n", mu);
}
AssertFatal((k2 + delta) >= DURATION_RX_TO_TX,
......
......@@ -650,7 +650,58 @@ bool nr_mac_update_cellgroup(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupCon
exit(1);
}
nr_mac_update_RA(nrmac, rnti, CellGroup);
process_CellGroup(CellGroup, &UE->UE_sched_ctrl);
return true;
}
bool nr_mac_update_RA(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup)
{
// Checking for free RA process
NR_COMMON_channels_t *cc = &nrmac->common_channels[0];
uint8_t ra_index = 0;
for (; ra_index < NR_NB_RA_PROC_MAX; ra_index++) {
if ((cc->ra[ra_index].state == RA_IDLE) && (!cc->ra[ra_index].cfra))
break;
}
if (ra_index == NR_NB_RA_PROC_MAX) {
LOG_E(NR_MAC, "%s() %s:%d RA processes are not available for CFRA RNTI :%x\n", __FUNCTION__, __FILE__, __LINE__, rnti);
return -1;
}
NR_RA_t *ra = &cc->ra[ra_index];
if (CellGroup->spCellConfig && CellGroup->spCellConfig->reconfigurationWithSync
&& CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated != NULL) {
if (CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra != NULL) {
ra->cfra = true;
ra->rnti = rnti;
ra->CellGroup = CellGroup;
struct NR_CFRA *cfra = CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra;
uint8_t num_preamble = cfra->resources.choice.ssb->ssb_ResourceList.list.count;
ra->preambles.num_preambles = num_preamble;
ra->preambles.preamble_list = (uint8_t *)malloc(num_preamble * sizeof(uint8_t));
for (int i = 0; i < cc->num_active_ssb; i++) {
for (int j = 0; j < num_preamble; j++) {
if (cc->ssb_index[i] == cfra->resources.choice.ssb->ssb_ResourceList.list.array[j]->ssb) {
// One dedicated preamble for each beam
ra->preambles.preamble_list[i] = cfra->resources.choice.ssb->ssb_ResourceList.list.array[j]->ra_PreambleIndex;
break;
}
}
}
}
} else {
ra->cfra = false;
ra->rnti = 0;
if (ra->preambles.preamble_list == NULL) {
ra->preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
ra->preambles.preamble_list = (uint8_t *)malloc(MAX_NUM_NR_PRACH_PREAMBLES * sizeof(uint8_t));
for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
ra->preambles.preamble_list[i] = i;
}
}
LOG_I(NR_MAC, "Added new %s process for UE RNTI %04x with initial CellGroup\n", ra->cfra ? "CFRA" : "CBRA", rnti);
return true;
}
......@@ -1375,10 +1375,18 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
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) {
if (ra->cfra) {
NR_UE_info_t *UE = find_nr_UE(&RC.nrmac[module_idP]->UE_info, ra->rnti);
if (UE) {
const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL;
uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS;
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
sched_ctrl->rrc_processing_timer = (delay_ms << ra->DL_BWP.scs);
}
LOG_D(NR_MAC, "Frame %d, Subframe %d: Setting RA-Msg3 reception (CFRA) for SFN.Slot %d.%d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot);
} else {
LOG_D(NR_MAC, "Frame %d, Subframe %d: Setting RA-Msg3 reception (CBRA) for SFN.Slot %d.%d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot);
}
else LOG_D(NR_MAC, "Frame %d, Subframe %d: Setting RA-Msg3 reception (CBRA) for SFN.Slot %d.%d\n", frameP, slotP, ra->Msg3_frame, ra->Msg3_slot);
T(T_GNB_MAC_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(ra->RA_rnti), T_INT(frameP),
T_INT(slotP), T_INT(0), T_BUFFER(&tx_req->TLVs[0].value.direct[0], tx_req->TLVs[0].length));
......
......@@ -58,6 +58,7 @@ void nr_mac_config_sib1(gNB_MAC_INST *nrmac, NR_BCCH_DL_SCH_Message_t *sib1);
bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup);
bool nr_mac_prepare_ra_nsa_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup);
bool nr_mac_update_cellgroup(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup);
bool nr_mac_update_RA(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup);
void clear_nr_nfapi_information(gNB_MAC_INST * gNB,
int CC_idP,
......
......@@ -1239,6 +1239,7 @@ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id){
nr_ue_if_module_inst[module_id]->current_frame = 0;
nr_ue_if_module_inst[module_id]->current_slot = 0;
nr_ue_if_module_inst[module_id]->phy_config_request = nr_ue_phy_config_request;
nr_ue_if_module_inst[module_id]->synch_request = nr_ue_synch_request;
if (get_softmodem_params()->emulate_l1)
nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response_stub;
else
......
......@@ -151,6 +151,16 @@ typedef struct {
} nr_phy_config_t;
typedef struct {
/// module id
uint8_t Mod_id;
/// component carrier id
uint8_t CC_id;
/// Flag signaling that synch_request was received
uint8_t received_synch_request;
/// NR UE FAPI message
fapi_nr_synch_request_t synch_req;
} nr_synch_request_t;
/*
* Generic type of an application-defined callback to return various
......@@ -171,6 +181,12 @@ typedef int8_t (nr_ue_scheduled_response_f)(nr_scheduled_response_t *scheduled_r
*/
typedef int8_t (nr_ue_phy_config_request_f)(nr_phy_config_t *phy_config);
/*
* Generic type of an application-defined callback to return various
* types of data to the application.
*/
typedef void (nr_ue_synch_request_f)(nr_synch_request_t *synch_request);
/*
* Generic type of an application-defined callback to return various
......@@ -196,6 +212,7 @@ typedef int (nr_ue_dcireq_f)(nr_dcireq_t *ul_info);
typedef struct nr_ue_if_module_s {
nr_ue_scheduled_response_f *scheduled_response;
nr_ue_phy_config_request_f *phy_config_request;
nr_ue_synch_request_f *synch_request;
nr_ue_dl_indication_f *dl_indication;
nr_ue_ul_indication_f *ul_indication;
//nr_ue_dcireq_f *dcireq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment