/* 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"
-
-#define CU_ID 1
-#define CU_NAME "ORAN_OAM_CU"
-#define DU_IP_V4_ADDR "192.168.130.81"
-#define CU_IP_V4_ADDR "192.168.130.82"
-#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"
-#define DU_PORT 38472
-#define CU_PORT 38472
-#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
+#include "OCTET_STRING.h"
+#include "cu_f1ap_msg_hdl.h"
+#include "cu_stub.h"
+
+#ifdef O1_ENABLE
+#include "CmInterface.h"
+#endif
+
+
+#ifdef O1_ENABLE
+extern StartupConfig g_cfg;
+#endif
+
+/*******************************************************************
+ *
+ * @brief Fetches pointer to DU Database
+ *
+ * @details
+ *
+ * Function : getDuDb
+ *
+ * Functionality:
+ * Searches and returns pointer to DU structure based on DU Id
+ *
+ * @params[in] DU Id
+ * @return Pointer to DU Db
+ *
+ ******************************************************************/
+DuDb* getDuDb(uint32_t duId)
+{
+ uint8_t duIdx;
+ for(duIdx=0; duIdx < cuCb.numDu; duIdx++)
+ {
+ if(cuCb.duInfo[duIdx].duId == duId)
+ return (&cuCb.duInfo[duIdx]);
+ }
+ return NULLP;
+}
+
+/*******************************************************************
+ *
+ * @brief Fetches pointer to Cell Cb
+ *
+ * @details
+ *
+ * Function : getCellCb
+ *
+ * Functionality:
+ * Searches for a cell within a DU based on NR cell Id
+ * Returns pointer to this cell Cb structure
+ *
+ * @params[in] Pointer to DU Db
+ * NR Cell ID
+ * @return Pointer to cell Cb
+ *
+ ******************************************************************/
+CuCellCb* getCellCb(DuDb *duDb, uint32_t cellId)
+{
+ uint8_t cellIdx;
+ for(cellIdx=0; cellIdx < duDb->numCells; cellIdx++)
+ {
+ if(duDb->cellCb[cellIdx].nrCellId == cellId)
+ return &(duDb->cellCb[cellIdx]);
+ }
+ return NULLP;
+}
/*******************************************************************
*
void init_log()
{
- openlog("CU_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
+ openlog("CU_STUB",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
}
/*******************************************************************
*
pthread_attr_t attr;
init_log();
- DU_LOG("\nStarting CU_STUB\n");
+ DU_LOG("\nINFO --> CU_STUB : Starting CU_STUB\n");
/* Start thread to receive console input */
pthread_attr_init(&attr);
retVal = pthread_create(&conThrdId, &attr, cuConsoleHandler, NULLP);
if(retVal != 0)
{
- DU_LOG("\nCU_STUB: Thread creation failed. Cause %d", retVal);
+ DU_LOG("\nERROR --> CU_STUB : Thread creation failed. Cause %d", retVal);
}
pthread_attr_destroy(&attr);
void readCuCfg()
{
+ uint8_t *numDu;
uint32_t ipv4_du, ipv4_cu;
- DU_LOG("\nReading CU configurations");
+ DU_LOG("\nDEBUG --> CU_STUB : Reading CU configurations");
- cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
- cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
-
- 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;
- cuCfgParams.sctpParams.duPort = DU_PORT;
+ cuCb.cuCfgParams.cuId = CU_ID;
+ strcpy(cuCb.cuCfgParams.cuName, CU_NAME);
+
+#ifdef O1_ENABLE
+ if( getStartupConfigForStub(&g_cfg) != ROK )
+ {
+ DU_LOG("\nError --> CU_STUB : Could not fetch startup "\
+ "configurations from Netconf interface\n");
+ exit(1);
+ }
+
+ cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV4Addr = ipv4_du;
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duIpAddr.ipV6Pres = false;
+
+ cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuIpAddr.ipV4Addr = ipv4_cu;
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuIpAddr.ipV6Pres = false;
+
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[0].duPort = g_cfg.DU_Port;
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[0].cuPort = g_cfg.CU_Port;
+ cuCb.cuCfgParams.sctpParams.numDu = 1;
+#else
+ cuCb.cuCfgParams.sctpParams.numDu = 0;
+ numDu = &cuCb.cuCfgParams.sctpParams.numDu;
+ while(*numDu < MAX_DU_SUPPORTED)
+ {
+ /* DU IP Address and Port*/
+ memset(&ipv4_du, 0, sizeof(uint32_t));
+ cmInetAddr((S8*)DU_IP_V4_ADDR[*numDu], &ipv4_du);
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[*numDu].duIpAddr.ipV4Addr = ipv4_du;
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[*numDu].duIpAddr.ipV6Pres = false;
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[*numDu].duPort = DU_SCTP_PORT[*numDu];
+
+ /* CU IP Address and Port*/
+ memset(&ipv4_du, 0, sizeof(uint32_t));
+ cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[*numDu].cuIpAddr.ipV4Addr = ipv4_cu;
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[*numDu].cuIpAddr.ipV6Pres = false;
+ cuCb.cuCfgParams.sctpParams.sctpAssoc[*numDu].cuPort = CU_SCTP_PORT_TO_DU[*numDu];
+ (*numDu)++;
+ }
- /* CU IP Address and Port*/
- cuCfgParams.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
- cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false;
- cuCfgParams.sctpParams.cuPort = CU_PORT;
+#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;
+ cuCb.cuCfgParams.egtpParams.localIp.ipV4Pres = TRUE;
+ cuCb.cuCfgParams.egtpParams.localIp.ipV4Addr = ipv4_cu;
+ cuCb.cuCfgParams.egtpParams.localPort = CU_EGTP_PORT;
+ cuCb.cuCfgParams.egtpParams.destIp.ipV4Pres = TRUE;
+ cuCb.cuCfgParams.egtpParams.destIp.ipV4Addr = ipv4_du;
+ cuCb.cuCfgParams.egtpParams.destPort = DU_EGTP_PORT;
+ cuCb.cuCfgParams.egtpParams.minTunnelId = MIN_TEID;
+ cuCb.cuCfgParams.egtpParams.currTunnelId = cuCb.cuCfgParams.egtpParams.minTunnelId;
+ cuCb.cuCfgParams.egtpParams.maxTunnelId = MAX_TEID;
} /* 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)
+{
+ DuDb *duDb = NULLP;
+ CuUeCb *ueCb = NULLP;
+
+ duDb = getDuDb(sourceDuId);
+ if(duDb)
+ ueCb = &duDb->ueCb[ueId-1];
+ if(ueCb)
+ ueCb->state = HANDOVER_IN_PROGRESS;
+
+ 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 Handles Console input
void *cuConsoleHandler(void *args)
{
char ch;
+ uint8_t teId = 0;
+ uint8_t ret = ROK;
+ uint8_t cnt = 0;
+
+ /* 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] */
+ int32_t totalNumOfTestFlow = 500;
+
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("\nEGTP: 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
+ while(totalNumOfTestFlow)
+ {
+ for(teId = 1; teId <= NUM_TUNNEL_TO_PUMP_DATA; teId++)
+ {
+ 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;
+ }
+ /* TODO : sleep(1) will be removed later once we will be able to
+ * support the continuous data pack transfer */
+ sleep(1);
+ cnt++;
+ }
+ }
+ totalNumOfTestFlow--;
+ }
+#endif
+ continue;
}
+
+ /* Start Handover procedure towards DU when 'h' is received from console input */
+ else if(ch == 'h')
+ {
+ uint32_t sourceDuId, targetDuId, ueId;
+
+ DU_LOG("\nEnter Source DU ID for Inter-DU Handover");
+ scanf("%d", &sourceDuId);
+ DU_LOG("\nEnter Target DU ID for Inter-DU Handover");
+ scanf("%d", &targetDuId);
+ DU_LOG("\nEnter DU UE F1AP ID to be handed over");
+ scanf("%d", &ueId);
+
+ initiateInterDuHandover(sourceDuId, targetDuId, ueId);
+ }
}
}
/**********************************************************************