+ DU_LOG("\nDU_APP : Tunnel management confirm OK");
+
+#ifdef EGTP_TEST
+ duSendUeCreateReqToRlc();
+
+ duSendEgtpTestData();
+
+ /* For testing purpose. TTI thread should actually be in L1 */
+ duStartTtiThread();
+#endif
+ }
+ else
+ {
+ DU_LOG("\nDU_APP : Tunnel management failed");
+ ret = RFAILED;
+ }
+
+ RETVALUE(ret);
+}
+
+S16 duSendEgtpDatInd(Buffer *mBuf)
+{
+ EgtpMsg egtpMsg;
+
+ /* Fill EGTP header */
+ egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
+ egtpMsg.msgHdr.nPdu.pres = FALSE;
+ egtpMsg.msgHdr.seqNum.pres = FALSE;
+ egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
+ egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
+ egtpMsg.msgHdr.teId = 1;
+ egtpMsg.msg = mBuf;
+
+ egtpHdlDatInd(egtpMsg);
+
+ return ROK;
+
+}
+
+#ifdef EGTP_TEST
+/*******************************************************************
+ *
+ * @brief Simulate UL Data for intial test
+ *
+ * @details
+ *
+ * Function : duSendEgtpTestData
+ *
+ * Functionality:
+ * Simulate UL data for initial test
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 duSendEgtpTestData()
+{
+ char data[30] = "This is EGTP data from DU";
+ int datSize = 30;
+
+ Buffer *mBuf;
+
+ if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
+ {
+ if(SAddPstMsgMult((Data *)data, datSize, mBuf) != ROK)
+ {
+ DU_LOG("\nDU_APP : SAddPstMsgMult failed");
+ SPutMsg(mBuf);
+ RETVALUE(RFAILED);
+ }
+ }
+ else
+ {
+ DU_LOG("\nDU_APP : Failed to allocate memory");
+ RETVALUE(RFAILED);
+ }
+
+ /* filling IPv4 header */
+ CmIpv4Hdr ipv4Hdr;
+ MsgLen mLen;
+
+ mLen = 0;
+ SFndLenMsg(mBuf, &mLen);
+
+ cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
+ ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
+ ipv4Hdr.hdrVer = 0x45;
+ ipv4Hdr.proto = 1;
+ ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
+ ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
+
+ /* Packing IPv4 header into buffer */
+ S16 ret, cnt, idx;
+ Data revPkArray[CM_IPV4_HDRLEN];
+ Data pkArray[CM_IPV4_HDRLEN];
+
+ /* initialize locals */
+ cnt = 0;
+ cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
+ cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
+
+ /* Pack Header Version */
+ pkArray[cnt++] = ipv4Hdr.hdrVer;
+
+ /* Pack TOS */
+ pkArray[cnt++] = ipv4Hdr.tos;
+
+ pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
+ pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
+
+ /* Pack Id */
+ pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
+ pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
+
+ /* Pack Offset */
+ pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
+ pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
+
+ /* Pack TTL */
+ pkArray[cnt++] = ipv4Hdr.ttl;
+
+ /* Pack Protocol */
+ pkArray[cnt++] = ipv4Hdr.proto;
+
+ /* Pack Checksum */
+ pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
+ pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
+
+ /* Pack Source Address */
+ pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
+ pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
+ pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
+ pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
+
+ /* Pack Destination Address */
+ pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
+ pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
+ pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
+ pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
+
+ for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
+ revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
+
+ /* this function automatically reverses revPkArray */
+ ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
+
+ duSendEgtpDatInd(mBuf);
+
+ RETVALUE(ROK);
+}
+#endif /* EGTP_TEST */
+
+
+/**************************************************************************
+ * @brief Function to send configs to SCH
+ *
+ * @details
+ *
+ * Function : duSendSchCfg
+ *
+ * Functionality:
+ * Sends general config to Scheduler via MAC layer
+ *
+ * @param[in] void
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ***************************************************************************/
+S16 duSendSchCfg()
+{
+ RgMngmt rgMngmt;
+ RgSchInstCfg *cfg = NULLP;
+ Pst pst;
+
+ DU_SET_ZERO(&pst, sizeof(Pst));
+ DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
+
+ cfg = &(rgMngmt.t.cfg.s.schInstCfg);
+
+ /* Filling of Instance Id */
+ cfg->instId = DEFAULT_CELLS + 1;
+ /* Filling of Gen config */
+ cfg->genCfg.mem.region = RG_MEM_REGION;
+ cfg->genCfg.mem.pool = RG_POOL;
+ cfg->genCfg.tmrRes = 10;
+
+#ifdef LTE_ADV
+ cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
+ cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
+#endif/*LTE_ADV*/
+ cfg->genCfg.startCellId = 1;
+ cfg->genCfg.lmPst.dstProcId = DU_PROC;
+ cfg->genCfg.lmPst.srcProcId = DU_PROC;
+ cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
+ cfg->genCfg.lmPst.dstInst = DU_INST;
+ cfg->genCfg.lmPst.srcEnt = ENTRG;
+ cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
+ cfg->genCfg.lmPst.prior = PRIOR0;
+ cfg->genCfg.lmPst.route = RTESPEC;
+ cfg->genCfg.lmPst.region = RG_MEM_REGION;
+ cfg->genCfg.lmPst.pool = RG_POOL;
+ cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
+
+ /* Fill Header */
+ rgMngmt.hdr.msgType = TCFG;
+ rgMngmt.hdr.entId.ent = ENTRG;
+ rgMngmt.hdr.entId.inst = DU_INST;
+ rgMngmt.hdr.elmId.elmnt = STSCHINST;
+ rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
+ rgMngmt.hdr.response.mem.pool = RG_POOL;
+
+ /* Fill Pst */
+ pst.selector = DU_SELECTOR_LC;
+ pst.srcEnt = ENTDUAPP;
+ pst.dstEnt = ENTRG;
+ pst.dstProcId = DU_PROC;
+ pst.srcProcId = DU_PROC;
+ pst.srcInst = DU_INST;
+ pst.dstInst = 0;
+ pst.region = duCb.init.region;
+ pst.event = (Event) EVTMACSCHGENCFGREQ;
+
+ DU_LOG("\nDU_APP : MAC Sch Cfg sent");
+
+ /* Send the request to MAC */
+ cmPkLrgSchCfgReq(&pst, &rgMngmt);
+
+ return ROK;
+}
+
+
+/**************************************************************************
+ * @brief Function to configure SCTP params and
+ * responsible for F1 and E2 interfaces
+ *
+ * @details
+ *
+ * Function : duLayerConfigComplete
+ *
+ * Functionality:
+ * Configures SCTP Params and responsible for handling
+ * F1 and E2 interface.
+ *
+ * @param[in] void
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ***************************************************************************/
+S16 duLayerConfigComplete()
+{
+ S16 ret = ROK;
+
+ DU_LOG("\nDU_APP : Configuring all Layer is complete");
+
+ if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
+ {
+ DU_LOG("\nDU_APP : Failed configuring Sctp Params");
+ ret = RFAILED;
+ }
+ if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
+ {
+ DU_LOG("\nDU_APP : Failed to send AssocReq F1");
+ ret = RFAILED;
+ }
+ if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
+ {
+ DU_LOG("\nDU_APP : Failed to send AssocReq E2");
+ ret = RFAILED;
+ }
+
+ RETVALUE(ret);
+}
+
+/**************************************************************************
+ * @brief Function to handle SCH Config Confirm from MAC
+ *
+ * @details
+ *
+ * Function : duHdlSchCfgComplete
+ *
+ * Functionality:
+ * Handles Scheduler Gen Config Confirm from MAC
+ *
+ * @param[in] Pst *pst, Post structure of the primitive.
+ * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ***************************************************************************/
+S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
+{
+ if (cfm->cfm.status == LCM_PRIM_OK)
+ {
+ switch (cfm->hdr.elmId.elmnt)
+ {
+ case STSCHINST:
+ {
+ DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
+ break;
+ }
+ default:
+ break;
+ }