Commit f48d86d7 authored by Robert Schmidt's avatar Robert Schmidt

UE Ctxt Release Req/Cmd/Complete

parent d24454ce
......@@ -418,7 +418,8 @@ typedef enum F1ap_Cause_e {
} f1ap_Cause_t;
typedef struct f1ap_ue_context_release_s {
uint16_t rnti;
uint32_t gNB_CU_ue_id;
uint32_t gNB_DU_ue_id;
f1ap_Cause_t cause;
long cause_value;
uint8_t *rrc_container;
......
......@@ -784,17 +784,12 @@ int CU_handle_UE_CONTEXT_RELEASE_REQUEST(instance_t instance, uint32_t assoc_id,
/* GNB_CU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
const rnti_t rnti = f1ap_get_rnti_by_cu_id(true, instance,
ie->value.choice.GNB_CU_UE_F1AP_ID);
req->rnti = rnti;
req->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
/* GNB_DU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
const rnti_t rnti2 = f1ap_get_rnti_by_du_id(CUtype, instance,
ie->value.choice.GNB_DU_UE_F1AP_ID);
AssertFatal(rnti == rnti2, "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n",
rnti2, rnti);
req->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
/* Cause */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseRequestIEs_t, ie, container,
......@@ -855,14 +850,14 @@ int CU_send_UE_CONTEXT_RELEASE_COMMAND(instance_t instance,
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_GNB_CU_UE_F1AP_ID;
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(CUtype, instance, cmd->rnti);
ie1->value.choice.GNB_CU_UE_F1AP_ID = cmd->gNB_CU_ue_id;
/* mandatory */
/* c2. GNB_DU_UE_F1AP_ID */
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie2);
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
ie2->criticality = F1AP_Criticality_reject;
ie2->value.present = F1AP_UEContextReleaseCommandIEs__value_PR_GNB_DU_UE_F1AP_ID;
ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(CUtype, instance, cmd->rnti);
ie2->value.choice.GNB_DU_UE_F1AP_ID = cmd->gNB_DU_ue_id;
/* mandatory */
/* c3. Cause */
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseCommandIEs_t, ie3);
......
......@@ -574,14 +574,14 @@ int DU_send_UE_CONTEXT_RELEASE_REQUEST(instance_t instance,
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(DUtype, instance, req->rnti);
ie1->value.choice.GNB_CU_UE_F1AP_ID = req->gNB_CU_ue_id;
/* mandatory */
/* c2. GNB_DU_UE_F1AP_ID */
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseRequestIEs_t, ie2);
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
ie2->criticality = F1AP_Criticality_reject;
ie2->value.present = F1AP_UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, req->rnti);
ie2->value.choice.GNB_DU_UE_F1AP_ID = req->gNB_DU_ue_id;
/* mandatory */
/* c3. Cause */
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextReleaseRequestIEs_t, ie3);
......@@ -642,13 +642,11 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, uint32_t assoc_id,
// GNB_CU_UE_F1AP_ID
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
f1ap_ue_context_release_cmd->rnti = f1ap_get_rnti_by_cu_id(DUtype, instance, ie->value.choice.GNB_CU_UE_F1AP_ID);
f1ap_ue_context_release_cmd->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
// GNB_DU_UE_F1AP_ID
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextReleaseCommandIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
const rnti_t rnti = f1ap_get_rnti_by_du_id(DUtype, instance,
ie->value.choice.GNB_DU_UE_F1AP_ID);
AssertFatal(f1ap_ue_context_release_cmd->rnti == rnti, "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n", rnti, f1ap_ue_context_release_cmd->rnti);
f1ap_ue_context_release_cmd->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
// We don't need the Cause
// Optional RRC Container: if present, send to UE
......@@ -709,14 +707,14 @@ int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, f1ap_ue_context_rel
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(DUtype, instance, complete->rnti);
ie1->value.choice.GNB_CU_UE_F1AP_ID = complete->gNB_CU_ue_id;
/* mandatory */
/* c2. GNB_DU_UE_F1AP_ID */
asn1cSequenceAdd(out->protocolIEs.list,F1AP_UEContextReleaseCompleteIEs_t, ie2);
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
ie2->criticality = F1AP_Criticality_reject;
ie2->value.present = F1AP_UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, complete->rnti);
ie2->value.choice.GNB_DU_UE_F1AP_ID = complete->gNB_DU_ue_id;
/* optional -> currently not used */
/* c3. CriticalityDiagnostics */
//if (0) {
......@@ -778,7 +776,7 @@ int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, f1ap_ue_context_rel
buffer,
len,
getCxt(false, instance)->default_sctp_stream_id);
f1ap_remove_ue(DUtype, instance, complete->rnti);
f1ap_remove_ue(DUtype, instance, complete->gNB_DU_ue_id);
return 0;
}
......
......@@ -47,6 +47,7 @@
#include "RRC/NR/MESSAGES/asn1_msg.h"
#include "intertask_interface.h"
#include "openair2/F1AP/f1ap_ids.h"
#include "T.h"
......@@ -2983,8 +2984,10 @@ void nr_mac_check_ul_failure(const gNB_MAC_INST *nrmac, int rnti, NR_UE_sched_ct
/* to trigger only once: trigger when ul_failure_timer == 1, but timer will
* stop at 0 and we wait for a UE release command from upper layers */
if (sched_ctrl->ul_failure_timer == 1) {
f1_ue_data_t ue_data = du_get_f1_ue_data(rnti);
f1ap_ue_context_release_complete_t complete = {
.rnti = rnti,
.gNB_CU_ue_id = ue_data.secondary_ue,
.gNB_DU_ue_id = rnti,
.cause = F1AP_CAUSE_RADIO_NETWORK,
.cause_value = 12, // F1AP_CauseRadioNetwork_rl_failure_others
};
......
......@@ -248,25 +248,26 @@ void ue_context_release_command(const f1ap_ue_context_release_cmd_t *cmd)
/* mark UE as to be deleted after PUSCH failure */
gNB_MAC_INST *mac = RC.nrmac[0];
pthread_mutex_lock(&mac->sched_lock);
NR_UE_info_t *UE = find_nr_UE(&mac->UE_info, cmd->rnti);
NR_UE_info_t *UE = find_nr_UE(&mac->UE_info, cmd->gNB_DU_ue_id);
if (UE->UE_sched_ctrl.ul_failure || cmd->rrc_container_length == 0) {
/* The UE is already not connected anymore or we have nothing to forward*/
nr_rlc_remove_ue(cmd->rnti);
mac_remove_nr_ue(mac, cmd->rnti);
nr_rlc_remove_ue(cmd->gNB_DU_ue_id);
mac_remove_nr_ue(mac, cmd->gNB_DU_ue_id);
} else {
/* UE is in sync: forward release message and mark to be deleted
* after UL failure */
nr_rlc_srb_recv_sdu(cmd->rnti, cmd->srb_id, cmd->rrc_container, cmd->rrc_container_length);
nr_rlc_srb_recv_sdu(cmd->gNB_DU_ue_id, cmd->srb_id, cmd->rrc_container, cmd->rrc_container_length);
nr_mac_trigger_release_timer(&UE->UE_sched_ctrl, UE->current_UL_BWP.scs);
}
pthread_mutex_unlock(&mac->sched_lock);
f1ap_ue_context_release_complete_t complete = {
.rnti = cmd->rnti,
.gNB_CU_ue_id = cmd->gNB_CU_ue_id,
.gNB_DU_ue_id = cmd->gNB_DU_ue_id,
};
mac->mac_rrc.ue_context_release_complete(&complete);
du_remove_f1_ue_data(cmd->rnti);
du_remove_f1_ue_data(cmd->gNB_DU_ue_id);
}
void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc)
......
......@@ -106,7 +106,7 @@ static void ue_context_release_request_f1ap(const f1ap_ue_context_release_req_t*
static void ue_context_release_complete_f1ap(const f1ap_ue_context_release_complete_t *complete)
{
newGtpuDeleteAllTunnels(0, complete->rnti);
newGtpuDeleteAllTunnels(0, complete->gNB_DU_ue_id);
MessageDef *msg = itti_alloc_new_message(TASK_MAC_GNB, 0, F1AP_UE_CONTEXT_RELEASE_COMPLETE);
f1ap_ue_context_release_complete_t *f1ap_msg = &F1AP_UE_CONTEXT_RELEASE_COMPLETE(msg);
......
......@@ -2315,10 +2315,10 @@ static void rrc_CU_process_ue_context_release_request(MessageDef *msg_p)
const int instance = 0;
f1ap_ue_context_release_req_t *req = &F1AP_UE_CONTEXT_RELEASE_REQ(msg_p);
gNB_RRC_INST *rrc = RC.nrrrc[instance];
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, req->rnti);
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, req->gNB_CU_ue_id); //here
/* TODO: marshall types correctly */
LOG_I(NR_RRC, "received UE Context Release Request for UE %04x, forwarding to AMF\n", req->rnti);
LOG_I(NR_RRC, "received UE Context Release Request for UE %u, forwarding to AMF\n", req->gNB_CU_ue_id);
rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_REQ(instance,
ue_context_p,
NGAP_CAUSE_RADIO_NETWORK,
......@@ -2330,7 +2330,7 @@ static void rrc_CU_process_ue_context_release_complete(MessageDef *msg_p)
const int instance = 0;
f1ap_ue_context_release_complete_t *complete = &F1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_p);
gNB_RRC_INST *rrc = RC.nrrrc[instance];
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, complete->rnti);
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, complete->gNB_CU_ue_id); // here
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
nr_pdcp_remove_UE(UE->rnti);
......@@ -2946,22 +2946,17 @@ rrc_gNB_generate_UECapabilityEnquiry(
nr_rrc_transfer_protected_rrc_message(rrc, ue, DCCH, buffer, size);
}
typedef struct deliver_ue_ctxt_release_data_t {
gNB_RRC_INST *rrc;
f1ap_ue_context_release_cmd_t *release_cmd;
} deliver_ue_ctxt_release_data_t;
static void rrc_deliver_ue_ctxt_release_cmd(void *deliver_pdu_data, ue_id_t ue_id, int srb_id, char *buf, int size, int sdu_id)
{
DevAssert(deliver_pdu_data != NULL);
gNB_RRC_INST *rrc = deliver_pdu_data;
uint8_t *rrc_container = malloc(size);
AssertFatal(rrc_container != NULL, "out of memory\n");
memcpy(rrc_container, buf, size);
f1ap_ue_context_release_cmd_t ue_context_release_cmd = {
.rnti = ue_id, /* TODO: proper IDs! */
.cause = F1AP_CAUSE_RADIO_NETWORK,
.cause_value = 10, // 10 = F1AP_CauseRadioNetwork_normal_release
.srb_id = srb_id,
.rrc_container = rrc_container,
.rrc_container_length = size,
};
rrc->mac_rrc.ue_context_release_command(&ue_context_release_cmd);
deliver_ue_ctxt_release_data_t *data = deliver_pdu_data;
data->release_cmd->rrc_container = (uint8_t*) buf;
data->release_cmd->rrc_container_length = size;
data->rrc->mac_rrc.ue_context_release_command(data->release_cmd);
}
//-----------------------------------------------------------------------------
......@@ -2985,7 +2980,17 @@ rrc_gNB_generate_RRCRelease(
size);
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, rrc_deliver_ue_ctxt_release_cmd, rrc);
const gNB_RRC_UE_t *UE = &ue_context_pP->ue_context;
f1_ue_data_t ue_data = cu_get_f1_ue_data(UE->rnti);
f1ap_ue_context_release_cmd_t ue_context_release_cmd = {
.gNB_CU_ue_id = UE->cu_ue_id,
.gNB_DU_ue_id = ue_data.secondary_ue,
.cause = F1AP_CAUSE_RADIO_NETWORK,
.cause_value = 10, // 10 = F1AP_CauseRadioNetwork_normal_release
.srb_id = DCCH,
};
deliver_ue_ctxt_release_data_t data = {.rrc = rrc, .release_cmd = &ue_context_release_cmd};
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, rrc_deliver_ue_ctxt_release_cmd, &data);
/* UE will be freed after UE context release complete */
}
......
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