- RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
-}
-
-\f
-/**
- * @brief Layer Manager Trace Indication generation.
- *
- * @details
- *
- * Function : rgLMMTrcInd
- *
- * This API is used by the other modules of MAC to send a
- * Trace indication to the Layer Manager.
- *
- * @param[in] Inst inst
- * @param[in] Buffer *srcMbuf, the Message Buffer .
- * @param[in] U8 event, the trace event.
- * @return Void
- **/
-#ifdef ANSI
-PUBLIC Void rgLMMTrcInd
-(
-Inst inst,
-Buffer *srcMbuf, /* Message Buffer */
-U8 event /* event */
-)
-#else
-PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
-Inst inst;
-Buffer *srcMbuf; /* Message Buffer */
-U8 event; /* event */
-#endif
-{
- Buffer *dstMbuf = NULLP;
- MsgLen bufLen = 0;
- Data *tempBuf;
- MsgLen tempCnt;
- RgMngmt trc;
- Pst pst;
-
- TRC2(rgLMMTrcInd)
-
-
- if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
- {
- RLOG0(L_ERROR, "Trace Disabled.");
- RETVOID;
- }
-
- cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
-
- pst = rgCb[inst].rgInit.lmPst;
- pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
- pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
- pst.route = rgCb[inst].genCfg.trcResp.response.route;
- pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
- pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
-
- trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
-
- SGetDateTime(&trc.t.trc.dt);
-
- /* Check if the whole buffer is to be sent in Trace indication */
- if(rgCb[inst].trcLen == LRG_FULL_TRACE)
- {
- if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
- != ROK)
- {
- RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
- RETVOID;
- }
- trc.cfm.status = LCM_PRIM_OK;
- trc.cfm.reason = LCM_REASON_NOT_APPL;
- trc.t.trc.evnt = event;
-
- /* Send Trace Indication to Layer manager */
- RgMiLrgTrcInd(&pst, &trc, dstMbuf);
- }
- /* check if only a specified number of bytes are to be sent */
- else if(rgCb[inst].trcLen > 0)
- {
- /* Get the length of the recvd message buffer */
- if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
- {
- RLOG0(L_ERROR, "SFndLenMsg Failed.");
- RETVOID;
- }
- /* Check if the recvd buffer size is less than request trace len */
- if(bufLen < rgCb[inst].trcLen)
- {
- /* Copy the whole of the recvd buffer in trace indication */
-
- if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
- != ROK)
- {
- RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
- RETVOID;
- }
-
- trc.cfm.status = LCM_PRIM_OK;
- trc.cfm.reason = LCM_REASON_NOT_APPL;
- trc.t.trc.evnt = event;
-
- /* Send Trace Indication to Layer manager */
- RgMiLrgTrcInd(&pst, &trc, dstMbuf);
- }
- /* if the recvd buffer size is greater than request trace len */
- if(bufLen >= rgCb[inst].trcLen)
- {
- /* Get a temporary buffer to store the msg */
- if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
- {
- RLOG0(L_ERROR, "rgAllocSBuf Failed.");
- RETVOID;
- }
-
- /* Copy trcLen nos of bytes from the recvd message */
- if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
- {
- RLOG0(L_ERROR, "SCpyMsgFix Failed.");
- RETVOID;
- }
-
- if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
- {
- RLOG0(L_ERROR, "dstMbuf Allocation Failed");
- RETVOID;
- }
- /* Copy the tempBuf data to dst mBuf */
- if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
- {
- RLOG0(L_ERROR, "SCpyFixMsg Failed.");
- RETVOID;
- }
-
- /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
- assignment */
- /* Free the memory allocated for tempBuf */
- rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
-
- trc.cfm.status = LCM_PRIM_OK;
- trc.cfm.reason = LCM_REASON_NOT_APPL;
- trc.t.trc.evnt = event;
-
- /* Send Trace Indication to Layer manager */
- RgMiLrgTrcInd(&pst, &trc, dstMbuf);
- }
- }
- RETVOID;
-}
-
-\f
-/**
- * @brief Layer Manager Control Confirm generation handler
- * for Bind Confirm reception at TFU interface.
- * RgLiTfuBndCfm() forwards the confirmation to this
- * function. All SAP state related handling is restricted
- * to LMM modules, hence the cfm forwarding.
- *
- * @details
- *
- * Function : rgLMMBndCfm
- *
- * This API is used by the LIM module of MAC to forward
- * the Bind Confirm it receives over the TFU interface.
- *
- * @param[in] Pst *pst, Post Structure
- * @param[in] SuId suId, Service user ID
- * @param[in] U8 status, Status
- * @return S16
- * -# ROK
- **/
-#ifdef ANSI
-PUBLIC S16 rgLMMBndCfm
-(
-Pst *pst, /* Post Structure */
-SuId suId, /* Service user ID */
-U8 status /* Status */
-)
-#else
-PUBLIC S16 rgLMMBndCfm(pst,suId,status)
-Pst *pst; /* Post Structure */
-SuId suId; /* Service user ID */
-U8 status; /* Status */
-#endif
-{
- Inst inst = pst->dstInst - RG_INST_START;
- S16 ret = ROK;
- RgMngmt cntrlCfm;
- Pst cfmPst;
-
- TRC3(rgLMMBndCfm)
-
- UNUSED(pst);
-
- /* Check if the suId is valid */
- if(rgCb[inst].tfuSap.sapCfg.suId != suId)
- {
- RLOG0(L_ERROR, "Invalid SuId");
- RETVALUE(RFAILED);
- }
-
- /* check the Sap State */
- switch(rgCb[inst].tfuSap.sapSta.sapState)
- {
- case LRG_WAIT_BNDCFM:
- break;
- case LRG_BND:
- /* SAP is already bound */
- RETVALUE(ROK);
- default:
- RETVALUE(RFAILED);
- }
-
- cfmPst = rgCb[inst].rgInit.lmPst;
- cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
- cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
- cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
- cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
- cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
-
- cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
-
- switch(status)
- {
- case CM_BND_OK: /* status is OK */
- /* Change SAP state to Bound */
- rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
- if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
- {
- ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
- }
- /* Send Control Confirm with status as OK to Layer Manager */
- cntrlCfm.cfm.status = LCM_PRIM_OK;
- cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
- break;
-
- default:
- /* Change SAP state to UnBound */
- rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
- if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
- {
- ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
- }
- /* Send Control Confirm with status as NOK to Layer Manager */
- cntrlCfm.cfm.status = LCM_PRIM_NOK;
- cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
- break;
- }
- rgCb[inst].tfuSap.numBndRetries = 0;
- cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
- cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
-
- ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
-
- RETVALUE(ret);
-}
-
-\f
-/**
- * @brief LTE MAC timer call back function registered with SSI.
- *
- * @details
- *
- * Function : rgActvTmr
- *
- * This function is invoked by SSI for every timer activation
- * period expiry.
- *
- * @return S16
- * -# ROK
- **/
-#ifdef ANSI
-PUBLIC S16 rgActvTmr
-(
- Ent ent,
- Inst inst
-)
-#else
-PUBLIC S16 rgActvTmr(ent, inst)
-Ent ent;
-Inst inst;
-#endif
-{
- Inst macInst = (inst - RG_INST_START);
- TRC3(rgActvTmr)
-
- /* Check if any MAC timer has expired */
- cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
-
- RETVALUE(ROK);
-
-} /* end of rgActvTmr */
-
-/**
- * @brief Layer Manager Configuration request handler for Scheduler
- *
- * @details
- *
- * Function : MacSchGenCfgReq
- *
- * This function receives general configurations for Scheduler
- * from DU APP and forwards to Scheduler.
- *
- * @param[in] Pst *pst, the post structure
- * @param[in] RgMngmt *cfg, the configuration parameter's structure
- * @return S16
- * -# ROK
- **/
-#ifdef ANSI
-PUBLIC S16 MacSchGenCfgReq
-(
-Pst *pst, /* post structure */
-RgMngmt *cfg /* config structure */
-)
-#else
-PUBLIC S16 MacSchGenCfgReq(pst, cfg)
-Pst *pst; /* post structure */
-RgMngmt *cfg; /* config structure */
-#endif
-{
- printf("\nReceived Scheduler gen config at MAC");
- pst->dstInst = DEFAULT_CELLS + 1;
- HandleSchGenCfgReq(pst, cfg);
-
- return ROK;
-}
-
-/**
- * @brief Layer Manager Configuration response from Scheduler
- *
- * @details
- *
- * Function : SchSendCfgCfm
- *
- * This function sends general configurations response from
- * Scheduler to DU APP.
- *
- * @param[in] Pst *pst, the post structure
- * @param[in] RgMngmt *cfm, the configuration confirm structure
- * @return S16
- * -# ROK
- **/
-#ifdef ANSI
-PUBLIC S16 SchSendCfgCfm
-(
-Pst *pst, /* post structure */
-RgMngmt *cfm /* config confirm structure */
-)
-#else
-PUBLIC S16 SchSendCfgCfm(pst, cfm)
-Pst *pst; /* post structure */
-RgMngmt *cfm; /* config confirm structure */
-#endif
-{
- printf("\nSending Scheduler config confirm to DU APP");
- pst->dstEnt = ENTDUAPP;
- pst->dstInst = 0;
- pst->srcInst = 0;
- pst->selector = MAC_SCH_LC_SELECTOR;
- RgMiLrgSchCfgCfm(pst, cfm);
-
- RETVALUE(ROK);
-}
-
-\f
-/***********************************************************
- *
- * Func : macCellCfgFillCfmPst
- *
- *
- * Desc : Fills the Confirmation Post Structure cfmPst
- *
- * Ret : Void
- *
- * Notes:
- *
- * File : rg_lmm.c
- *
- **********************************************************/
-Void macCellCfgFillCfmPst
-(
-Pst *reqPst,
-Pst *cfmPst
-)
-{
- Inst inst;
- inst = reqPst->dstInst;
-
- cfmPst->srcEnt = rgCb[inst].rgInit.ent;
- cfmPst->srcInst = rgCb[inst].rgInit.inst;
- cfmPst->srcProcId = rgCb[inst].rgInit.procId;
-
- cfmPst->dstEnt = ENTDUAPP;
- cfmPst->dstInst = 0;
- cfmPst->dstProcId = cfmPst->srcProcId;
-
- cfmPst->selector = LRG_SEL_LC;
- cfmPst->prior = reqPst->prior;
- cfmPst->route = reqPst->route;
- cfmPst->region = reqPst->region;
- cfmPst->pool = reqPst->pool;
- cfmPst->event = EVENT_MAC_CELL_CONFIG_CFM;
-
- RETVOID;
-}
-
-/**
- * @brief Layer Manager Configuration request handler.
- *
- * @details
- *
- * Function : MacHdlCellCfgReq
- *
- * This function handles the gNB and cell configuration
- * request received from DU APP.
- * This API unapcks and forwards the config towards SCH
- *
- * @param[in] Pst *pst
- * @param[in] MacCellCfg *macCellCfg
- * @return S16
- * -# ROK
- **/
-int MacHdlCellCfgReq
-(
- Pst *pst,
- MacCellCfg *macCellCfg
-)
-{
- Pst cfmPst;
- int ret = ROK;
- RgCellCb *cellCb;
- MacCellCb *macCellCb;
- Inst inst = pst->dstInst;
-
- cmMemset((U8 *)&cfmPst, 0, sizeof(Pst));
- MAC_ALLOC(cellCb,sizeof(RgCellCb));
-
- if(cellCb == NULLP)
- {
- DU_LOG("\nMAC : cellCb is NULL at handling of macCellCfg\n");
- return RFAILED;
- }
-
- memcpy(&cellCb->macCellCfg,macCellCfg,sizeof(MacCellCfg));
- rgCb[inst].cell = cellCb;
-
- MAC_ALLOC(macCellCb,sizeof(MacCellCb));
- if(macCellCb == NULLP)
- {
- DU_LOG("\nMAC : macCellCb is NULL at handling of macCellCfg\n");
- return RFAILED;
- }
- macCb.macCell = macCellCb;
- macCb.macCell->cellId = macCellCfg->cellId;
- /* Send cell cfg to scheduler */
- ret = MacSchCellCfgReq(pst, macCellCfg);
- if(ret != ROK)
- {
- MacCellCfgCfm macCellCfgCfm;
- macCellCfgCfm.rsp = RSP_NOK;
- macCellCfgCfm.transId = macCellCfg->transId;
- macCellCfgFillCfmPst(pst,&cfmPst);
- ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
- }
- return ret;
-} /* end of MacHdlCellCfgReq */
-
-/**
- * @brief Layer Manager Configuration request handler.
- *
- * @details
- *
- * Function : MacSchCellCfgReq
- *
- * This function sends cell configuration to SCH
- *
- * @param[in] Pst *pst
- * @param[in] MacCellCfg *macCellCfg
- * @return S16
- * -# ROK
- **/
-int MacSchCellCfgReq
-(
- Pst *pst,
- MacCellCfg *macCellCfg
-)
-{
- SchCellCfg schCellCfg;
- Pst cfgPst;
- int ret;
-
- cmMemset((U8 *)&cfgPst, 0, sizeof(Pst));
- schCellCfg.cellId = macCellCfg->cellId;
- schCellCfg.phyCellId = macCellCfg->phyCellId;
- schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
- schCellCfg.dupMode = macCellCfg->dupType;
-
- /* fill ssb scheduler parameters */
- schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
- schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
- schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
- schCellCfg.ssbSchCfg.ssbPeriod = macCellCfg->ssbCfg.ssbPeriod;
- schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
- for(uint8_t idx=0; idx<SSB_MASK_SIZE; idx++)
- {
- schCellCfg.ssbSchCfg.nSSBMask[idx] = macCellCfg->ssbCfg.ssbMask[idx];
- }
-
- /* fill SIB1 scheduler parameters */
- schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
- schCellCfg.sib1SchCfg.sib1NewTxPeriod = macCellCfg->sib1Cfg.sib1NewTxPeriod;
- schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
- schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
- schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
- schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
-
- cfgPst.srcProcId = pst->dstProcId;
- cfgPst.dstProcId = pst->srcProcId;
- cfgPst.srcEnt = ENTRG;
- cfgPst.srcInst = 0;
- cfgPst.dstEnt = ENTRG;
- cfgPst.dstInst = 1;
- cfgPst.selector = MAC_SCH_TC_SELECTOR;
- cfgPst.event = EVENT_SCH_CELL_CFG;
-
- ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
- return ret;
-} /* end of MacSchCellCfgReq */
-
-
-/*******************************************************************
- *
- * @brief Sends Cell config confirm to DU APP
- *
- * @details
- *
- * Function : MacSendCellCfgCfm
- *
- * Functionality:
- * Sends Cell config confirm to DU APP
- *
- * @params[in] Response status
- * @return void
- *
- * ****************************************************************/
-void MacSendCellCfgCfm(uint8_t response)
-{
- Pst pst;
- RgCellCb *cellCb;
- MacCellCfgCfm macCellCfgCfm;
-
- cmMemset((U8 *)&pst, 0, sizeof(Pst));
- cellCb = rgCb[macCb.macInst].cell;
-
- macCellCfgCfm.transId = cellCb->macCellCfg.transId;
- macCellCfgCfm.rsp = response;
-
- memcpy((void *)&pst, (void *)&rgCb[macCb.macInst].rgInit.lmPst, sizeof(Pst));
- pst.event = EVENT_MAC_CELL_CONFIG_CFM;
- (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
-}
-
-
-/**
- * @brief Layer Manager Configuration response handler.
- *
- * @details
- *
- * Function : MacProcSchCellCfgCfm
- *
- * This function processes cell configuration to SCH
- *
- * @param[in] Pst *pst
- * @param[in] SchCellCfgCfm *schCellCfgCfm
- * @return int
- * -# ROK
- **/
-int MacProcSchCellCfgCfm
-(
- Pst *pst,
- SchCellCfgCfm *schCellCfgCfm
-)
-{
- if(schCellCfgCfm->rsp == RSP_OK)
- {
- sendToLowerMac(PARAM_REQUEST, 0, (void *)NULL);
- }
- else
- {
- MacSendCellCfgCfm(RSP_NOK);
- }
- return ROK;