+/*******************************************************************
+ *
+ * @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 duUeF1apId)
+{
+ uint8_t duIdx = 0;
+ DuDb *duDb = NULLP;
+ CuUeCb *ueCb = NULLP;
+
+ DU_LOG("\nINFO --> CU_STUB: Inter-DU Handover Started for ueId [%d] from DU ID [%d] to DU ID [%d]", \
+ duUeF1apId, sourceDuId, targetDuId);
+
+ SEARCH_DU_DB(duIdx, sourceDuId, duDb);
+ if(duDb)
+ ueCb = &duDb->ueCb[duUeF1apId-1];
+ if(ueCb)
+ {
+ ueCb->state = UE_HANDOVER_IN_PROGRESS;
+ ueCb->hoInfo.HOType = Inter_DU_HO;
+ ueCb->hoInfo.srcNodeId = sourceDuId;
+ ueCb->hoInfo.tgtNodeId = targetDuId;
+
+ BuildAndSendUeContextModificationReq(sourceDuId, ueCb, QUERY_CONFIG);
+ }
+ else
+ {
+ DU_LOG("\nINFO --> CU_STUB: DU UE F1AP ID [%d] not found", duUeF1apId);
+ }
+}
+
+
+/*******************************************************************
+ *
+ * @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 targetCuId, uint32_t cellId, uint32_t cuUeF1apId)
+{
+ uint8_t duIdx, ueIdx;
+ CuUeCb *ueCb = NULLP;
+
+ DU_LOG("\nINFO --> CU_STUB: Inter-CU Handover Started for ueId [%d] to CU ID [%d]", \
+ cuUeF1apId, targetCuId);
+
+ for(duIdx = 0; duIdx < cuCb.numDu; duIdx++)
+ {
+ for(ueIdx = 0; ueIdx < (MAX_NUM_CELL * MAX_NUM_UE); ueIdx++)
+ {
+ ueCb = &cuCb.duInfo[duIdx].ueCb[ueIdx];
+ if(cuCb.duInfo[duIdx].ueCb[ueIdx].gnbCuUeF1apId == cuUeF1apId)
+ {
+ ueCb = &cuCb.duInfo[duIdx].ueCb[ueIdx];
+ break;
+ }
+ }
+ if(ueCb)
+ break;
+ }
+
+ if(ueCb)
+ {
+ ueCb->state = UE_HANDOVER_IN_PROGRESS;
+ ueCb->hoInfo.HOType = Xn_Based_Inter_CU_HO;
+ ueCb->hoInfo.srcNodeId = cuCb.cuCfgParams.cuId;
+ ueCb->hoInfo.tgtNodeId = targetCuId;
+ ueCb->hoInfo.tgtCellId = cellId;
+ ueCb->hoInfo.cuUeF1apIdSrc = ueCb->gnbCuUeF1apId;
+
+ BuildAndSendUeContextModificationReq(cuCb.duInfo[duIdx].duId, ueCb, QUERY_CONFIG);
+ }
+ else
+ {
+ DU_LOG("\nINFO --> CU_STUB: CU UE F1AP ID [%d] not found", cuUeF1apId);
+ }
+}
+
+/*******************************************************************
+ *
+ * @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 = 200;
+ 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;
+}
+