+/*****************************************************************
+* @brief Handles slot indication from MAC
+*
+* @details
+*
+* Function : duHandleSlotInd
+*
+* Functionality:
+* Handles slot indication from MAC
+*
+* @params[in] Post structure pointer
+* SlotTimingInfo *slotIndInfo
+* @return ROK - success
+* RFAILED - failure
+*
+*
+*****************************************************************/
+uint8_t duHandleSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo)
+{
+ uint8_t cellIdx = 0, ret = ROK;
+ DuCellCb *duCellCb = NULLP;
+
+ if(slotIndInfo)
+ {
+ GET_CELL_IDX(slotIndInfo->cellId, cellIdx);
+ duCellCb = duCb.actvCellLst[cellIdx];
+
+ if(duCellCb)
+ {
+ duCellCb->currSlotInfo.sfn = slotIndInfo->sfn;
+ duCellCb->currSlotInfo.slot = slotIndInfo->slot;
+ checkPagingRecord(duCellCb);
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : CellId[%d] doesnot exist", slotIndInfo->cellId);
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, slotIndInfo, sizeof(SlotTimingInfo));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Recevied null pointer from MAC");
+ ret = RFAILED;
+ }
+ return(ret);
+}
+/*******************************************************************
+ *
+ * @brief Handles cell up indication from MAC
+ *
+ * @details
+ *
+ * Function : duHandleCellUpInd
+ *
+ * Functionality:
+ * Handles cell up indication from MAC
+ *
+ * @params[in] Post structure pointer
+ * cell Up info
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t duHandleCellUpInd(Pst *pst, OduCellId *cellId)
+{
+ DuCellCb *cellCb = NULLP;
+
+ if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
+ {
+ DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleCellUpInd()", cellId->cellId);
+ return RFAILED;
+ }
+
+ if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
+ return RFAILED;
+
+ if((cellCb != NULL) && (cellCb->cellStatus == ACTIVATION_IN_PROGRESS))
+ {
+ DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is UP", cellId->cellId);
+ cellCb->cellStatus = ACTIVATED;
+ gCellStatus = CELL_UP;
+
+ if(duCfgParam.tempSliceCfg.numOfRrmPolicy)
+ BuildAndSendSliceConfigReq();
+#ifdef O1_ENABLE
+ DU_LOG("\nINFO --> DU APP : Raise cell UP alarm for cell id=%d", cellId->cellId);
+ raiseCellAlrm(CELL_UP_ALARM_ID, cellId->cellId);
+ setCellOpState(cellId->cellId, ENABLED, ACTIVE);
+#endif
+ duCfgParam.macCellCfg.cellCfg.opState = OP_ENABLED;
+ duCfgParam.macCellCfg.cellCfg.cellState = CELL_ACTIVE;
+ }
+
+ if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, sizeof(OduCellId));
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Handle Cell delete response from MAC
+ *
+ * @details
+ *
+ * Function : DuProcMacCellDeleteRsp
+ *
+ * Functionality: Handle Cell delete response from MAC
+ *
+ * @params[in] Pointer to MacCellDeleteRsp and Pst
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t DuProcMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *deleteRsp)
+{
+ uint8_t ret = ROK;
+ uint16_t cellIdx=0, pfIdx=0;
+ DuPagInfoList *pagInfoLLFromPF=NULLP;
+
+ if(deleteRsp)
+ {
+ if(deleteRsp->status == SUCCESSFUL)
+ {
+ GET_CELL_IDX(deleteRsp->cellId, cellIdx);
+ DU_LOG("\nINFO --> DU APP : MAC CELL Delete Response : SUCCESS [CELL IDX : %d]", deleteRsp->cellId);
+ if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == deleteRsp->cellId))
+ {
+ for(pfIdx =0; pfIdx < MAX_SFN; pfIdx++)
+ {
+ pagInfoLLFromPF = findPagingInfoFromMap(pfIdx, &(duCb.actvCellLst[cellIdx]->pagingInfoMap));
+ if(pagInfoLLFromPF)
+ {
+ cmHashListDelete(&(duCb.actvCellLst[cellIdx]->pagingInfoMap), (PTR)pagInfoLLFromPF);
+ DU_FREE(pagInfoLLFromPF, sizeof(DuPagInfoList));
+ }
+ }
+
+ memset(duCb.actvCellLst[cellIdx], 0, sizeof(DuCellCb));
+ gCellStatus = CELL_DOWN;
+
+#ifdef O1_ENABLE
+ DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", deleteRsp->cellId);
+ raiseCellAlrm(CELL_DOWN_ALARM_ID, deleteRsp->cellId);
+ setCellOpState(deleteRsp->cellId, DISABLED, INACTIVE);
+#endif
+
+ duCb.numActvCells--;
+ duCb.numCfgCells--;
+ DU_FREE(duCb.actvCellLst[cellIdx], sizeof(DuCellCb));
+
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): CellId [%d] doesnot exist", deleteRsp->cellId);
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): MAC CELL Delete Response : FAILED\
+ [CELL IDX : %d]", deleteRsp->cellId);
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacCellDeleteRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): Received MAC cell delete response is NULL");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Sending Cell Delete Req To Mac
+ *
+ * @details
+ *
+ * Function : sendCellDeleteReqToMac
+ *
+ * Functionality:
+ * sending Cell Delete Req To Mac
+ *
+ * @params[in] uint16_t cellId
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *
+ *****************************************************************/
+
+uint8_t sendCellDeleteReqToMac(uint16_t cellId)
+{
+ Pst pst;
+ uint8_t ret=ROK;
+ MacCellDeleteReq *cellDelete = NULLP;
+
+ DU_ALLOC_SHRABL_BUF(cellDelete, sizeof(MacCellDeleteReq));
+ if(cellDelete)
+ {
+ cellDelete->cellId = cellId;
+ FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_DELETE_REQ);
+
+ DU_LOG("\nINFO --> DU APP : Sending Cell Delete Request to MAC");
+ /* Processing one Cell at a time to MAC */
+ ret = (*packMacCellDeleteReqOpts[pst.selector])(&pst, cellDelete);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to send Cell delete Req to MAC");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellDelete, sizeof(MacCellDeleteReq));
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to allocate memory");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief DU preocess Cell Delete Req to MAC
+ *
+ * @details
+ *
+ * Function : duSendCellDeletReq
+ *
+ * Functionality: DU process Cell Delete Req to MAC
+ *
+ * @params[in] uint16_t cellId
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duSendCellDeletReq(uint16_t cellId)
+{
+ uint16_t cellIdx = 0;
+ DU_LOG("\nINFO --> DU APP : Processing Cell Delete Request ");
+ GET_CELL_IDX(cellId, cellIdx);
+
+ if(duCb.actvCellLst[cellIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): CellId[%d] is not found", cellId);
+ return RFAILED;
+ }
+
+ if(duCb.actvCellLst[cellIdx]->cellId != cellId)
+ {
+ DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): CellId[%d] is not found", cellId);
+ return RFAILED;
+
+ }
+
+ if(duCb.actvCellLst[cellIdx]->cellStatus != DELETION_IN_PROGRESS)
+ {
+ DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): CellStatus[%d] of cellId[%d] is not correct.\
+ Expected CellStatus is DELETION_IN_PROGRESS",duCb.actvCellLst[cellIdx]->cellStatus, cellId);
+ return RFAILED;
+ }
+
+ if(duBuildAndSendMacCellStop(cellId) == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): Failed to build and send cell stop request to MAC for\
+ cellId[%d]",cellId);
+ return RFAILED;
+ }
+
+ return ROK;
+}
+
+/*******************************************************************
+ * @brief Free PCCH PDU structure
+ *
+ * @details
+ *
+ * Function : freePcchPdu
+ *
+ * Functionality: Free PCCH PDU structure
+ *
+ * @params[in] PCCH_Message_t *pcchMsg
+ *
+ * @return void
+ *
+ * ****************************************************************/
+void freePcchPdu(PCCH_Message_t *pcchMsg)
+{
+ PagingRrc_t *pagingMsg = NULLP;
+ uint8_t recordIdx = 0;
+
+ if(pcchMsg != NULLP)