+ MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
+ if(!deleteRsp)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
+ return RFAILED;
+ }
+
+ /* Filling UE delete response */
+ deleteRsp->cellId = cellId;
+ GET_UE_ID(crnti, deleteRsp->ueId);
+ deleteRsp->status = status;
+
+ /* Fill Post structure and send UE delete response*/
+ memset(&rspPst, 0, sizeof(Pst));
+ FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
+ return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
+}
+
+/*******************************************************************
+*
+* @brief freeing the Pucch Resrc Cfg
+*
+* @details
+*
+* Function : deletePucchResourcesCfg
+*
+* Functionality: freeing the Pucch Resrc Cfg
+*
+* @params[in] PucchResrcCfg *resrcCfg
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
+{
+ uint8_t resrcIdx;
+ for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
+ {
+ switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
+ {
+ case PUCCH_FORMAT_0:
+ {
+ MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
+ break;
+ }
+ case PUCCH_FORMAT_1:
+ {
+ MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
+ break;
+ }
+ case PUCCH_FORMAT_2:
+ {
+ MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
+ break;
+ }
+ case PUCCH_FORMAT_3:
+ {
+ MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
+ break;
+ }
+ case PUCCH_FORMAT_4:
+ {
+ MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
+ break;
+ }
+ }
+ }
+
+}
+
+/*******************************************************************
+*
+* @brief Processes UE delete response from scheduler
+*
+* @details
+*
+* Function : MacProcSchUeDeleteRsp
+*
+* Functionality:
+* Processes UE delete from scheduler
+*
+* @params[in] Pst : Post structure
+* schUeDelRsp : Scheduler UE delete respons
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
+{
+ uint8_t ueId =0, isCrntiValid = 0, tbIdx =0, idx=0;
+ uint16_t cellIdx=0;
+ uint8_t ret = RFAILED;
+ CauseOfResult status;
+ DlHarqEnt *dlHarqEnt;
+
+#ifdef CALL_FLOW_DEBUG_LOG
+ DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
+#endif
+
+ if(schUeDelRsp)
+ {
+ if(schUeDelRsp->rsp == RSP_OK)
+ {
+ DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
+ GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
+ if(macCb.macCell[cellIdx])
+ {
+ CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
+ if(!isCrntiValid)
+ {
+ /*C-RNTI value is out of Acceptable range*/
+ DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
+ status = UEID_INVALID;
+ }
+ else
+ {
+ GET_UE_ID(schUeDelRsp->crnti, ueId);
+ if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
+ {
+
+ /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
+#if 0
+ /*Looping around LCs to free S-NSSAI memory*/
+ for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
+ {
+ MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
+ }
+ for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
+ {
+ MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
+ }
+#endif
+ dlHarqEnt = &macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.dlHarqEnt;
+ for(idx =0 ; idx<MAX_NUM_HARQ_PROC; idx++)
+ {
+ tbIdx = 0;
+ while(dlHarqEnt->harqProcCb[idx].numTb)
+ {
+
+ MAC_FREE(dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tb, dlHarqEnt->harqProcCb[idx].tbInfo[tbIdx].tbSize);
+ dlHarqEnt->harqProcCb[idx].numTb--;
+ tbIdx++;
+ }
+ }
+ memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
+ macCb.macCell[cellIdx]->numActvUe--;
+ status = SUCCESSFUL;
+ ret = ROK;
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
+ status = UEID_INVALID;
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
+ status = CELLID_INVALID;
+ }
+ }
+ else
+ status = schUeDelRsp->cause;
+
+ if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, status) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+*
+* @brief Sends UE delete req to Scheduler
+*
+* @details
+*
+* Function : sendUeDelReqToSch
+*
+* Functionality: sends UE delete req to Scheduler
+*
+* @params[in] Pst *pst, MacUeDelete *ueDelete
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
+{
+ if(ueDelete != NULLP)
+ {
+ Pst schPst;
+ SchUeDelete schUeDel;
+
+ memset(&schUeDel, 0, sizeof(SchUeDelete));
+ schUeDel.cellId = ueDelete->cellId;
+ schUeDel.crnti = ueDelete->crnti;
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
+ FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
+ return(SchMessageRouter(&schPst, (void *)&schUeDel));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Handles UE Delete requst from DU APP
+ *
+ * @details
+ *
+ * Function : MacProcUeDeleteReq
+ *
+ * Functionality: Handles UE Delete requst from DU APP
+ *
+ * @params[in] Pst *pst, MacUeDelete *ueDelete
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
+{
+ uint8_t ret = ROK;
+ uint8_t cellIdx=0;
+ CauseOfResult status =SUCCESSFUL;
+ MacUeCb *ueCb = NULLP;
+ MacCellCb *cellCb = NULLP;
+
+ DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
+
+ if(ueDelete)
+ {
+ GET_CELL_IDX(ueDelete->cellId, cellIdx);
+ cellCb = macCb.macCell[cellIdx];
+ if(cellCb)
+ {
+ ueCb = &cellCb->ueCb[ueDelete->ueId-1];
+ if(ueCb->crnti == ueDelete->crnti)
+ {
+ ret = sendUeDelReqToSch(pst, ueDelete);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
+ status = UEID_INVALID;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
+ status = CELLID_INVALID;
+ }
+
+ if(status!= SUCCESSFUL)
+ {
+ MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, status);
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+*
+* @brief Fill and Send UE Reset response from MAC to DU APP
+*
+* @details
+*
+* Function : MacSendUeResetRsp
+*
+* Functionality: Fill and Send UE Reset response from MAC to DUAPP
+*
+* @params[in] MAC UE Reset result
+* SCH UE Reset response
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t MacSendUeResetRsp(uint16_t cellId, uint16_t ueId, CauseOfResult status)
+{
+ MacUeResetRsp *ResetRsp;
+ Pst rspPst;
+
+ MAC_ALLOC_SHRABL_BUF(ResetRsp, sizeof(MacUeResetRsp));
+ if(!ResetRsp)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation for UE Reset response failed");
+ return RFAILED;
+ }
+
+ /* Filling UE Reset response */
+ ResetRsp->cellId = cellId;
+ ResetRsp->ueId = ueId;
+ ResetRsp->status = status;
+
+ /* Fill Post structure and send UE Reset response*/
+ memset(&rspPst, 0, sizeof(Pst));
+ FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RESET_RSP);
+ return (*macDuUeResetRspOpts[rspPst.selector])(&rspPst, ResetRsp);
+}
+
+/*******************************************************************
+ *
+ * @brief Handles UE Reset request from DU APP
+ *
+ * @details
+ *
+ * Function : MacProcUeResetReq
+ *
+ * Functionality: Handles UE Reset requst from DU APP
+ *
+ * @params[in] Pst *pst, MacUeResetReq *ueReset
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t MacProcUeResetReq(Pst *pst, MacUeResetReq *ueReset)
+{
+ uint8_t cellIdx=0;
+ CauseOfResult status =SUCCESSFUL;
+ MacUeCb *ueCb = NULLP;
+ MacCellCb *cellCb = NULLP;
+
+ DU_LOG("\nINFO --> MAC : UE Reset Request received for ueId[%d]", ueReset->ueId);
+
+ if(ueReset)
+ {
+ GET_CELL_IDX(ueReset->cellId, cellIdx);
+ cellCb = macCb.macCell[cellIdx];
+ if(cellCb)
+ {
+ ueCb = &cellCb->ueCb[ueReset->ueId-1];
+ if(ueCb->ueId == ueReset->ueId)
+ {
+ /* TODO := complete the processing of UE reset request*/
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): UE ID [%d] not found in Cell Id [%d]", ueCb->ueId , ueReset->cellId);
+ status = UEID_INVALID;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): Cell Id [%d] not found ",ueReset->cellId);
+ status = CELLID_INVALID;
+ }
+
+ MacSendUeResetRsp(ueReset->cellId, ueReset->ueId, status);
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReset, sizeof(MacUeResetReq));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : MacProcUeResetReq(): MAC UE reset request processing failed");
+ return RFAILED;
+ }
+ return ROK;
+}