diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 6bce1c21f0a4613a04c670410549fab330dcac8b..a3deeec8000f2da36c58b5ddb326426979a1926d 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -832,45 +832,58 @@ rrc_eNB_free_mem_UE_context( } //----------------------------------------------------------------------------- -// should be called when UE is lost by eNB +/* +* Should be called when UE context in eNB should be released +* or when S1 command UE_CONTEXT_RELEASE_REQ should be sent +*/ void -rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* const ue_context_pP) +rrc_eNB_free_UE( + const module_id_t enb_mod_idP, + const struct rrc_eNB_ue_context_s *const ue_context_pP) //----------------------------------------------------------------------------- { - - - protocol_ctxt_t ctxt; + protocol_ctxt_t ctxt; rnti_t rnti = ue_context_pP->ue_context.rnti; + if (enb_mod_idP >= NB_eNB_INST) { - LOG_I(RRC, "eNB inst invalid (%d/%d) for UE %x!\n",enb_mod_idP, NB_eNB_INST,rnti); - return; + LOG_I(RRC, "eNB instance invalid (%d/%d) for UE %x!\n", + enb_mod_idP, + NB_eNB_INST, + rnti); + + return; } - /* ue_context_p = rrc_eNB_get_ue_context( - &RC.rrc[enb_mod_idP], - rntiP - ); - */ + if (NULL != ue_context_pP) { - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0,enb_mod_idP); - LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rnti); - - if(EPC_MODE_ENABLED) { - - if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && - (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ RNTI %x\n", enb_mod_idP, rnti); - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost - /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) - * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before - * triggering the S1 UE Context Release Request procedure - * in order to allow the UE to perform the NAS recovery - * procedure, see TS 23.401 [17]. - */ - return; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0, enb_mod_idP); + + LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", + enb_mod_idP, + rnti); + + if (EPC_MODE_ENABLED) { + if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x\n", + enb_mod_idP, + rnti); + + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); + // send cause 21: connection with ue lost + /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) + * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before + * triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery + * procedure, see TS 23.401 [17]. + */ + + return; + } + // TODO : add here cause ul inactivity } - } + // add UE info to freeList - LOG_I(RRC, "put UE %x into freeList\n", rnti); + LOG_I(RRC, "Put UE %x into freeList\n", + rnti); + put_UE_in_freelist(enb_mod_idP, rnti, 1); } } @@ -1980,44 +1993,40 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject( } //----------------------------------------------------------------------------- +/* +* Generate the RRC Connection Release to UE. +* If received, UE should switch to RRC_IDLE mode. +*/ void rrc_eNB_generate_RRCConnectionRelease( const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + rrc_eNB_ue_context_t* const ue_context_pP ) //----------------------------------------------------------------------------- { - - uint8_t buffer[RRC_BUF_SIZE]; - uint16_t size; + uint8_t buffer[RRC_BUF_SIZE] = 0; + uint16_t size = 0; T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); - // set release timer - //ue_context_pP->ue_context.ue_release_timer=1; - // remove UE after 10 frames after RRCConnectionRelease is triggered - //ue_context_pP->ue_context.ue_release_timer_thres=100; - // set release timer -// ue_context_pP->ue_context.ue_release_timer_rrc = 1; - // remove UE after 10 frames after RRCConnectionRelease is triggered -// ue_context_pP->ue_context.ue_release_timer_thres_rrc = 100; + ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; - //ue_context_pP->ue_context.ue_release_timer_s1 = 0; + LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - size); + PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size); LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - size, - rrc_eNB_mui, - DCCH); + PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + size, + rrc_eNB_mui, + DCCH); MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, @@ -2029,31 +2038,39 @@ rrc_eNB_generate_RRCConnectionRelease( ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); + pthread_mutex_lock(&rrc_release_freelist); - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 0){ - if(ue_context_pP->ue_context.ue_release_timer_s1 > 0){ + for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) { + + if (ue_context_pP->ue_context.ue_release_timer_s1 > 0) { rrc_release_info.RRC_release_ctrl[release_num].flag = 1; - }else{ + } else { rrc_release_info.RRC_release_ctrl[release_num].flag = 2; } + rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt_pP->rnti; rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = rrc_eNB_mui; rrc_release_info.num_UEs++; - LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num, - ctxt_pP->rnti, rrc_eNB_mui,rrc_release_info.RRC_release_ctrl[release_num].flag); + + LOG_D(RRC, "Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n", + release_num, + ctxt_pP->rnti, + rrc_eNB_mui, + rrc_release_info.RRC_release_ctrl[release_num].flag); + break; } } pthread_mutex_unlock(&rrc_release_freelist); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + + rrc_data_req(ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } uint8_t qci_to_priority[9]={2,4,3,5,1,6,7,8,9}; @@ -7904,6 +7921,11 @@ rrc_rx_tx( if (ue_context_p->ue_context.ue_release_timer >= ue_context_p->ue_context.ue_release_timer_thres) { LOG_I(RRC, "Removing UE %x instance because of RRC Connection Setup timer timeout\n", ue_context_p->ue_context.rnti); + /* + * TODO: Naming problem here: ue_release_timer seems to have been used when RRC Connection Release was sent. + * It is no more the case. + * The timer should be renamed. + */ ue_to_be_removed = ue_context_p; ue_context_p->ue_context.ue_release_timer = 0; diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index d225b6eae0a48c77ba4bf580e6dda295a84347c0..0bec59f6476e163b7cc5043b1b7d53f1bf0f5e22 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -1201,66 +1201,64 @@ void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( } -/*------------------------------------------------------------------------------*/ -int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const char *msg_name, instance_t instance) +//----------------------------------------------------------------------------- +/* +* Process the S1 command UE_CONTEXT_RELEASE_COMMAND, sent by MME. +* The eNB should remove all e-rab, S1 context, and other context of the UE. +*/ +int +rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND ( + MessageDef *msg_p, + const char *msg_name, + instance_t instance) { +//----------------------------------------------------------------------------- uint32_t eNB_ue_s1ap_id; - protocol_ctxt_t ctxt; + protocol_ctxt_t ctxt; struct rrc_eNB_ue_context_s *ue_context_p = NULL; - struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; + struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p).eNB_ue_s1ap_id; - - ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); if (ue_context_p == NULL) { /* Can not associate this message to an UE index */ - MessageDef *msg_complete_p; + MessageDef *msg_complete_p = NULL; - LOG_W(RRC, - "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: unknown UE from eNB_ue_s1ap_id (%d)\n", - instance, - eNB_ue_s1ap_id); + LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: unknown UE from eNB_ue_s1ap_id (%d)\n", + instance, + eNB_ue_s1ap_id); - MSC_LOG_EVENT( - MSC_RRC_ENB, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found", + MSC_LOG_EVENT(MSC_RRC_ENB, "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found", eNB_ue_s1ap_id); - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - NULL,0, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_S1AP_ENB, + NULL, + 0, + "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", eNB_ue_s1ap_id); msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p); - rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids( - RC.rrc[instance], - UE_INITIAL_ID_INVALID, - eNB_ue_s1ap_id); + rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); if (NULL != rrc_ue_s1ap_ids) { - rrc_eNB_S1AP_remove_ue_ids( - RC.rrc[instance], - rrc_ue_s1ap_ids); + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); } - return (-1); + + return -1; } else { ue_context_p->ue_context.ue_release_timer_s1 = 0; + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + rrc_eNB_generate_RRCConnectionRelease(&ctxt, ue_context_p); - /* - LOG_W(RRC, - "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: TODO call rrc_eNB_connection_release for eNB %d\n", - instance, - eNB_ue_s1ap_id); - */ - return (0); + + return 0; } }