X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcu_stub%2Fcu_stub.c;h=df86911b898f6bcb31ac30d9c85a005ced1fa02f;hb=b4e352a998576ab71aa74eb8b970f0ba39b471af;hp=6c5980047e1a6316690131a906fff59771dae0f5;hpb=2dc9d6735bc5ff973a761b7d6b3f71f97e95d60e;p=o-du%2Fl2.git diff --git a/src/cu_stub/cu_stub.c b/src/cu_stub/cu_stub.c index 6c5980047..df86911b8 100644 --- a/src/cu_stub/cu_stub.c +++ b/src/cu_stub/cu_stub.c @@ -18,48 +18,21 @@ /* This functions contains main() for cu_app */ #include "common_def.h" -#include "cu_stub.h" #include "cu_stub_sctp.h" #include "cu_stub_egtp.h" -#include "du_log.h" +#include "OCTET_STRING.h" +#include "cu_f1ap_msg_hdl.h" +#include "cu_stub.h" #ifdef O1_ENABLE -#include "ConfigInterface.h" -#endif - -#define CU_ID 1 -#define CU_NAME "ORAN_OAM_CU" - -#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001" -#define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011" - -#ifndef O1_ENABLE - -#define DU_IP_V4_ADDR "192.168.130.81" -#define CU_IP_V4_ADDR "192.168.130.82" -#define DU_PORT 38472 -#define CU_PORT 38472 - +#include "CmInterface.h" #endif -#define DU_EGTP_PORT 39001 -#define CU_EGTP_PORT 39002 -#define RRC_VER 0 -#define EXT_RRC_VER 5 -#define PLMN_MCC0 3 -#define PLMN_MCC1 1 -#define PLMN_MCC2 1 -#define PLMN_MNC0 4 -#define PLMN_MNC1 8 -#define PLMN_MNC2 0 #ifdef O1_ENABLE - extern StartupConfig g_cfg; - #endif - /******************************************************************* * * @brief Handles SCTP notification @@ -160,10 +133,14 @@ uint8_t tst() void readCuCfg() { - uint32_t ipv4_du, ipv4_cu; + uint8_t numDu, *numRemoteCu; + uint32_t ipv4_du, ipv4_cu, ipv4_remote_cu; DU_LOG("\nDEBUG --> CU_STUB : Reading CU configurations"); + cuCb.cuCfgParams.cuId = CU_ID; + strcpy(cuCb.cuCfgParams.cuName, CU_NAME); + #ifdef O1_ENABLE if( getStartupConfigForStub(&g_cfg) != ROK ) { @@ -173,53 +150,236 @@ void readCuCfg() } cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du); + cuCb.cuCfgParams.sctpParams.destCb[0].destIpAddr.ipV4Addr = ipv4_du; + cuCb.cuCfgParams.sctpParams.destCb[0].destIpAddr.ipV6Pres = false; + cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu); + cuCb.cuCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_cu; + cuCb.cuCfgParams.sctpParams.localIpAddr.ipV6Pres = false; + + cuCb.cuCfgParams.sctpParams.destCb[0].destPort = g_cfg.DU_Port; + cuCb.cuCfgParams.sctpParams.f1SctpPort = g_cfg.CU_Port; + cuCb.cuCfgParams.sctpParams.numDestNode = 1; + + cuCb.cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE; + cuCb.cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu; + cuCb.cuCfgParams.egtpParams.localPort = F1_EGTP_PORT; + cuCb.cuCfgParams.egtpParams.dstCfg[0].dstIp.ipV4Pres = TRUE; + cuCb.cuCfgParams.egtpParams.dstCfg[0].dstIp.ipV4Addr = ipv4_du; + cuCb.cuCfgParams.egtpParams.dstCfg[0].dstPort = F1_EGTP_PORT; + cuCb.cuCfgParams.egtpParams.minTunnelId = MIN_TEID; + cuCb.cuCfgParams.egtpParams.currTunnelId = cuCb.cuCfgParams.egtpParams.minTunnelId; + cuCb.cuCfgParams.egtpParams.maxTunnelId = MAX_TEID; + cuCb.cuCfgParams.egtpParams.numDu = 1; - cuCfgParams.sctpParams.duPort = g_cfg.DU_Port; - cuCfgParams.sctpParams.cuPort = g_cfg.CU_Port; #else - cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du); - cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu); - cuCfgParams.sctpParams.duPort = DU_PORT; - cuCfgParams.sctpParams.cuPort = CU_PORT; -#endif - - cuCfgParams.cuId = CU_ID; - strcpy(cuCfgParams.cuName, CU_NAME); - - /* DU IP Address and Port*/ - cuCfgParams.sctpParams.duIpAddr.ipV4Addr = ipv4_du; - cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false; - /* CU IP Address and Port*/ - cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu; - cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false; + memset(&ipv4_du, 0, sizeof(uint32_t)); + cmInetAddr((S8*)LOCAL_IP_CU, &ipv4_cu); + + cuCb.cuCfgParams.sctpParams.localIpAddr.ipV4Addr = ipv4_cu; + cuCb.cuCfgParams.sctpParams.localIpAddr.ipV6Pres = false; + + /* SCTP and EGTP configuration for F1 Interface */ + cuCb.cuCfgParams.sctpParams.f1SctpInfo.port = F1_SCTP_PORT; + + cuCb.cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE; + cuCb.cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu; + cuCb.cuCfgParams.egtpParams.localPort = F1_EGTP_PORT; + + cuCb.cuCfgParams.sctpParams.f1SctpInfo.numDestNode = 0; + cuCb.cuCfgParams.egtpParams.numDu = 0; + + numDu = 0; + while(numDu < NUM_F1_ASSOC) + { + /* DU IP Address */ + memset(&ipv4_du, 0, sizeof(uint32_t)); + cmInetAddr((S8*)REMOTE_IP_DU[numDu], &ipv4_du); + + /* SCTP Parameters */ + cuCb.cuCfgParams.sctpParams.f1SctpInfo.destCb[numDu].destIpAddr.ipV4Addr = ipv4_du; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.destCb[numDu].destIpAddr.ipV6Pres = false; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.destCb[numDu].destPort = F1_SCTP_PORT; + + /* EGTP Parameters */ + cuCb.cuCfgParams.egtpParams.dstCfg[numDu].dstIp.ipV4Pres = TRUE; + cuCb.cuCfgParams.egtpParams.dstCfg[numDu].dstIp.ipV4Addr = ipv4_du; + cuCb.cuCfgParams.egtpParams.dstCfg[numDu].dstPort = F1_EGTP_PORT; + + (numDu)++; + } + + cuCb.cuCfgParams.egtpParams.minTunnelId = MIN_TEID; + cuCb.cuCfgParams.egtpParams.currTunnelId = cuCb.cuCfgParams.egtpParams.minTunnelId; + cuCb.cuCfgParams.egtpParams.maxTunnelId = MAX_TEID; + cuCb.cuCfgParams.egtpParams.numDu = numDu; + cuCb.cuCfgParams.sctpParams.f1SctpInfo.numDestNode = numDu; + + /* SCTP configuration for Xn interface */ + cuCb.cuCfgParams.sctpParams.xnSctpInfo.port = XN_SCTP_PORT; + cuCb.cuCfgParams.sctpParams.xnSctpInfo.localNodeType = LOCAL_NODE_TYPE; + numRemoteCu = &cuCb.cuCfgParams.sctpParams.xnSctpInfo.numDestNode; + (*numRemoteCu) = 0; + while((*numRemoteCu) < NUM_XN_ASSOC) + { + /* Remote CU IP address */ + memset(&ipv4_remote_cu, 0, sizeof(uint32_t)); + cmInetAddr((S8*)REMOTE_IP_CU[*numRemoteCu], &ipv4_remote_cu); + + /* SCTP Parameters */ + cuCb.cuCfgParams.sctpParams.xnSctpInfo.destCb[*numRemoteCu].destIpAddr.ipV4Addr = ipv4_remote_cu; + cuCb.cuCfgParams.sctpParams.xnSctpInfo.destCb[*numRemoteCu].destIpAddr.ipV6Pres = false; + cuCb.cuCfgParams.sctpParams.xnSctpInfo.destCb[*numRemoteCu].destPort = XN_SCTP_PORT; + + (*numRemoteCu)++; + } +#endif /*PLMN*/ - cuCfgParams.plmn.mcc[0] = PLMN_MCC0; - cuCfgParams.plmn.mcc[1] = PLMN_MCC1; - cuCfgParams.plmn.mcc[2] = PLMN_MCC2; - cuCfgParams.plmn.mnc[0] = PLMN_MNC0; - cuCfgParams.plmn.mnc[1] = PLMN_MNC1; - cuCfgParams.plmn.mnc[2] = PLMN_MNC2; + cuCb.cuCfgParams.plmn.mcc[0] = PLMN_MCC0; + cuCb.cuCfgParams.plmn.mcc[1] = PLMN_MCC1; + cuCb.cuCfgParams.plmn.mcc[2] = PLMN_MCC2; + cuCb.cuCfgParams.plmn.mnc[0] = PLMN_MNC0; + cuCb.cuCfgParams.plmn.mnc[1] = PLMN_MNC1; + cuCb.cuCfgParams.plmn.mnc[2] = PLMN_MNC2; /*RRC Version*/ - cuCfgParams.rrcVersion.rrcVer = RRC_VER; - cuCfgParams.rrcVersion.extRrcVer = EXT_RRC_VER; + cuCb.cuCfgParams.rrcVersion.rrcVer = RRC_VER; + cuCb.cuCfgParams.rrcVersion.extRrcVer = EXT_RRC_VER; - /* EGTP Parameters */ - cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE; - cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu; - cuCfgParams.egtpParams.localPort = CU_EGTP_PORT; - cuCfgParams.egtpParams.destIp.ipV4Pres = TRUE; - cuCfgParams.egtpParams.destIp.ipV4Addr = ipv4_du; - cuCfgParams.egtpParams.destPort = DU_EGTP_PORT; - cuCfgParams.egtpParams.minTunnelId = 0; - cuCfgParams.egtpParams.maxTunnelId = 10; } /* End of readCuCfg */ +/******************************************************************* + * + * @brief Initiates inter DU handover + * + * @details + * + * Function : initiateInterDuHandover + * + * Functionality: Initiates the first procedure of inter-DU + * handover i.eG GNB-DU configuration query to source DU + * + * @params[in] Source DU Id + * Target DU Id + * UE Id to be handed off + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void initiateInterDuHandover(uint32_t sourceDuId, uint32_t targetDuId, uint32_t ueId) +{ + uint8_t duIdx = 0; + DuDb *duDb = NULLP; + CuUeCb *ueCb = NULLP; + + SEARCH_DU_DB(duIdx, sourceDuId, duDb); + if(duDb) + ueCb = &duDb->ueCb[ueId-1]; + if(ueCb) + { + ueCb->state = UE_HANDOVER_IN_PROGRESS; + ueCb->hoInfo.sourceDuId = sourceDuId; + ueCb->hoInfo.targetDuId = targetDuId; + } + + DU_LOG("\nINFO --> CU_STUB: Inter-DU Handover Started for ueId [%d] from DU ID [%d] to DU ID [%d]", \ + ueId, sourceDuId, targetDuId); + BuildAndSendUeContextModificationReq(sourceDuId, ueCb, QUERY_CONFIG); +} + + +/******************************************************************* + * + * @brief Initiates inter CU handover + * + * @details + * + * Function : initiateInterCuHandover + * + * Functionality: Initiates the first procedure of inter-CU + * handover + * + * @params[in] Source CU Id + * Target CU Id + * UE Id to be handed off + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void initiateInterCuHandover(uint32_t sourceCuId, uint32_t targetCuId, uint32_t ueId) +{ + DU_LOG("\nINFO --> CU_STUB: Inter-CU Handover Started for ueId [%d] from CU ID [%d] to CU ID [%d]", \ + ueId, sourceCuId, targetCuId); + //TODO : First message of HO procedure to be triggered here. Changes to be done in next commit. +} + +/******************************************************************* + * + * @brief start Dl data + * + * @details + * + * Function : startDlData + * + * Functionality: start the downlink data + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t startDlData() +{ + uint32_t teId = 0; + uint32_t duId; + uint8_t ret = ROK; + uint8_t cnt = 0; + int32_t totalNumOfTestFlow = 20; + EgtpTeIdCb *teidCb = NULLP; + + while(totalNumOfTestFlow) + { + for(duId = 1; duId <= cuCb.cuCfgParams.egtpParams.numDu; duId++) + { + for(teId = 1; teId <= NUM_TUNNEL_TO_PUMP_DATA; teId++) + { + teidCb = NULLP; + cmHashListFind(&(egtpCb.dstCb[duId-1].teIdLst), (uint8_t *)&(teId), sizeof(uint32_t), 0, (PTR *)&teidCb); + if(teidCb) + { + cnt =0; + DU_LOG("\nDEBUG --> EGTP: Sending DL User Data(duId %d, teId:%d)\n", duId, teId); + while(cnt < NUM_DL_PACKETS) + { + ret = cuEgtpDatReq(duId, teId); + if(ret != ROK) + { + DU_LOG("\nERROR --> EGTP: Issue with teid=%d\n",teId); + break; + } + /* TODO : sleep(1) will be removed later once we will be able to + * support the continuous data pack transfer */ + sleep(1); + cnt++; + } + } + else + { + DU_LOG("\nDEBUG --> EGTP: TunnelId Not Found for (duId %d, teId:%d)\n", duId, teId); + } + } + } + totalNumOfTestFlow--; + } + + return ROK; +} + /******************************************************************* * * @brief Handles Console input @@ -238,15 +398,119 @@ void readCuCfg() void *cuConsoleHandler(void *args) { char ch; + while(true) { + ch = getchar(); /* Send DL user data to CU when user enters 'd' on console */ - if((ch = getchar()) == 'd') + if(ch == 'd') { + + /* Change #if 0 to #if 1 to take input from user */ +#if 0 + DU_LOG("\n EGTP --> : Enter TEID id(1..10) where DL Data to be sent\n"); + scanf("%d",&teId); + + if(teId > MAX_TEID || teId < MIN_TEID) + { + DU_LOG("\nERROR --> EGTP : TEID(%x) OUT Of Range",teId); + printf("\n"); + continue; + } /* Start Pumping data from CU to DU */ - DU_LOG("\nDEBUG --> EGTP: Sending DL User Data"); - cuEgtpDatReq(); + DU_LOG("\nDEBUG --> EGTP: Sending DL User Data(teId:%d)\n",teId); + + cnt =0; + while(cnt < NUM_DL_PACKETS) + { + ret = cuEgtpDatReq(teId); + if(ret != ROK) + { + DU_LOG("\nERROR --> EGTP: Issue with teid=%d\n",teId); + break; + } + cnt++; + } +#else + + /* This variable is taken for sending specific number of downlink data packet. + * Presently the code is supporting total 4500 data packets trasfer for 3 UEs only with sleep(1). + * If you wants to pump data for 3 UE change the following macro values + * NUM_TUNNEL_TO_PUMP_DATA = 9, NUM_DL_PACKETS = 1. + * totalDataPacket = totalNumOfTestFlow * NUM_TUNNEL_TO_PUMP_DATA * NUM_DL_PACKETS + * totalDataPacket = [500*9*1] */ + + startDlData(); +#endif + continue; } + + /* Start Handover procedure towards DU when 'h' is received from console input */ + else if(ch == 'h') + { + HandoverType hoType; + uint32_t sourceId, targetId, ueId; + + DU_LOG("\n\nChoose the type of handover to initiate : \nEnter 1 for Inter-CU Handover over Xn interface\nEnter 2 for Inter-DU Handover\n"); + scanf("%d", &hoType); + + if(hoType == Xn_Based_Inter_CU_HO) + { + DU_LOG("\nEnter Source CU ID for Inter-CU Handover : "); + scanf("%d", &sourceId); + DU_LOG("\nEnter Target CU ID for Inter-CU Handover : "); + scanf("%d", &targetId); + DU_LOG("\nEnter CU UE F1AP ID to be handed over : "); + scanf("%d", &ueId); + + initiateInterCuHandover(sourceId, targetId, ueId); + } + else if(hoType == Inter_DU_HO) + { + DU_LOG("\nEnter Source DU ID for Inter-DU Handover : "); + scanf("%d", &sourceId); + DU_LOG("\nEnter Target DU ID for Inter-DU Handover : "); + scanf("%d", &targetId); + DU_LOG("\nEnter DU UE F1AP ID to be handed over : "); + scanf("%d", &ueId); + + initiateInterDuHandover(sourceId, targetId, ueId); + } + } + /* Start Idle mode paging when 'p' is received from console input */ + else if(ch == 'p') + { + uint64_t sTmsi = 0; + uint8_t duId = 0; + + DU_LOG("\nEnter DU ID on which this UE to be pagged"); + scanf("%d", &duId); + DU_LOG("\nEnter 5g-S-TMSI"); + scanf("%lu", &sTmsi); + + if(BuildAndSendPagingMsg(sTmsi, duId) != ROK) + { + DU_LOG("\nERROR --> EGTP: Failed to build and send paging message for 5gsTmsi[%lu]\n", sTmsi); + } + continue; + } + else if(ch == 'm') + { + uint8_t ueId = 1; + uint8_t duId = 1; + uint8_t duIdx = 0; + + DU_LOG("\nINFO --> CU_STUB: UE Context Mod for ueId [%d] at DU ID [%d]", \ + ueId, duId ); + DuDb *duDb = NULLP; + CuUeCb *ueCb = NULLP; + + SEARCH_DU_DB(duIdx, duId, duDb); + if(duDb) + ueCb = &duDb->ueCb[ueId-1]; + BuildAndSendUeContextModificationReq(duId, ueCb, MODIFY_UE); + + } } } /**********************************************************************