diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 5da5fe42f5..47af01a6de 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -313,12 +313,12 @@ int create_gNB_tasks(uint32_t gnb_nb) { } } - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { - char* gnb_ipv4_address_for_NGU = NULL; - uint32_t gnb_port_for_NGU = 0; - char* gnb_ipv4_address_for_S1U = NULL; - uint32_t gnb_port_for_S1U = 0; + char* gnb_ipv4_address_for_NGU = NULL; + uint32_t gnb_port_for_NGU = 0; + char* gnb_ipv4_address_for_S1U = NULL; + uint32_t gnb_port_for_S1U = 0; paramdef_t NETParams[] = GNBNETPARAMS_DESC; char aprefix[MAX_OPTNAME_SIZE*2 + 8]; sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); @@ -326,23 +326,17 @@ int create_gNB_tasks(uint32_t gnb_nb) { for(int i = GNB_INTERFACE_NAME_FOR_NG_AMF_IDX; i <= GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX; i++) { if( NETParams[i].strptr == NULL) { - LOG_E(NGAP, "No configuration in the file.\n"); - NGAP_CONF_MODE = 0; + LOG_E(NGAP, "No AMF configuration in the file.\n"); } else { LOG_D(NGAP, "Configuration in the file: %s.\n",*NETParams[i].strptr); } } - + if (gnb_nb > 0) { - if(NGAP_CONF_MODE) { - if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) { - LOG_E(NGAP, "Create task for NGAP failed\n"); - return -1; - } - } else { - LOG_I(NGAP, "Ngap task not created\n"); + if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) { + LOG_E(NGAP, "Create task for NGAP failed\n"); + return -1; } - } } @@ -359,8 +353,8 @@ int create_gNB_tasks(uint32_t gnb_nb) { return -1; } - //Use check on x2ap to consider the NSA scenario and check on AMF_MODE_ENABLED for the SA scenario - if(is_x2ap_enabled() || AMF_MODE_ENABLED) { + //Use check on x2ap to consider the NSA scenario and check for SA scenario + if(is_x2ap_enabled() || get_softmodem_params()->sa) { if (itti_create_task (TASK_GTPV1_U, >pv1uTask, NULL) < 0) { LOG_E(GTPU, "Create task for GTPV1U failed\n"); return -1; @@ -630,8 +624,6 @@ int main( int argc, char **argv ) { } openair0_cfg[0].threequarter_fs = threequarter_fs; - AMF_MODE_ENABLED = get_softmodem_params()->sa; - NGAP_CONF_MODE = get_softmodem_params()->sa; if (get_softmodem_params()->do_ra) AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index d3af2acd77..c556f66361 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -63,7 +63,6 @@ void fill_scc_sim(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_R void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap); void prepare_scc(NR_ServingCellConfigCommon_t *scc); void prepare_scd(NR_ServingCellConfig_t *scd); -ngap_gNB_config_t ngap_config; uint32_t ngap_generate_gNB_id(void) {return 0;} void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) { return;} void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { return;} diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index 821e2def84..b2fa3be46f 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -88,7 +88,7 @@ static uint32_t gNB_app_register(uint32_t gnb_id_start, uint32_t gnb_id_end)//, for (gnb_id = gnb_id_start; (gnb_id < gnb_id_end) ; gnb_id++) { { - if(NGAP_CONF_MODE){ + if(get_softmodem_params()->sa){ ngap_register_gnb_req_t *ngap_register_gNB; //Type Temporarily reuse // note: there is an implicit relationship between the data structure and the message name @@ -187,7 +187,7 @@ void *gNB_app_task(void *args_p) /* For the CU case the gNB registration with the AMF might have to take place after the F1 setup, as the PLMN info * can originate from the DU. Add check on whether x2ap is enabled to account for ENDC NSA scenario.*/ - if ((AMF_MODE_ENABLED || is_x2ap_enabled()) && !NODE_IS_DU(RC.nrrrc[0]->node_type) ) { //&& !NODE_IS_CU(RC.nrrrc[0]->node_type)) { + if ((get_softmodem_params()->sa || is_x2ap_enabled()) && !NODE_IS_DU(RC.nrrrc[0]->node_type) ) { //&& !NODE_IS_CU(RC.nrrrc[0]->node_type)) { /* Try to register each gNB */ //registered_gnb = 0; __attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 25df321b3a..184e1b210d 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -34,6 +34,7 @@ #include "common/utils/nr/nr_common.h" #include "common/utils/LOG/log_extern.h" #include "assertions.h" +#include "executables/softmodem-common.h" #include "gnb_config.h" #include "gnb_paramdef.h" #include "enb_paramdef.h" @@ -639,7 +640,7 @@ void RCconfig_nr_flexran() /* gNB ID from configuration, as read in by RCconfig_RRC() */ if (!GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr) { // Calculate a default gNB ID - if (AMF_MODE_ENABLED) + if (get_softmodem_params()->sa) gnb_id = i + (ngap_generate_gNB_id () & 0xFFFFFF8); else gnb_id = i; @@ -1064,24 +1065,6 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; AssertFatal (i0) { // Output a list of all gNBs. ////////// Identification parameters @@ -1089,7 +1072,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { if (GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr == NULL) { // Calculate a default gNB ID - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { uint32_t hash; hash = ngap_generate_gNB_id (); gnb_id = i + (hash & 0xFFFFFF8); @@ -1349,26 +1332,8 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { /* get global parameters, defined outside any section in the config file */ config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); - - /* - if (AMF_MODE_ENABLED) { - if (strcasecmp( *(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr), GNB_CONFIG_STRING_ASN1_VERBOSITY_NONE) == 0) { - asn_debug = 0; - asn1_xer_print = 0; - } else if (strcasecmp( *(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr), GNB_CONFIG_STRING_ASN1_VERBOSITY_INFO) == 0) { - asn_debug = 1; - asn1_xer_print = 1; - } else if (strcasecmp(*(GNBSParams[GNB_ASN1_VERBOSITY_IDX].strptr) , GNB_CONFIG_STRING_ASN1_VERBOSITY_ANNOYING) == 0) { - asn_debug = 1; - asn1_xer_print = 2; - } else { - asn_debug = 0; - asn1_xer_print = 0; - } - } - */ - AssertFatal (isa) { uint32_t hash; hash = ngap_generate_gNB_id (); @@ -1536,7 +1501,7 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { // SCTP SETTING NGAP_REGISTER_GNB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; NGAP_REGISTER_GNB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,k,GNB_CONFIG_STRING_SCTP_CONFIG); config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); NGAP_REGISTER_GNB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); @@ -1660,7 +1625,7 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { for (k = 0; k < GNBParamList.numelt; k++) { if (GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr == NULL) { // Calculate a default eNB ID - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { uint32_t hash; hash = ngap_generate_gNB_id (); gnb_id = k + (hash & 0xFFFFFF8); @@ -1803,7 +1768,7 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,k,GNB_CONFIG_STRING_SCTP_CONFIG); config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr); diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index ec90817500..1e2266adb1 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -590,7 +590,7 @@ void rlc_data_ind ( T(T_ENB_RLC_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP)); #endif const ngran_node_t type = RC.rrc[ctxt_pP->module_id]->node_type; - AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU, + AssertFatal(!NODE_IS_CU(type), "Can't be CU, bad node type %d\n", type); if (NODE_IS_DU(type) && srb_flagP == 1) { diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 30d1d13baa..3901a05424 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -514,7 +514,7 @@ rb_found: T_INT(ue->rnti), T_INT(rb_id), T_INT(size)); const ngran_node_t type = RC.nrrrc[0 /*ctxt_pP->module_id*/]->node_type; - AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU, + AssertFatal(!NODE_IS_CU(type), "Can't be CU, bad node type %d\n", type); // if (NODE_IS_DU(type) && is_srb == 0) { diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c index 11ae770e3e..914484c1b6 100644 --- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c +++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c @@ -415,7 +415,7 @@ rb_found: T_INT(ue->rnti), T_INT(rb_id), T_INT(size)); const ngran_node_t type = RC.rrc[0 /*ctxt_pP->module_id*/]->node_type; - AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU, + AssertFatal(!NODE_IS_CU(type), "Can't be CU, bad node type %d\n", type); if (NODE_IS_DU(type)) { diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index aefbc01831..7154b34962 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -1004,9 +1004,7 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char } - if ((RC.rrc[ctxt.module_id]->node_type == ngran_eNB_CU) || - (RC.rrc[ctxt.module_id]->node_type == ngran_ng_eNB_CU) || - (RC.rrc[ctxt.module_id]->node_type == ngran_gNB_CU) ){ + if (NODE_IS_CU(RC.rrc[ctxt.module_id]->node_type)) { struct eNB_RRC_INST_s *rrc= RC.rrc[0]; MessageDef *message_p = itti_alloc_new_message (TASK_RRC_ENB, 0, F1AP_UE_CONTEXT_SETUP_REQ); f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 8be829f51f..5cb9aea1cb 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -524,7 +524,7 @@ rrc_gNB_process_RRCSetupComplete( ue_context_pP->ue_context.Srb1.Srb_info.Srb_id = 1; ue_context_pP->ue_context.StatusRrc = NR_RRC_CONNECTED; - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); } else { rrc_gNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP); @@ -1616,7 +1616,7 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( ue_context_pP->ue_context.Srb1.Active = 1; //ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2; - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { hashtable_rc_t h_rc; int j; rrc_ue_ngap_ids_t *rrc_ue_ngap_ids_p = NULL; @@ -1693,13 +1693,13 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( ue_context_pP->ue_context.ul_failure_timer = 0; return; } - } /* AMF_MODE_ENABLED */ + } /* Update RNTI in ue_context */ ue_context_pP->ue_id_rnti = ctxt_pP->rnti; // here ue_id_rnti is just a key, may be something else ue_context_pP->ue_context.rnti = ctxt_pP->rnti; - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { uint8_t send_security_mode_command = false; nr_rrc_pdcp_config_security( ctxt_pP, @@ -2342,7 +2342,7 @@ rrc_gNB_decode_dcch( ul_dcch_msg->message.choice.c1->choice.rrcReconfigurationComplete->rrc_TransactionIdentifier); } - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { if(ue_context_p->ue_context.pdu_session_release_command_flag == 1) { xid = ul_dcch_msg->message.choice.c1->choice.rrcReconfigurationComplete->rrc_TransactionIdentifier; ue_context_p->ue_context.pdu_session_release_command_flag = 0; @@ -2475,7 +2475,7 @@ rrc_gNB_decode_dcch( LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, "[MSG] RRC UL Information Transfer \n"); - if (AMF_MODE_ENABLED == 1) { + if (get_softmodem_params()->sa) { rrc_gNB_send_NGAP_UPLINK_NAS(ctxt_pP, ue_context_p, ul_dcch_msg); @@ -2623,7 +2623,7 @@ rrc_gNB_decode_dcch( if(eutra_index == -1) break; } - if (AMF_MODE_ENABLED == 1) { + if (get_softmodem_params()->sa) { rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(ctxt_pP, ue_context_p, ul_dcch_msg); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index bf4f053ba6..a1a5665a01 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -152,7 +152,7 @@ static int nr_rrc_set_state (module_id_t ue_mod_idP, Rrc_State_NR_t state) { } static int nr_rrc_set_sub_state( module_id_t ue_mod_idP, Rrc_Sub_State_NR_t subState ) { - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { switch (NR_UE_rrc_inst[ue_mod_idP].nrRrcState) { case RRC_STATE_INACTIVE_NR: AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST_NR <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST_NR), @@ -835,7 +835,7 @@ int nr_decode_SI( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index // After SI is received, prepare RRCConnectionRequest if (NR_UE_rrc_inst[ctxt_pP->module_id].MBMS_flag < 3) // see -Q option - if (AMF_MODE_ENABLED) { + if (get_softmodem_params()->sa) { nr_rrc_ue_generate_RRCSetupRequest( ctxt_pP->module_id, gNB_index ); } @@ -1341,20 +1341,16 @@ static void rrc_ue_generate_RRCSetupComplete( const char *nas_msg; int nas_msg_length; - if (AMF_MODE_ENABLED) { - if (get_softmodem_params()->sa) { - as_nas_info_t initialNasMsg; - generateRegistrationRequest(&initialNasMsg, ctxt_pP->module_id); - nas_msg = (char*)initialNasMsg.data; - nas_msg_length = initialNasMsg.length; - } else { - nas_msg = (char *) NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; - nas_msg_length = NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; - } + if (get_softmodem_params()->sa) { + as_nas_info_t initialNasMsg; + generateRegistrationRequest(&initialNasMsg, ctxt_pP->module_id); + nas_msg = (char*)initialNasMsg.data; + nas_msg_length = initialNasMsg.length; } else { nas_msg = nr_nas_attach_req_imsi; nas_msg_length = sizeof(nr_nas_attach_req_imsi); } + size = do_RRCSetupComplete(ctxt_pP->module_id, buffer, sizeof(buffer), Transaction_id, sel_plmn_id, nas_msg_length, nas_msg); LOG_I(NR_RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCSetupComplete (bytes%d, gNB %d)\n", @@ -1708,9 +1704,6 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index) { uint8_t i=0,rv[6]; - if(get_softmodem_params()->sa) { - AMF_MODE_ENABLED = 1; - } if(NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size ==0) { // Get RRCConnectionRequest, fill random for now // Generate random byte stream for contention resolution @@ -1802,7 +1795,7 @@ nr_rrc_ue_establish_srb2( LOG_I(NR_RRC,"[UE %d] Frame %d: processing RRCReconfiguration: reconfiguring DRB %ld\n", ue_mod_idP, frameP, DRB_config->drb_Identity); - if(!AMF_MODE_ENABLED) { + if(!get_softmodem_params()->sa) { ip_addr_offset3 = 0; ip_addr_offset4 = 1; LOG_I(OIP, "[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, diff --git a/openair3/NGAP/ngap_gNB.c b/openair3/NGAP/ngap_gNB.c index 59e275ad53..bce973354b 100644 --- a/openair3/NGAP/ngap_gNB.c +++ b/openair3/NGAP/ngap_gNB.c @@ -64,8 +64,6 @@ #include "oaisim_amf_test_s1c.h" #endif -ngap_gNB_config_t ngap_config; - static int ngap_gNB_generate_ng_setup_request( ngap_gNB_instance_t *instance_p, ngap_gNB_amf_data_t *ngap_amf_data_p); diff --git a/openair3/NGAP/ngap_gNB.h b/openair3/NGAP/ngap_gNB.h index e6a24acdb4..2aa0080cd1 100644 --- a/openair3/NGAP/ngap_gNB.h +++ b/openair3/NGAP/ngap_gNB.h @@ -39,18 +39,6 @@ #ifndef NGAP_GNB_H_ #define NGAP_GNB_H_ -typedef struct ngap_gNB_config_s { - // MME related params - unsigned char amf_enabled; ///< AMF enabled ? - unsigned char ngap_enabled; ///< NGAP enabled ? -} ngap_gNB_config_t; - -extern ngap_gNB_config_t ngap_config; - -#define AMF_MODE_ENABLED ngap_config.amf_enabled -#define NGAP_CONF_MODE ngap_config.ngap_enabled - - void *ngap_gNB_process_itti_msg(void*); void ngap_gNB_init(void); void *ngap_gNB_task(void *arg);