+ DU_LOG("\nERROR --> DU APP: Issue in Building Page RRC PDU i_s:%d",pagInfo->i_s);
+ return RFAILED;
+ }
+ handlePageInfoLL(pf, pagInfo->i_s, &(pagInfoLLFromPF->pagInfoList), DELETE);
+ }
+ if(pagInfoLLFromPF->pagInfoList.first == NULLP)
+ {
+ break;
+ }
+ }while(pagInfo != NULLP);
+
+ cmHashListDelete(&(cellCb->pagingInfoMap), (PTR)pagInfoLLFromPF);
+ DU_FREE(pagInfoLLFromPF, sizeof(DuPagInfoList));
+ return ROK;
+}
+
+/******************************************************************
+ *
+ * @brief Send pcch indication to MAC
+ *
+ * @details
+ *
+ * Function : sendDlPcchIndToMac
+ *
+ * Functionality: Send pcch indication to MAC
+ *
+ * @Params[in] DlPcchInd *pcchInd
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t sendDlPcchIndToMac(DlPcchInd *pcchInd)
+{
+ uint8_t ret = ROK;
+ Pst pst;
+
+ if(pcchInd)
+ {
+ /* Fill Pst */
+ FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_PCCH_IND);
+
+ ret = (*packMacDlPcchIndOpts[pst.selector])(&pst, pcchInd);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : sendDlPcchIndToMac(): Failed to DL PCCH indication to MAC");
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP: sendDlPcchIndToMac(): Received pcchInd is NULLP");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+
+/*****************************************************************
+* @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)
+ {
+ if(pcchMsg->message.choice.c1 != NULLP)
+ {
+ pagingMsg = pcchMsg->message.choice.c1->choice.paging;
+ if(pagingMsg != NULLP)
+ {
+ if(pagingMsg->pagingRecordList)
+ {
+ if(pagingMsg->pagingRecordList->list.array != NULLP)
+ {
+ for(recordIdx = 0; recordIdx < pagingMsg->pagingRecordList->list.count; recordIdx++)
+ {
+ if(pagingMsg->pagingRecordList->list.array[recordIdx] != NULLP)
+ {
+ DU_FREE(pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.buf,\
+ pagingMsg->pagingRecordList->list.array[recordIdx]->ue_Identity.choice.ng_5G_S_TMSI.size);
+ DU_FREE(pagingMsg->pagingRecordList->list.array[recordIdx], sizeof(PagingRecord_t));
+ }
+ }
+ DU_FREE(pagingMsg->pagingRecordList->list.array, pagingMsg->pagingRecordList->list.size);
+ }
+ DU_FREE(pagingMsg->pagingRecordList, sizeof(PagingRecordList_t));
+ }
+ DU_FREE(pcchMsg->message.choice.c1->choice.paging, sizeof(PagingRrc_t));
+ }
+ DU_FREE(pcchMsg->message.choice.c1 , sizeof(PCCH_MessageType_t));
+ }
+ DU_FREE(pcchMsg , sizeof(PCCH_Message_t));
+ }
+}
+
+/*******************************************************************
+ * @brief Builds the Pcch RRC PDU and forwards it to MAC
+ *
+ * @details
+ *
+ * Function : BuildAndSendDlPcchIndToMac
+ *
+ * Functionality: Builds the Pcch RRC PDU[As per Spec 38.331, Annexure A]
+ * and forwards it to MAC as Buffer along with PF and i_s
+ *
+ * @params[in] uint16_t cellId, uint16_t pf, uint8_t i_s,CmLListCp *pageUeLL
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildAndSendDlPcchIndToMac(uint16_t cellId, uint16_t pf, uint8_t i_s, CmLListCp *pageUeLL)
+{
+ CmLList *node = NULLP, *next = NULLP;
+ DuPagUeRecord *ueRecord = NULLP;
+ PCCH_Message_t *pcchMsg = NULLP;
+ asn_enc_rval_t encRetVal;
+ PagingRrc_t *pagingMsg = NULLP;
+ DlPcchInd *macPcchInd = NULLP;
+ uint8_t recordIdx = 0, ret = RFAILED;
+
+ /*As per 38.473 Sec 9.3.1.39,5G-S-TMSI :48 Bits >> Bytes and 0 UnusedBits */
+ uint8_t totalByteInTmsi = 6, unusedBitsInTmsi = 0;
+
+ if(pageUeLL == NULLP || pageUeLL->count == 0)
+ {
+ DU_LOG("\nERROR --> DU APP: UE Page Record LL is empty");
+ return RFAILED;
+ }
+
+ while(true)
+ {
+ memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
+ DU_ALLOC(pcchMsg , sizeof(PCCH_Message_t));
+ if(pcchMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP: BuildAndSendDlPcchIndToMac(): (pccchMsg) Memory Alloction failed!");
+ break;
+ }
+ pcchMsg->message.present = PCCH_MessageType_PR_c1;
+ DU_ALLOC(pcchMsg->message.choice.c1 , sizeof(PCCH_MessageType_t));
+ if(pcchMsg->message.choice.c1 == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP: BuildAndSendDlPcchIndToMac(); (C1) Memory Alloction failed!");
+ break;
+ }
+ pcchMsg->message.choice.c1->present = PCCH_MessageType__c1_PR_paging;
+ DU_ALLOC(pcchMsg->message.choice.c1->choice.paging, sizeof(PagingRrc_t));
+
+ pagingMsg = pcchMsg->message.choice.c1->choice.paging;
+ if(pagingMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP: BuildAndSendDlPcchIndToMac(); (Paging) Memory Alloction failed!");
+ break;
+ }
+ DU_ALLOC(pagingMsg->pagingRecordList, sizeof(PagingRecordList_t));
+ if(pagingMsg->pagingRecordList == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP: BuildAndSendDlPcchIndToMac(); (Paging Record List) Memory Alloction failed!");
+ break;
+ }
+
+ pagingMsg->pagingRecordList->list.count = pageUeLL->count;
+
+ /*As per Spec 38.331, maxNrofPageRec : 32 [Maximum number of page records]*/
+ if(pageUeLL->count > MAX_PAGING_UE_RECORDS)
+ {
+ pagingMsg->pagingRecordList->list.count = MAX_PAGING_UE_RECORDS;
+ }
+
+ pagingMsg->pagingRecordList->list.size = pageUeLL->count * (sizeof(PagingRecord_t *));
+ DU_ALLOC(pagingMsg->pagingRecordList->list.array, pagingMsg->pagingRecordList->list.size);
+ if(pagingMsg->pagingRecordList->list.array == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP: BuildAndSendDlPcchIndToMac(); (Array) Memory Alloction failed!");
+ break;
+ }
+ for(recordIdx = 0; recordIdx < pageUeLL->count; recordIdx++)
+ {
+ DU_ALLOC(pagingMsg->pagingRecordList->list.array[recordIdx], sizeof(PagingRecord_t));
+ if(pagingMsg->pagingRecordList->list.array[recordIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP: BuildAndSendDlPcchIndToMac(); (Record) Memory Alloction failed!");