From d220ee23e2c54a490f7088ac42fbf61d806a250b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 26 May 2023 16:36:28 +0200 Subject: [PATCH] UL RRC Message has CU/DU UE IDs --- openair2/COMMON/f1ap_messages_types.h | 3 ++- openair2/F1AP/f1ap_cu_rrc_message_transfer.c | 12 +++++++++++- openair2/F1AP/f1ap_du_rrc_message_transfer.c | 18 +++++++++++------- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 7 ++++++- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 16 +++++++++++++--- openair2/RRC/NR/rrc_gNB.c | 3 ++- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index ea328c7671..16e67e2927 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -317,7 +317,8 @@ typedef struct f1ap_initial_ul_rrc_message_s { } f1ap_initial_ul_rrc_message_t; typedef struct f1ap_ul_rrc_message_s { - uint16_t rnti; + uint32_t gNB_CU_ue_id; + uint32_t gNB_DU_ue_id; uint8_t srb_id; uint8_t *rrc_container; int rrc_container_length; diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c index c91d662893..061b693d3e 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c @@ -32,6 +32,7 @@ #include "f1ap_common.h" #include "f1ap_encoder.h" +#include "f1ap_ids.h" #include "f1ap_itti_messaging.h" #include "f1ap_cu_rrc_message_transfer.h" #include "common/ran_context.h" @@ -253,6 +254,15 @@ int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance, du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID; LOG_D(F1AP, "du_ue_f1ap_id %lu associated with RNTI %x\n", du_ue_f1ap_id, f1ap_get_rnti_by_cu_id(CUtype, instance, du_ue_f1ap_id)); + /* the RLC-PDCP does not transport the DU UE ID (yet), so we drop it here. + * For the moment, let's hope this won't become relevant; to sleep in peace, + * let's put an assert to check that it is the expected DU UE ID. */ + f1_ue_data_t ue_data = cu_get_f1_ue_data(cu_ue_f1ap_id); + AssertFatal(ue_data.secondary_ue == du_ue_f1ap_id, + "unexpected DU UE ID %d received, expected it to be %ld\n", + ue_data.secondary_ue, + du_ue_f1ap_id); + /* mandatory */ /* SRBID */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container, @@ -272,7 +282,7 @@ int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance, protocol_ctxt_t ctxt={0}; ctxt.instance = instance; ctxt.module_id = instance; - ctxt.rntiMaybeUEid = f1ap_get_rnti_by_cu_id(CUtype, instance, cu_ue_f1ap_id); + ctxt.rntiMaybeUEid = cu_ue_f1ap_id; ctxt.enb_flag = 1; ctxt.eNB_index = 0; mem_block_t *mb = get_free_mem_block(ie->value.choice.RRCContainer.size,__func__); diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index 76d6108386..91e2c29f4b 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -220,15 +220,19 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instanceP, const f1ap_ini return 0; } -int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, - const f1ap_ul_rrc_message_t *msg) { - const rnti_t rnti = msg->rnti; +int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, const f1ap_ul_rrc_message_t *msg) +{ F1AP_F1AP_PDU_t pdu= {0}; F1AP_ULRRCMessageTransfer_t *out; uint8_t *buffer = NULL; uint32_t len; - LOG_D(F1AP, "[DU %ld] %s: size %d UE RNTI %x in SRB %d\n", - instance, __func__, msg->rrc_container_length, rnti, msg->srb_id); + LOG_D(F1AP, + "[DU %ld] %s: size %d UE RNTI %x in SRB %d\n", + instance, + __func__, + msg->rrc_container_length, + msg->gNB_DU_ue_id, + msg->srb_id); //for (int i = 0;i < msg->rrc_container_length; i++) // printf("%02x ", msg->rrc_container[i]); //printf("\n"); @@ -246,14 +250,14 @@ int DU_send_UL_NR_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_ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID; - ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(DUtype, instance, rnti); + ie1->value.choice.GNB_CU_UE_F1AP_ID = msg->gNB_CU_ue_id; /* mandatory */ /* c2. GNB_DU_UE_F1AP_ID */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie2); ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; ie2->criticality = F1AP_Criticality_reject; ie2->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID; - ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(DUtype, instance, rnti); + ie2->value.choice.GNB_DU_UE_F1AP_ID = msg->gNB_DU_ue_id; /* mandatory */ /* c3. SRBID */ asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie3); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 1cb0c24aa0..32d8e4d0ed 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -36,6 +36,7 @@ #include "oai_asn1.h" #include "nr_pdcp_oai_api.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" +#include "openair2/F1AP/f1ap_ids.h" #include #include "openair2/SDAP/nr_sdap/nr_sdap.h" #include "nr_pdcp_e1_api.h" @@ -710,7 +711,11 @@ srb_found: MessageDef *message_p = itti_alloc_new_message(TASK_PDCP_GNB, 0, F1AP_UL_RRC_MESSAGE); AssertFatal(message_p != NULL, "OUT OF MEMORY\n"); f1ap_ul_rrc_message_t *ul_rrc = &F1AP_UL_RRC_MESSAGE(message_p); - ul_rrc->rnti = ue->rntiMaybeUEid; + ul_rrc->gNB_CU_ue_id = ue->rntiMaybeUEid; + /* look up the correct secondary UE ID to provide complete information to + * RRC, the RLC-PDCP interface does not transport this information */ + f1_ue_data_t ue_data = cu_get_f1_ue_data(ue->rntiMaybeUEid); + ul_rrc->gNB_DU_ue_id = ue_data.secondary_ue; ul_rrc->srb_id = srb_id; ul_rrc->rrc_container = malloc(size); AssertFatal(ul_rrc->rrc_container != NULL, "OUT OF MEMORY\n"); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index f4097d721b..a22fe04b1b 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -39,6 +39,7 @@ #include "NR_UL-CCCH-Message.h" #include "openair2/F1AP/f1ap_du_rrc_message_transfer.h" +#include "openair2/F1AP/f1ap_ids.h" extern RAN_CONTEXT_t RC; @@ -425,11 +426,18 @@ rb_found: ctx.eNB_index = 0; ctx.brOption = 0; + is_enb = nr_rlc_manager_get_enb_flag(nr_rlc_ue_manager); + /* used fields? */ ctx.module_id = 0; + /* CU (PDCP, RRC, SDAP) use a different ID than RNTI, so below set the CU UE + * ID if in gNB, else use RNTI normally */ ctx.rntiMaybeUEid = ue->rnti; + if (is_enb) { + f1_ue_data_t ue_data = du_get_f1_ue_data(ue->rnti); + ctx.rntiMaybeUEid = ue_data.secondary_ue; + } - is_enb = nr_rlc_manager_get_enb_flag(nr_rlc_ue_manager); ctx.enb_flag = is_enb; if (is_enb) { @@ -453,7 +461,8 @@ rb_found: msg = itti_alloc_new_message(TASK_RLC_ENB, 0, F1AP_UL_RRC_MESSAGE); uint8_t *message_buffer = itti_malloc (TASK_RLC_ENB, TASK_DU_F1, size); memcpy (message_buffer, buf, size); - F1AP_UL_RRC_MESSAGE(msg).rnti = ue->rnti; + F1AP_UL_RRC_MESSAGE(msg).gNB_CU_ue_id = ctx.rntiMaybeUEid; + F1AP_UL_RRC_MESSAGE(msg).gNB_DU_ue_id = ue->rnti; F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_id; F1AP_UL_RRC_MESSAGE(msg).rrc_container = message_buffer; F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size; @@ -467,7 +476,7 @@ rb_found: memcpy(req->buffer,buf,size); req->length=size; req->offset=0; - req->ue_id=ue->rnti; + req->ue_id=ctx.rntiMaybeUEid; req->bearer_id=rb_id; LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size); extern instance_t DUuniqInstance; @@ -477,6 +486,7 @@ rb_found: } } + /* UE or monolithic gNB */ memblock = get_free_mem_block(size, __func__); if (memblock == NULL) { LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 84f9363c4f..986f37080f 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -2754,7 +2754,7 @@ void *rrc_gnb_task(void *args_p) { PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, - F1AP_UL_RRC_MESSAGE(msg_p).rnti, + F1AP_UL_RRC_MESSAGE(msg_p).gNB_CU_ue_id, 0, 0); LOG_D(NR_RRC, @@ -2764,6 +2764,7 @@ void *rrc_gnb_task(void *args_p) { instance, &ctxt, F1AP_UL_RRC_MESSAGE(msg_p).rrc_container_length); + DevAssert(F1AP_UL_RRC_MESSAGE(msg_p).gNB_CU_ue_id == F1AP_UL_RRC_MESSAGE(msg_p).gNB_DU_ue_id); rrc_gNB_decode_dcch(&ctxt, F1AP_UL_RRC_MESSAGE(msg_p).srb_id, F1AP_UL_RRC_MESSAGE(msg_p).rrc_container,