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,
protocol_ctxt_t ctxt;
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) {
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;
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 {
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,
sdu_len, rnti);
/* 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)) {
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_id]);
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);
}
if (NODE_IS_DU(RC.nrrrc[module_id]->node_type))
rrc_gNB_create_ue_context(rnti, RC.nrrrc[module_id], rnti);
const NR_ServingCellConfigCommon_t *scc = RC.nrrrc[module_id]->carrier.servingcellconfigcommon;
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 *
/* TODO: drop the RRC context */
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;
ue_p->SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList;
ue_p->masterCellGroup = cellGroup;
......
......@@ -162,7 +162,7 @@ int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP,
const rnti_t rntiP,
const int dl_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_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,
const frame_t frameP,
const sub_frame_t subframeP,
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) {
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,
const frame_t frameP,
const sub_frame_t subframeP,
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) {
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;
......
......@@ -176,7 +176,7 @@ static NR_SRB_ToAddModList_t **generateSRB2_confList(gNB_RRC_UE_t *ue, NR_SRB_To
return SRB_configList2;
}
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;
protocol_ctxt_t ctxt = {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
const int dl_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
rrc_gNB_generate_dedicatedRRCReconfiguration_release(
const protocol_ctxt_t *const ctxt_pP,
......
This diff is collapsed.
......@@ -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);
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) {
LOG_E(NR_RRC, "UE table error\n");
return -1;
......
......@@ -592,7 +592,6 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu
protocol_ctxt_t ctxt = {0};
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);
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
if (ue_context_p == NULL) {
/* 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
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);
/* 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
RB_GENERATE(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 *new_p = calloc(1, sizeof(*new_p));
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;
}
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
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);
}
//------------------------------------------------------------------------------
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 */
temp.ue_context.rnti = rntiP;
rrc_gNB_ue_context_t *ue_context_p = RB_FIND(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, &temp);
if (ue_context_p != NULL)
return ue_context_p;
temp.ue_context.gNB_ue_ngap_id = ue;
return RB_FIND(rrc_nr_ue_tree_s, &rrc_instance_pP->rrc_ue_head, &temp);
}
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))
{
if (ue_context_p->ue_context.rnti == rntiP)
return ue_context_p;
}
LOG_W(NR_RRC, "search by rnti not found %04x\n", rntiP);
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)
//-----------------------------------------------------------------------------
{
LOG_T(RRC,
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
free(ue_context_pP);
LOG_T(NR_RRC, " Clearing UE context 0x%p (free internal structs)\n", 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)
//------------------------------------------------------------------------------
{
if (rrc_instance_pP == NULL) {
LOG_E(RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Bad RRC instance\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
LOG_E(NR_RRC, " Bad RRC instance\n");
return;
}
if (ue_context_pP == NULL) {
LOG_E(RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Trying to free a NULL UE context\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
LOG_E(NR_RRC, "Trying to free a NULL UE context\n");
return;
}
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);
free(ue_context_pP);
rrc_instance_pP->Nb_ue --;
LOG_I(RRC,
PROTOCOL_NR_RRC_CTXT_UE_FMT" Removed UE context\n",
PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
LOG_I(NR_RRC, "Removed UE context\n");
}
//-----------------------------------------------------------------------------
......@@ -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
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)
// return a new ue context structure if ue_identityP, rnti not found in collection
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) {
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;
}
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)
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;
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;
}
......@@ -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);
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_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
......@@ -60,7 +60,7 @@ void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerL
}
// 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;
if (ueCapabilityRAT_Container_nr != NULL) {
......@@ -409,5 +409,5 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) {
}
gtpv1u_delete_s1u_tunnel(rrc->module_id, &tmp);
/* 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,
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;
ngap_gNB_amf_data_t *amf_desc_p = NULL;
NGAP_InitialContextSetupRequest_t *container;
......@@ -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);
memset(msg, 0, sizeof(*msg));
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;
/* id-UEAggregateMaximumBitRate */
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,
return 0;
}
static
int ngap_gNB_handle_ue_context_release_command(uint32_t assoc_id,
uint32_t stream,
......@@ -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);
memset(msg, 0, sizeof(*msg));
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;
/* UE Aggregated Maximum Bitrate */
......@@ -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);
ngap_pdusession_modify_req_t * msg=&NGAP_PDUSESSION_MODIFY_REQ(message_p);
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->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