Commit bdef3296 authored by matzakos's avatar matzakos

Add handling of F1 Ue context setup request message at the DU side

- Trigger SRB2 and DRB configuration and RRC->MAC configuration
- Remaining: gtp-u tunnel creation at the DU side, triggering and handling of UE context setup response
parent 22b072d8
...@@ -326,6 +326,11 @@ typedef struct f1ap_drb_to_be_setup_s { ...@@ -326,6 +326,11 @@ typedef struct f1ap_drb_to_be_setup_s {
rlc_mode_t rlc_mode; rlc_mode_t rlc_mode;
} f1ap_drb_to_be_setup_t; } f1ap_drb_to_be_setup_t;
typedef struct f1ap_srb_to_be_setup_s {
long srb_id;
rlc_mode_t rlc_mode;
} f1ap_srb_to_be_setup_t;
typedef struct f1ap_ue_context_setup_req_s { typedef struct f1ap_ue_context_setup_req_s {
uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti uint32_t gNB_CU_ue_id; // BK: need to replace by use from rnti
uint32_t *gNB_DU_ue_id; uint32_t *gNB_DU_ue_id;
...@@ -342,6 +347,8 @@ typedef struct f1ap_ue_context_setup_req_s { ...@@ -342,6 +347,8 @@ typedef struct f1ap_ue_context_setup_req_s {
uint8_t cu_to_du_rrc_information_length; uint8_t cu_to_du_rrc_information_length;
f1ap_drb_to_be_setup_t *drbs_to_be_setup; // BK: need to replace by s1ap_initial_context_setup_req f1ap_drb_to_be_setup_t *drbs_to_be_setup; // BK: need to replace by s1ap_initial_context_setup_req
uint8_t drbs_to_be_setup_length; // BK: need to replace by s1ap_initial_context_setup_req uint8_t drbs_to_be_setup_length; // BK: need to replace by s1ap_initial_context_setup_req
f1ap_srb_to_be_setup_t *srbs_to_be_setup;
uint8_t srbs_to_be_setup_length;
s1ap_initial_context_setup_req_t *s1ap_initial_context_setup_req; s1ap_initial_context_setup_req_t *s1ap_initial_context_setup_req;
// coniatner for the rrc_eNB_generate_SecurityModeCommand message // coniatner for the rrc_eNB_generate_SecurityModeCommand message
uint8_t *rrc_container; uint8_t *rrc_container;
......
...@@ -87,7 +87,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ...@@ -87,7 +87,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID; ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
ie1->criticality = F1AP_Criticality_reject; ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_CU_UE_F1AP_ID; ie1->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_ue_context_setup_req->gNB_CU_ue_id; ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(true, instance, f1ap_ue_context_setup_req->rnti); //f1ap_ue_context_setup_req->gNB_CU_ue_id;
/* optional */ /* optional */
/* c2. GNB_DU_UE_F1AP_ID */ /* c2. GNB_DU_UE_F1AP_ID */
...@@ -96,7 +96,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ...@@ -96,7 +96,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID; ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
ie2->criticality = F1AP_Criticality_ignore; ie2->criticality = F1AP_Criticality_ignore;
ie2->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_DU_UE_F1AP_ID; ie2->value.present = F1AP_UEContextSetupRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
ie2->value.choice.GNB_DU_UE_F1AP_ID = *f1ap_ue_context_setup_req->gNB_DU_ue_id; ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(true, instance, f1ap_ue_context_setup_req->rnti); //*f1ap_ue_context_setup_req->gNB_DU_ue_id;
} }
/* mandatory */ /* mandatory */
......
...@@ -100,6 +100,8 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ...@@ -100,6 +100,8 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
f1ap_ue_context_setup_req->cellULConfigured = NULL; f1ap_ue_context_setup_req->cellULConfigured = NULL;
} }
f1ap_drb_to_be_setup_t *drb_p;
f1ap_srb_to_be_setup_t *srb_p;
if (RC.nrrrc) { if (RC.nrrrc) {
/* RRCContainer */ /* RRCContainer */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
...@@ -111,7 +113,7 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ...@@ -111,7 +113,7 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
"could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n"); "could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n");
for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; ++i) { for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; ++i) {
f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_setup_req->drbs_to_be_setup[i]; drb_p = &f1ap_ue_context_setup_req->drbs_to_be_setup[i];
F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p; F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p;
drbs_tobesetup_item_p = &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ie->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item; drbs_tobesetup_item_p = &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ie->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item;
drb_p->drb_id = drbs_tobesetup_item_p->dRBID; drb_p->drb_id = drbs_tobesetup_item_p->dRBID;
...@@ -135,12 +137,40 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ...@@ -135,12 +137,40 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
break; break;
} }
} }
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List, true);
f1ap_ue_context_setup_req->srbs_to_be_setup_length = ie->value.choice.SRBs_ToBeSetup_List.list.count;
f1ap_ue_context_setup_req->srbs_to_be_setup = calloc(f1ap_ue_context_setup_req->srbs_to_be_setup_length,
sizeof(f1ap_srb_to_be_setup_t));
AssertFatal(f1ap_ue_context_setup_req->srbs_to_be_setup,
"could not allocate memory for f1ap_ue_context_setup_req->srbs_to_be_setup\n");
for (i = 0; i < f1ap_ue_context_setup_req->srbs_to_be_setup_length; ++i) {
srb_p = &f1ap_ue_context_setup_req->srbs_to_be_setup[i];
F1AP_SRBs_ToBeSetup_Item_t *srbs_tobesetup_item_p;
srbs_tobesetup_item_p = &((F1AP_SRBs_ToBeSetup_ItemIEs_t *)ie->value.choice.SRBs_ToBeSetup_List.list.array[i])->value.choice.SRBs_ToBeSetup_Item;
srb_p->srb_id = srbs_tobesetup_item_p->sRBID;
}
} }
/* RRCContainer */ /* RRCContainer */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_RRCContainer, false); F1AP_ProtocolIE_ID_id_RRCContainer, false);
if(f1ap_ue_context_setup_req->gNB_DU_ue_id!=NULL){
f1ap_ue_context_setup_req->rnti = f1ap_get_rnti_by_du_id(false, instance, *f1ap_ue_context_setup_req->gNB_DU_ue_id);
}
else{
f1ap_ue_context_setup_req->rnti = f1ap_get_rnti_by_cu_id(false, instance, f1ap_ue_context_setup_req->gNB_CU_ue_id);
}
if(f1ap_ue_context_setup_req->rnti<0){
LOG_E(F1AP, "Could not retrieve UE rnti based on the CU/DU UE id \n");
}
else{
LOG_I(F1AP, "Retrieved rnti is: %d \n", f1ap_ue_context_setup_req->rnti);
}
if (ie) { if (ie) {
/* correct here */ /* correct here */
f1ap_ue_context_setup_req->rrc_container = malloc(ie->value.choice.RRCContainer.size); f1ap_ue_context_setup_req->rrc_container = malloc(ie->value.choice.RRCContainer.size);
...@@ -170,6 +200,9 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ...@@ -170,6 +200,9 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
} else { } else {
LOG_E(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); LOG_E(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer);
} }
itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p);
return 0; return 0;
} }
......
...@@ -506,6 +506,10 @@ rb_found: ...@@ -506,6 +506,10 @@ rb_found:
itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg); itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg);
return; return;
} }
else if(NODE_IS_DU(type) && is_srb == 0) {
LOG_W(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, but F1-U implementation is not in place yet \n");
return;
}
} }
if (!pdcp_data_ind(&ctx, is_srb, 0, rb_id, size, memblock)) { if (!pdcp_data_ind(&ctx, is_srb, 0, rb_id, size, memblock)) {
...@@ -715,7 +719,7 @@ static void add_rlc_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig ...@@ -715,7 +719,7 @@ static void add_rlc_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig
sn_field_length); sn_field_length);
nr_rlc_ue_add_srb_rlc_entity(ue, srb_id, nr_rlc_am); nr_rlc_ue_add_srb_rlc_entity(ue, srb_id, nr_rlc_am);
LOG_D(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); LOG_I(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti);
} }
nr_rlc_manager_unlock(nr_rlc_ue_manager); nr_rlc_manager_unlock(nr_rlc_ue_manager);
} }
...@@ -797,7 +801,7 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ ...@@ -797,7 +801,7 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_
sn_field_length); sn_field_length);
nr_rlc_ue_add_drb_rlc_entity(ue, drb_id, nr_rlc_am); nr_rlc_ue_add_drb_rlc_entity(ue, drb_id, nr_rlc_am);
LOG_D(RLC, "%s:%d:%s: added drb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti); LOG_I(RLC, "%s:%d:%s: added drb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, drb_id, rnti);
} }
nr_rlc_manager_unlock(nr_rlc_ue_manager); nr_rlc_manager_unlock(nr_rlc_ue_manager);
} }
......
...@@ -400,7 +400,7 @@ void apply_macrlc_config(gNB_RRC_INST *rrc, ...@@ -400,7 +400,7 @@ void apply_macrlc_config(gNB_RRC_INST *rrc,
nr_rrc_rlc_config_asn1_req(ctxt_pP, nr_rrc_rlc_config_asn1_req(ctxt_pP,
ue_context_pP->ue_context.SRB_configList, ue_context_pP->ue_context.SRB_configList,
NULL, ue_context_pP->ue_context.DRB_configList,
NULL, NULL,
NULL, NULL,
get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL);
...@@ -3107,6 +3107,52 @@ static int rrc_process_DU_DL(MessageDef *msg_p, const char *msg_name, instance_ ...@@ -3107,6 +3107,52 @@ static int rrc_process_DU_DL(MessageDef *msg_p, const char *msg_name, instance_
return 0; return 0;
} }
static void rrc_DU_process_ue_context_setup_request(MessageDef *msg_p, const char *msg_name, instance_t instance){
f1ap_ue_context_setup_req_t * req=&F1AP_UE_CONTEXT_SETUP_REQ(msg_p);
protocol_ctxt_t ctxt;
ctxt.rnti = req->rnti;
ctxt.module_id = instance;
ctxt.instance = instance;
ctxt.enb_flag = 1;
gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id];
struct rrc_gNB_ue_context_s *ue_context_p =
rrc_gNB_get_ue_context(rrc, ctxt.rnti);
NR_CellGroupConfig_t *cellGroupConfig;
cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t));
fill_mastercellGroupConfig(cellGroupConfig, ue_context_p->ue_context.masterCellGroup);
/* Configure SRB2 */
NR_SRB_ToAddMod_t *SRB2_config = NULL;
NR_SRB_ToAddModList_t *SRB_configList = ue_context_p->ue_context.SRB_configList;
if(SRB_configList != NULL){
for (int i=0; i<req->srbs_to_be_setup_length; i++){
SRB2_config = CALLOC(1, sizeof(*SRB2_config));
SRB2_config->srb_Identity = req->srbs_to_be_setup[i].srb_id;
ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config);
}
}
else{
LOG_E(NR_RRC, "The SRB list of the UE context is empty before the addition of SRB2 \n");
return;
}
/* Configure DRB */
NR_DRB_ToAddMod_t *DRB_config = NULL;
if(ue_context_p->ue_context.DRB_configList == NULL){
ue_context_p->ue_context.DRB_configList = CALLOC(1, sizeof(*ue_context_p->ue_context.DRB_configList));
}
NR_DRB_ToAddModList_t *DRB_configList = ue_context_p->ue_context.DRB_configList;
for (int i=0; i<req->drbs_to_be_setup_length; i++){
DRB_config = CALLOC(1, sizeof(*DRB_config));
DRB_config->drb_Identity = req->drbs_to_be_setup[i].drb_id;
ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config);
}
apply_macrlc_config(rrc, ue_context_p, &ctxt);
}
unsigned int mask_flip(unsigned int x) { unsigned int mask_flip(unsigned int x) {
return((((x>>8) + (x<<8))&0xffff)>>6); return((((x>>8) + (x<<8))&0xffff)>>6);
} }
...@@ -3602,6 +3648,10 @@ void *rrc_gnb_task(void *args_p) { ...@@ -3602,6 +3648,10 @@ void *rrc_gnb_task(void *args_p) {
rrc_process_DU_DL(msg_p, msg_name_p, instance); rrc_process_DU_DL(msg_p, msg_name_p, instance);
break; break;
case F1AP_UE_CONTEXT_SETUP_REQ:
rrc_DU_process_ue_context_setup_request(msg_p, msg_name_p, instance);
break;
/* Messages from X2AP */ /* Messages from X2AP */
case X2AP_ENDC_SGNB_ADDITION_REQ: case X2AP_ENDC_SGNB_ADDITION_REQ:
LOG_I(NR_RRC, "Received ENDC sgNB addition request from X2AP \n"); LOG_I(NR_RRC, "Received ENDC sgNB addition request from X2AP \n");
......
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