Commit 09438910 authored by Robert Schmidt's avatar Robert Schmidt

Use CU/DU UE ID in DL RRC Message Transfer, manage at DU, refactor

- The CU/DU UE ID is used in DL RRC Message Transfer
- Note: The CU UE ID currently is still the RNTI
- on every DL RRC Message, the DU verifies that the UE exists
- Refactor RRC: common function to forward protected SRB PDUs
parent 0a0f6b79
......@@ -286,8 +286,7 @@ typedef struct f1ap_dl_rrc_message_s {
uint32_t gNB_CU_ue_id;
uint32_t gNB_DU_ue_id;
uint32_t old_gNB_DU_ue_id;
uint16_t rnti;
uint32_t *old_gNB_DU_ue_id;
uint8_t srb_id;
uint8_t execute_duplication;
uint8_t *rrc_container;
......
......@@ -138,17 +138,18 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(CUtype, instance, f1ap_dl_rrc->rnti);
LOG_D(F1AP, "Setting GNB_CU_UE_F1AP_ID %llu associated with UE RNTI %x (instance %ld)\n",
(unsigned long long int)ie1->value.choice.GNB_CU_UE_F1AP_ID, f1ap_dl_rrc->rnti, instance);
DevAssert(f1ap_dl_rrc->gNB_CU_ue_id != 0);
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_dl_rrc->gNB_CU_ue_id;
/* mandatory */
/* c2. GNB_DU_UE_F1AP_ID */
asn1cSequenceAdd(out->protocolIEs.list, F1AP_DLRRCMessageTransferIEs_t, ie2);
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
ie2->criticality = F1AP_Criticality_reject;
ie2->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(CUtype, instance, f1ap_dl_rrc->rnti);
LOG_D(F1AP, "GNB_DU_UE_F1AP_ID %llu associated with UE RNTI %x \n", (unsigned long long int)ie2->value.choice.GNB_DU_UE_F1AP_ID, f1ap_dl_rrc->rnti);
DevAssert(f1ap_dl_rrc->gNB_DU_ue_id != 0);
ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_dl_rrc->gNB_DU_ue_id;
/* optional */
/* c3. oldgNB_DU_UE_F1AP_ID */
/* if (f1ap_dl_rrc->old_gNB_DU_ue_id != 0xFFFFFFFF) {
......
......@@ -60,8 +60,6 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
F1AP_F1AP_PDU_t *pdu) {
F1AP_DLRRCMessageTransfer_t *container;
F1AP_DLRRCMessageTransferIEs_t *ie;
uint64_t cu_ue_f1ap_id;
uint64_t du_ue_f1ap_id;
int executeDuplication;
//uint64_t subscriberProfileIDforRFP;
//uint64_t rAT_FrequencySelectionPriority;
......@@ -70,15 +68,11 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
/* GNB_CU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
LOG_D(F1AP, "cu_ue_f1ap_id %lu \n", cu_ue_f1ap_id);
uint32_t cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
/* GNB_DU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
LOG_D(F1AP, "du_ue_f1ap_id %lu associated with UE RNTI %x \n",
du_ue_f1ap_id,
f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id)); // this should be the one transmitted via initial ul rrc message transfer
uint32_t du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
if (f1ap_du_add_cu_ue_id(instance,du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) {
LOG_E(F1AP, "Failed to find the F1AP UID \n");
......@@ -135,9 +129,10 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
}
f1ap_dl_rrc_message_t dl_rrc = {
.gNB_CU_ue_id = cu_ue_f1ap_id,
.gNB_DU_ue_id = du_ue_f1ap_id,
.rrc_container_length = ie->value.choice.RRCContainer.size,
.rrc_container = ie->value.choice.RRCContainer.buf,
.rnti = f1ap_get_rnti_by_du_id(DUtype, instance, du_ue_f1ap_id),
.srb_id = srb_id
};
dl_rrc_message_transfer(&dl_rrc);
......
......@@ -22,6 +22,7 @@
#include "mac_rrc_dl_handler.h"
#include "mac_proto.h"
#include "openair2/F1AP/f1ap_ids.h"
#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include "openair2/RRC/NR/MESSAGES/asn1_msg.h"
......@@ -266,12 +267,37 @@ void ue_context_release_command(const f1ap_ue_context_release_cmd_t *cmd)
.rnti = cmd->rnti,
};
mac->mac_rrc.ue_context_release_complete(&complete);
du_remove_f1_ue_data(cmd->rnti);
}
void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc)
{
LOG_D(NR_MAC, "DL RRC Message Transfer with %d bytes for RNTI %04x SRB %d\n", dl_rrc->rrc_container_length, dl_rrc->rnti, dl_rrc->srb_id);
LOG_D(NR_MAC,
"DL RRC Message Transfer with %d bytes for RNTI %04x SRB %d\n",
dl_rrc->rrc_container_length,
dl_rrc->gNB_DU_ue_id,
dl_rrc->srb_id);
gNB_MAC_INST *mac = RC.nrmac[0];
pthread_mutex_lock(&mac->sched_lock);
/* check first that the scheduler knows such UE */
NR_UE_info_t *UE = find_nr_UE(&mac->UE_info, dl_rrc->gNB_DU_ue_id);
if (UE == NULL) {
LOG_E(MAC, "ERROR: unknown UE with RNTI %04x, ignoring DL RRC Message Transfer\n", dl_rrc->gNB_DU_ue_id);
pthread_mutex_unlock(&mac->sched_lock);
return;
}
pthread_mutex_unlock(&mac->sched_lock);
if (!du_exists_f1_ue_data(dl_rrc->gNB_DU_ue_id)) {
LOG_I(NR_MAC, "No CU UE ID stored for UE RNTI %04x, adding CU UE ID %d\n", dl_rrc->gNB_DU_ue_id, dl_rrc->gNB_CU_ue_id);
f1_ue_data_t new_ue_data = {.secondary_ue = dl_rrc->gNB_CU_ue_id};
du_add_f1_ue_data(dl_rrc->gNB_DU_ue_id, &new_ue_data);
}
AssertFatal(dl_rrc->old_gNB_DU_ue_id == NULL, "changing RNTI not implemented yet\n");
/* the DU ue id is the RNTI */
nr_rlc_srb_recv_sdu(dl_rrc->rnti, dl_rrc->srb_id, dl_rrc->rrc_container, dl_rrc->rrc_container_length);
nr_rlc_srb_recv_sdu(dl_rrc->gNB_DU_ue_id, dl_rrc->srb_id, dl_rrc->rrc_container, dl_rrc->rrc_container_length);
}
......@@ -740,19 +740,6 @@ void deliver_pdu_srb_rlc(void *deliver_pdu_data, ue_id_t ue_id, int srb_id,
enqueue_rlc_data_req(&ctxt, 1, MBMS_FLAG_NO, srb_id, sdu_id, 0, size, memblock);
}
void deliver_pdu_srb_f1(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;
f1ap_dl_rrc_message_t dl_rrc = {.old_gNB_DU_ue_id = 0xFFFFFF,
.rrc_container = (uint8_t *)buf,
.rrc_container_length = size,
.rnti = ue_id,
.srb_id = srb_id};
rrc->mac_rrc.dl_rrc_message_transfer(&dl_rrc);
}
static void add_srb(int is_gnb, ue_id_t rntiMaybeUEid, struct NR_SRB_ToAddMod *s, int ciphering_algorithm, int integrity_algorithm, unsigned char *ciphering_key, unsigned char *integrity_key)
{
nr_pdcp_entity_t *pdcp_srb;
......
......@@ -80,10 +80,7 @@ bool cu_f1u_data_req(protocol_ctxt_t *ctxt_pP,
typedef void (*deliver_pdu)(void *data, ue_id_t ue_id, int srb_id,
char *buf, int size, int sdu_id);
/* default implementation of deliver_pdu */
void deliver_pdu_srb_rlc(void *data, ue_id_t ue_id, int srb_id, char *buf,
int size, int sdu_id);
void deliver_pdu_srb_f1(void *data, ue_id_t ue_id, int srb_id, char *buf,
int size, int sdu_id);
void deliver_pdu_srb_rlc(void *data, ue_id_t ue_id, int srb_id, char *buf, int size, int sdu_id);
bool nr_pdcp_data_req_srb(ue_id_t ue_id,
const rb_id_t rb_id,
const mui_t muiP,
......
......@@ -92,6 +92,11 @@ static void dl_rrc_message_transfer_f1ap(const f1ap_dl_rrc_message_t *dl_rrc)
MessageDef *message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_DL_RRC_MESSAGE);
f1ap_dl_rrc_message_t *msg = &F1AP_DL_RRC_MESSAGE(message_p);
*msg = *dl_rrc;
if (dl_rrc->old_gNB_DU_ue_id) {
msg->old_gNB_DU_ue_id = malloc(sizeof(*msg->old_gNB_DU_ue_id));
AssertFatal(msg->old_gNB_DU_ue_id != NULL, "out of memory\n");
*msg->old_gNB_DU_ue_id = *dl_rrc->old_gNB_DU_ue_id;
}
if (dl_rrc->rrc_container) {
msg->rrc_container = malloc(dl_rrc->rrc_container_length);
AssertFatal(msg->rrc_container != NULL, "out of memory\n");
......
......@@ -172,4 +172,7 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
int rrc_gNB_generate_pcch_msg(uint32_t tmsi, uint8_t paging_drx, instance_t instance, uint8_t CC_id);
void nr_rrc_transfer_protected_rrc_message(const gNB_RRC_INST *rrc, const gNB_RRC_UE_t *ue_p, uint8_t srb_id, const uint8_t* buffer, int size);
#endif
......@@ -228,6 +228,29 @@ static void nr_rrc_addmod_drbs(int rnti,
}
}
typedef struct deliver_dl_rrc_message_data_s {
const gNB_RRC_INST *rrc;
f1ap_dl_rrc_message_t *dl_rrc;
} deliver_dl_rrc_message_data_t;
static void rrc_deliver_dl_rrc_message(void *deliver_pdu_data, ue_id_t ue_id, int srb_id, char *buf, int size, int sdu_id)
{
DevAssert(deliver_pdu_data != NULL);
deliver_dl_rrc_message_data_t *data = (deliver_dl_rrc_message_data_t *)deliver_pdu_data;
data->dl_rrc->rrc_container = (uint8_t *)buf;
data->dl_rrc->rrc_container_length = size;
DevAssert(data->dl_rrc->srb_id == srb_id);
data->rrc->mac_rrc.dl_rrc_message_transfer(data->dl_rrc);
}
void nr_rrc_transfer_protected_rrc_message(const gNB_RRC_INST *rrc, const gNB_RRC_UE_t *ue_p, uint8_t srb_id, const uint8_t* buffer, int size)
{
DevAssert(size > 0);
f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->cu_ue_id);
f1ap_dl_rrc_message_t dl_rrc = {.gNB_CU_ue_id = ue_p->cu_ue_id, .gNB_DU_ue_id = ue_data.secondary_ue, .srb_id = srb_id};
deliver_dl_rrc_message_data_t data = {.rrc = rrc, .dl_rrc = &dl_rrc};
nr_pdcp_data_req_srb(ue_p->cu_ue_id, srb_id, rrc_gNB_mui++, size, (unsigned char *const)buffer, rrc_deliver_dl_rrc_message, &data);
}
///---------------------------------------------------------------------------------------------------------------///
///---------------------------------------------------------------------------------------------------------------///
......@@ -471,11 +494,12 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance,
nr_pdcp_add_srbs(true, rnti, SRBs, 0, NULL, NULL);
freeSRBlist(SRBs);
f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rnti);
f1ap_dl_rrc_message_t dl_rrc = {
.old_gNB_DU_ue_id = 0xFFFFFF,
.gNB_CU_ue_id = ue_p->cu_ue_id,
.gNB_DU_ue_id = ue_data.secondary_ue,
.rrc_container = buf,
.rrc_container_length = size,
.rnti = ue_p->rnti,
.srb_id = CCCH
};
rrc->mac_rrc.dl_rrc_message_transfer(&dl_rrc);
......@@ -531,11 +555,12 @@ static int rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t m
PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, 0, GNB_FLAG_YES, rnti, 0, 0);
apply_macrlc_config(rrc_instance_p, ue_context_pP, &ctxt);
f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rnti);
f1ap_dl_rrc_message_t dl_rrc = {
.old_gNB_DU_ue_id = 0xFFFFFF,
.gNB_CU_ue_id = ue_p->cu_ue_id,
.gNB_DU_ue_id = ue_data.secondary_ue,
.rrc_container = buf,
.rrc_container_length = size,
.rnti = ue_p->rnti,
.srb_id = CCCH
};
rrc_instance_p->mac_rrc.dl_rrc_message_transfer(&dl_rrc);
......@@ -560,13 +585,12 @@ static void rrc_gNB_generate_RRCReject(module_id_t module_id, rrc_gNB_ue_context
"[MSG] RRCReject \n");
LOG_I(NR_RRC, " [RAPROC] ue %04x Logical Channel DL-CCCH, Generating NR_RRCReject (bytes %d)\n", ue_p->rnti, size);
f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rnti);
f1ap_dl_rrc_message_t dl_rrc = {
.gNB_CU_ue_id = 0,
.gNB_DU_ue_id = 0,
.old_gNB_DU_ue_id = 0xFFFFFF,
.gNB_CU_ue_id = ue_p->cu_ue_id,
.gNB_DU_ue_id = ue_data.secondary_ue,
.rrc_container = buf,
.rrc_container_length = size,
.rnti = ue_p->rnti,
.srb_id = CCCH,
.execute_duplication = 1,
.RAT_frequency_priority_information.en_dc = 0
......@@ -674,7 +698,7 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co
ue_context_pP->ue_context.rnti);
AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n");
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size);
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
......@@ -781,7 +805,7 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c
ctxt_pP->module_id,
DCCH);
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size);
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, ue_context_pP->ue_context.masterCellGroup);
......@@ -934,7 +958,7 @@ rrc_gNB_modify_dedicatedRRCReconfiguration(
DCCH);
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size);
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated
......@@ -1015,7 +1039,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release(
DCCH);
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size);
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated
......@@ -1218,7 +1242,7 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
apply_macrlc_config_reest(rrc, ue_context_pP, ctxt_pP, ctxt_pP->rntiMaybeUEid);
}
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size);
}
/// @brief Function used in RRCReestablishmentComplete procedure to update the NGU Tunnels.
......@@ -1401,7 +1425,7 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx
DCCH);
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, cellGroupConfig);
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size);
}
if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) {
......@@ -1457,7 +1481,7 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, masterCellGroup);
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size);
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated
......@@ -2912,7 +2936,8 @@ rrc_gNB_generate_UECapabilityEnquiry(
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n");
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
const gNB_RRC_UE_t *ue = &ue_context_pP->ue_context;
nr_rrc_transfer_protected_rrc_message(rrc, ue, DCCH, buffer, size);
}
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)
......
......@@ -58,6 +58,7 @@
#include "NR_UE-CapabilityRAT-ContainerList.h"
#include "NGAP_CauseRadioNetwork.h"
#include "f1ap_messages_types.h"
#include "openair2/F1AP/f1ap_ids.h"
#include "openair2/E1AP/e1ap_asnc.h"
#include "NGAP_asn_constant.h"
#include "NGAP_PDUSessionResourceSetupRequestTransfer.h"
......@@ -618,7 +619,7 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu
AssertFatal(!NODE_IS_DU(RC.nrrrc[ctxt.module_id]->node_type), "illegal node type DU: receiving NGAP messages at this node\n");
/* Transfer data to PDCP */
rb_id_t srb_id = UE->Srb[2].Active ? DCCH1 : DCCH;
nr_pdcp_data_req_srb(ctxt.rntiMaybeUEid, srb_id, (*rrc_gNB_mui)++, length, buffer, deliver_pdu_srb_f1, RC.nrrrc[instance]);
nr_rrc_transfer_protected_rrc_message(RC.nrrrc[instance], UE, srb_id, buffer, length);
return 0;
}
......
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