Commit 14caab46 authored by laurent's avatar laurent

fix multi-UEs, and partially confusion rnti versus 5GC UE id

parent c1aec063
...@@ -958,13 +958,13 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, ...@@ -958,13 +958,13 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance,
protocol_ctxt_t ctxt; protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, instance, ENB_FLAG_YES, rnti, 0, 0, instance); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, instance, ENB_FLAG_YES, rnti, 0, 0, instance);
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[instance], rnti);
if (ue_context_p) { if (ue_context_p) {
MessageDef *msg = itti_alloc_new_message(TASK_CU_F1, 0, NGAP_UE_CONTEXT_RELEASE_COMPLETE); MessageDef *msg = itti_alloc_new_message(TASK_CU_F1, 0, NGAP_UE_CONTEXT_RELEASE_COMPLETE);
NGAP_UE_CONTEXT_RELEASE_COMPLETE(msg).gNB_ue_ngap_id = ue_context_p->ue_context.gNB_ue_ngap_id; NGAP_UE_CONTEXT_RELEASE_COMPLETE(msg).gNB_ue_ngap_id = ue_context_p->ue_context.gNB_ue_ngap_id;
itti_send_msg_to_task(TASK_NGAP, instance, msg); itti_send_msg_to_task(TASK_NGAP, instance, msg);
rrc_gNB_remove_ue_context(&ctxt, RC.nrrrc[instance], ue_context_p); rrc_gNB_remove_ue_context(RC.nrrrc[instance], ue_context_p);
} else { } else {
LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti); LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti);
} }
......
...@@ -2903,12 +2903,8 @@ void send_initial_ul_rrc_message(module_id_t module_id, ...@@ -2903,12 +2903,8 @@ void send_initial_ul_rrc_message(module_id_t module_id,
sdu_len, rnti); sdu_len, rnti);
/* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */ /* TODO REMOVE_DU_RRC: the RRC in the DU is a hack and should be taken out in the future */
if (NODE_IS_DU(RC.nrrrc[module_id]->node_type)) { if (NODE_IS_DU(RC.nrrrc[module_id]->node_type))
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_id]); rrc_gNB_create_ue_context(rnti, RC.nrrrc[module_id], rnti);
ue_context_p->ue_context.rnti = rnti;
ue_context_p->ue_context.random_ue_identity = rnti;
RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[module_id]->rrc_ue_head, ue_context_p);
}
const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon; const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon;
const NR_ServingCellConfig_t *sccd = RC.nrrrc[module_id]->configuration.scd; const NR_ServingCellConfig_t *sccd = RC.nrrrc[module_id]->configuration.scd;
......
...@@ -118,7 +118,7 @@ int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t * ...@@ -118,7 +118,7 @@ int dl_rrc_message_rrcSetup(module_id_t module_id, const f1ap_dl_rrc_message_t *
/* TODO: drop the RRC context */ /* TODO: drop the RRC context */
gNB_RRC_INST *rrc = RC.nrrrc[module_id]; gNB_RRC_INST *rrc = RC.nrrrc[module_id];
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, dl_rrc->rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, dl_rrc->rnti);
gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context;
ue_p->SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList; ue_p->SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList;
ue_p->masterCellGroup = cellGroup; ue_p->masterCellGroup = cellGroup;
......
...@@ -162,7 +162,7 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, ...@@ -162,7 +162,7 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP,
const rnti_t rntiP, const rnti_t rntiP,
const int dl_bwp_id, const int dl_bwp_id,
const int ul_bwp_id) { const int ul_bwp_id) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[module_idP], rntiP); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[module_idP], rntiP);
protocol_ctxt_t ctxt; protocol_ctxt_t ctxt;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP, 0); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, GNB_FLAG_YES, rntiP, frameP, sub_frameP, 0);
...@@ -176,7 +176,7 @@ void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, ...@@ -176,7 +176,7 @@ void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t subframeP, const sub_frame_t subframeP,
const rnti_t rntiP) { const rnti_t rntiP) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_instP], rntiP); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[Mod_instP], rntiP);
if (ue_context_p != NULL) { if (ue_context_p != NULL) {
LOG_D(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP); LOG_D(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP);
...@@ -191,7 +191,7 @@ void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP, ...@@ -191,7 +191,7 @@ void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t subframeP, const sub_frame_t subframeP,
const rnti_t rntiP) { const rnti_t rntiP) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_instP], rntiP); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[Mod_instP], rntiP);
if (ue_context_p != NULL) { if (ue_context_p != NULL) {
LOG_W(RRC,"Frame %d, Subframe %d: UE %x UL failure reset, deactivating timer\n",frameP,subframeP,rntiP); LOG_W(RRC,"Frame %d, Subframe %d: UE %x UL failure reset, deactivating timer\n",frameP,subframeP,rntiP);
ue_context_p->ue_context.ul_failure_timer=0; ue_context_p->ue_context.ul_failure_timer=0;
......
...@@ -176,7 +176,7 @@ static NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_To ...@@ -176,7 +176,7 @@ static NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_To
return SRB_configList2; return SRB_configList2;
} }
static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const req, instance_t instance) { static void cucp_cuup_bearer_context_setup_direct(e1ap_bearer_setup_req_t *const req, instance_t instance) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], req->rnti); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[instance], req->rnti);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
protocol_ctxt_t ctxt = {0}; protocol_ctxt_t ctxt = {0};
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, UE->rnti, 0, 0, 0); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, UE->rnti, 0, 0, 0);
......
...@@ -163,12 +163,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP ...@@ -163,12 +163,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP
const int dl_bwp_id, const int dl_bwp_id,
const int ul_bwp_id); const int ul_bwp_id);
int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
const uint8_t *buffer,
int buffer_length,
const uint8_t *du_to_cu_rrc_container,
int du_to_cu_rrc_container_length);
void void
rrc_gNB_generate_dedicatedRRCReconfiguration_release( rrc_gNB_generate_dedicatedRRCReconfiguration_release(
const protocol_ctxt_t *const ctxt_pP, const protocol_ctxt_t *const ctxt_pP,
......
...@@ -196,7 +196,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration ...@@ -196,7 +196,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration
pthread_mutex_unlock(&rrc->cell_info_mutex); pthread_mutex_unlock(&rrc->cell_info_mutex);
if (get_softmodem_params()->phy_test > 0 || get_softmodem_params()->do_ra > 0) { if (get_softmodem_params()->phy_test > 0 || get_softmodem_params()->do_ra > 0) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_allocate_new_UE_context(rrc); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_allocate_new_ue_context(rrc);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
UE->spCellConfig = calloc(1, sizeof(struct NR_SpCellConfig)); UE->spCellConfig = calloc(1, sizeof(struct NR_SpCellConfig));
UE->spCellConfig->spCellConfigDedicated = configuration->scd; UE->spCellConfig->spCellConfigDedicated = configuration->scd;
...@@ -344,27 +344,21 @@ void apply_macrlc_config_reest(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue ...@@ -344,27 +344,21 @@ void apply_macrlc_config_reest(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void rrc_gNB_generate_RRCSetup(const protocol_ctxt_t *const ctxt_pP, static void rrc_gNB_generate_RRCSetup(instance_t instance,
rnti_t rnti,
rrc_gNB_ue_context_t *const ue_context_pP, rrc_gNB_ue_context_t *const ue_context_pP,
const uint8_t *masterCellGroup, const uint8_t *masterCellGroup,
int masterCellGroup_len, int masterCellGroup_len,
NR_ServingCellConfigCommon_t *scc) NR_ServingCellConfigCommon_t *scc)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup for RNTI %04lx\n", ctxt_pP->rntiMaybeUEid); LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup for RNTI %04x\n", rnti);
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; gNB_RRC_INST *rrc = RC.nrrrc[instance];
unsigned char buf[1024]; unsigned char buf[1024];
const NR_ServingCellConfig_t *sccd = rrc->configuration.scd; const NR_ServingCellConfig_t *sccd = rrc->configuration.scd;
int size = do_RRCSetup(ue_context_pP, int size = do_RRCSetup(ue_context_pP, buf, rrc_gNB_get_next_transaction_identifier(instance), masterCellGroup, masterCellGroup_len, scc, sccd, &rrc->configuration);
buf,
rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id),
masterCellGroup,
masterCellGroup_len,
scc,
sccd,
&rrc->configuration);
AssertFatal(size > 0, "do_RRCSetup failed\n"); AssertFatal(size > 0, "do_RRCSetup failed\n");
AssertFatal(size <= 1024, "memory corruption\n"); AssertFatal(size <= 1024, "memory corruption\n");
...@@ -379,7 +373,7 @@ static void rrc_gNB_generate_RRCSetup(const protocol_ctxt_t *const ctxt_pP, ...@@ -379,7 +373,7 @@ static void rrc_gNB_generate_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
ue_context_pP->ue_context.ue_release_timer_thres = 1000; ue_context_pP->ue_context.ue_release_timer_thres = 1000;
/* TODO: this should go through the E1 interface */ /* TODO: this should go through the E1 interface */
nr_pdcp_add_srbs(ctxt_pP->enb_flag, ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.SRB_configList, 0, NULL, NULL); nr_pdcp_add_srbs(true, rnti, ue_context_pP->ue_context.SRB_configList, 0, NULL, NULL);
f1ap_dl_rrc_message_t dl_rrc = { f1ap_dl_rrc_message_t dl_rrc = {
.old_gNB_DU_ue_id = 0xFFFFFF, .old_gNB_DU_ue_id = 0xFFFFFF,
...@@ -388,31 +382,24 @@ static void rrc_gNB_generate_RRCSetup(const protocol_ctxt_t *const ctxt_pP, ...@@ -388,31 +382,24 @@ static void rrc_gNB_generate_RRCSetup(const protocol_ctxt_t *const ctxt_pP,
.rnti = ue_p->rnti, .rnti = ue_p->rnti,
.srb_id = CCCH .srb_id = CCCH
}; };
rrc->mac_rrc.dl_rrc_message_transfer(ctxt_pP->module_id, &dl_rrc); rrc->mac_rrc.dl_rrc_message_transfer(instance, &dl_rrc);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protocol_ctxt_t *const ctxt_pP, const int CC_id) static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t module_id, rnti_t rnti, const int CC_id)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
LOG_I(NR_RRC, "generate RRCSetup for RRCReestablishmentRequest \n"); LOG_I(NR_RRC, "generate RRCSetup for RRCReestablishmentRequest \n");
rrc_gNB_ue_context_t *ue_context_pP = NULL; rrc_gNB_ue_context_t *ue_context_pP = NULL;
gNB_RRC_INST *rrc_instance_p = RC.nrrrc[ctxt_pP->module_id]; gNB_RRC_INST *rrc_instance_p = RC.nrrrc[module_id];
const NR_ServingCellConfigCommon_t *scc=rrc_instance_p->carrier.servingcellconfigcommon; const NR_ServingCellConfigCommon_t *scc=rrc_instance_p->carrier.servingcellconfigcommon;
const NR_ServingCellConfig_t *sccd = rrc_instance_p->configuration.scd; const NR_ServingCellConfig_t *sccd = rrc_instance_p->configuration.scd;
ue_context_pP = rrc_gNB_create_ue_context(ctxt_pP, rrc_instance_p, 0); ue_context_pP = rrc_gNB_create_ue_context(rnti, rrc_instance_p, 0);
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
unsigned char buf[1024]; unsigned char buf[1024];
int size = do_RRCSetup(ue_context_pP, int size = do_RRCSetup(ue_context_pP, buf, rrc_gNB_get_next_transaction_identifier(module_id), NULL, 0, scc, sccd, &rrc_instance_p->configuration);
buf,
rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id),
NULL,
0,
scc,
sccd,
&rrc_instance_p->configuration);
AssertFatal(size > 0, "do_RRCSetup failed\n"); AssertFatal(size > 0, "do_RRCSetup failed\n");
AssertFatal(size <= 1024, "memory corruption\n"); AssertFatal(size <= 1024, "memory corruption\n");
...@@ -423,9 +410,7 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protoc ...@@ -423,9 +410,7 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protoc
size, size,
"[MSG] RRC Setup\n"); "[MSG] RRC Setup\n");
LOG_D(NR_RRC, LOG_D(NR_RRC, "RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB for rnti %04x\n", rnti);
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_mac_config_req_gNB(rrc_instance_p->module_id,
rrc_instance_p->configuration.pdsch_AntennaPorts, rrc_instance_p->configuration.pdsch_AntennaPorts,
...@@ -436,19 +421,18 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protoc ...@@ -436,19 +421,18 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protoc
&rrc_instance_p->carrier.mib, &rrc_instance_p->carrier.mib,
rrc_instance_p->carrier.siblock1, rrc_instance_p->carrier.siblock1,
0, 0,
ue_context_pP->ue_context.rnti, rnti,
NULL); NULL);
LOG_I(NR_RRC, LOG_I(NR_RRC, " [RAPROC] rnti: %04x Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n", rnti, size);
PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
size);
// activate release timer, if RRCSetupComplete not received after 100 frames, remove UE // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE
ue_context_pP->ue_context.ue_release_timer = 1; ue_context_pP->ue_context.ue_release_timer = 1;
// remove UE after 10 frames after RRCConnectionRelease is triggered // remove UE after 10 frames after RRCConnectionRelease is triggered
ue_context_pP->ue_context.ue_release_timer_thres = 1000; ue_context_pP->ue_context.ue_release_timer_thres = 1000;
// configure MAC // configure MAC
apply_macrlc_config(rrc_instance_p,ue_context_pP,ctxt_pP); protocol_ctxt_t ctxt = {0};
PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, 0, GNB_FLAG_YES, rnti, 0, 0);
apply_macrlc_config(rrc_instance_p, ue_context_pP, &ctxt);
//nr_pdcp_add_srbs(ctxt_pP->enb_flag, ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.SRB_configList, 0, NULL, NULL); //nr_pdcp_add_srbs(ctxt_pP->enb_flag, ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.SRB_configList, 0, NULL, NULL);
//apply_pdcp_config(ue_context_pP,ctxt_pP); //apply_pdcp_config(ue_context_pP,ctxt_pP);
...@@ -462,18 +446,18 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protoc ...@@ -462,18 +446,18 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(const protoc
.rnti = ue_p->rnti, .rnti = ue_p->rnti,
.srb_id = CCCH .srb_id = CCCH
}; };
rrc_instance_p->mac_rrc.dl_rrc_message_transfer(ctxt_pP->module_id, &dl_rrc); rrc_instance_p->mac_rrc.dl_rrc_message_transfer(module_id, &dl_rrc);
} }
static void rrc_gNB_generate_RRCReject(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP) static void rrc_gNB_generate_RRCReject(module_id_t module_id, rrc_gNB_ue_context_t *const ue_context_pP)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
LOG_I(NR_RRC, "rrc_gNB_generate_RRCReject \n"); LOG_I(NR_RRC, "rrc_gNB_generate_RRCReject \n");
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; gNB_RRC_INST *rrc = RC.nrrrc[module_id];
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
unsigned char buf[1024]; unsigned char buf[1024];
int size = do_RRCReject(ctxt_pP->module_id, buf); int size = do_RRCReject(module_id, buf);
AssertFatal(size > 0, "do_RRCReject failed\n"); AssertFatal(size > 0, "do_RRCReject failed\n");
AssertFatal(size <= 1024, "memory corruption\n"); AssertFatal(size <= 1024, "memory corruption\n");
...@@ -481,10 +465,7 @@ static void rrc_gNB_generate_RRCReject(const protocol_ctxt_t *const ctxt_pP, rrc ...@@ -481,10 +465,7 @@ static void rrc_gNB_generate_RRCReject(const protocol_ctxt_t *const ctxt_pP, rrc
(char *)buf, (char *)buf,
size, size,
"[MSG] RRCReject \n"); "[MSG] RRCReject \n");
LOG_I(NR_RRC, LOG_I(NR_RRC, " [RAPROC] ue %04x Logical Channel DL-CCCH, Generating NR_RRCReject (bytes %d)\n", ue_p->rnti, size);
PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating NR_RRCReject (bytes %d)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
size);
f1ap_dl_rrc_message_t dl_rrc = { f1ap_dl_rrc_message_t dl_rrc = {
.gNB_CU_ue_id = 0, .gNB_CU_ue_id = 0,
...@@ -497,7 +478,7 @@ static void rrc_gNB_generate_RRCReject(const protocol_ctxt_t *const ctxt_pP, rrc ...@@ -497,7 +478,7 @@ static void rrc_gNB_generate_RRCReject(const protocol_ctxt_t *const ctxt_pP, rrc
.execute_duplication = 1, .execute_duplication = 1,
.RAT_frequency_priority_information.en_dc = 0 .RAT_frequency_priority_information.en_dc = 0
}; };
rrc->mac_rrc.dl_rrc_message_transfer(ctxt_pP->module_id, &dl_rrc); rrc->mac_rrc.dl_rrc_message_transfer(module_id, &dl_rrc);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -525,6 +506,7 @@ static void rrc_gNB_process_RRCSetupComplete(const protocol_ctxt_t *const ctxt_p ...@@ -525,6 +506,7 @@ static void rrc_gNB_process_RRCSetupComplete(const protocol_ctxt_t *const ctxt_p
static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP) static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id);
/******************** Radio Bearer Config ********************/ /******************** Radio Bearer Config ********************/
...@@ -554,7 +536,6 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co ...@@ -554,7 +536,6 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co
dedicatedNAS_MessageList = NULL; dedicatedNAS_MessageList = NULL;
} }
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
NR_MeasConfig_t *measconfig = get_defaultMeasConfig(&rrc->configuration); NR_MeasConfig_t *measconfig = get_defaultMeasConfig(&rrc->configuration);
uint8_t buffer[RRC_BUF_SIZE] = {0}; uint8_t buffer[RRC_BUF_SIZE] = {0};
...@@ -1112,12 +1093,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( ...@@ -1112,12 +1093,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release(
/* /*
* Process the RRC Reconfiguration Complete from the UE * Process the RRC Reconfiguration Complete from the UE
*/ */
void static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP, const uint8_t xid)
rrc_gNB_process_RRCReconfigurationComplete(
const protocol_ctxt_t *const ctxt_pP,
rrc_gNB_ue_context_t *ue_context_pP,
const uint8_t xid
)
{ {
int drb_id; int drb_id;
uint8_t *kRRCenc = NULL; uint8_t *kRRCenc = NULL;
...@@ -1309,7 +1285,7 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1309,7 +1285,7 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
scc, scc,
&rrc->carrier); &rrc->carrier);
LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " [RAPROC] Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), size); LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", ue_p->rnti, size);
#if (0) #if (0)
/* TODO : It may be needed if gNB goes into full stack working. */ /* TODO : It may be needed if gNB goes into full stack working. */
UE = find_nr_UE(module_id, rnti); UE = find_nr_UE(module_id, rnti);
...@@ -1319,7 +1295,7 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1319,7 +1295,7 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
/* Reject UE after 10 frames, NR_RRCReestablishmentReject is triggered */ /* Reject UE after 10 frames, NR_RRCReestablishmentReject is triggered */
RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 100; RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 100;
} else { } else {
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " Generating NR_RRCReestablishment without UE_id(MAC) rnti %x\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), rnti); LOG_E(NR_RRC, " Generating NR_RRCReestablishment without UE_id(MAC) rnti %x\n", rnti);
} }
#endif #endif
...@@ -1345,7 +1321,7 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1345,7 +1321,7 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
NULL, NULL,
NULL); NULL);
} }
LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); LOG_D(NR_RRC, "UE %04x --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n", ue_p->rnti);
} }
} // if (*SRB_configList != NULL) } // if (*SRB_configList != NULL)
...@@ -1370,10 +1346,8 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP, ...@@ -1370,10 +1346,8 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctxt_pP, const rnti_t reestablish_rnti, rrc_gNB_ue_context_t *ue_context_pP, const uint8_t xid) void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctxt_pP, const rnti_t reestablish_rnti, rrc_gNB_ue_context_t *ue_context_pP, const uint8_t xid)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
LOG_I(NR_RRC,
PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, processing NR_RRCReestablishmentComplete from UE (SRB1 Active)\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel UL-DCCH, processing NR_RRCReestablishmentComplete from UE (SRB1 Active)\n", ue_p->rnti);
NR_DRB_ToAddModList_t *DRB_configList = ue_p->DRB_configList; NR_DRB_ToAddModList_t *DRB_configList = ue_p->DRB_configList;
NR_SRB_ToAddModList_t *SRB_configList = ue_p->SRB_configList; NR_SRB_ToAddModList_t *SRB_configList = ue_p->SRB_configList;
...@@ -1665,26 +1639,20 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP ...@@ -1665,26 +1639,20 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP
} }
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, static int nr_rrc_gNB_decode_ccch(module_id_t module_id, rnti_t rnti, const uint8_t *buffer, int buffer_length, const uint8_t *du_to_cu_rrc_container, int du_to_cu_rrc_container_len)
const uint8_t *buffer,
int buffer_length,
const uint8_t *du_to_cu_rrc_container,
int du_to_cu_rrc_container_len)
{ {
module_id_t Idx; module_id_t Idx;
asn_dec_rval_t dec_rval; asn_dec_rval_t dec_rval;
NR_UL_CCCH_Message_t *ul_ccch_msg = NULL; NR_UL_CCCH_Message_t *ul_ccch_msg = NULL;
gNB_RRC_INST *gnb_rrc_inst = RC.nrrrc[ctxt_pP->module_id]; gNB_RRC_INST *gnb_rrc_inst = RC.nrrrc[module_id];
NR_RRCSetupRequest_IEs_t *rrcSetupRequest = NULL; NR_RRCSetupRequest_IEs_t *rrcSetupRequest = NULL;
NR_RRCReestablishmentRequest_IEs_t rrcReestablishmentRequest; NR_RRCReestablishmentRequest_IEs_t rrcReestablishmentRequest;
LOG_I(NR_RRC, "Decoding CCCH: RNTI %04lx, inst %ld, payload_size %d\n", ctxt_pP->rntiMaybeUEid, ctxt_pP->instance, buffer_length); LOG_I(NR_RRC, "Decoding CCCH: RNTI %04x, payload_size %d\n", rnti, buffer_length);
dec_rval = uper_decode(NULL, &asn_DEF_NR_UL_CCCH_Message, (void **) &ul_ccch_msg, buffer, buffer_length, 0, 0); dec_rval = uper_decode(NULL, &asn_DEF_NR_UL_CCCH_Message, (void **) &ul_ccch_msg, buffer, buffer_length, 0, 0);
if (dec_rval.code != RC_OK || dec_rval.consumed == 0) { if (dec_rval.code != RC_OK || dec_rval.consumed == 0) {
LOG_E(NR_RRC, LOG_E(NR_RRC, " FATAL Error in receiving CCCH\n");
PROTOCOL_NR_RRC_CTXT_UE_FMT" FATAL Error in receiving CCCH\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
return -1; return -1;
} }
...@@ -1692,16 +1660,15 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1692,16 +1660,15 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
switch (ul_ccch_msg->message.choice.c1->present) { switch (ul_ccch_msg->message.choice.c1->present) {
case NR_UL_CCCH_MessageType__c1_PR_NOTHING: case NR_UL_CCCH_MessageType__c1_PR_NOTHING:
/* TODO */ /* TODO */
LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT " Received PR_NOTHING on UL-CCCH-Message\n", PROTOCOL_NR_RRC_CTXT_ARGS(ctxt_pP)); LOG_I(NR_RRC, "Received PR_NOTHING on UL-CCCH-Message\n");
break; break;
case NR_UL_CCCH_MessageType__c1_PR_rrcSetupRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcSetupRequest:
LOG_D(NR_RRC, "Received RRCSetupRequest on UL-CCCH-Message (UE rnti %lx)\n", ctxt_pP->rntiMaybeUEid); LOG_D(NR_RRC, "Received RRCSetupRequest on UL-CCCH-Message (UE rnti %04x)\n", rnti);
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(gnb_rrc_inst, rnti);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
if (ue_context_p != NULL) { if (ue_context_p != NULL) {
LOG_W(NR_RRC, "Got RRC setup request for a already registered RNTI %x, dropping the old one\n", UE->rnti); LOG_W(NR_RRC, "Got RRC setup request for a already registered RNTI %x, dropping the old one and give up this rrcSetupRequest\n", ue_context_p->ue_context.rnti);
rrc_gNB_free_mem_UE_context(ctxt_pP, ue_context_p); rrc_gNB_remove_ue_context(gnb_rrc_inst, ue_context_p);
} else { } else {
rrcSetupRequest = &ul_ccch_msg->message.choice.c1->choice.rrcSetupRequest->rrcSetupRequest; rrcSetupRequest = &ul_ccch_msg->message.choice.c1->choice.rrcSetupRequest->rrcSetupRequest;
if (NR_InitialUE_Identity_PR_randomValue == rrcSetupRequest->ue_Identity.present) { if (NR_InitialUE_Identity_PR_randomValue == rrcSetupRequest->ue_Identity.present) {
...@@ -1716,13 +1683,13 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1716,13 +1683,13 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
/* if there is already a registered UE (with another RNTI) with this random_value, /* if there is already a registered UE (with another RNTI) with this random_value,
* the current one must be removed from MAC/PHY (zombie UE) * the current one must be removed from MAC/PHY (zombie UE)
*/ */
if ((ue_context_p = rrc_gNB_ue_context_random_exist(RC.nrrrc[ctxt_pP->module_id], random_value))) { if ((ue_context_p = rrc_gNB_ue_context_random_exist(gnb_rrc_inst, random_value))) {
UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
LOG_W(NR_RRC, "new UE rnti %lx (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", ctxt_pP->rntiMaybeUEid, UE->rnti, UE->rnti); LOG_W(NR_RRC, "new UE rnti (coming with random value) is already there, removing UE %x from MAC/PHY\n", rnti);
UE->ul_failure_timer = 20000; UE->ul_failure_timer = 20000;
} }
ue_context_p = rrc_gNB_create_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], random_value); ue_context_p = rrc_gNB_create_ue_context(rnti, gnb_rrc_inst, random_value);
} else if (NR_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1 == rrcSetupRequest->ue_Identity.present) { } else if (NR_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1 == rrcSetupRequest->ue_Identity.present) {
/* TODO */ /* TODO */
/* <5G-S-TMSI> = <AMF Set ID><AMF Pointer><5G-TMSI> 48-bit */ /* <5G-S-TMSI> = <AMF Set ID><AMF Pointer><5G-TMSI> 48-bit */
...@@ -1738,20 +1705,16 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1738,20 +1705,16 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
// rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.buf, // rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.buf,
// rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.size); // rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.size);
if ((ue_context_p = rrc_gNB_ue_context_5g_s_tmsi_exist(RC.nrrrc[ctxt_pP->module_id], s_tmsi_part1))) { if ((ue_context_p = rrc_gNB_ue_context_5g_s_tmsi_exist(gnb_rrc_inst, s_tmsi_part1))) {
UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
LOG_I(NR_RRC, " 5G-S-TMSI-Part1 exists, ue_context_p %p, old rnti %x => %lx\n", ue_context_p, UE->rnti, ctxt_pP->rntiMaybeUEid); LOG_I(NR_RRC, " 5G-S-TMSI-Part1 exists, old rnti %04x => %04x\n", UE->rnti, rnti);
// TODO: MAC structures should not be accessed directly from the RRC! An implementation using the F1 interface should be developed. // TODO: MAC structures should not be accessed directly from the RRC! An implementation using the F1 interface should be developed.
gNB_MAC_INST *nrmac = RC.nrmac[ctxt_pP->module_id]; // WHAT A BEAUTIFULL RACE CONDITION !!! gNB_MAC_INST *nrmac = RC.nrmac[module_id]; // why MAC instances match RRC instances ?
mac_remove_nr_ue(nrmac, UE->rnti); mac_remove_nr_ue(nrmac, UE->rnti);
/* replace rnti in the context */ /* replace rnti in the context */
/* for that, remove the context from the RB tree */ UE->rnti = rnti;
RB_REMOVE(rrc_nr_ue_tree_s, &RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
/* and insert again, after changing rnti everywhere it has to be changed */
UE->rnti = ctxt_pP->rntiMaybeUEid;
RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p);
/* reset timers */ /* reset timers */
UE->ul_failure_timer = 0; UE->ul_failure_timer = 0;
UE->ue_release_timer = 0; UE->ue_release_timer = 0;
...@@ -1759,32 +1722,33 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1759,32 +1722,33 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
UE->ue_release_timer_s1 = 0; UE->ue_release_timer_s1 = 0;
UE->ue_release_timer_rrc = 0; UE->ue_release_timer_rrc = 0;
} else { } else {
LOG_I(NR_RRC, " 5G-S-TMSI-Part1 doesn't exist, setting ng_5G_S_TMSI_Part1 to %p => %ld\n", ue_context_p, s_tmsi_part1); LOG_I(NR_RRC, "UE %04x 5G-S-TMSI-Part1 doesn't exist, setting ng_5G_S_TMSI_Part1 => %ld\n", rnti, s_tmsi_part1);
ue_context_p = rrc_gNB_create_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], s_tmsi_part1); ue_context_p = rrc_gNB_create_ue_context(rnti, gnb_rrc_inst, s_tmsi_part1);
if (ue_context_p == NULL) { if (ue_context_p == NULL) {
LOG_E(NR_RRC, "%s:%d:%s: rrc_gNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(NR_RRC, "rrc_gNB_get_next_free_ue_context returned NULL\n");
return -1; return -1;
} }
UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
UE->Initialue_identity_5g_s_TMSI.presence = true; UE->Initialue_identity_5g_s_TMSI.presence = true;
UE->ng_5G_S_TMSI_Part1 = s_tmsi_part1; UE->ng_5G_S_TMSI_Part1 = s_tmsi_part1;
} }
} else { } else {
/* TODO */ /* TODO */
uint64_t random_value = 0; uint64_t random_value = 0;
memcpy(((uint8_t *)&random_value) + 3, rrcSetupRequest->ue_Identity.choice.randomValue.buf, rrcSetupRequest->ue_Identity.choice.randomValue.size); memcpy(((uint8_t *)&random_value) + 3, rrcSetupRequest->ue_Identity.choice.randomValue.buf, rrcSetupRequest->ue_Identity.choice.randomValue.size);
rrc_gNB_create_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], random_value); ue_context_p = rrc_gNB_create_ue_context(rnti, gnb_rrc_inst, random_value);
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " RRCSetupRequest without random UE identity or S-TMSI not supported, let's reject the UE\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); LOG_E(NR_RRC, "RRCSetupRequest without random UE identity or S-TMSI not supported, let's reject the UE %04x\n", rnti);
rrc_gNB_generate_RRCReject(ctxt_pP, rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid)); rrc_gNB_generate_RRCReject(module_id, ue_context_p);
break; break;
} }
UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
UE = &ue_context_p->ue_context;
UE->establishment_cause = rrcSetupRequest->establishmentCause; UE->establishment_cause = rrcSetupRequest->establishmentCause;
rrc_gNB_generate_RRCSetup( rrc_gNB_generate_RRCSetup(
ctxt_pP, rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid), du_to_cu_rrc_container, du_to_cu_rrc_container_len, gnb_rrc_inst->carrier.servingcellconfigcommon); module_id, rnti, rrc_gNB_get_ue_context_by_rnti(gnb_rrc_inst, rnti), du_to_cu_rrc_container, du_to_cu_rrc_container_len, gnb_rrc_inst->carrier.servingcellconfigcommon);
} }
break; break;
...@@ -1793,30 +1757,28 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1793,30 +1757,28 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
break; break;
case NR_UL_CCCH_MessageType__c1_PR_rrcReestablishmentRequest: { case NR_UL_CCCH_MessageType__c1_PR_rrcReestablishmentRequest: {
LOG_I(NR_RRC, "Received rrcReestablishmentRequest message\n");
LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)(buffer), buffer_length, "[MSG] RRC Reestablishment Request\n"); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)(buffer), buffer_length, "[MSG] RRC Reestablishment Request\n");
LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT "MAC_gNB--- MAC_DATA_IND (rrcReestablishmentRequest on SRB0) --> RRC_gNB\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
rrcReestablishmentRequest = ul_ccch_msg->message.choice.c1->choice.rrcReestablishmentRequest->rrcReestablishmentRequest; rrcReestablishmentRequest = ul_ccch_msg->message.choice.c1->choice.rrcReestablishmentRequest->rrcReestablishmentRequest;
const NR_ReestablishmentCause_t cause = rrcReestablishmentRequest.reestablishmentCause;
const long physCellId = rrcReestablishmentRequest.ue_Identity.physCellId;
LOG_I(NR_RRC, LOG_I(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT " NR_RRCReestablishmentRequest cause %s\n", "UE %04x NR_RRCReestablishmentRequest cause %s\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), rnti,
((rrcReestablishmentRequest.reestablishmentCause == NR_ReestablishmentCause_otherFailure) ? "Other Failure" ((cause == NR_ReestablishmentCause_otherFailure) ? "Other Failure"
: (rrcReestablishmentRequest.reestablishmentCause == NR_ReestablishmentCause_handoverFailure) ? "Handover Failure" : (cause == NR_ReestablishmentCause_handoverFailure) ? "Handover Failure"
: "reconfigurationFailure")); : "reconfigurationFailure"));
if (rrcReestablishmentRequest.ue_Identity.physCellId != RC.nrrrc[ctxt_pP->module_id]->carrier.physCellId) { if (physCellId != gnb_rrc_inst->carrier.physCellId) {
/* UE was moving from previous cell so quickly that RRCReestablishment for previous cell was received in this cell */ /* UE was moving from previous cell so quickly that RRCReestablishment for previous cell was received in this cell */
LOG_E(NR_RRC, LOG_E(NR_RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT " NR_RRCReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), fallback to RRC establishment\n", " NR_RRCReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), physCellId,
rrcReestablishmentRequest.ue_Identity.physCellId, gnb_rrc_inst->carrier.physCellId);
RC.nrrrc[ctxt_pP->module_id]->carrier.physCellId); rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, rnti, 0);
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0);
break; break;
} }
LOG_I(NR_RRC, "physCellId: %ld\n", rrcReestablishmentRequest.ue_Identity.physCellId); LOG_I(NR_RRC, "physCellId: %ld\n", physCellId);
for (int i = 0; i < rrcReestablishmentRequest.ue_Identity.shortMAC_I.size; i++) { for (int i = 0; i < rrcReestablishmentRequest.ue_Identity.shortMAC_I.size; i++) {
LOG_D(NR_RRC, "rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[%d] = %x\n", i, rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[i]); LOG_D(NR_RRC, "rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[%d] = %x\n", i, rrcReestablishmentRequest.ue_Identity.shortMAC_I.buf[i]);
...@@ -1826,7 +1788,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1826,7 +1788,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
if (rrcReestablishmentRequest.ue_Identity.c_RNTI < 0x1 || rrcReestablishmentRequest.ue_Identity.c_RNTI > 0xffef) { if (rrcReestablishmentRequest.ue_Identity.c_RNTI < 0x1 || rrcReestablishmentRequest.ue_Identity.c_RNTI > 0xffef) {
/* c_RNTI range error should not happen */ /* c_RNTI range error should not happen */
LOG_E(NR_RRC, "NR_RRCReestablishmentRequest c_RNTI range error, fallback to RRC establishment\n"); LOG_E(NR_RRC, "NR_RRCReestablishmentRequest c_RNTI range error, fallback to RRC establishment\n");
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, rnti, 0);
break; break;
} }
...@@ -1836,17 +1798,14 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1836,17 +1798,14 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
if (ue_context_p == NULL) { if (ue_context_p == NULL) {
LOG_E(NR_RRC, "NR_RRCReestablishmentRequest without UE context, fallback to RRC establishment\n"); LOG_E(NR_RRC, "NR_RRCReestablishmentRequest without UE context, fallback to RRC establishment\n");
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, c_rnti, 0);
break; break;
} }
#if 0
#if (0) int UE_id = find_nr_UE_id(gnb_rrc_inst, c_rnti);
/* TODO : It may be needed if gNB goes into full stack working. */
int UE_id = find_nr_UE_id(ctxt_pP->module_id, c_rnti);
if (UE_id == -1) { if (UE_id == -1) {
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " NR_RRCReestablishmentRequest without UE_id(MAC) rnti %x, fallback to RRC establishment\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), c_rnti); LOG_E(NR_RRC, "NR_RRCReestablishmentRequest without MAC context, rnti %04x, fallback to RRC establishment\n", c_rnti);
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0); rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, rnti, 0);
break; break;
} }
...@@ -1861,14 +1820,11 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1861,14 +1820,11 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
} }
if (previous_rnti != 0) { if (previous_rnti != 0) {
UE_id = find_nr_UE_id(ctxt_pP->module_id, previous_rnti); UE_id = find_nr_UE_id(gnb_rrc_inst, previous_rnti);
if (UE_id == -1) { if (UE_id == -1) {
LOG_E(NR_RRC, LOG_E(NR_RRC,"RRCReestablishmentRequest without mac context previous rnti %04x, nex rnti %04x, fallback to RRC establishment\n",
PROTOCOL_NR_RRC_CTXT_UE_FMT " RRCReestablishmentRequest without UE_id(MAC) previous rnti %x, fallback to RRC establishment\n", previous_rnti, c_rnti);
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, rnti, 0);
previous_rnti);
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(ctxt_pP, 0);
break; break;
} }
} }
...@@ -1884,7 +1840,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1884,7 +1840,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
LOG_E(NR_RRC, "RRRCReconfigurationComplete(Previous) don't receive, delete the Previous UE,\nprevious Status %d, new Status NR_RRC_RECONFIGURED\n", UE->StatusRrc); LOG_E(NR_RRC, "RRRCReconfigurationComplete(Previous) don't receive, delete the Previous UE,\nprevious Status %d, new Status NR_RRC_RECONFIGURED\n", UE->StatusRrc);
UE->StatusRrc = NR_RRC_RECONFIGURED; UE->StatusRrc = NR_RRC_RECONFIGURED;
protocol_ctxt_t ctxt_old_p; protocol_ctxt_t ctxt_old_p;
PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt_old_p, ctxt_pP->instance, GNB_FLAG_YES, c_rnti, ctxt_pP->frame, ctxt_pP->subframe); PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt_old_p, module_id, GNB_FLAG_YES, c_rnti, 0, 0);
rrc_gNB_process_RRCReconfigurationComplete(&ctxt_old_p, ue_context_p, UE->reestablishment_xid); rrc_gNB_process_RRCReconfigurationComplete(&ctxt_old_p, ue_context_p, UE->reestablishment_xid);
for (uint8_t pdusessionid = 0; pdusessionid < UE->nb_of_pdusessions; pdusessionid++) { for (uint8_t pdusessionid = 0; pdusessionid < UE->nb_of_pdusessions; pdusessionid++) {
...@@ -1906,18 +1862,18 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1906,18 +1862,18 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
// Insert C-RNTI to map // Insert C-RNTI to map
for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) {
nr_reestablish_rnti_map_t *nr_reestablish_rnti_map = &(RC.nrrrc[ctxt_pP->module_id])->nr_reestablish_rnti_map[i]; nr_reestablish_rnti_map_t *nr_reestablish_rnti_map = &gnb_rrc_inst->nr_reestablish_rnti_map[i];
LOG_I(NR_RRC, "Insert nr_reestablish_rnti_map[%d] UEid: %lx, RNTI: %04x\n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti); LOG_I(NR_RRC, "Insert nr_reestablish_rnti_map[%d] UEid: %lx, RNTI: %04x\n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti);
if (nr_reestablish_rnti_map->ue_id == 0) { if (nr_reestablish_rnti_map->ue_id == 0) {
nr_reestablish_rnti_map->ue_id = ctxt_pP->rntiMaybeUEid; nr_reestablish_rnti_map->ue_id = rnti;
nr_reestablish_rnti_map->c_rnti = c_rnti; nr_reestablish_rnti_map->c_rnti = c_rnti;
LOG_I(NR_RRC, "Insert nr_reestablish_rnti_map[%d] UEid: %lx, RNTI: %04x\n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti); LOG_W(NR_RRC, "Insert nr_reestablish_rnti_map[%d] UEid: %lx, RNTI: %04x bug in UEid to fix \n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti);
break; break;
} }
} }
UE->reestablishment_cause = rrcReestablishmentRequest.reestablishmentCause; UE->reestablishment_cause = cause;
LOG_D(NR_RRC, "Accept RRCReestablishmentRequest from UE physCellId %ld cause %ld\n", rrcReestablishmentRequest.ue_Identity.physCellId, UE->reestablishment_cause); LOG_D(NR_RRC, "Accept RRCReestablishmentRequest from UE physCellId %ld cause %ld\n", physCellId, cause);
UE->primaryCC_id = 0; UE->primaryCC_id = 0;
// LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; // LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH;
...@@ -1932,20 +1888,19 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ...@@ -1932,20 +1888,19 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
UE->Srb[2].Srb_info.Srb_id = Idx; UE->Srb[2].Srb_info.Srb_id = Idx;
rrc_init_nr_srb_param(&UE->Srb[2].Srb_info.Lchan_desc[0]); rrc_init_nr_srb_param(&UE->Srb[2].Srb_info.Lchan_desc[0]);
rrc_init_nr_srb_param(&UE->Srb[2].Srb_info.Lchan_desc[1]); rrc_init_nr_srb_param(&UE->Srb[2].Srb_info.Lchan_desc[1]);
protocol_ctxt_t ctxt = {.rntiMaybeUEid = UE->rnti, .module_id = module_id, .instance = module_id, .enb_flag = 1, .eNB_index = module_id};
rrc_gNB_generate_RRCReestablishment(ctxt_pP, ue_context_p, du_to_cu_rrc_container, gnb_rrc_inst->carrier.servingcellconfigcommon, 0); rrc_gNB_generate_RRCReestablishment(&ctxt, ue_context_p, du_to_cu_rrc_container, gnb_rrc_inst->carrier.servingcellconfigcommon, 0);
LOG_I(NR_RRC, "CALLING RLC CONFIG SRB1 (rbid %d)\n", Idx); LOG_I(NR_RRC, "CALLING RLC CONFIG SRB1 (rbid %d)\n", Idx);
} break; } break;
case NR_UL_CCCH_MessageType__c1_PR_rrcSystemInfoRequest: case NR_UL_CCCH_MessageType__c1_PR_rrcSystemInfoRequest:
LOG_I(NR_RRC, "receive rrcSystemInfoRequest message \n"); LOG_I(NR_RRC, "UE %04x receive rrcSystemInfoRequest message \n", rnti);
/* TODO */ /* TODO */
break; break;
default: default:
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Unknown message\n", LOG_E(NR_RRC, "UE %04x Unknown message\n", rnti);
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
break; break;
} }
} }
...@@ -2007,21 +1962,16 @@ rrc_gNB_decode_dcch( ...@@ -2007,21 +1962,16 @@ rrc_gNB_decode_dcch(
asn_dec_rval_t dec_rval; asn_dec_rval_t dec_rval;
NR_UL_DCCH_Message_t *ul_dcch_msg = NULL; NR_UL_DCCH_Message_t *ul_dcch_msg = NULL;
uint8_t xid; uint8_t xid;
gNB_RRC_INST *gnb_rrc_inst = RC.nrrrc[ctxt_pP->module_id];
int i; int i;
if ((Srb_id != 1) && (Srb_id != 2)) { if ((Srb_id != 1) && (Srb_id != 2)) {
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Received message on SRB%ld, should not have ...\n", LOG_E(NR_RRC, "Received message on SRB%ld, should not have ...\n", Srb_id);
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
Srb_id);
} else { } else {
LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Received message on SRB%ld\n", LOG_D(NR_RRC, "Received message on SRB%ld\n", Srb_id);
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
Srb_id);
} }
LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Decoding UL-DCCH Message\n", LOG_D(NR_RRC, "Decoding UL-DCCH Message\n");
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
//for (int i=0;i<sdu_sizeP;i++) printf("%02x ",Rx_sdu[i]); //for (int i=0;i<sdu_sizeP;i++) printf("%02x ",Rx_sdu[i]);
//printf("\n"); //printf("\n");
...@@ -2048,21 +1998,17 @@ rrc_gNB_decode_dcch( ...@@ -2048,21 +1998,17 @@ rrc_gNB_decode_dcch(
} }
if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Failed to decode UL-DCCH (%zu bytes)\n", LOG_E(NR_RRC, "Failed to decode UL-DCCH (%zu bytes)\n", dec_rval.consumed);
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
dec_rval.consumed);
return -1; return -1;
} }
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
if (ul_dcch_msg->message.present == NR_UL_DCCH_MessageType_PR_c1) { if (ul_dcch_msg->message.present == NR_UL_DCCH_MessageType_PR_c1) {
switch (ul_dcch_msg->message.choice.c1->present) { switch (ul_dcch_msg->message.choice.c1->present) {
case NR_UL_DCCH_MessageType__c1_PR_NOTHING: case NR_UL_DCCH_MessageType__c1_PR_NOTHING:
LOG_I(NR_RRC, LOG_I(NR_RRC, "Received PR_NOTHING on UL-DCCH-Message\n");
PROTOCOL_NR_RRC_CTXT_FMT" Received PR_NOTHING on UL-DCCH-Message\n",
PROTOCOL_NR_RRC_CTXT_ARGS(ctxt_pP));
break; break;
case NR_UL_DCCH_MessageType__c1_PR_rrcReconfigurationComplete: case NR_UL_DCCH_MessageType__c1_PR_rrcReconfigurationComplete:
...@@ -2389,14 +2335,13 @@ rrc_gNB_decode_dcch( ...@@ -2389,14 +2335,13 @@ rrc_gNB_decode_dcch(
ul_dcch_msg); ul_dcch_msg);
} }
if(!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)){ if (!NODE_IS_CU(gnb_rrc_inst->node_type)) {
if (UE->established_pdu_sessions_flag == 1) { if (UE->established_pdu_sessions_flag == 1) {
rrc_gNB_generate_dedicatedRRCReconfiguration(ctxt_pP, ue_context_p, NULL); rrc_gNB_generate_dedicatedRRCReconfiguration(ctxt_pP, ue_context_p, NULL);
} else { } else {
rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p);
} }
} } else {
else{
/*Generate a UE context setup request message towards the DU to provide the UE /*Generate a UE context setup request message towards the DU to provide the UE
*capability info and get the updates on master cell group config from the DU*/ *capability info and get the updates on master cell group config from the DU*/
MessageDef *message_p; MessageDef *message_p;
...@@ -2406,10 +2351,10 @@ rrc_gNB_decode_dcch( ...@@ -2406,10 +2351,10 @@ rrc_gNB_decode_dcch(
req->gNB_CU_ue_id = 0; req->gNB_CU_ue_id = 0;
req->gNB_DU_ue_id = 0; req->gNB_DU_ue_id = 0;
req->rnti = UE->rnti; req->rnti = UE->rnti;
req->mcc = RC.nrrrc[ctxt_pP->module_id]->configuration.mcc[0]; req->mcc = gnb_rrc_inst->configuration.mcc[0];
req->mnc = RC.nrrrc[ctxt_pP->module_id]->configuration.mnc[0]; req->mnc = gnb_rrc_inst->configuration.mnc[0];
req->mnc_digit_length = RC.nrrrc[ctxt_pP->module_id]->configuration.mnc_digit_length[0]; req->mnc_digit_length = gnb_rrc_inst->configuration.mnc_digit_length[0];
req->nr_cellid = RC.nrrrc[ctxt_pP->module_id]->nr_cellid; req->nr_cellid = gnb_rrc_inst->nr_cellid;
if (UE->established_pdu_sessions_flag == 1) { if (UE->established_pdu_sessions_flag == 1) {
/*Instruction towards the DU for SRB2 configuration*/ /*Instruction towards the DU for SRB2 configuration*/
...@@ -2426,11 +2371,11 @@ rrc_gNB_decode_dcch( ...@@ -2426,11 +2371,11 @@ rrc_gNB_decode_dcch(
LOG_I(RRC, "Length of DRB list:%d \n", req->drbs_to_be_setup_length); LOG_I(RRC, "Length of DRB list:%d \n", req->drbs_to_be_setup_length);
DRBs[0].drb_id = 1; DRBs[0].drb_id = 1;
DRBs[0].rlc_mode = RLC_MODE_AM; DRBs[0].rlc_mode = RLC_MODE_AM;
DRBs[0].up_ul_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt_pP->module_id]->eth_params_s.my_addr); DRBs[0].up_ul_tnl[0].tl_address = inet_addr(gnb_rrc_inst->eth_params_s.my_addr);
DRBs[0].up_ul_tnl[0].port=RC.nrrrc[ctxt_pP->module_id]->eth_params_s.my_portd; DRBs[0].up_ul_tnl[0].port = gnb_rrc_inst->eth_params_s.my_portd;
DRBs[0].up_ul_tnl_length = 1; DRBs[0].up_ul_tnl_length = 1;
DRBs[0].up_dl_tnl[0].tl_address = inet_addr(RC.nrrrc[ctxt_pP->module_id]->eth_params_s.remote_addr); DRBs[0].up_dl_tnl[0].tl_address = inet_addr(gnb_rrc_inst->eth_params_s.remote_addr);
DRBs[0].up_dl_tnl[0].port=RC.nrrrc[ctxt_pP->module_id]->eth_params_s.remote_portd; DRBs[0].up_dl_tnl[0].port = gnb_rrc_inst->eth_params_s.remote_portd;
DRBs[0].up_dl_tnl_length = 1; DRBs[0].up_dl_tnl_length = 1;
} }
if( ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.present == if( ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.present ==
...@@ -2457,49 +2402,42 @@ rrc_gNB_decode_dcch( ...@@ -2457,49 +2402,42 @@ rrc_gNB_decode_dcch(
itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p);
} }
break; break;
case NR_UL_DCCH_MessageType__c1_PR_rrcReestablishmentComplete: { case NR_UL_DCCH_MessageType__c1_PR_rrcReestablishmentComplete: {
LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)Rx_sdu, sdu_sizeP, "[MSG] NR_RRC Connection Reestablishment Complete\n"); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)Rx_sdu, sdu_sizeP, "[MSG] NR_RRC Connection Reestablishment Complete\n");
LOG_I(NR_RRC, LOG_I(NR_RRC, "RLC RB %02d --- RLC_DATA_IND %d bytes (rrcReestablishmentComplete) ---> RRC_gNB\n", DCCH, sdu_sizeP);
PROTOCOL_RRC_CTXT_UE_FMT
" RLC RB %02d --- RLC_DATA_IND %d bytes "
"(rrcReestablishmentComplete) ---> RRC_gNB\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
DCCH,
sdu_sizeP);
rnti_t reestablish_rnti = 0; rnti_t reestablish_rnti = 0;
// Select C-RNTI from map // Select C-RNTI from map
for (i = 0; i < MAX_MOBILES_PER_GNB; i++) { for (i = 0; i < MAX_MOBILES_PER_GNB; i++) {
nr_reestablish_rnti_map_t *nr_reestablish_rnti_map = &(RC.nrrrc[ctxt_pP->module_id])->nr_reestablish_rnti_map[i]; nr_reestablish_rnti_map_t *nr_reestablish_rnti_map = &gnb_rrc_inst->nr_reestablish_rnti_map[i];
LOG_I(NR_RRC, "nr_reestablish_rnti_map[%d] UEid %lx, RNTI %04x, ctxt_pP->rntiMaybeUEid: %lx\n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti, ctxt_pP->rntiMaybeUEid); LOG_I(NR_RRC, "nr_reestablish_rnti_map[%d] UEid %lx, RNTI %04x, ctxt_pP->rntiMaybeUEid: %lx\n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti, ctxt_pP->rntiMaybeUEid);
if (nr_reestablish_rnti_map->ue_id == ctxt_pP->rntiMaybeUEid) { if (nr_reestablish_rnti_map->ue_id == ctxt_pP->rntiMaybeUEid) {
LOG_I(NR_RRC, "Removing nr_reestablish_rnti_map[%d] UEid %lx, RNTI %04x\n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti); LOG_I(NR_RRC, "Removing nr_reestablish_rnti_map[%d] UEid %lx, RNTI %04x\n", i, nr_reestablish_rnti_map->ue_id, nr_reestablish_rnti_map->c_rnti);
reestablish_rnti = nr_reestablish_rnti_map->c_rnti; reestablish_rnti = nr_reestablish_rnti_map->c_rnti;
ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], reestablish_rnti); ue_context_p = rrc_gNB_get_ue_context(gnb_rrc_inst, reestablish_rnti);
break; break;
} }
} }
if (!ue_context_p) { if (!ue_context_p) {
LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " NR_RRCReestablishmentComplete without UE context, falt\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); LOG_E(NR_RRC, "NR_RRCReestablishmentComplete without UE context, fault\n");
break; break;
} }
#if (0) #if (0)
/* TODO : It may be needed if gNB goes into full stack working. */ /* TODO : It may be needed if gNB goes into full stack working. */
// clear // clear
int UE_id = find_nr_UE_id(ctxt_pP->module_id, ctxt_pP->rntiMaybeUEid); int UE_id = find_nr_UE_id(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid);
if (UE_id == -1) { if (UE_id == -1) {
LOG_E(NR_RRC, PROTOCOL_RRC_CTXT_UE_FMT " NR_RRCReestablishmentComplete without UE_id(MAC) rnti %lx, fault\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ctxt_pP->rntiMaybeUEid); LOG_E(NR_RRC, PROTOCOL_RRC_CTXT_UE_FMT " NR_RRCReestablishmentComplete without UE_id(MAC) rnti %lx, fault\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ctxt_pP->rntiMaybeUEid);
break; break;
} }
RC.nrmac[ctxt_pP->module_id]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0; RC.nrmac[gnb_rrc_inst]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0;
#endif #endif
if (ul_dcch_msg->message.choice.c1->choice.rrcReestablishmentComplete->criticalExtensions.present == NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete) { if (ul_dcch_msg->message.choice.c1->choice.rrcReestablishmentComplete->criticalExtensions.present == NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete) {
...@@ -2637,14 +2575,7 @@ void rrc_gNB_process_initial_ul_rrc_message(const f1ap_initial_ul_rrc_message_t ...@@ -2637,14 +2575,7 @@ void rrc_gNB_process_initial_ul_rrc_message(const f1ap_initial_ul_rrc_message_t
i = 0; i = 0;
LOG_W(RRC, "initial UL RRC message nr_cellid %ld does not match RRC's %ld\n", ul_rrc->nr_cellid, RC.nrrrc[0]->nr_cellid); LOG_W(RRC, "initial UL RRC message nr_cellid %ld does not match RRC's %ld\n", ul_rrc->nr_cellid, RC.nrrrc[0]->nr_cellid);
} }
protocol_ctxt_t ctxt = { 0 }; nr_rrc_gNB_decode_ccch(i, ul_rrc->crnti, ul_rrc->rrc_container, ul_rrc->rrc_container_length, ul_rrc->du2cu_rrc_container, ul_rrc->du2cu_rrc_container_length);
PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, i, GNB_FLAG_YES, ul_rrc->crnti, 0, 0);
nr_rrc_gNB_decode_ccch(&ctxt,
ul_rrc->rrc_container,
ul_rrc->rrc_container_length,
ul_rrc->du2cu_rrc_container,
ul_rrc->du2cu_rrc_container_length);
if (ul_rrc->rrc_container) if (ul_rrc->rrc_container)
free(ul_rrc->rrc_container); free(ul_rrc->rrc_container);
...@@ -3513,8 +3444,10 @@ static int get_dl_mimo_layers(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability ...@@ -3513,8 +3444,10 @@ static int get_dl_mimo_layers(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability
void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
MessageDef *msg; MessageDef *msg;
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
rrc_gNB_ue_context_t *ue_context_p = NULL; rrc_gNB_ue_context_t *ue_context_p = NULL;
RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head)) { RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &rrc->rrc_ue_head)
{
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
ctxt_pP->rntiMaybeUEid = UE->rnti; ctxt_pP->rntiMaybeUEid = UE->rnti;
gNB_MAC_INST *nrmac=RC.nrmac[ctxt_pP->module_id]; //WHAT A BEAUTIFULL RACE CONDITION !!! gNB_MAC_INST *nrmac=RC.nrmac[ctxt_pP->module_id]; //WHAT A BEAUTIFULL RACE CONDITION !!!
...@@ -3535,20 +3468,20 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { ...@@ -3535,20 +3468,20 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
// Remove here the MAC and RRC context when RRC is not connected or gNB is not connected to CN5G // Remove here the MAC and RRC context when RRC is not connected or gNB is not connected to CN5G
if (UE->StatusRrc < NR_RRC_CONNECTED || UE->gNB_ue_ngap_id == 0) { if (UE->StatusRrc < NR_RRC_CONNECTED || UE->gNB_ue_ngap_id == 0) {
if(!NODE_IS_CU(RC.nrrrc[ctxt_pP->instance]->node_type)){ if (!NODE_IS_CU(rrc->node_type)) {
mac_remove_nr_ue(nrmac, ctxt_pP->rntiMaybeUEid); mac_remove_nr_ue(nrmac, ctxt_pP->rntiMaybeUEid);
rrc_rlc_remove_ue(ctxt_pP); rrc_rlc_remove_ue(ctxt_pP);
pdcp_remove_UE(ctxt_pP); pdcp_remove_UE(ctxt_pP);
/* remove RRC UE Context */ /* remove RRC UE Context */
ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid); ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt_pP->rntiMaybeUEid);
if (ue_context_p) { if (ue_context_p) {
rrc_gNB_remove_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], ue_context_p); rrc_gNB_remove_ue_context(rrc, ue_context_p);
LOG_I(NR_RRC, "remove UE %lx \n", ctxt_pP->rntiMaybeUEid); LOG_I(NR_RRC, "remove UE %lx \n", ctxt_pP->rntiMaybeUEid);
} }
} }
// In case of CU trigger UE context release command towards the DU // In case of CU trigger UE context release command towards the DU
else{ else {
MessageDef *message_p; MessageDef *message_p;
message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_RELEASE_CMD); message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_RELEASE_CMD);
f1ap_ue_context_release_cmd_t *rel_cmd=&F1AP_UE_CONTEXT_RELEASE_CMD (message_p); f1ap_ue_context_release_cmd_t *rel_cmd=&F1AP_UE_CONTEXT_RELEASE_CMD (message_p);
...@@ -3575,9 +3508,9 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { ...@@ -3575,9 +3508,9 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
newGtpuDeleteAllTunnels(ctxt_pP->instance, ctxt_pP->rntiMaybeUEid); newGtpuDeleteAllTunnels(ctxt_pP->instance, ctxt_pP->rntiMaybeUEid);
/* remove RRC UE Context */ /* remove RRC UE Context */
ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid); ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt_pP->rntiMaybeUEid);
if (ue_context_p) { if (ue_context_p) {
rrc_gNB_remove_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], ue_context_p); rrc_gNB_remove_ue_context(rrc, ue_context_p);
LOG_I(NR_RRC, "remove UE %lx \n", ctxt_pP->rntiMaybeUEid); LOG_I(NR_RRC, "remove UE %lx \n", ctxt_pP->rntiMaybeUEid);
} }
...@@ -3936,10 +3869,7 @@ rrc_gNB_generate_SecurityModeCommand( ...@@ -3936,10 +3869,7 @@ rrc_gNB_generate_SecurityModeCommand(
NR_IntegrityProtAlgorithm_t integrity_algorithm = (NR_IntegrityProtAlgorithm_t)ue_p->integrity_algorithm; NR_IntegrityProtAlgorithm_t integrity_algorithm = (NR_IntegrityProtAlgorithm_t)ue_p->integrity_algorithm;
size = do_NR_SecurityModeCommand(ctxt_pP, buffer, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), ue_p->ciphering_algorithm, &integrity_algorithm); size = do_NR_SecurityModeCommand(ctxt_pP, buffer, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), ue_p->ciphering_algorithm, &integrity_algorithm);
LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Security Mode Command\n"); LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Security Mode Command\n");
LOG_I(NR_RRC, LOG_I(NR_RRC, "UE %04x Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n", ue_p->rnti, size);
PROTOCOL_NR_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
size);
switch (RC.nrrrc[ctxt_pP->module_id]->node_type) { switch (RC.nrrrc[ctxt_pP->module_id]->node_type) {
case ngran_gNB_CU: case ngran_gNB_CU:
......
...@@ -83,7 +83,7 @@ int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ct ...@@ -83,7 +83,7 @@ int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ct
} }
LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " RX CREATE_TUNNEL_RESP num tunnels %u \n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), create_tunnel_resp_pP->num_tunnels); LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " RX CREATE_TUNNEL_RESP num tunnels %u \n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), create_tunnel_resp_pP->num_tunnels);
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid);
if (!ue_context_p) { if (!ue_context_p) {
LOG_E(NR_RRC, "UE table error\n"); LOG_E(NR_RRC, "UE table error\n");
return -1; return -1;
......
...@@ -592,7 +592,6 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu ...@@ -592,7 +592,6 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu
protocol_ctxt_t ctxt = {0}; protocol_ctxt_t ctxt = {0};
ngap_downlink_nas_t *req = &NGAP_DOWNLINK_NAS(msg_p); ngap_downlink_nas_t *req = &NGAP_DOWNLINK_NAS(msg_p);
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], req->gNB_ue_ngap_id); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], req->gNB_ue_ngap_id);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
if (ue_context_p == NULL) { if (ue_context_p == NULL) {
/* Can not associate this message to an UE index, send a failure to NGAP and discard it! */ /* Can not associate this message to an UE index, send a failure to NGAP and discard it! */
...@@ -608,6 +607,7 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu ...@@ -608,6 +607,7 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu
return (-1); return (-1);
} }
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rnti, 0, 0); PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rnti, 0, 0);
/* Create message for PDCP (DLInformationTransfer_t) */ /* Create message for PDCP (DLInformationTransfer_t) */
......
...@@ -56,16 +56,14 @@ int rrc_gNB_compare_ue_rnti_id(rrc_gNB_ue_context_t *c1_pP, rrc_gNB_ue_context_t ...@@ -56,16 +56,14 @@ int rrc_gNB_compare_ue_rnti_id(rrc_gNB_ue_context_t *c1_pP, rrc_gNB_ue_context_t
RB_GENERATE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, RB_GENERATE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries,
rrc_gNB_compare_ue_rnti_id); rrc_gNB_compare_ue_rnti_id);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
rrc_gNB_ue_context_t *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance_pP) rrc_gNB_ue_context_t *rrc_gNB_allocate_new_ue_context(gNB_RRC_INST *rrc_instance_pP)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
rrc_gNB_ue_context_t *new_p = calloc(1, sizeof(*new_p)); rrc_gNB_ue_context_t *new_p = calloc(1, sizeof(*new_p));
if (new_p == NULL) { if (new_p == NULL) {
LOG_E(RRC, "Cannot allocate new ue context\n"); LOG_E(NR_RRC, "Cannot allocate new ue context\n");
return NULL; return NULL;
} }
new_p->ue_context.gNB_ue_ngap_id = uid_linear_allocator_new(&rrc_instance_pP->uid_allocator); new_p->ue_context.gNB_ue_ngap_id = uid_linear_allocator_new(&rrc_instance_pP->uid_allocator);
...@@ -76,70 +74,60 @@ rrc_gNB_ue_context_t *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance ...@@ -76,70 +74,60 @@ rrc_gNB_ue_context_t *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance
new_p->ue_context.modify_e_rab[i].xid = -1; new_p->ue_context.modify_e_rab[i].xid = -1;
} }
LOG_D(NR_RRC,"Returning new UE context at %p\n",new_p); LOG_I(NR_RRC, "Returning new RRC UE context RRC ue id: %d\n", new_p->ue_context.gNB_ue_ngap_id);
return(new_p); return(new_p);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
rrc_gNB_ue_context_t *rrc_gNB_get_ue_context(gNB_RRC_INST *rrc_instance_pP, rnti_t rntiP) rrc_gNB_ue_context_t *rrc_gNB_get_ue_context(gNB_RRC_INST *rrc_instance_pP, ue_id_t ue)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
rrc_gNB_ue_context_t temp = {0}; rrc_gNB_ue_context_t temp;
/* gNB ue rrc id = 24 bits wide */ /* gNB ue rrc id = 24 bits wide */
temp.ue_context.rnti = rntiP; temp.ue_context.gNB_ue_ngap_id = ue;
rrc_gNB_ue_context_t *ue_context_p = RB_FIND(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, &temp); return RB_FIND(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, &temp);
}
if (ue_context_p != NULL)
return ue_context_p;
rrc_gNB_ue_context_t *rrc_gNB_get_ue_context_by_rnti(gNB_RRC_INST *rrc_instance_pP, rnti_t rntiP)
{
rrc_gNB_ue_context_t *ue_context_p;
RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(rrc_instance_pP->rrc_ue_head)) RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(rrc_instance_pP->rrc_ue_head))
{ {
if (ue_context_p->ue_context.rnti == rntiP) if (ue_context_p->ue_context.rnti == rntiP)
return ue_context_p; return ue_context_p;
} }
LOG_W(NR_RRC, "search by rnti not found %04x\n", rntiP);
return NULL; return NULL;
} }
void rrc_gNB_free_mem_UE_context(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP) void rrc_gNB_free_mem_ue_context(rrc_gNB_ue_context_t *const ue_context_pP)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
free(ue_context_pP);
LOG_T(RRC, LOG_T(NR_RRC, " Clearing UE context 0x%p (free internal structs)\n", ue_context_pP);
PROTOCOL_NR_RRC_CTXT_UE_FMT" Clearing UE context 0x%p (free internal structs)\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_pP);
//ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_LTE_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[0]);
//ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_LTE_SCellToAddMod_r10, &ue_context_pP->ue_context.sCell_config[1]);
// empty the internal fields of the UE context here
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void rrc_gNB_remove_ue_context(const protocol_ctxt_t *const ctxt_pP, gNB_RRC_INST *rrc_instance_pP, rrc_gNB_ue_context_t *ue_context_pP) void rrc_gNB_remove_ue_context(gNB_RRC_INST *rrc_instance_pP, rrc_gNB_ue_context_t *ue_context_pP)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
if (rrc_instance_pP == NULL) { if (rrc_instance_pP == NULL) {
LOG_E(RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Bad RRC instance\n", LOG_E(NR_RRC, " Bad RRC instance\n");
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
return; return;
} }
if (ue_context_pP == NULL) { if (ue_context_pP == NULL) {
LOG_E(RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Trying to free a NULL UE context\n", LOG_E(NR_RRC, "Trying to free a NULL UE context\n");
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
return; return;
} }
RB_REMOVE(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_pP); RB_REMOVE(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_pP);
rrc_gNB_free_mem_UE_context(ctxt_pP, ue_context_pP); rrc_gNB_free_mem_ue_context(ue_context_pP);
uid_linear_allocator_free(&rrc_instance_pP->uid_allocator, ue_context_pP->ue_context.gNB_ue_ngap_id); uid_linear_allocator_free(&rrc_instance_pP->uid_allocator, ue_context_pP->ue_context.gNB_ue_ngap_id);
free(ue_context_pP); free(ue_context_pP);
rrc_instance_pP->Nb_ue --; rrc_instance_pP->Nb_ue --;
LOG_I(RRC, LOG_I(NR_RRC, "Removed UE context\n");
PROTOCOL_NR_RRC_CTXT_UE_FMT" Removed UE context\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -171,24 +159,24 @@ rrc_gNB_ue_context_t *rrc_gNB_ue_context_5g_s_tmsi_exist(gNB_RRC_INST *rrc_insta ...@@ -171,24 +159,24 @@ rrc_gNB_ue_context_t *rrc_gNB_ue_context_5g_s_tmsi_exist(gNB_RRC_INST *rrc_insta
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// return a new ue context structure if ue_identityP, ctxt_pP->rnti not found in collection // return a new ue context structure if ue_identityP, rnti not found in collection
rrc_gNB_ue_context_t *rrc_gNB_create_ue_context(const protocol_ctxt_t *const ctxt_pP, gNB_RRC_INST *rrc_instance_pP, const uint64_t ue_identityP) rrc_gNB_ue_context_t *rrc_gNB_create_ue_context(rnti_t rnti, gNB_RRC_INST *rrc_instance_pP, const uint64_t ue_identityP)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc_instance_pP, ctxt_pP->rntiMaybeUEid); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc_instance_pP, rnti);
if (ue_context_p) { if (ue_context_p) {
LOG_E(NR_RRC, " Cannot create new UE context, already exist rnti: %lx\n", ctxt_pP->rntiMaybeUEid); LOG_E(NR_RRC, "Cannot create new UE context, already exist rnti: %04x\n", rnti);
return ue_context_p; return ue_context_p;
} }
ue_context_p = rrc_gNB_allocate_new_UE_context(rrc_instance_pP); ue_context_p = rrc_gNB_allocate_new_ue_context(rrc_instance_pP);
if (ue_context_p == NULL) if (ue_context_p == NULL)
return NULL; return NULL;
ue_context_p->ue_context.rnti = ctxt_pP->rntiMaybeUEid; ue_context_p->ue_context.rnti = rnti;
ue_context_p->ue_context.random_ue_identity = ue_identityP; ue_context_p->ue_context.random_ue_identity = ue_identityP;
RB_INSERT(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_p); RB_INSERT(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, ue_context_p);
LOG_D(NR_RRC, " Created new UE context rnti: %lx, random ue id %lx, local uid %u\n", ctxt_pP->rntiMaybeUEid, ue_identityP, ue_context_p->ue_context.gNB_ue_ngap_id); LOG_W(NR_RRC, " Created new UE context rnti: %04x, random ue id %lx, RRC ue id %u\n", rnti, ue_identityP, ue_context_p->ue_context.gNB_ue_ngap_id);
return ue_context_p; return ue_context_p;
} }
...@@ -38,18 +38,19 @@ int rrc_gNB_compare_ue_rnti_id(rrc_gNB_ue_context_t* c1_pP, rrc_gNB_ue_context_t ...@@ -38,18 +38,19 @@ int rrc_gNB_compare_ue_rnti_id(rrc_gNB_ue_context_t* c1_pP, rrc_gNB_ue_context_t
RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, rrc_gNB_compare_ue_rnti_id); RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries, rrc_gNB_compare_ue_rnti_id);
rrc_gNB_ue_context_t* rrc_gNB_allocate_new_UE_context(gNB_RRC_INST* rrc_instance_pP); rrc_gNB_ue_context_t* rrc_gNB_allocate_new_ue_context(gNB_RRC_INST* rrc_instance_pP);
rrc_gNB_ue_context_t* rrc_gNB_get_ue_context(gNB_RRC_INST* rrc_instance_pP, rnti_t rntiP); rrc_gNB_ue_context_t* rrc_gNB_get_ue_context(gNB_RRC_INST* rrc_instance_pP, ue_id_t ue);
rrc_gNB_ue_context_t* rrc_gNB_get_ue_context_by_rnti(gNB_RRC_INST* rrc_instance_pP, rnti_t rntiP);
void rrc_gNB_free_mem_UE_context(const protocol_ctxt_t* const ctxt_pP, rrc_gNB_ue_context_t* const ue_context_pP); void rrc_gNB_free_mem_ue_context(rrc_gNB_ue_context_t* const ue_context_pP);
void rrc_gNB_remove_ue_context(const protocol_ctxt_t* const ctxt_pP, gNB_RRC_INST* rrc_instance_pP, rrc_gNB_ue_context_t* ue_context_pP); void rrc_gNB_remove_ue_context(gNB_RRC_INST* rrc_instance_pP, rrc_gNB_ue_context_t* ue_context_pP);
rrc_gNB_ue_context_t* rrc_gNB_ue_context_random_exist(gNB_RRC_INST* rrc_instance_pP, const uint64_t ue_identityP); rrc_gNB_ue_context_t* rrc_gNB_ue_context_random_exist(gNB_RRC_INST* rrc_instance_pP, const uint64_t ue_identityP);
rrc_gNB_ue_context_t* rrc_gNB_ue_context_5g_s_tmsi_exist(gNB_RRC_INST* rrc_instance_pP, const uint64_t s_TMSI); rrc_gNB_ue_context_t* rrc_gNB_ue_context_5g_s_tmsi_exist(gNB_RRC_INST* rrc_instance_pP, const uint64_t s_TMSI);
rrc_gNB_ue_context_t* rrc_gNB_create_ue_context(const protocol_ctxt_t* const ctxt_pP, gNB_RRC_INST* rrc_instance_pP, const uint64_t ue_identityP); rrc_gNB_ue_context_t* rrc_gNB_create_ue_context(rnti_t rnti, gNB_RRC_INST* rrc_instance_pP, const uint64_t ue_identityP);
#endif #endif
...@@ -60,7 +60,7 @@ void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerL ...@@ -60,7 +60,7 @@ void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerL
} }
// decode and store capabilities // decode and store capabilities
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_allocate_new_UE_context(rrc); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_allocate_new_ue_context(rrc);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context; gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
if (ueCapabilityRAT_Container_nr != NULL) { if (ueCapabilityRAT_Container_nr != NULL) {
...@@ -409,5 +409,5 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) { ...@@ -409,5 +409,5 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) {
} }
gtpv1u_delete_s1u_tunnel(rrc->module_id, &tmp); gtpv1u_delete_s1u_tunnel(rrc->module_id, &tmp);
/* remove context */ /* remove context */
rrc_gNB_remove_ue_context(&ctxt, rrc, ue_context); rrc_gNB_remove_ue_context(rrc, ue_context);
} }
...@@ -678,12 +678,8 @@ int ngap_gNB_handle_error_indication(uint32_t assoc_id, ...@@ -678,12 +678,8 @@ int ngap_gNB_handle_error_indication(uint32_t assoc_id,
return 0; return 0;
} }
static int ngap_gNB_handle_initial_context_request(uint32_t assoc_id, uint32_t stream, NGAP_NGAP_PDU_t *pdu)
static {
int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
uint32_t stream,
NGAP_NGAP_PDU_t *pdu) {
int i; int i;
ngap_gNB_amf_data_t *amf_desc_p = NULL; ngap_gNB_amf_data_t *amf_desc_p = NULL;
NGAP_InitialContextSetupRequest_t *container; NGAP_InitialContextSetupRequest_t *container;
...@@ -733,8 +729,6 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id, ...@@ -733,8 +729,6 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
ngap_initial_context_setup_req_t * msg=&NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p); ngap_initial_context_setup_req_t * msg=&NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p);
memset(msg, 0, sizeof(*msg)); memset(msg, 0, sizeof(*msg));
msg->gNB_ue_ngap_id = ue_desc_p->gNB_ue_ngap_id; msg->gNB_ue_ngap_id = ue_desc_p->gNB_ue_ngap_id;
ue_desc_p->gNB_ue_ngap_id = 0;
msg->gNB_ue_ngap_id = ue_desc_p->gNB_ue_ngap_id;
msg->amf_ue_ngap_id = ue_desc_p->amf_ue_ngap_id; msg->amf_ue_ngap_id = ue_desc_p->amf_ue_ngap_id;
/* id-UEAggregateMaximumBitRate */ /* id-UEAggregateMaximumBitRate */
NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container, NGAP_FIND_PROTOCOLIE_BY_ID(NGAP_InitialContextSetupRequestIEs_t, ie, container,
...@@ -842,7 +836,6 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id, ...@@ -842,7 +836,6 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
return 0; return 0;
} }
static static
int ngap_gNB_handle_ue_context_release_command(uint32_t assoc_id, int ngap_gNB_handle_ue_context_release_command(uint32_t assoc_id,
uint32_t stream, uint32_t stream,
...@@ -958,8 +951,6 @@ int ngap_gNB_handle_pdusession_setup_request(uint32_t assoc_id, ...@@ -958,8 +951,6 @@ int ngap_gNB_handle_pdusession_setup_request(uint32_t assoc_id,
ngap_pdusession_setup_req_t * msg=&NGAP_PDUSESSION_SETUP_REQ(message_p); ngap_pdusession_setup_req_t * msg=&NGAP_PDUSESSION_SETUP_REQ(message_p);
memset(msg, 0, sizeof(*msg)); memset(msg, 0, sizeof(*msg));
msg->gNB_ue_ngap_id = ue_desc_p->gNB_ue_ngap_id; msg->gNB_ue_ngap_id = ue_desc_p->gNB_ue_ngap_id;
ue_desc_p->gNB_ue_ngap_id = 0;
msg->gNB_ue_ngap_id = ue_desc_p->gNB_ue_ngap_id;
msg->amf_ue_ngap_id = ue_desc_p->amf_ue_ngap_id; msg->amf_ue_ngap_id = ue_desc_p->amf_ue_ngap_id;
/* UE Aggregated Maximum Bitrate */ /* UE Aggregated Maximum Bitrate */
...@@ -1158,7 +1149,6 @@ static int ngap_gNB_handle_pdusession_modify_request(uint32_t assoc_id, uint32_t ...@@ -1158,7 +1149,6 @@ static int ngap_gNB_handle_pdusession_modify_request(uint32_t assoc_id, uint32_t
MessageDef *message_p = itti_alloc_new_message(TASK_NGAP, 0, NGAP_PDUSESSION_MODIFY_REQ); MessageDef *message_p = itti_alloc_new_message(TASK_NGAP, 0, NGAP_PDUSESSION_MODIFY_REQ);
ngap_pdusession_modify_req_t * msg=&NGAP_PDUSESSION_MODIFY_REQ(message_p); ngap_pdusession_modify_req_t * msg=&NGAP_PDUSESSION_MODIFY_REQ(message_p);
memset(msg, 0, sizeof(*msg)); memset(msg, 0, sizeof(*msg));
msg->gNB_ue_ngap_id = ue_desc_p->gNB_ue_ngap_id;
msg->amf_ue_ngap_id = amf_ue_ngap_id; msg->amf_ue_ngap_id = amf_ue_ngap_id;
msg->gNB_ue_ngap_id = gnb_ue_ngap_id; msg->gNB_ue_ngap_id = gnb_ue_ngap_id;
......
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