Split rrc_mac_config_req_gNB() in multiple functions
This commit is contained in:
@@ -720,11 +720,11 @@ int main(int argc, char **argv)
|
||||
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
|
||||
|
||||
// common configuration
|
||||
rrc_mac_config_req_gNB(0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 0, 0, NULL);
|
||||
nr_mac_config_scc(RC.nrmac[0], pdsch_AntennaPorts, n_tx, 0, 6, scc);
|
||||
// UE dedicated configuration
|
||||
rrc_mac_config_req_gNB(0, pdsch_AntennaPorts, n_tx, 0, 6, scc, NULL, NULL, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
|
||||
nr_mac_add_test_ue(RC.nrmac[0], secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, secondaryCellGroup);
|
||||
// reset preprocessor to the one of DLSIM after it has been set during
|
||||
// rrc_mac_config_req_gNB
|
||||
// nr_mac_config_scc()
|
||||
gNB_mac->pre_processor_dl = nr_dlsim_preprocessor;
|
||||
phy_init_nr_gNB(gNB);
|
||||
N_RB_DL = gNB->frame_parms.N_RB_DL;
|
||||
@@ -736,7 +736,7 @@ int main(int argc, char **argv)
|
||||
// nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
|
||||
// call MAC to configure common parameters
|
||||
|
||||
/* rrc_mac_config_req_gNB() has created one user, so set the scheduling
|
||||
/* nr_mac_add_test_ue() has created one user, so set the scheduling
|
||||
* parameters from command line in global variables that will be picked up by
|
||||
* scheduling preprocessor */
|
||||
if (g_mcsIndex < 0) g_mcsIndex = 9;
|
||||
|
||||
@@ -654,10 +654,10 @@ int main(int argc, char **argv)
|
||||
|
||||
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
|
||||
// common configuration
|
||||
rrc_mac_config_req_gNB(0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 0, 0, NULL);
|
||||
nr_mac_config_scc(RC.nrmac[0], conf.pdsch_AntennaPorts, n_tx, 0, 6, scc);
|
||||
nr_mac_config_mib(RC.nrmac[0], &rrc.carrier.mib);
|
||||
// UE dedicated configuration
|
||||
rrc_mac_config_req_gNB(0, conf.pdsch_AntennaPorts, n_rx, 0, 6, scc, &rrc.carrier.mib, rrc.carrier.siblock1, 1,
|
||||
secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, secondaryCellGroup);
|
||||
nr_mac_add_test_ue(RC.nrmac[0], secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, secondaryCellGroup);
|
||||
frame_parms->nb_antennas_tx = 1;
|
||||
frame_parms->nb_antennas_rx = n_rx;
|
||||
nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
|
||||
|
||||
@@ -2084,24 +2084,6 @@ void du_extract_and_decode_SI(int inst, int si_ind, uint8_t *si_container, int s
|
||||
} else AssertFatal(1 == 0, "No SI messages\n");
|
||||
}
|
||||
|
||||
void configure_gnb_du_mac(int inst) {
|
||||
gNB_RRC_INST *rrc = RC.nrrrc[inst];
|
||||
// LOG_I(GNB_APP,"Configuring MAC/L1 %d, carrier->sib2 %p\n", inst, &carrier->sib2->radioResourceConfigCommon);
|
||||
LOG_I(GNB_APP,"Configuring gNB DU MAC/L1 %d \n", inst);
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
rrc->configuration.scc,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0, // rnti
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
int gNB_app_handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) {
|
||||
int i, j, si_ind;
|
||||
int ret=0;
|
||||
@@ -2126,9 +2108,6 @@ int gNB_app_handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) {
|
||||
resp->cells_to_activate[j].SI_container[si_ind],
|
||||
resp->cells_to_activate[j].SI_container_length[si_ind]);
|
||||
}
|
||||
|
||||
// perform MAC/L1 common configuration
|
||||
configure_gnb_du_mac(i);
|
||||
ret++;
|
||||
} else {
|
||||
LOG_E(GNB_APP, "F1 Setup Response not matching\n");
|
||||
@@ -2161,9 +2140,6 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up
|
||||
gnb_cu_cfg_update->cells_to_activate[j].SI_container[si_ind],
|
||||
gnb_cu_cfg_update->cells_to_activate[j].SI_container_length[si_ind]);
|
||||
}
|
||||
|
||||
// perform MAC/L1 common configuration
|
||||
configure_gnb_du_mac(i);
|
||||
ret++;
|
||||
} else {
|
||||
LOG_E(GNB_APP, "GNB_CU_CONFIGURATION_UPDATE not matching\n");
|
||||
|
||||
+186
-175
@@ -459,190 +459,201 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, rnti_t rnti, NR_S
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rrc_mac_config_req_gNB(module_id_t Mod_idP,
|
||||
rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts,
|
||||
int pusch_AntennaPorts,
|
||||
int sib1_tda,
|
||||
int minRXTXTIMEpdsch,
|
||||
NR_ServingCellConfigCommon_t *scc,
|
||||
NR_BCCH_BCH_Message_t *mib,
|
||||
NR_BCCH_DL_SCH_Message_t *sib1,
|
||||
int add_ue,
|
||||
uint32_t rnti,
|
||||
NR_CellGroupConfig_t *CellGroup) {
|
||||
void nr_mac_config_scc(gNB_MAC_INST *nrmac,
|
||||
rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts,
|
||||
int pusch_AntennaPorts,
|
||||
int sib1_tda,
|
||||
int minRXTXTIMEpdsch,
|
||||
NR_ServingCellConfigCommon_t *scc)
|
||||
{
|
||||
DevAssert(nrmac != NULL);
|
||||
AssertFatal(nrmac->common_channels[0].ServingCellConfigCommon == NULL, "logic error: multiple configurations of SCC\n");
|
||||
|
||||
if (scc != NULL ) {
|
||||
AssertFatal((scc->ssb_PositionsInBurst->present > 0) && (scc->ssb_PositionsInBurst->present < 4), "SSB Bitmap type %d is not valid\n",scc->ssb_PositionsInBurst->present);
|
||||
DevAssert(scc != NULL);
|
||||
AssertFatal(scc->ssb_PositionsInBurst->present > 0 && scc->ssb_PositionsInBurst->present < 4,
|
||||
"SSB Bitmap type %d is not valid\n",
|
||||
scc->ssb_PositionsInBurst->present);
|
||||
|
||||
int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing];
|
||||
if (*scc->ssbSubcarrierSpacing == 0)
|
||||
n <<= 1; // to have enough room for feedback possibly beyond the frame we need a larger array at 15kHz SCS
|
||||
RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL = calloc(n * MAX_BWP_SIZE, sizeof(uint16_t));
|
||||
RC.nrmac[Mod_idP]->vrb_map_UL_size = n;
|
||||
AssertFatal(RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL,
|
||||
"could not allocate memory for RC.nrmac[]->common_channels[0].vrb_map_UL\n");
|
||||
int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing];
|
||||
if (*scc->ssbSubcarrierSpacing == 0)
|
||||
n <<= 1; // to have enough room for feedback possibly beyond the frame we need a larger array at 15kHz SCS
|
||||
nrmac->common_channels[0].vrb_map_UL = calloc(n * MAX_BWP_SIZE, sizeof(uint16_t));
|
||||
nrmac->vrb_map_UL_size = n;
|
||||
AssertFatal(nrmac->common_channels[0].vrb_map_UL,
|
||||
"could not allocate memory for RC.nrmac[]->common_channels[0].vrb_map_UL\n");
|
||||
|
||||
LOG_I(NR_MAC,"Configuring common parameters from NR ServingCellConfig\n");
|
||||
LOG_I(NR_MAC, "Configuring common parameters from NR ServingCellConfig\n");
|
||||
|
||||
int num_pdsch_antenna_ports = pdsch_AntennaPorts.N1 * pdsch_AntennaPorts.N2 * pdsch_AntennaPorts.XP;
|
||||
RC.nrmac[Mod_idP]->xp_pdsch_antenna_ports = pdsch_AntennaPorts.XP;
|
||||
config_common(RC.nrmac[Mod_idP],
|
||||
num_pdsch_antenna_ports,
|
||||
pusch_AntennaPorts,
|
||||
scc);
|
||||
LOG_D(NR_MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req);
|
||||
|
||||
if (NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) {
|
||||
// fake that the gNB is configured in nFAPI mode, which would normally be
|
||||
// done in a NR_PHY_config_req, but in this mode, there is no PHY
|
||||
RC.gNB[Mod_idP]->configured = 1;
|
||||
} else {
|
||||
NR_PHY_Config_t phycfg = {
|
||||
.Mod_id = Mod_idP,
|
||||
.CC_id = 0,
|
||||
.cfg = &RC.nrmac[Mod_idP]->config[0]
|
||||
};
|
||||
DevAssert(RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req);
|
||||
RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req(&phycfg);
|
||||
}
|
||||
int num_pdsch_antenna_ports = pdsch_AntennaPorts.N1 * pdsch_AntennaPorts.N2 * pdsch_AntennaPorts.XP;
|
||||
nrmac->xp_pdsch_antenna_ports = pdsch_AntennaPorts.XP;
|
||||
config_common(nrmac, num_pdsch_antenna_ports, pusch_AntennaPorts, scc);
|
||||
|
||||
RC.nrmac[Mod_idP]->minRXTXTIMEpdsch = minRXTXTIMEpdsch;
|
||||
find_SSB_and_RO_available(RC.nrmac[Mod_idP]);
|
||||
|
||||
const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL;
|
||||
|
||||
int nr_slots_period = n;
|
||||
int nr_dl_slots = n;
|
||||
int nr_ulstart_slot = 0;
|
||||
if (tdd) {
|
||||
nr_dl_slots = tdd->nrofDownlinkSlots + (tdd->nrofDownlinkSymbols != 0);
|
||||
nr_ulstart_slot = get_first_ul_slot(tdd->nrofDownlinkSlots, tdd->nrofDownlinkSymbols, tdd->nrofUplinkSymbols);
|
||||
nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity);
|
||||
}
|
||||
else
|
||||
// if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration
|
||||
AssertFatal(RC.nrmac[Mod_idP]->common_channels[0].frame_type == FDD,"Dynamic TDD not handled yet\n");
|
||||
|
||||
for (int slot = 0; slot < n; ++slot) {
|
||||
RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) < nr_dl_slots) << (slot % 64);
|
||||
RC.nrmac[Mod_idP]->ulsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) >= nr_ulstart_slot) << (slot % 64);
|
||||
|
||||
LOG_I(NR_MAC, "In %s: slot %d DL %d UL %d\n",
|
||||
__FUNCTION__,
|
||||
slot,
|
||||
(RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] & ((uint64_t)1 << (slot % 64))) != 0,
|
||||
(RC.nrmac[Mod_idP]->ulsch_slot_bitmap[slot / 64] & ((uint64_t)1 << (slot % 64))) != 0);
|
||||
}
|
||||
|
||||
if (get_softmodem_params()->phy_test) {
|
||||
RC.nrmac[Mod_idP]->pre_processor_dl = nr_preprocessor_phytest;
|
||||
RC.nrmac[Mod_idP]->pre_processor_ul = nr_ul_preprocessor_phytest;
|
||||
} else {
|
||||
RC.nrmac[Mod_idP]->pre_processor_dl = nr_init_fr1_dlsch_preprocessor(0);
|
||||
RC.nrmac[Mod_idP]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(0);
|
||||
}
|
||||
|
||||
if (get_softmodem_params()->sa > 0) {
|
||||
NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[0];
|
||||
RC.nrmac[Mod_idP]->sib1_tda = sib1_tda;
|
||||
for (int n=0;n<NR_NB_RA_PROC_MAX;n++ ) {
|
||||
cc->ra[n].cfra = false;
|
||||
cc->ra[n].msg3_dcch_dtch = false;
|
||||
cc->ra[n].rnti = 0;
|
||||
cc->ra[n].preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
|
||||
cc->ra[n].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++)
|
||||
cc->ra[n].preambles.preamble_list[i] = i;
|
||||
}
|
||||
}
|
||||
if (NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) {
|
||||
// fake that the gNB is configured in nFAPI mode, which would normally be
|
||||
// done in a NR_PHY_config_req, but in this mode, there is no PHY
|
||||
RC.gNB[0]->configured = 1;
|
||||
} else {
|
||||
NR_PHY_Config_t phycfg = {.Mod_id = 0, .CC_id = 0, .cfg = &nrmac->config[0]};
|
||||
DevAssert(nrmac->if_inst->NR_PHY_config_req);
|
||||
nrmac->if_inst->NR_PHY_config_req(&phycfg);
|
||||
}
|
||||
|
||||
if (mib) RC.nrmac[Mod_idP]->common_channels[0].mib = mib;
|
||||
if (sib1) RC.nrmac[Mod_idP]->common_channels[0].sib1 = sib1;
|
||||
|
||||
if (CellGroup) {
|
||||
nrmac->minRXTXTIMEpdsch = minRXTXTIMEpdsch;
|
||||
find_SSB_and_RO_available(nrmac);
|
||||
|
||||
if (add_ue == 1 && get_softmodem_params()->phy_test) {
|
||||
NR_UE_info_t* UE = add_new_nr_ue(RC.nrmac[Mod_idP], rnti, CellGroup);
|
||||
if (UE) {
|
||||
LOG_I(NR_MAC,"Added new UE %x with initial CellGroup\n", rnti);
|
||||
} else {
|
||||
LOG_E(NR_MAC,"Error adding UE %04x\n", rnti);
|
||||
return -1;
|
||||
}
|
||||
process_CellGroup(CellGroup,&UE->UE_sched_ctrl);
|
||||
} else if (add_ue == 1 && !get_softmodem_params()->phy_test) {
|
||||
const int CC_id = 0;
|
||||
NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[CC_id];
|
||||
uint8_t ra_index = 0;
|
||||
/* checking for free RA process */
|
||||
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];
|
||||
ra->CellGroup = CellGroup;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL;
|
||||
|
||||
int nr_slots_period = n;
|
||||
int nr_dl_slots = n;
|
||||
int nr_ulstart_slot = 0;
|
||||
if (tdd) {
|
||||
nr_dl_slots = tdd->nrofDownlinkSlots + (tdd->nrofDownlinkSymbols != 0);
|
||||
nr_ulstart_slot = get_first_ul_slot(tdd->nrofDownlinkSlots, tdd->nrofDownlinkSymbols, tdd->nrofUplinkSymbols);
|
||||
nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity);
|
||||
} else {
|
||||
// if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration
|
||||
AssertFatal(nrmac->common_channels[0].frame_type == FDD,"Dynamic TDD not handled yet\n");
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < n; ++slot) {
|
||||
nrmac->dlsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) < nr_dl_slots) << (slot % 64);
|
||||
nrmac->ulsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) >= nr_ulstart_slot) << (slot % 64);
|
||||
|
||||
LOG_I(NR_MAC,
|
||||
"slot %d DL %d UL %d\n",
|
||||
slot,
|
||||
(nrmac->dlsch_slot_bitmap[slot / 64] & ((uint64_t)1 << (slot % 64))) != 0,
|
||||
(nrmac->ulsch_slot_bitmap[slot / 64] & ((uint64_t)1 << (slot % 64))) != 0);
|
||||
}
|
||||
|
||||
if (get_softmodem_params()->phy_test) {
|
||||
nrmac->pre_processor_dl = nr_preprocessor_phytest;
|
||||
nrmac->pre_processor_ul = nr_ul_preprocessor_phytest;
|
||||
} else {
|
||||
nrmac->pre_processor_dl = nr_init_fr1_dlsch_preprocessor(0);
|
||||
nrmac->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(0);
|
||||
}
|
||||
|
||||
if (get_softmodem_params()->sa > 0) {
|
||||
NR_COMMON_channels_t *cc = &nrmac->common_channels[0];
|
||||
nrmac->sib1_tda = sib1_tda;
|
||||
for (int n = 0; n < NR_NB_RA_PROC_MAX; n++) {
|
||||
NR_RA_t *ra = &cc->ra[n];
|
||||
ra->cfra = false;
|
||||
ra->msg3_dcch_dtch = false;
|
||||
LOG_I(NR_MAC,"Added new RA process for UE RNTI %04x with initial CellGroup\n", rnti);
|
||||
} else { // CellGroup has been updated
|
||||
NR_UE_info_t *UE = find_nr_UE(&RC.nrmac[Mod_idP]->UE_info, rnti);
|
||||
if (!UE) {
|
||||
LOG_E(NR_MAC, "Can't find UE %04x\n", rnti);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* copy CellGroup by calling asn1c encode
|
||||
this is a temporary hack to avoid the gNB having
|
||||
a pointer to RRC CellGroup structure
|
||||
(otherwise it would be applied to early)
|
||||
TODO remove once we have a proper implementation */
|
||||
UE->enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
|
||||
NULL,
|
||||
(void *) CellGroup,
|
||||
UE->cg_buf,
|
||||
32768);
|
||||
|
||||
if (UE->enc_rval.encoded == -1) {
|
||||
LOG_E(NR_MAC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n",
|
||||
UE->enc_rval.failed_type->name, UE->enc_rval.encoded);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
process_CellGroup(CellGroup,&UE->UE_sched_ctrl);
|
||||
ra->rnti = 0;
|
||||
ra->preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
|
||||
ra->preambles.preamble_list = malloc(MAX_NUM_NR_PRACH_PREAMBLES * sizeof(*ra->preambles.preamble_list));
|
||||
for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
|
||||
ra->preambles.preamble_list[i] = i;
|
||||
}
|
||||
}
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}// END rrc_mac_config_req_gNB
|
||||
void nr_mac_config_mib(gNB_MAC_INST *nrmac, NR_BCCH_BCH_Message_t *mib)
|
||||
{
|
||||
DevAssert(nrmac != NULL);
|
||||
DevAssert(mib != NULL);
|
||||
NR_COMMON_channels_t *cc = &nrmac->common_channels[0];
|
||||
|
||||
AssertFatal(cc->mib == NULL, "logic bug: updated MIB multiple times\n");
|
||||
cc->mib = mib;
|
||||
}
|
||||
|
||||
void nr_mac_config_sib1(gNB_MAC_INST *nrmac, NR_BCCH_DL_SCH_Message_t *sib1)
|
||||
{
|
||||
DevAssert(nrmac != NULL);
|
||||
DevAssert(sib1 != NULL);
|
||||
NR_COMMON_channels_t *cc = &nrmac->common_channels[0];
|
||||
|
||||
AssertFatal(cc->sib1 == NULL, "logic bug: updated SIB1 multiple times\n");
|
||||
cc->sib1 = sib1;
|
||||
}
|
||||
|
||||
bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup)
|
||||
{
|
||||
DevAssert(nrmac != NULL);
|
||||
DevAssert(CellGroup != NULL);
|
||||
DevAssert(get_softmodem_params()->phy_test);
|
||||
|
||||
NR_UE_info_t* UE = add_new_nr_ue(nrmac, rnti, CellGroup);
|
||||
if (UE) {
|
||||
LOG_I(NR_MAC,"Force-added new UE %x with initial CellGroup\n", rnti);
|
||||
} else {
|
||||
LOG_E(NR_MAC,"Error adding UE %04x\n", rnti);
|
||||
return false;
|
||||
}
|
||||
process_CellGroup(CellGroup,&UE->UE_sched_ctrl);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nr_mac_prepare_ra_nsa_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup)
|
||||
{
|
||||
DevAssert(nrmac != NULL);
|
||||
DevAssert(CellGroup != NULL);
|
||||
DevAssert(!get_softmodem_params()->phy_test);
|
||||
|
||||
// NSA case: need to pre-configure CFRA
|
||||
const int CC_id = 0;
|
||||
NR_COMMON_channels_t *cc = &nrmac->common_channels[CC_id];
|
||||
uint8_t ra_index = 0;
|
||||
/* checking for free RA process */
|
||||
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, "RA processes are not available for CFRA RNTI %04x\n", rnti);
|
||||
return false;
|
||||
}
|
||||
NR_RA_t *ra = &cc->ra[ra_index];
|
||||
ra->CellGroup = CellGroup;
|
||||
AssertFatal(CellGroup->spCellConfig && CellGroup->spCellConfig->reconfigurationWithSync
|
||||
&& CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated != NULL
|
||||
&& CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra != NULL,
|
||||
"invalid CellGroup for RNTI %04x, cannot create RA occasion\n",
|
||||
rnti);
|
||||
|
||||
ra->cfra = true;
|
||||
ra->rnti = rnti;
|
||||
struct NR_CFRA *cfra = CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra;
|
||||
uint8_t num_preamble = cfra->resources.choice.ssb->ssb_ResourceList.list.count;
|
||||
AssertFatal(ra->preambles.num_preambles == 0 && ra->preambles.preamble_list == NULL,
|
||||
"preamble_list already configured means logic bug, list is allocated here\n");
|
||||
ra->preambles.num_preambles = num_preamble;
|
||||
ra->preambles.preamble_list = calloc(ra->preambles.num_preambles, sizeof(*ra->preambles.preamble_list));
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
ra->msg3_dcch_dtch = false;
|
||||
LOG_I(NR_MAC,"Added new RA process for UE RNTI %04x with initial CellGroup\n", rnti);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nr_mac_update_cellgroup(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup)
|
||||
{
|
||||
DevAssert(nrmac != NULL);
|
||||
DevAssert(CellGroup != NULL);
|
||||
|
||||
NR_UE_info_t *UE = find_nr_UE(&nrmac->UE_info, rnti);
|
||||
AssertFatal(UE != NULL, "Can't find UE %04x for CellGroup update\n", rnti);
|
||||
|
||||
/* copy CellGroup by calling asn1c encode this is a temporary hack to avoid the gNB having a pointer to RRC CellGroup structure
|
||||
* (otherwise it would be applied to early)
|
||||
* TODO remove once we have a proper implementation */
|
||||
UE->enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)CellGroup, UE->cg_buf, 32768);
|
||||
|
||||
if (UE->enc_rval.encoded == -1) {
|
||||
LOG_E(NR_MAC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", UE->enc_rval.failed_type->name, UE->enc_rval.encoded);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
process_CellGroup(CellGroup, &UE->UE_sched_ctrl);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -47,17 +47,17 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP,
|
||||
NR_SubcarrierSpacing_t subcarrierSpacing,
|
||||
uint32_t rrc_reconfiguration_delay);
|
||||
|
||||
int rrc_mac_config_req_gNB(module_id_t Mod_idP,
|
||||
rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts,
|
||||
int pusch_AntennaPorts,
|
||||
int sib1_tda,
|
||||
int minRXTXTIMEpdsch,
|
||||
NR_ServingCellConfigCommon_t *scc,
|
||||
NR_BCCH_BCH_Message_t *mib,
|
||||
NR_BCCH_DL_SCH_Message_t *sib1,
|
||||
int add_ue,
|
||||
uint32_t rnti,
|
||||
NR_CellGroupConfig_t *CellGroup);
|
||||
void nr_mac_config_scc(gNB_MAC_INST *nrmac,
|
||||
rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts,
|
||||
int pusch_AntennaPorts,
|
||||
int sib1_tda,
|
||||
int minRXTXTIMEpdsch,
|
||||
NR_ServingCellConfigCommon_t *scc);
|
||||
void nr_mac_config_mib(gNB_MAC_INST *nrmac, NR_BCCH_BCH_Message_t *mib);
|
||||
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);
|
||||
|
||||
void clear_nr_nfapi_information(gNB_MAC_INST * gNB,
|
||||
int CC_idP,
|
||||
|
||||
@@ -101,20 +101,8 @@ int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *
|
||||
AssertFatal(dec_rval.code == RC_OK, "could not decode masterCellGroup\n");
|
||||
|
||||
/* there might be a memory leak for the cell group if we call this multiple
|
||||
* times. Also, the first parameters of rrc_mac_config_req_gNB() are only
|
||||
* relevant when setting the scc, which we don't do (and cannot do) here. */
|
||||
rrc_pdsch_AntennaPorts_t pap = {0};
|
||||
rrc_mac_config_req_gNB(module_id,
|
||||
pap, /* only when scc != NULL */
|
||||
0, /* only when scc != NULL */
|
||||
0, /* only when scc != NULL */
|
||||
0, /* only when scc != NULL */
|
||||
NULL, /* scc */
|
||||
NULL, /* mib */
|
||||
NULL, /* sib1 */
|
||||
0, /* add_ue */
|
||||
dl_rrc->rnti,
|
||||
cellGroup);
|
||||
* times. */
|
||||
nr_mac_update_cellgroup(RC.nrmac[module_id], dl_rrc->rnti, cellGroup);
|
||||
|
||||
/* TODO: drop the RRC context */
|
||||
gNB_RRC_INST *rrc = RC.nrrrc[module_id];
|
||||
|
||||
+25
-91
@@ -176,17 +176,16 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration
|
||||
LOG_I(NR_RRC,"Done init_NR_SI\n");
|
||||
|
||||
if (NODE_IS_MONOLITHIC(rrc->node_type) || NODE_IS_DU(rrc->node_type)){
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
rrc->carrier.servingcellconfigcommon,
|
||||
&rrc->carrier.mib,
|
||||
rrc->carrier.siblock1,
|
||||
0,
|
||||
0, // WIP hardcoded rnti
|
||||
NULL);
|
||||
// update SI info
|
||||
nr_mac_config_scc(RC.nrmac[rrc->module_id],
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
rrc->carrier.servingcellconfigcommon);
|
||||
nr_mac_config_mib(RC.nrmac[rrc->module_id], &rrc->carrier.mib);
|
||||
if (get_softmodem_params()->sa)
|
||||
nr_mac_config_sib1(RC.nrmac[rrc->module_id], rrc->carrier.siblock1);
|
||||
}
|
||||
|
||||
/* set flag to indicate that cell information is configured. This is required
|
||||
@@ -306,17 +305,7 @@ unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP)
|
||||
static void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP)
|
||||
{
|
||||
NR_CellGroupConfig_t *cgc = get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL;
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
ue_context_pP->ue_context.rnti,
|
||||
cgc);
|
||||
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, cgc);
|
||||
|
||||
nr_rrc_rlc_config_asn1_req(ctxt_pP,
|
||||
ue_context_pP->ue_context.SRB_configList,
|
||||
@@ -327,17 +316,7 @@ static void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const u
|
||||
|
||||
void apply_macrlc_config_reest(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP, ue_id_t ue_id)
|
||||
{
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
ue_id,
|
||||
get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL);
|
||||
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, ue_context_pP->ue_context.masterCellGroup);
|
||||
|
||||
nr_rrc_rlc_config_asn1_req(ctxt_pP,
|
||||
ue_context_pP->ue_context.SRB_configList,
|
||||
@@ -430,17 +409,15 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protoc
|
||||
PROTOCOL_NR_RRC_CTXT_UE_FMT" RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n",
|
||||
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
|
||||
|
||||
rrc_mac_config_req_gNB(rrc_instance_p->module_id,
|
||||
rrc_instance_p->configuration.pdsch_AntennaPorts,
|
||||
rrc_instance_p->configuration.pusch_AntennaPorts,
|
||||
rrc_instance_p->configuration.sib1_tda,
|
||||
rrc_instance_p->configuration.minRXTXTIME,
|
||||
rrc_instance_p->carrier.servingcellconfigcommon,
|
||||
&rrc_instance_p->carrier.mib,
|
||||
rrc_instance_p->carrier.siblock1,
|
||||
0,
|
||||
ue_context_pP->ue_context.rnti,
|
||||
NULL);
|
||||
// update SCC and MIB/SIB (two calls)
|
||||
nr_mac_config_scc(RC.nrmac[rrc_instance_p->module_id],
|
||||
rrc_instance_p->configuration.pdsch_AntennaPorts,
|
||||
rrc_instance_p->configuration.pusch_AntennaPorts,
|
||||
rrc_instance_p->configuration.sib1_tda,
|
||||
rrc_instance_p->configuration.minRXTXTIME,
|
||||
rrc_instance_p->carrier.servingcellconfigcommon);
|
||||
nr_mac_config_mib(RC.nrmac[rrc_instance_p->module_id], &rrc_instance_p->carrier.mib);
|
||||
nr_mac_config_sib1(RC.nrmac[rrc_instance_p->module_id], rrc_instance_p->carrier.siblock1);
|
||||
|
||||
LOG_I(NR_RRC,
|
||||
PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n",
|
||||
@@ -639,17 +616,7 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co
|
||||
|
||||
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
|
||||
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
ue_p->rnti,
|
||||
ue_p->masterCellGroup);
|
||||
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_p->rnti, ue_p->masterCellGroup);
|
||||
|
||||
uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup &&
|
||||
ue_context_pP->ue_context.masterCellGroup->spCellConfig &&
|
||||
@@ -909,17 +876,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration(
|
||||
PDCP_TRANSMISSION_MODE_CONTROL);
|
||||
|
||||
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
ue_context_pP->ue_context.rnti,
|
||||
ue_context_pP->ue_context.masterCellGroup);
|
||||
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, ue_context_pP->ue_context.masterCellGroup);
|
||||
|
||||
uint32_t delay_ms = ue_context_pP->ue_context.masterCellGroup &&
|
||||
ue_context_pP->ue_context.masterCellGroup->spCellConfig &&
|
||||
@@ -1726,19 +1683,7 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx
|
||||
ctxt_pP->module_id,
|
||||
DCCH);
|
||||
|
||||
gNB_RrcConfigurationReq *configuration = &RC.nrrrc[ctxt_pP->module_id]->configuration;
|
||||
rrc_mac_config_req_gNB(ctxt_pP->module_id,
|
||||
configuration->pdsch_AntennaPorts,
|
||||
configuration->pusch_AntennaPorts,
|
||||
configuration->sib1_tda,
|
||||
configuration->minRXTXTIME,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
ue_context_pP->ue_context.rnti,
|
||||
cellGroupConfig);
|
||||
|
||||
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, cellGroupConfig);
|
||||
nr_rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, SDU_CONFIRM_NO, size, buffer, PDCP_TRANSMISSION_MODE_CONTROL);
|
||||
}
|
||||
|
||||
@@ -1791,18 +1736,7 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP
|
||||
NULL,
|
||||
masterCellGroup);
|
||||
|
||||
gNB_RrcConfigurationReq *configuration = &RC.nrrrc[ctxt_pP->module_id]->configuration;
|
||||
rrc_mac_config_req_gNB(ctxt_pP->module_id,
|
||||
configuration->pdsch_AntennaPorts,
|
||||
configuration->pusch_AntennaPorts,
|
||||
configuration->sib1_tda,
|
||||
configuration->minRXTXTIME,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
ue_context_pP->ue_context.rnti,
|
||||
masterCellGroup);
|
||||
nr_mac_update_cellgroup(RC.nrmac[ctxt_pP->module_id], ue_context_pP->ue_context.rnti, masterCellGroup);
|
||||
|
||||
nr_rrc_data_req(ctxt_pP,
|
||||
DCCH,
|
||||
|
||||
@@ -821,7 +821,6 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS(
|
||||
|
||||
case ngran_gNB:
|
||||
{
|
||||
// rrc_mac_config_req_gNB
|
||||
/* Transfer data to PDCP */
|
||||
nr_rrc_data_req (
|
||||
&ctxt,
|
||||
|
||||
@@ -348,31 +348,14 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_
|
||||
|
||||
rrc->Nb_ue++;
|
||||
// configure MAC and RLC
|
||||
if (NODE_IS_DU(rrc->node_type)) {
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
rrc->carrier.servingcellconfigcommon,
|
||||
&rrc->carrier.mib,
|
||||
NULL,
|
||||
1, // add_ue flag
|
||||
ue_context_p->ue_id_rnti,
|
||||
ue_context_p->ue_context.secondaryCellGroup);
|
||||
bool ret = false;
|
||||
if (get_softmodem_params()->phy_test) {
|
||||
// phytest mode: we don't set up RA, etc
|
||||
ret = nr_mac_add_test_ue(RC.nrmac[rrc->module_id], ue_context_p->ue_id_rnti, ue_context_p->ue_context.secondaryCellGroup);
|
||||
} else {
|
||||
rrc_mac_config_req_gNB(rrc->module_id,
|
||||
rrc->configuration.pdsch_AntennaPorts,
|
||||
rrc->configuration.pusch_AntennaPorts,
|
||||
rrc->configuration.sib1_tda,
|
||||
rrc->configuration.minRXTXTIME,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
1, // add_ue flag
|
||||
ue_context_p->ue_id_rnti,
|
||||
ue_context_p->ue_context.secondaryCellGroup);
|
||||
ret = nr_mac_prepare_ra_nsa_ue(RC.nrmac[rrc->module_id], ue_context_p->ue_id_rnti, ue_context_p->ue_context.secondaryCellGroup);
|
||||
}
|
||||
AssertFatal(ret, "cannot add NSA UE in MAC, aborting\n");
|
||||
|
||||
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, rrc->module_id, GNB_FLAG_YES, ue_context_p->ue_id_rnti, 0, 0, rrc->module_id);
|
||||
if (get_softmodem_params()->do_ra) ctxt.enb_flag = 0;
|
||||
|
||||
Reference in New Issue
Block a user