From 7f2e622b0e2c8c0d042025d7864924fef6835193 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Wed, 7 Jul 2021 11:55:34 -0700 Subject: [PATCH] Sending tunnel interface 'up' command to NR UE Once the LTE UE's tunnel interface with the EPC is ready to be established, if we are in NSA mode, we do not want to launch the tunnel interface from the LTE UE side, but in the NR UE. Via itti_msgs we send the string containing the tunnel interface 'up' command to the NR UE and bring it up from the NR UE. --- executables/nr-softmodem.c | 2 ++ executables/nr-uesoftmodem.c | 15 ++++------ executables/nr-uesoftmodem.h | 3 +- nfapi/open-nFAPI/vnf/src/vnf_interface.c | 2 +- nfapi/open-nFAPI/vnf/src/vnf_p7.c | 4 +-- openair2/COMMON/as_message.h | 4 +++ openair2/COMMON/rrc_messages_def.h | 2 ++ openair2/COMMON/rrc_messages_types.h | 4 +++ openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 4 +-- openair2/RRC/LTE/rrc_UE.c | 17 ++++++++++-- openair2/RRC/LTE/rrc_eNB.c | 6 ++-- openair2/RRC/LTE/rrc_types.h | 3 +- openair2/RRC/NR/rrc_gNB_nsa.c | 22 +++++++-------- openair2/RRC/NR_UE/rrc_UE.c | 13 +++++++++ openair3/NAS/UE/ESM/esm_ebr_context.c | 34 +++++++++++++++++++---- openair3/NAS/UE/nas_ue_task.c | 2 +- 16 files changed, 99 insertions(+), 38 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 4863e8c0b0..50be753740 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -672,6 +672,8 @@ int main( int argc, char **argv ) printf("Reading in command-line options\n"); get_options (); + EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; + if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { fprintf(stderr,"Getting configuration failed\n"); exit(-1); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index b04498f6f7..b26e192dcf 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -531,16 +531,13 @@ int main( int argc, char **argv ) { ue_id_g = (node_number == 0) ? 0 : node_number - 2; AssertFatal(ue_id_g >= 0, "UE id is expected to be nonnegative.\n"); - if(IS_SOFTMODEM_NOS1) + if(node_number == 0) { - if(node_number == 0) - { - init_pdcp(0); - } - else - { - init_pdcp(mode_offset + node_number - 1); - } + init_pdcp(0); + } + else + { + init_pdcp(mode_offset + node_number - 1); } NB_UE_INST=1; diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 892f56620c..eae00ac482 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -31,7 +31,8 @@ {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, iptr:(int32_t *)&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ - {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0} \ + {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \ + {"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \ } diff --git a/nfapi/open-nFAPI/vnf/src/vnf_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_interface.c index 5d0d085b58..56a4b18bdf 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_interface.c @@ -1154,7 +1154,7 @@ int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy info->timing_window = 30; // This seems to override what gets set by the user - why??? //TODO: Change in NR in terms of microsecends,what should be the value? info->timing_info_mode = 0x03; - info->timing_info_period = 128; // Melissa come back to this + info->timing_info_period = 19; // Melissa come back to this nfapi_vnf_phy_info_list_add(config, info); diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index 3c7f0d1056..2ae1c76ac9 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -1294,7 +1294,7 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) NFAPI_TRACE(NFAPI_TRACE_NOTE, "VNF P7 In Sync with phy (phy_id:%d)\n", phy->phy_id); if(vnf_p7->_public.sync_indication) - (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), 1); + (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), phy->in_sync); } phy->in_sync = 1; @@ -1803,7 +1803,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 NFAPI_TRACE(NFAPI_TRACE_NOTE, "VNF P7 In Sync with phy (phy_id:%d)\n", phy->phy_id); if(vnf_p7->_public.sync_indication) - (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), 1); + (vnf_p7->_public.sync_indication)(&(vnf_p7->_public), phy->in_sync); } phy->in_sync = 1; diff --git a/openair2/COMMON/as_message.h b/openair2/COMMON/as_message.h index 829c3c9e33..630a021588 100644 --- a/openair2/COMMON/as_message.h +++ b/openair2/COMMON/as_message.h @@ -219,6 +219,10 @@ typedef struct kenb_refresh_req_s { Byte_t kenb[32]; } kenb_refresh_req_t; +typedef struct nsa_oai_tun_nsa_s { + uint8_t buffer[500]; //Melissa TODO +} nas_oai_tun_nsa_t; + /* * NAS->AS - Cell Information request * NAS request AS to search for a suitable cell belonging to the selected diff --git a/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index cde2497880..d93f07d8f8 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -65,6 +65,8 @@ MESSAGE_DEF(NAS_UPLINK_DATA_REQ, MESSAGE_PRIORITY_MED, NasUlDataReq MESSAGE_DEF(NAS_RAB_ESTABLI_RSP, MESSAGE_PRIORITY_MED, NasRabEstRsp, nas_rab_est_rsp) +MESSAGE_DEF(NAS_OAI_TUN_NSA, MESSAGE_PRIORITY_MED, NasOaiTunNsa, nas_oai_tun_nsa) + // UE: RRC -> NAS messages MESSAGE_DEF(NAS_CELL_SELECTION_CNF, MESSAGE_PRIORITY_MED, NasCellSelectionCnf, nas_cell_selection_cnf) MESSAGE_DEF(NAS_CELL_SELECTION_IND, MESSAGE_PRIORITY_MED, NasCellSelectionInd, nas_cell_selection_ind) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 02f878ee2e..19e0e0019b 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -89,6 +89,8 @@ #define RLC_SDU_INDICATION(mSGpTR) (mSGpTR)->ittiMsg.rlc_sdu_indication +#define NAS_OAI_TUN_NSA(mSGpTR) (mSGpTR)->ittiMsg.nas_oai_tun_nsa + //-------------------------------------------------------------------------------------------// typedef struct RrcStateInd_s { Rrc_State_t state; @@ -420,6 +422,8 @@ typedef ul_info_transfer_req_t NasUlDataReq; typedef rab_establish_rsp_t NasRabEstRsp; +typedef nas_oai_tun_nsa_t NasOaiTunNsa; + // UE: RRC -> NAS messages typedef cell_info_cnf_t NasCellSelectionCnf; typedef cell_info_ind_t NasCellSelectionInd; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index e44f5bebd8..6a60dc4db2 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -377,10 +377,10 @@ uint64_t nr_pdcp_module_init(uint64_t _pdcp_optmask, int id) nas_getparams(); if(UE_NAS_USE_TUN) { - /* TODO: Brute force changes made below to allow nr-UE to have unique tunnel interfaces. + /* Melissa TODO: Brute force changes made below to allow nr-UE to have unique tunnel interfaces. When the NODE_NUMBER param is not used to determine functionality and LTE tunnel interfaces, we should update the netlink_init_tun() and nas_config() calls below as well. */ - int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 )? MAX_MOBILES_PER_ENB : 1; + int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1; netlink_init_tun("nrue", num_if, id); //Add --nr-ip-over-lte option check for next line if (IS_SOFTMODEM_NOS1) diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index c45afbf6c8..c1077eaa3d 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -2057,6 +2057,7 @@ rrc_ue_process_rrcConnectionReconfiguration( NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer; itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); } + LOG_I(RRC, "Melissa Elkadi, we have sent NAS_CONN_ESTABLI_CNF to NAS layer via itti!\n"); free (r_r8->dedicatedInfoNASList); } @@ -2513,7 +2514,8 @@ rrc_ue_decode_dcch( // Save ueCapabilityEnquiry so we can use in nsa mode after nrUE response is received UE_RRC_INFO *info = &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP]; if (info->dl_dcch_msg != NULL) { - SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, info->dl_dcch_msg, ASFM_FREE_EVERYTHING); + info->dl_dcch_msg = NULL; + //SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, info->dl_dcch_msg, ASFM_FREE_EVERYTHING); Melissa } info->dl_dcch_msg = dl_dcch_msg; dl_dcch_msg = NULL; @@ -2528,7 +2530,8 @@ rrc_ue_decode_dcch( // Save ueCapabilityEnquiry so we can use in nsa mode after nrUE response is received UE_RRC_INFO *info = &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP]; if (info->dl_dcch_msg != NULL) { - SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, info->dl_dcch_msg, ASFM_FREE_EVERYTHING); + info->dl_dcch_msg = NULL; + //SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, info->dl_dcch_msg, ASFM_FREE_EVERYTHING); Melissa } info->dl_dcch_msg = dl_dcch_msg; dl_dcch_msg = NULL; @@ -5060,6 +5063,16 @@ void *rrc_ue_task( void *args_p ) { AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); break; } + case NAS_OAI_TUN_NSA: + { + LOG_I(NAS, "Melissa Elkadi Received %s: length %lu. About to send this to the NR UE\n", ITTI_MSG_NAME (msg_p), + sizeof(NAS_OAI_TUN_NSA (msg_p).buffer)); + char buffer[RRC_BUF_SIZE]; + memcpy(buffer, NAS_OAI_TUN_NSA(msg_p).buffer, sizeof(buffer)); + nsa_sendmsg_to_nrue(buffer, sizeof(buffer), OAI_TUN_IFACE_NSA); + break; + } + case NAS_KENB_REFRESH_REQ: memcpy((void *)UE_rrc_inst[ue_mod_id].kenb, (void *)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb)); diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index cbbdc37684..e3ebfa559f 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -4606,10 +4606,10 @@ rrc_eNB_process_MeasurementReport( memcpy(X2AP_ENDC_SGNB_ADDITION_REQ(msg).rrc_buffer,enc_buf,enc_size); X2AP_ENDC_SGNB_ADDITION_REQ(msg).rrc_buffer_size = enc_size; - #if 0 //Melissa: We hacked this: + X2AP_ENDC_SGNB_ADDITION_REQ(msg).target_physCellId = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId; - #endif + X2AP_ENDC_SGNB_ADDITION_REQ(msg).target_physCellId = 0; //For the moment we have a single E-RAB which will be the one to be added to the gNB //Not sure how to select bearers to be added if there are multiple. @@ -7703,7 +7703,7 @@ rrc_eNB_decode_dcch( /*FK: left the condition as is for the case MME is used (S1 mode) but setting dedicated_DRB = 1 otherwise (noS1 mode) so that no second RRCReconfiguration message activationg more DRB is sent as this causes problems with the nasmesh driver.*/ int flexran_agent_handover = 0; - if (1) { //Melissa: This is a hack. We are bypassing EPC mode here. + if (1) { //Melissa: This is a hack. We are bypassing EPC mode here. if(EPC_MODE_ENABLED) if (ue_context_p->ue_context.Status == RRC_RECONFIGURED) { dedicated_DRB = 1; LOG_I(RRC, diff --git a/openair2/RRC/LTE/rrc_types.h b/openair2/RRC/LTE/rrc_types.h index b58ba58ec6..6b339af563 100644 --- a/openair2/RRC/LTE/rrc_types.h +++ b/openair2/RRC/LTE/rrc_types.h @@ -70,7 +70,8 @@ typedef enum Rrc_Msg_Type_e { RRC_MEASUREMENT_PROCEDURE, NR_UE_RRC_MEASUREMENT, RRC_CONFIG_COMPLETE_REQ, - NR_RRC_CONFIG_COMPLETE_REQ + NR_RRC_CONFIG_COMPLETE_REQ, + OAI_TUN_IFACE_NSA } Rrc_Msg_Type_t; diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 62ffcdaf75..ca820ab657 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -280,18 +280,18 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ create_tunnel_req.num_tunnels = m->nb_e_rabs_tobeadded; RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[rrc->module_id]->rrc_ue_head, ue_context_p); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, rrc->module_id, GNB_FLAG_YES, ue_context_p->ue_id_rnti, 0, 0,rrc->module_id); - #if 1 //Melissa this is a hack: we are bypassing the EPC functionality. memset(&create_tunnel_resp, 0, sizeof(create_tunnel_resp)); - #else - gtpv1u_create_s1u_tunnel( - ctxt.instance, - &create_tunnel_req, - &create_tunnel_resp); - rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( - &ctxt, - &create_tunnel_resp, - &inde_list[0]); - #endif + if (!IS_SOFTMODEM_NOS1) { + LOG_I(RRC, "Melissa Elkadi calling gtpv1u_create_s1u_tunnel()\n"); + gtpv1u_create_s1u_tunnel( + ctxt.instance, + &create_tunnel_req, + &create_tunnel_resp); + rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( + &ctxt, + &create_tunnel_resp, + &inde_list[0]); + } X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).nb_e_rabs_admitted_tobeadded = m->nb_e_rabs_tobeadded; X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).target_assoc_id = m->target_assoc_id; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 111bab4c91..b9bbab8f43 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -3131,6 +3131,19 @@ void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len) break; } + case OAI_TUN_IFACE_NSA: + { + LOG_I(NR_RRC, "We got an OAI_TUN_IFACE_NSA!!\n"); + char cmd_line[RRC_BUF_SIZE]; + memcpy(cmd_line, msg_buffer, sizeof(cmd_line)); + LOG_I(NR_RRC, "Melissa Elkadi, this is the command line we got: %s\n", cmd_line); + if (background_system(cmd_line) != 0) + { + LOG_E(NR_RRC, "ESM-PROC - failed command '%s'", cmd_line); + } + break; + } + default: LOG_E(NR_RRC, "No NSA Message Found\n"); } diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c index 0c79fa3e3a..db935453d8 100644 --- a/openair3/NAS/UE/ESM/esm_ebr_context.c +++ b/openair3/NAS/UE/ESM/esm_ebr_context.c @@ -51,6 +51,7 @@ Description Defines functions used to handle EPS bearer contexts. #include "assertions.h" #include "pdcp.h" #include "nfapi/oai_integration/vendor_ext.h" +#include "executables/softmodem-common.h" #include #include @@ -262,6 +263,19 @@ int esm_ebr_context_create( netmask = 32; strcpy(broadcast, ipv4_addr); } + LOG_I(NAS, "Melissa Elkadi setting commandline string: " + "ip address add %s/%d broadcast %s dev %s%d && " + "ip link set %s%d up && " + "ip rule add from %s/32 table %d && " + "ip rule add to %s/32 table %d && " + "ip route add default dev %s%d table %d", + ipv4_addr, netmask, broadcast, + UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, + UE_NAS_USE_TUN ? "oaitun_ue" : "oip", ueid + 1, + ipv4_addr, ueid + 10000, + ipv4_addr, ueid + 10000, + UE_NAS_USE_TUN ? "oaitun_ue" : "oip", + ueid + 1, ueid + 10000); res = sprintf(command_line, "ip address add %s/%d broadcast %s dev %s%d && " @@ -281,9 +295,6 @@ int esm_ebr_context_create( LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string"); } - LOG_TRACE(INFO, "ESM-PROC - executing %s ", - command_line); - /* Calling system() here disrupts UE's realtime processing in some cases. * This may be because of the call to fork(), which, for some * unidentified reason, interacts badly with other (realtime) threads. @@ -294,8 +305,21 @@ int esm_ebr_context_create( * The processes interact through standard pipes. See * common/utils/system.c for details. */ - if (background_system(command_line) != 0) - LOG_TRACE(ERROR, "ESM-PROC - failed command '%s'", command_line); + if (get_softmodem_params()->nsa == 0) + { + LOG_TRACE(INFO, "Melissa Elkadi ESM-PROC - executing %s ", + command_line); + if (background_system(command_line) != 0) + { + LOG_TRACE(ERROR, "ESM-PROC - failed command '%s'", command_line); + } + } + else if (get_softmodem_params()->nsa) { + LOG_I(NAS, "Melissa Elkadi, sending NAS_OAI_TUN_NSA msg to LTE UE via itti\n"); + MessageDef *msg_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_OAI_TUN_NSA); + memcpy(NAS_OAI_TUN_NSA(msg_p).buffer, command_line, sizeof(NAS_OAI_TUN_NSA(msg_p).buffer)); + itti_send_msg_to_task(TASK_RRC_UE, 0, msg_p); + } break; diff --git a/openair3/NAS/UE/nas_ue_task.c b/openair3/NAS/UE/nas_ue_task.c index da718d856a..decc939caa 100644 --- a/openair3/NAS/UE/nas_ue_task.c +++ b/openair3/NAS/UE/nas_ue_task.c @@ -251,7 +251,7 @@ void *nas_ue_task(void *args_p) break; case NAS_CONN_ESTABLI_CNF: - LOG_I(NAS, "[UE %d] Received %s: errCode %u, length %u\n", Mod_id, ITTI_MSG_NAME (msg_p), + LOG_I(NAS, "Melissa Elkadi [UE %d] Received %s: errCode %u, length %u\n", Mod_id, ITTI_MSG_NAME (msg_p), NAS_CONN_ESTABLI_CNF (msg_p).errCode, NAS_CONN_ESTABLI_CNF (msg_p).nasMsg.length); if ((NAS_CONN_ESTABLI_CNF (msg_p).errCode == AS_SUCCESS)