Commit 0dce41dc authored by General ABS's avatar General ABS Committed by abs

Get C-RNTI and new UE context at gNB-CU, and new F1AP UE context at gNB-DU

parent 21ae0019
......@@ -411,6 +411,7 @@ typedef struct f1ap_ue_context_setup_s {
//uint8_t *du_to_cu_rrc_information;
du_to_cu_rrc_information_t *du_to_cu_rrc_information;
uint32_t du_to_cu_rrc_information_length;
uint16_t *crnti;
f1ap_drb_to_be_setup_t *drbs_to_be_setup;
uint8_t drbs_to_be_setup_length;
f1ap_drb_to_be_setup_t *drbs_to_be_modified;
......
......@@ -671,6 +671,28 @@ int CU_handle_UE_CONTEXT_SETUP_RESPONSE(instance_t instance,
LOG_D(F1AP, "f1ap_ue_context_setup_resp->gNB_DU_ue_id is: %d \n", f1ap_ue_context_setup_resp->gNB_DU_ue_id);
f1ap_ue_context_setup_resp->rnti =
f1ap_get_rnti_by_du_id(CUtype, instance, f1ap_ue_context_setup_resp->gNB_DU_ue_id);
f1ap_cudu_inst_t *f1_inst = getCxt(CUtype, instance);
if (f1ap_ue_context_setup_resp->rnti == (uint16_t)(-1)) {
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container, F1AP_ProtocolIE_ID_id_C_RNTI, false);
if (ie == NULL) {
LOG_E(F1AP,"%s %d: RNTI was not found!\n",__FILE__,__LINE__);
return -1;
} else {
f1ap_ue_context_setup_resp->rnti = ie->value.choice.C_RNTI;
int f1ap_uid = f1ap_add_ue(CUtype, instance, ie->value.choice.C_RNTI);
if (f1ap_uid < 0 ) {
LOG_E(F1AP, "Failed to add UE \n");
return -1;
}
f1_inst->rnti_update.new_rnti = f1ap_ue_context_setup_resp->rnti;
f1ap_ue_context_setup_resp->crnti = calloc(1, sizeof(uint16_t));
*f1ap_ue_context_setup_resp->crnti = f1ap_ue_context_setup_resp->rnti;
f1ap_ue_context_setup_resp->gNB_CU_ue_id = f1ap_get_cu_ue_f1ap_id(CUtype, instance, ie->value.choice.C_RNTI);
f1ap_ue_context_setup_resp->gNB_DU_ue_id = f1ap_get_du_ue_f1ap_id(CUtype, instance, ie->value.choice.C_RNTI);
}
}
// DUtoCURRCInformation
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupResponseIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_DUtoCURRCInformation, true);
......
......@@ -38,6 +38,7 @@
#include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
#include <SIMULATION/TOOLS/sim.h>
bool DURecvCb(protocol_ctxt_t *ctxt_pP,
const srb_flag_t srb_flagP,
......@@ -304,14 +305,12 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, f1ap_ue_context_setup
/* optional */
/* c4. C_RNTI */
if (0) {
if (resp->crnti!=NULL) {
asn1cSequenceAdd(out->protocolIEs.list, F1AP_UEContextSetupResponseIEs_t, ie4);
ie4->id = F1AP_ProtocolIE_ID_id_C_RNTI;
ie4->criticality = F1AP_Criticality_ignore;
ie4->value.present = F1AP_UEContextSetupResponseIEs__value_PR_C_RNTI;
//C_RNTI_TO_BIT_STRING(rntiP, &ie->value.choice.C_RNTI);
ie4->value.choice.C_RNTI=resp->rnti;
LOG_E(F1AP,"RNTI to code!\n");
ie4->value.choice.C_RNTI = *resp->crnti;
}
/* optional */
......
......@@ -172,7 +172,7 @@ void ue_context_setup_request(instance_t instance, const f1ap_ue_context_setup_t
}
if (req->rrc_container != NULL)
nr_rlc_srb_recv_sdu(req->rnti, DCCH, req->rrc_container, req->rrc_container_length);
nr_rlc_srb_recv_sdu(resp.rnti, DCCH, req->rrc_container, req->rrc_container_length);
//nr_mac_update_cellgroup()
resp.du_to_cu_rrc_information = calloc(1, sizeof(du_to_cu_rrc_information_t));
......
......@@ -24,7 +24,7 @@
#include "mac_rrc_ul.h"
static void ue_context_setup_response_direct(const f1ap_ue_context_setup_t *req, const f1ap_ue_context_setup_t *resp)
static void ue_context_setup_response_direct(instance_t instance, const f1ap_ue_context_setup_t *req, const f1ap_ue_context_setup_t *resp)
{
DevAssert(req->drbs_to_be_setup_length == resp->drbs_to_be_setup_length);
AssertFatal(req->drbs_to_be_setup_length == 0, "not implemented\n");
......
......@@ -29,12 +29,13 @@
#include "mac_rrc_ul.h"
static void ue_context_setup_response_f1ap(const f1ap_ue_context_setup_t *req, const f1ap_ue_context_setup_t *resp)
static void ue_context_setup_response_f1ap(instance_t instance,
const f1ap_ue_context_setup_t *req,
const f1ap_ue_context_setup_t *resp)
{
DevAssert(req->drbs_to_be_setup_length == resp->drbs_to_be_setup_length);
AssertFatal(req->drbs_to_be_setup_length == 0, "not implmented\n");
DevAssert(req->srbs_to_be_setup_length == resp->srbs_to_be_setup_length);
MessageDef *msg = itti_alloc_new_message (TASK_MAC_GNB, 0, F1AP_UE_CONTEXT_SETUP_RESP);
f1ap_ue_context_setup_t *f1ap_msg = &F1AP_UE_CONTEXT_SETUP_RESP(msg);
/* copy all fields, but reallocate rrc_containers! */
......@@ -48,6 +49,15 @@ static void ue_context_setup_response_f1ap(const f1ap_ue_context_setup_t *req, c
f1ap_msg->srbs_to_be_setup[i] = resp->srbs_to_be_setup[i];
}
if (resp->drbs_to_be_setup_length > 0) {
DevAssert(resp->drbs_to_be_setup != NULL);
f1ap_msg->drbs_to_be_setup_length = resp->drbs_to_be_setup_length;
f1ap_msg->drbs_to_be_setup = calloc(f1ap_msg->drbs_to_be_setup_length, sizeof(*f1ap_msg->drbs_to_be_setup));
for (int i = 0; i < f1ap_msg->drbs_to_be_setup_length; ++i) {
f1ap_msg->drbs_to_be_setup[i] = resp->drbs_to_be_setup[i];
}
}
f1ap_msg->du_to_cu_rrc_information = malloc(sizeof(*resp->du_to_cu_rrc_information));
AssertFatal(f1ap_msg->du_to_cu_rrc_information != NULL, "out of memory\n");
f1ap_msg->du_to_cu_rrc_information_length = resp->du_to_cu_rrc_information_length;
......@@ -57,7 +67,7 @@ static void ue_context_setup_response_f1ap(const f1ap_ue_context_setup_t *req, c
AssertFatal(du2cu->cellGroupConfig != NULL, "out of memory\n");
memcpy(du2cu->cellGroupConfig, resp->du_to_cu_rrc_information->cellGroupConfig, du2cu->cellGroupConfig_length);
itti_send_msg_to_task(TASK_DU_F1, 0, msg);
itti_send_msg_to_task(TASK_DU_F1, instance, msg);
}
static void ue_context_modification_response_f1ap(const f1ap_ue_context_modif_req_t *req, const f1ap_ue_context_modif_resp_t *resp)
......
......@@ -2550,11 +2550,39 @@ void rrc_gNB_process_dc_overall_timeout(const module_id_t gnb_mod_idP, x2ap_ENDC
rrc_remove_nsa_user(rrc, m->rnti);
}
struct rrc_gNB_ue_context_s *find_ho_ue_context_in_source(uint8_t modid_t, uint8_t *modid_s, uint8_t *ho_idx)
{
for (int ho_id = 0; ho_id < NUMBER_OF_DU_PER_CU_MAX; ho_id++) {
if (ho_rnti_map[ho_id][3] == modid_t) {
if (modid_s != NULL) {
*modid_s = ho_rnti_map[ho_id][1];
}
if (ho_idx != NULL) {
*ho_idx = ho_id;
}
return rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[ho_rnti_map[ho_id][1]], ho_rnti_map[ho_id][0]);
}
}
return NULL;
}
static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, instance_t instance)
{
f1ap_ue_context_setup_t *resp = &F1AP_UE_CONTEXT_SETUP_RESP(msg_p);
gNB_RRC_INST *rrc = RC.nrrrc[instance];
uint8_t modid_s;
uint8_t ho_idx;
rrc_gNB_ue_context_t *ho_ue_context_in_source = NULL;
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, resp->rnti);
rrc_gNB_ue_context_t *ue_context_old = NULL;
if (ue_context_p == NULL && resp->crnti != NULL) {
ue_context_p = rrc_gNB_create_ue_context(resp->rnti, rrc, resp->rnti);
ho_ue_context_in_source = find_ho_ue_context_in_source(instance, &modid_s, &ho_idx);
ho_rnti_map[ho_idx][2] = resp->rnti;
ue_context_old = rrc_gNB_get_ue_context_by_rnti(RC.nrrrc[modid_s], ho_rnti_map[ho_idx][0]);
ue_context_p->ue_context.handover_info = ue_context_old->ue_context.handover_info;
}
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
NR_CellGroupConfig_t *cellGroupConfig = NULL;
......@@ -2576,6 +2604,38 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, instance
/* at this point, we don't have to do anything: the UE context setup request
* includes the Security Command, whose response will trigger the following
* messages (UE capability, to be specific) */
if (ho_ue_context_in_source != NULL) {
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_MODIFICATION_REQ);
f1ap_ue_context_setup_t *req = &F1AP_UE_CONTEXT_MODIFICATION_REQ(message_p);
req->rnti = ho_ue_context_in_source->ue_context.rnti;
req->mcc = RC.nrrrc[modid_s]->configuration.mcc[0];
req->mnc = RC.nrrrc[modid_s]->configuration.mnc[0];
req->mnc_digit_length = RC.nrrrc[modid_s]->configuration.mnc_digit_length[0];
req->nr_cellid = RC.nrrrc[modid_s]->nr_cellid;
protocol_ctxt_t ctxt = {.rntiMaybeUEid = ho_rnti_map[ho_idx][0], .module_id = instance, .instance = RC.nrrrc[instance]->f1_instance, .enb_flag = 1, .eNB_index = instance};
req->rrc_container = calloc(1, RRC_BUF_SIZE*sizeof(uint8_t));
req->rrc_container_length = rrc_gNB_generate_HO_RRCReconfiguration(&ctxt,
modid_s,
instance,
ue_context_p,
ue_context_old,
req->rrc_container,
RRC_BUF_SIZE,
cellGroupConfig);
// To DU send the Downlink Data Delivery Status
req->ReconfigComplOutcome = RRCreconf_success;
// To stop the data transmission
req->transmission_action_indicator = calloc(1, sizeof(uint8_t));
*req->transmission_action_indicator = 0;
itti_send_msg_to_task(TASK_CU_F1, RC.nrrrc[modid_s]->f1_instance, message_p);
}
}
static void rrc_CU_process_ue_context_release_request(MessageDef *msg_p)
......
......@@ -182,6 +182,6 @@ rrc_gNB_ue_context_t *rrc_gNB_create_ue_context(rnti_t rnti, gNB_RRC_INST *rrc_i
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_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);
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;
}
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