################################################################################
*******************************************************************************/
-/* This file contains message handling functionality for DU cell management */
+/* This file contains message handling functionality for DU APP */
+#include "du_mgr.h"
#include "du_sctp.h"
-#include "f1ap_msg_hdl.h"
+#include "du_f1ap_msg_hdl.h"
+#include "lsctp.h"
+#include "legtp.h"
+#include "lphy_stub.h"
U8 rlcDlCfg = 0;
U8 numRlcDlSaps = 0;
U8 macCfg = 0;
U8 macCfgInst = 0;
+extern DuCfgParams duCfgParam;
extern S16 cmPkLkwCfgReq(Pst *pst, KwMngmt *cfg);
extern S16 cmPkLkwCntrlReq(Pst *pst, KwMngmt *cfg);
extern S16 cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
+packMacCellCfgReq packMacCellCfgOpts[] =
+{
+ packMacCellCfg, /* packing for loosely coupled */
+ MacHdlCellCfgReq, /* packing for tightly coupled */
+ packMacCellCfg, /* packing for light weight loosly coupled */
+};
+
+DuMacCellStartReq packMacCellStartReqOpts[] =
+{
+ packMacCellStartReq, /* Loose coupling */
+ MacHdlCellStartReq, /* TIght coupling */
+ packMacCellStartReq /* Light weight-loose coupling */
+};
+
+DuMacCellStopReq packMacCellStopReqOpts[] =
+{
+ packMacCellStopReq, /* Loose coupling */
+ MacHdlCellStopReq, /* TIght coupling */
+ packMacCellStopReq /* Light weight-loose coupling */
+};
+
/**************************************************************************
* @brief Function to fill configs required by RLC
*
pst.srcProcId = DU_PROC;
pst.region = duCb.init.region;
- printf("\nRLC Gen Cfg Req sent for inst %d", inst);
+ DU_LOG("\nDU_APP : RLC Gen Cfg Req sent for inst %d", inst);
/* Send the request to RLC */
cmPkLkwCfgReq(&pst, &kwMngmt);
lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
lSap->selector = (inst == RLC_UL_INST) ? DU_SELECTOR_LWLC : DU_SELECTOR_TC;
kwMngmt.hdr.elmId.elmnt = STRGUSAP;
- printf("\nRLC MAC Lower Sap Cfg Req sent for inst %d", inst);
+ DU_LOG("\nDU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
}
else
lSap->sapId = 0;
lSap->selector = DU_SELECTOR_LC;
kwMngmt.hdr.elmId.elmnt = STUDXSAP;
- printf("\nRLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
+ DU_LOG("\nDU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
}
cmPkLkwCfgReq(&pst, &kwMngmt);
pst.srcProcId = DU_PROC;
pst.region = duCb.init.region;
- printf("\nRLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
+ DU_LOG("\nDU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
cmPkLkwCfgReq(&pst, &kwMngmt);
return ROK;
}
+
+/**************************************************************************
+ * @brief Function to populate internal DS of DU APP
+ *
+ * @details
+ *
+ * Function : duProcCfgComplete
+ *
+ * Functionality:
+ * Populates internal data structures of DU APP after
+ * receiving configurations.
+ *
+ * @param[in] void
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ***************************************************************************/
+S16 duProcCfgComplete()
+{
+ S16 ret = ROK;
+ static U16 cellId = 0;
+ U16 idx;
+ for(idx=0; idx< DEFAULT_CELLS; idx++)
+ {
+ DuCellCb *cell;
+ DU_ALLOC(cell, sizeof(DuCellCb))
+ if(cell == NULLP)
+ {
+ DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
+ ret = RFAILED;
+ }
+ else
+ {
+ U32 nci;
+ U8 idx1;
+ memset(cell, 0, sizeof(DuCellCb));
+ cell->cellId = cellId++;
+ cell->cellInfo.nrEcgi.plmn.mcc[0] = PLMN_MCC0;
+ cell->cellInfo.nrEcgi.plmn.mcc[1] = PLMN_MCC1;
+ cell->cellInfo.nrEcgi.plmn.mcc[2] = PLMN_MCC2;
+ cell->cellInfo.nrEcgi.plmn.mnc[0] = PLMN_MNC0;
+ cell->cellInfo.nrEcgi.plmn.mnc[1] = PLMN_MNC1;
+ cell->cellInfo.nrEcgi.plmn.mnc[2] = PLMN_MNC2;
+ cell->cellInfo.nrEcgi.cellId = NR_CELL_ID;
+ cell->cellInfo.nrPci = NR_PCI;
+ cell->cellInfo.fiveGsTac = DU_TAC;
+ for(idx1=0; idx1<MAX_PLMN; idx1++)
+ {
+ cell->cellInfo.plmn[idx1].mcc[0] = PLMN_MCC0;
+ cell->cellInfo.plmn[idx1].mcc[1] = PLMN_MCC1;
+ cell->cellInfo.plmn[idx1].mcc[2] = PLMN_MCC2;
+ cell->cellInfo.plmn[idx1].mnc[0] = PLMN_MNC0;
+ cell->cellInfo.plmn[idx1].mnc[1] = PLMN_MNC1;
+ cell->cellInfo.plmn[idx1].mnc[2] = PLMN_MNC2;
+ }
+ cell->cellInfo.maxUe = duCfgParam.maxUe;
+ cell->cellStatus = CELL_OUT_OF_SERVICE;
+ nci = (U16)cell->cellInfo.nrEcgi.cellId;
+
+ duCb.cfgCellLst[nci-1] = cell;
+ }
+ }
+ if(ret != RFAILED)
+ {
+ //Start layer configs
+ ret = duSendRlcUlCfg();
+ }
+ return ret;
+}
/**************************************************************************
* @brief Function to invoke DU Layer Configs
*
{
if (pst->srcInst == RLC_DL_INST)
{
- printf("\nBIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
+ DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
macCfgInst++;
if(macCfgInst < DEFAULT_CELLS)
{
}
else
{
- printf("\nBIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
+ DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
macCfgInst++;
if(macCfgInst < DEFAULT_CELLS)
{
}
else
{
- duSctpStartReq();
+ duSendSchCfg();
}
-
break;
}
}
{
S16 ret;
- printf("\nRLC UL Cfg Status %d", cfm->cfm.status);
+ DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
if (cfm->cfm.status == LCM_PRIM_OK)
{
switch(cfm->hdr.elmId.elmnt)
default:
break;
}
- printf("\n RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
+ DU_LOG("\nDU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
{
rlcUlCfg = 0;
}
else
{
- printf("\nConfig confirm NOK from RLC UL");
+ DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
ret = RFAILED;
}
return ret;
***************************************************************************/
S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
{
- printf("\nRLC DL Cfg Status %d", cfm->cfm.status);
+ DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
if (cfm->cfm.status == LCM_PRIM_OK)
{
switch(cfm->hdr.elmId.elmnt)
break;
}
- printf("\n RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
+ DU_LOG("\nDU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
{
rlcDlCfg = 0;
}
else
{
- printf("\nConfig confirm NOK from RLC DL");
+ DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
}
return ROK;
}
pst.srcProcId = DU_PROC;
pst.region = duCb.init.region;
- printf("\nMAC Gen Cfg Req sent");
+ DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
/* Send the request to MAC */
cmPkLrgCfgReq(&pst, &rgMngmt);
pst.srcProcId = DU_PROC;
pst.region = duCb.init.region;
- printf("\nMAC Rgu USap Cfg Req sent");
+ DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
/* Send the request to MAC */
cmPkLrgCfgReq(&pst, &rgMngmt);
default:
break;
}
- printf("\n MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
+ DU_LOG("\nDU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
{
macCfg = 0;
- printf("\n Completed sending Configs");
+ DU_LOG("\nDU_APP : Completed sending Configs");
macCfgInst = 0;
duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
}
}
else
{
- printf("\nConfig confirm NOK from MAC");
+ DU_LOG("\nDU_APP : Config confirm NOK from MAC");
ret = RFAILED;
}
return ret;
if (action == ABND)
{
- printf("\nCntrl Req to RLC inst %d to bind MAC sap", inst);
+ DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
}
else
{
- printf("\nCntrl Req to RLC inst %d to unbind MAC sap", inst);
+ DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
}
cntrl = &(kwMngmt.t.cntrl);
}
/*******************************************************************
*
- * @brief Function to start SCTP
+ * @brief Handles SCTP notifications
+ *
+ * @details
+ *
+ * Function : duSctpNtfyHdl
+ *
+ * Functionality:
+ * Handles SCTP notification
+ *
+ * @params[in] Message Buffer
+ * SCTP notification
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
+{
+ if(f1Params.assocId == ntfy->u.assocChange.assocId)
+ {
+ if(BuildAndSendF1SetupReq() != ROK)
+ {
+ return RFAILED;
+ }
+ }
+ else if(ricParams.assocId == ntfy->u.assocChange.assocId)
+ {
+ if(BuildAndSendE2SetupReq() != ROK)
+ {
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nDU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Pst struct for ENTEGTP
+ *
+ * @details
+ *
+ * Function : duFillEgtpPst
+ *
+ * Functionality:
+ * Fills Pst struct for ENTEGTP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 duFillEgtpPst(Pst *pst, Event event)
+{
+ cmMemset((U8 *)pst, 0, sizeof(Pst));
+ pst->srcEnt = (Ent)ENTDUAPP;
+ pst->srcInst = (Inst)DU_INST;
+ pst->srcProcId = DU_PROC;
+ pst->dstEnt = (Ent)ENTEGTP;
+ pst->dstInst = (Inst)EGTP_INST;
+ pst->dstProcId = pst->srcProcId;
+ pst->event = event;
+ pst->selector = DU_SELECTOR_LC;
+ pst->pool= DU_POOL;
+
+ RETVALUE(ROK);
+}
+
+
+/*******************************************************************
+ *
+ * @brief Function to configure EGTP
+ *
+ * @details
+ *
+ * Function : duBuildEgtpCfgReq
+ *
+ * Functionality:
+ * Function to configure EGTP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+S16 duBuildEgtpCfgReq()
+{
+ Pst pst;
+ EgtpConfig egtpCfg;
+
+ DU_LOG("\nDU_APP : Sending EGTP config request");
+
+ cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
+ cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
+
+ duFillEgtpPst(&pst, EVTCFGREQ);
+ packEgtpCfgReq(&pst, egtpCfg);
+
+ RETVALUE(ROK);
+}
+
+/*******************************************************************
+ *
+ * @brief Function to configure EGTP
+ *
+ * @details
+ *
+ * Function : duBuildEgtpCfgReq
+ *
+ * Functionality:
+ * Function to configure EGTP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 duHdlEgtpCfgComplete(CmStatus cfm)
+{
+ S16 ret = ROK;
+
+ if(cfm.status == LCM_PRIM_OK)
+ {
+ DU_LOG("\nDU_APP : EGTP configuraton complete");
+#ifdef EGTP_TEST
+ duSendEgtpSrvOpenReq();
+#endif
+ }
+ else
+ {
+ DU_LOG("\nDU_APP : EGTP configuraton failed");
+ ret = RFAILED;
+ }
+
+ RETVALUE(ret);
+}
+
+/*******************************************************************
+ *
+ * @brief Sends server open request to EGTP
*
* @details
*
- * Function : duSctpStartReq
+ * Function : duSendEgtpSrvOpenReq
*
* Functionality:
- * Function to start SCTP
+ * Sends server open request to EGTP
*
* @params[in]
- * @return void
+ * @return ROK - success
+ * RFAILED - failure
*
* ****************************************************************/
-S16 duSctpStartReq()
+
+S16 duSendEgtpSrvOpenReq()
{
Pst pst;
- Buffer *mBuf;
- cmMemset((U8 *)&(pst), 0, sizeof(Pst));
- pst.srcEnt = (Ent)ENTDUAPP;
- pst.srcInst = (Inst)DU_INST;
+ DU_LOG("\nDU_APP : Sending EGTP server open request");
+
+ duFillEgtpPst(&pst, EVTSRVOPENREQ);
+ packEgtpSrvOpenReq(&pst);
+
+ RETVALUE(ROK);
+}
+
+/*******************************************************************
+ *
+ * @brief Handles server open confirmation
+ *
+ * @details
+ *
+ * Function : duHdlEgtpSrvOpenComplete
+ *
+ * Functionality:
+ * Handles server open confirmation
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
+{
+ S16 ret = ROK;
+
+ if(cfm.status == LCM_PRIM_OK)
+ {
+ DU_LOG("\nDU_APP : EGTP server opened successfully");
+#ifdef EGTP_TEST
+ duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
+#endif
+ }
+ else
+ {
+ DU_LOG("\nDU_APP : EGTP server opening failed");
+ ret = RFAILED;
+ }
+
+ RETVALUE(ret);
+}
+
+/*******************************************************************
+ *
+ * @brief Sends tunnel management request
+ *
+ * @details
+ *
+ * Function : duSendEgtpTnlMgmtReq
+ *
+ * Functionality:
+ * Builds and sends tunnel management request to EGTP
+ *
+ * @params[in] Action
+ * Local tunnel endpoint id
+ * Remote tunnel endpoint id
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
+{
+ Pst pst;
+ EgtpTnlEvt tnlEvt;
+
+ tnlEvt.action = action;
+ tnlEvt.lclTeid = lclTeid;
+ tnlEvt.remTeid = remTeid;
+
+ DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
+
+ duFillEgtpPst(&pst, EVTTNLMGMTREQ);
+ packEgtpTnlMgmtReq(&pst, tnlEvt);
+
+ RETVALUE(ROK);
+}
+
+/*******************************************************************
+ *
+ * @brief Handles Tunnel management confirm
+ *
+ * @details
+ *
+ * Function : duHdlEgtpTnlMgmtCfm
+ *
+ * Functionality:
+ * Handles tunnel management confirm received from Egtp
+ *
+ * @params[in] Tunnel Event
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
+{
+ S16 ret = ROK;
+
+ if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
+ {
+ DU_LOG("\nDU_APP : Tunnel management confirm OK");
+
+#ifdef EGTP_TEST
+ duSendUeCreateReqToRlc();
+
+ duSendEgtpTestData();
+#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.dstEnt = (Ent)ENTSCTP;
- pst.dstInst = (Inst)SCTP_INST;
- pst.dstProcId = pst.srcProcId;
- pst.event = EVTSCTPSTRT;
- pst.selector = DU_SELECTOR_LC;
- pst.pool= DU_POOL;
- if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
- {
- printf("\nMemory allocation failed in duReadCfg");
- return RFAILED;
+ 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;
}
- SPstTsk(&pst, mBuf);
+ 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;
+ }
+ }
+ duLayerConfigComplete();
+ duBuildEgtpCfgReq();
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Sends Slot indication to EGTP
+ *
+ * @details
+ *
+ * Function : duSendEgtpSlotInd
+ *
+ * Functionality:
+ * Sends Slot indication to EGTP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 duSendEgtpSlotInd()
+{
+ Pst pst;
+
+ duFillEgtpPst(&pst, EVTSLOTIND);
+ packEgtpSlotInd(&pst);
+
RETVALUE(ROK);
+
+}
+
+/**************************************************************************
+ * @brief Function to fill and send MacCellconfig
+ *
+ * @details
+ *
+ * Function : duBuildAndSendMacCellCfg
+ *
+ * Functionality:
+ * Initiates MAC Configs towards MAC
+ *
+ * @param[in] void
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ***************************************************************************/
+S16 duBuildAndSendMacCellCfg()
+{
+ Pst pst;
+ DU_SET_ZERO(&pst, sizeof(Pst));
+ MacCellCfg *duMacCellCfg = NULLP;
+
+ DU_ALLOC(duMacCellCfg, sizeof(MacCellCfg));
+ if(duMacCellCfg == NULLP)
+ {
+ return RFAILED;
+ }
+
+ /* store the address in the duCb so that we can free on confirm msg */
+ duCb.duMacCellCfg = duMacCellCfg;
+
+ /* copy the mac config structure from duCfgParams */
+ memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
+
+ duMacCellCfg->transId = getTransId(); /* transaction ID */
+
+ /* Fill Pst */
+ pst.selector = DU_SELECTOR_LWLC;
+ pst.srcEnt = ENTDUAPP;
+ pst.dstEnt = ENTRG;
+ pst.dstInst = 0;
+ pst.srcInst = 0;
+ pst.dstProcId = DU_PROC;
+ pst.srcProcId = DU_PROC;
+ pst.region = duCb.init.region;
+ pst.event = EVENT_MAC_CELL_CONFIG_REQ;
+
+ /* Send MAC cell config to MAC */
+ return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
+}
+
+/**************************************************************************
+ * @brief Function to Handle MAC cell config confirm
+ *
+ * @details
+ *
+ * Function : duHandleMacCellCfgCfm
+ *
+ * Functionality:
+ * Initiates general Configs towards MAC
+ *
+ * @param[in] void
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ***************************************************************************/
+uint16_t duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm)
+{
+ S16 ret = ROK;
+
+ if(macCellCfgCfm->rsp == ROK)
+ {
+ if(macCellCfgCfm->transId == duCb.duMacCellCfg->transId)
+ {
+ /* free the memory allocated during sending macCellCfg request */
+ DU_FREE(duCb.duMacCellCfg->sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
+ DU_FREE(duCb.duMacCellCfg,sizeof(MacCellCfg));
+ duCb.duMacCellCfg = NULLP;
+
+ /* Build and send GNB-DU config update */
+ ret = BuildAndSendDUConfigUpdate();
+
+ /* TODO: Trigger cell start req once cell up slot ind is received*/
+ /* Build and Send Cell Start Req to MAC */
+ ret = duBuildAndSendMacCellStartReq();
+
+ }
+ else
+ {
+ /* transaction ID missmatch */
+ DU_LOG("\n transaction ID mismatch in macCellCfg");
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nMac cell cfg failed");
+ ret = RFAILED;
+ }
+ return ret;
}
/*******************************************************************
*
- * @brief Handles SCTP notifications
+ * @brief Handles slot indication from MAC
*
* @details
*
- * Function : duSctpNtfyHdl
+ * Function : duHandleSlotInd
*
* Functionality:
- * Handles SCTP notification
+ * Handles slot indication from MAC
*
- * @params[in] Message Buffer
- * SCTP notification
+ * @params[in] Post structure pointer
+ * Slot Info pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo)
+{
+
+ DU_LOG("\nDU APP : Slot Indication received");
+
+ if(slotInfo->cellId <=0 || slotInfo->cellId > DU_MAX_CELLS)
+ {
+ DU_LOG("\nDU APP : Invalid Cell Id %d", slotInfo->cellId);
+ }
+ if(!duCb.actvCellLst[slotInfo->cellId-1]->firstSlotIndRcvd)
+ {
+ duCb.actvCellLst[slotInfo->cellId-1]->firstSlotIndRcvd = true;
+ if((duCb.actvCellLst[slotInfo->cellId-1] != NULL) && \
+ (duCb.actvCellLst[slotInfo->cellId-1]->cellStatus == \
+ ACTIVATION_IN_PROGRESS))
+ {
+ DU_LOG("\nDU APP : Cell Id %d is ACTIVE", slotInfo->cellId);
+ duCb.actvCellLst[slotInfo->cellId-1]->cellStatus = ACTIVATED;
+ }
+
+ }
+
+ /* TODO : Slot Indication to be moved out of EGTP_TEST when
+ * data path is established */
+#ifdef EGTP_TEST
+ duSendEgtpSlotInd();
+#endif
+ DU_FREE_MEM(pst->region, pst->pool, slotInfo, sizeof(SlotInfo));
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and sends cell start request to MAC
+ *
+ * @details
*
+ * Function : duBuildAndSendMacCellStartReq
+ *
+ * Functionality:
+ * Builds and sends cell start request to MAC
+ *
+ * @params[in]
* @return ROK - success
* RFAILED - failure
*
* ****************************************************************/
+uint16_t duBuildAndSendMacCellStartReq()
+{
+ Pst pst;
+ MacCellStartInfo *cellStartInfo = NULL;
-S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
+ DU_LOG("\nDU APP : Building and Sending cell start request to MAC");
+
+ /* Send Cell Start Request to MAC */
+ DU_ALLOC(cellStartInfo, sizeof(MacCellStartInfo));
+ if(!cellStartInfo)
+ {
+ DU_LOG("\nDU APP : Memory alloc failed while building cell start request");
+ return RFAILED;
+ }
+
+ for(uint8_t id = 0; id < DU_MAX_CELLS; id++)
+ {
+ if(duCb.actvCellLst[id])
+ {
+ duCb.actvCellLst[id]->firstSlotIndRcvd = FALSE;
+ cellStartInfo->cellId = duCb.actvCellLst[id]->cellInfo.nrEcgi.cellId;
+
+ /* Fill Pst */
+ pst.selector = DU_MAC_LWLC;
+ pst.srcEnt = ENTDUAPP;
+ pst.dstEnt = ENTRG;
+ pst.dstInst = 0;
+ pst.srcInst = 0;
+ pst.dstProcId = DU_PROC;
+ pst.srcProcId = DU_PROC;
+ pst.region = DU_APP_MEM_REGION;
+ pst.pool = DU_POOL;
+ pst.event = EVENT_MAC_CELL_START_REQ;
+
+ return (*packMacCellStartReqOpts[pst.selector])(&pst, cellStartInfo);
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and sends cell stop request to MAC
+ *
+ * @details
+ *
+ * Function : duBuildAndSendMacCellStopReq
+ *
+ * Functionality:
+ * Builds and sends cell stop request to MAC
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 duBuildAndSendMacCellStopReq()
{
- char *finalBuf;
- int i,j;
+ Pst pst;
+ MacCellStopInfo *cellStopInfo = NULL;
+
+ DU_LOG("\nDU APP : Building and Sending cell stop request to MAC");
- switch(ntfy->header.nType)
+ /* Send Cell Stop Request to MAC */
+ DU_ALLOC(cellStopInfo, sizeof(MacCellStopInfo));
+ if(!cellStopInfo)
{
- case CM_INET_SCTP_ASSOC_CHANGE:
- switch(ntfy->u.assocChange.state)
- {
- case CM_INET_SCTP_COMM_UP:
- {
- printf("\nSCTP communication UP");
- duCb.sctpStatus = TRUE;
- //Setup F1-C
- if(!duCb.f1Status)
- {
- /* Build and send F1 Setup response */
- Buffer *f1SetupReq;
- MsgLen copyCnt;
-
- BuildF1SetupReq();
- /* Reversing the encoded string */
- if(SGetSBuf(1, 1, (Data **)&finalBuf, (Size)encBufSize) != ROK)
- {
- printf("Memory allocation failed");
- RETVALUE(RFAILED);
- }
- for(i = 0, j = encBufSize-1; i<encBufSize; i++, j--)
- {
- finalBuf[j] = encBuf[i];
- }
-
- if(SGetMsg(1, 1, &f1SetupReq) == ROK)
- {
- if(SCpyFixMsg((Data *)finalBuf, f1SetupReq, 0, encBufSize, ©Cnt) == ROK)
- {
- printf("\nSending F1 setup request");
- SPrntMsg(f1SetupReq, 0,0);
- if(sctpOutMsgSend(f1SetupReq) != ROK)
- {
- printf("\nFailed Sending");
- }
- }
- }
- }
- else
- {
- }
- break;
- }
- }
- break;
+ DU_LOG("\nDU APP : Memory alloc failed while building cell stop request");
+ return RFAILED;
}
- RETVALUE(ROK);
+ cellStopInfo->cellId = duCb.actvCellLst[0]->cellId;
+
+ /* Fill Pst */
+ pst.selector = DU_MAC_LWLC;
+ pst.srcEnt = ENTDUAPP;
+ pst.dstEnt = ENTRG;
+ pst.dstInst = 0;
+ pst.srcInst = 0;
+ pst.dstProcId = DU_PROC;
+ pst.srcProcId = DU_PROC;
+ pst.region = DU_APP_MEM_REGION;
+ pst.pool = DU_POOL;
+ pst.event = EVENT_MAC_CELL_STOP_REQ;
+
+ return (*packMacCellStopReqOpts[pst.selector])(&pst, cellStopInfo);
}
+
/**********************************************************************
- End of file
-**********************************************************************/
+ End of file
+ **********************************************************************/