+/*******************************************************************
+ *
+ * @brief Sending UE Reset Req To Mac
+*
+* @details
+*
+* Function : sendUeResetReqToMac
+*
+* Functionality:
+* sending UE Reset Req To Mac
+*
+* @params[in] cellId, ueId, crnti
+* @return ROK - success
+* RFAILED - failure
+*
+*****************************************************************/
+
+uint8_t sendUeResetReqToMac(uint16_t cellId, uint8_t ueId)
+{
+ Pst pst;
+ uint8_t ret=ROK;
+ MacUeResetReq *ueReset = NULLP;
+
+ DU_ALLOC_SHRABL_BUF(ueReset, sizeof(MacUeResetReq));
+ if(ueReset)
+ {
+ ueReset->cellId = cellId;
+ ueReset->ueId = ueId;
+ FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RESET_REQ);
+
+ DU_LOG("\nDEBUG --> DU_APP: Sending UE Reset Request to MAC ");
+ ret = (*packMacUeResetReqOpts[pst.selector])(&pst, ueReset);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU_APP: sendUeResetReqToMac(): Failed to send UE Reset Req to MAC");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueReset, sizeof(MacUeResetReq));
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: sendUeResetReqToMac(): Failed to allocate memory");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief DU processes UE reset req and send it to MAC
+ *
+ * @details
+ *
+ * Function : duBuildAndSendUeResetReq
+ *
+ * Functionality: DU processes UE reset req and send to MAC
+ *
+ *
+ * @params[in] cellId, crnti
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendUeResetReq(uint16_t cellId, uint16_t crnti)
+{
+ uint8_t ueId =0;
+ uint16_t cellIdx = 0;
+
+ DU_LOG("\nDEBUG --> DU_APP : Building UE reset request");
+ GET_CELL_IDX(cellId, cellIdx);
+ GET_UE_ID(crnti, ueId);
+
+ if(duCb.actvCellLst[cellIdx] != NULLP)
+ {
+ if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
+ {
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeResetReq(): CRNTI [%d] not found", crnti);
+ return RFAILED;
+ }
+
+ duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_RESET_IN_PROGRESS;
+ if(sendUeResetReqToMac(cellId, ueId) == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeResetRsp(): Failed to build UE reset req for MAC ");
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeResetReq(): Cell Id %d not found", cellId);
+ return RFAILED;
+ }
+
+ return ROK;
+}
+
+/*******************************************************************
+*
+* @brief Handle UE reset response from MAC
+*
+* @details
+*
+* Function : DuProcMacUeResetRsp
+*
+* Functionality: Handle UE reset response from MAC
+*
+* @params[in] Pointer to MacUeResetRsp and Pst
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t DuProcMacUeResetRsp(Pst *pst, MacUeResetRsp *resetRsp)
+{
+ uint8_t ret =ROK;
+ uint16_t cellIdx=0;
+
+ if(resetRsp)
+ {
+ if(resetRsp->status == SUCCESSFUL)
+ {
+ DU_LOG("\nINFO --> DU APP : MAC UE Reset Response : SUCCESS [UE IDX : %d]", resetRsp->ueId);
+ GET_CELL_IDX(resetRsp->cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx])
+ {
+ duCb.actvCellLst[cellIdx]->ueCb[resetRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_RESET_COMPLETE;
+ /*TODO - Complete the processing after receiving successfully reset rsp*/
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeResetRsp(): MAC UE Reset Response : FAILURE [UE IDX : %d]",resetRsp->ueId);
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, resetRsp, sizeof(MacUeResetRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeResetRsp(): MAC UE Reset Response is null");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+*
+* @brief Handle UE sync status indication from MAC
+*
+* @details
+*
+* Function : DuProcMacUeSyncStatusInd
+*
+* Functionality: Handle UE sync status indication from MAC
+*
+* @params[in] Pointer to MacUeSyncStatusInd and Pst
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t DuProcMacUeSyncStatusInd(Pst *pst, MacUeSyncStatusInd *ueSyncStatusInd)
+{
+ uint8_t ret =RFAILED;
+ uint16_t cellIdx=0, crnti = 0;
+ char *status;
+
+ if(ueSyncStatusInd)
+ {
+ GET_CELL_IDX(ueSyncStatusInd->cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx])
+ {
+ GET_CRNTI(crnti, ueSyncStatusInd->ueId);
+ if(duCb.actvCellLst[cellIdx]->ueCb[ueSyncStatusInd->ueId-1].crnti == crnti)
+ {
+ switch(ueSyncStatusInd->status)
+ {
+ case IN_SYNC:
+ status = "IN_SYNC";
+ break;
+
+ case OUT_OF_SYNC:
+ status = "OUT_OF_SYNC";
+ break;
+
+ case OUT_OF_SUNC_MAX_RETRIES:
+ status = "OUT_OF_SUNC_MAX_RETRIES";
+ break;
+
+ default:
+ status = "INVALID";
+ break;
+
+ }
+ DU_LOG("\nINFO --> DU APP : MAC UE sync status for received UeId %d is %s", ueSyncStatusInd->ueId,status);
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeSyncStatusInd(): MAC UE sync status indication : Ue Id [%d] not found",ueSyncStatusInd->cellId);
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeSyncStatusInd(): MAC UE sync status indication : Cell Id [%d] not found",ueSyncStatusInd->cellId);
+ }
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, ueSyncStatusInd, sizeof(MacUeSyncStatusInd));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeSyncStatusInd(): MAC UE sync status indication is null");
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Sending UE Reestablishment Req To Rlc
+ *
+ * @details
+ *
+ * Function : sendUeReestablishReqToRlc
+ *
+ * Functionality:
+ * Sending UE Reestablishment Req To Rlc
+ *
+ * @params[in] cellId, ueId
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t sendUeReestablishReqToRlc(uint16_t cellId, uint8_t ueId, uint8_t numLcToReestablish, uint8_t *lcId)
+{
+ uint8_t ret=ROK,idx=0;
+ Pst pst;
+ RlcUeReestablishReq *ueReestablish;
+
+ DU_ALLOC_SHRABL_BUF(ueReestablish, sizeof(RlcUeReestablishReq));
+ if(ueReestablish !=NULLP)
+ {
+ ueReestablish->cellId = cellId;
+ ueReestablish->ueId = ueId;
+ ueReestablish->numLcsToReestablish = numLcToReestablish;
+
+ for(idx = 0;idx<numLcToReestablish; idx++)
+ {
+ ueReestablish->lcToReestablish[idx]= lcId[idx];
+ }
+ FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_REESTABLISH_REQ);
+
+ ret = (*packRlcUeReestablishReqOpts[pst.selector])(&pst, ueReestablish);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU_APP : sendUeReestablishReqToRlc():Failed to send UE Reestablishment Req to RLC");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueReestablish, sizeof(RlcUeReestablishReq));
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: sendUeReestablishReqToRlc():Memory allocation failed");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief DU processes UE reestablishment req and sends to MAC and RLC
+ *
+ * @details
+ *
+ * Function : duBuildAndSendUeReestablishReq
+ *
+ * Functionality: DU processes UE reestablishment req and sends to MAC
+ * and RLC
+ *
+ * @params[in] cellId, crnti, numLcToReestablish, ListOflcid
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendUeReestablishReq(uint16_t cellId, uint16_t crnti, uint8_t numLcToReestablish, uint8_t *lcId)
+{
+ uint8_t ueId =0;
+ uint16_t cellIdx = 0;
+
+ DU_LOG("\nDEBUG --> DU_APP: Building UE Reestablishment Request ");
+ GET_CELL_IDX(cellId, cellIdx);
+ GET_UE_ID(crnti, ueId);
+
+ if(duCb.actvCellLst[cellIdx] != NULLP)
+ {
+ if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
+ {
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeReestablishReq(): CRNTI [%d] not found", crnti);
+ return RFAILED;
+ }
+
+ if(sendUeReestablishReqToRlc(cellId, ueId, numLcToReestablish, lcId) == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeReestablishReq(): Failed to send UE reestablishment req for RLC ");
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeReestablishReq(): Cell Id %d is not found", cellId);
+ return RFAILED;
+ }
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UE Reestablishment Rsp received from RLC
+ *
+ * @details
+ *
+ * Function : DuProcRlcUeReestablishRsp
+ *
+ * Functionality:
+ * Processes UE Reestablishment Rsp received from RLC
+ *
+ * @params[in] Post structure
+ * Pointer to RlcUeReestablishRsp
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * *****************************************************************/
+
+uint8_t DuProcRlcUeReestablishRsp(Pst *pst, RlcUeReestablishRsp *ueReestablishRsp)
+{
+ uint8_t ueId = 0, ret = RFAILED;
+ uint16_t cellIdx = 0,crnti=0;
+
+ if(ueReestablishRsp)
+ {
+ ueId = ueReestablishRsp->ueId;
+ GET_CELL_IDX(ueReestablishRsp->cellId, cellIdx);
+
+ if(ueReestablishRsp->status == SUCCESSFUL)
+ {
+ if(duCb.actvCellLst[cellIdx]!=NULLP)
+ {
+ GET_CRNTI(crnti, ueId);
+ if(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].crnti == crnti)
+ {
+ /*TODO: complete the processing of UE Reestablishment Response */
+ DU_LOG("\nINFO --> DU_APP: RLC UE Reestablishment Response : SUCCESS [UE IDX:%d]", ueId);
+ ret = ROK;
+ }
+ else
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeReestablishRsp(): CRNTI [%d] not found", crnti);
+ }
+ else
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeReestablishRsp(): Cell Id[%d] is not found", ueReestablishRsp->cellId);
+
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: RLC UE Reestablishment Response : FAILED [UE IDX:%d]", ueId);
+ }
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, ueReestablishRsp, sizeof(RlcUeReestablishRsp));
+
+ }
+ return ret;
+}