diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index 8f01be8ee5926b225e5582672d16259e3a702786..43355728a2dbe5f4c70cc89a194640f0ede462c4 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -38,7 +38,7 @@ #include "assertions.h" extern f1ap_setup_req_t *f1ap_du_data; - +extern RAN_CONTEXT_t RC; int DU_handle_RESET(instance_t instance, uint32_t assoc_id, @@ -539,10 +539,16 @@ int DU_handle_F1_SETUP_RESPONSE(instance_t instance, MSC_AS_TIME_FMT" DU_handle_F1_SETUP_RESPONSE successfulOutcome assoc_id %d", 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), assoc_id); - - LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message to ENB_APP with assoc_id (%d->%d)\n", + + if (RC.nrrrc[0]->node_type == ngran_gNB_DU) { + LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message to GNB_APP with assoc_id (%d->%d)\n", assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); - itti_send_msg_to_task(TASK_ENB_APP, ENB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); + itti_send_msg_to_task(TASK_GNB_APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); + } else { + LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message to ENB_APP with assoc_id (%d->%d)\n", + assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); + itti_send_msg_to_task(TASK_ENB_APP, ENB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); + } return 0; } diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index dcdebe2b256fd193012c784b1837752930009d0e..0b866f4ad3235a6f66a9bb723c6ef3d2d53a66ab 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -136,7 +136,6 @@ static uint32_t gNB_app_register_x2(uint32_t gnb_id_start, uint32_t gnb_id_end) return register_gnb_x2_pending; } - /*------------------------------------------------------------------------------*/ void *gNB_app_task(void *args_p) { @@ -144,6 +143,9 @@ void *gNB_app_task(void *args_p) uint32_t gnb_nb = RC.nb_nr_inst; uint32_t gnb_id_start = 0; uint32_t gnb_id_end = gnb_id_start + gnb_nb; + uint32_t registered_gnb = 0; + uint32_t register_gnb_pending; + long gnb_register_retry_timer_id; uint32_t gnb_id; MessageDef *msg_p = NULL; @@ -189,8 +191,10 @@ void *gNB_app_task(void *args_p) if (AMF_MODE_ENABLED) { /* Try to register each gNB */ //registered_gnb = 0; - __attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end);//, gnb_properties_p); + register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end);//, gnb_properties_p); } else { + // for test + register_gnb_pending = 1; for (gnb_id = gnb_id_start; (gnb_id < gnb_id_end) ; gnb_id++) { if (!NODE_IS_DU(RC.nrrrc[gnb_id]->node_type)) { /* Start L2L1 task */ @@ -268,6 +272,50 @@ void *gNB_app_task(void *args_p) */ break; + case F1AP_SETUP_RESP: + AssertFatal(NODE_IS_DU(RC.nrrrc[0]->node_type), "Should not have received F1AP_SETUP_RESP in CU/gNB\n"); + + LOG_I(GNB_APP, "Received %s: associated ngran_gNB_CU %s with %d cells to activate\n", ITTI_MSG_NAME (msg_p), + F1AP_SETUP_RESP(msg_p).gNB_CU_name,F1AP_SETUP_RESP(msg_p).num_cells_to_activate); + + gNB_app_handle_f1ap_setup_resp(&F1AP_SETUP_RESP(msg_p)); + + DevAssert(register_gnb_pending > 0); + register_gnb_pending--; + + /* Check if at least gNB is registered with one AMF */ + if (F1AP_SETUP_RESP(msg_p).num_cells_to_activate > 0) { + registered_gnb++; + } + + /* Check if all register gNB requests have been processed */ + if (register_gnb_pending == 0) { + if (registered_gnb == gnb_nb) { + /* If all gNB cells are registered, start L2L1 task */ + MessageDef *msg_init_p; + + msg_init_p = itti_alloc_new_message (TASK_GNB_APP, INITIALIZE_MESSAGE); + itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p); + + } else { + LOG_W(GNB_APP, " %d gNB not associated with a AMF, retrying registration in %d seconds ...\n", + gnb_nb - registered_gnb, GNB_REGISTER_RETRY_DELAY); + + /* Restart the gNB registration process in GNB_REGISTER_RETRY_DELAY seconds */ + if (timer_setup (GNB_REGISTER_RETRY_DELAY, 0, TASK_GNB_APP, INSTANCE_DEFAULT, TIMER_ONE_SHOT, + NULL, &gnb_register_retry_timer_id) < 0) { + LOG_E(GNB_APP, " Can not start gNB register retry timer, use \"sleep\" instead!\n"); + + sleep(GNB_REGISTER_RETRY_DELAY); + /* Restart the registration process */ + registered_gnb = 0; + register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end); + } + } + } + + break; + case NGAP_DEREGISTERED_GNB_IND: LOG_W(GNB_APP, "[gNB %d] Received %s: associated AMF %d\n", instance, msg_name, NGAP_DEREGISTERED_GNB_IND(msg_p).nb_amf); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 5bc9f04083538b5424a754ae7e032120a32a4f88..35ed2b399bc14524cf6252a1a83593f1242f7bb5 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1419,3 +1419,39 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) { } return 0; } + +int du_check_plmn_identity(rrc_gNB_carrier_data_t *carrier,uint16_t mcc,uint16_t mnc,uint8_t mnc_digit_length) { + return (1); +} + +void gNB_app_handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { + int i, j, si_ind; + LOG_I(GNB_APP, "cells_to_activated %d, RRC instances %d\n", + resp->num_cells_to_activate, RC.nb_nr_inst); + + for (j = 0; j < resp->num_cells_to_activate; j++) { + for (i = 0; i < RC.nb_nr_inst; i++) { + rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[i]->carrier; + // identify local index of cell j by nr_cellid, plmn identity and physical cell ID + LOG_I(GNB_APP, "Checking cell %d, rrc inst %d : rrc->nr_cellid %lx, resp->nr_cellid %lx\n", + j, i, RC.nrrrc[i]->nr_cellid, resp->nr_cellid[j]); + + if (RC.nrrrc[i]->nr_cellid == resp->nr_cellid[j] && + (du_check_plmn_identity(carrier, resp->mcc[j], resp->mnc[j], resp->mnc_digit_length[j])>0 && + resp->nrpci[j] == carrier->physCellId)) { + // copy system information and decode it + for (si_ind=0; si_ind<resp->num_SI[j]; si_ind++) { + // extract_and_decode_SI(i, + // si_ind, + // resp->SI_container[j][si_ind], + // resp->SI_container_length[j][si_ind]); + } + + // perform MAC/L1 common configuration + // configure_du_mac(i); + } else { + LOG_E(GNB_APP, "F1 Setup Response not matching\n"); + } + } + } +} diff --git a/openair2/GNB_APP/gnb_config.h b/openair2/GNB_APP/gnb_config.h index a86a9b5e07a95377e97670b6608e2ae8fef7d58e..020aaf6f7b342b403ca6d58916e35949045355db 100644 --- a/openair2/GNB_APP/gnb_config.h +++ b/openair2/GNB_APP/gnb_config.h @@ -40,6 +40,7 @@ #include "PHY/defs_eNB.h" #include "s1ap_messages_types.h" #include "ngap_messages_types.h" +#include "f1ap_messages_types.h" #ifdef CMAKER #include "rrc_messages_types.h" @@ -106,6 +107,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc); int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i); int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i); int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i); +void gNB_app_handle_f1ap_setup_resp(f1ap_setup_resp_t *resp); #endif /* GNB_CONFIG_H_ */ /** @} */