+/* ****************************************************************
+ *
+ * @brief Process the DL Data transfer from DU APP
+ *
+ * @details
+ *
+ * Function : RlcProcDlUserDataTransfer
+ *
+ * Functionality: Process the DL transfer from DU APP
+ *
+ * @params[in] Post structure
+ * DL RRC Message info
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
+{
+ Buffer *mBuf = NULLP;
+ RlcDatReqInfo *datReqInfo = NULLP;
+
+ if(dlDataMsgInfo->dlMsg == NULLP)
+ {
+ DU_LOG("\nERROR --> RLC_DL : Received DL message is NULLP in RlcProcDlUserDataTransfer()");
+ return RFAILED;
+ }
+ RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
+ if(!datReqInfo)
+ {
+ DU_LOG("\nERROR --> RLC_DL : Memory allocation failed for DatReq in RlcProcDlUserDataTransfer()");
+ ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
+ RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
+ return RFAILED;
+ }
+
+ datReqInfo->rlcId.rbType = RB_TYPE_DRB;
+ datReqInfo->rlcId.rbId = dlDataMsgInfo->rbId;
+ datReqInfo->rlcId.ueId = dlDataMsgInfo->ueId;
+ datReqInfo->rlcId.cellId = dlDataMsgInfo->cellId;
+ datReqInfo->lcType = LCH_DTCH;
+ datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
+ mBuf = dlDataMsgInfo->dlMsg;
+ if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
+ {
+ return RFAILED;
+ }
+
+ /* Free memory allocated by du app */
+ RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
+ RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief sending UE delete response to DU
+ *
+ * @details
+ *
+ * Function : sendRlcUeDeleteRspToDu
+ *
+ * Functionality:
+ * sending UE delete response to DU
+ *
+ * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult status
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t sendRlcUeDeleteRspToDu(uint16_t cellId,uint8_t ueId, CauseOfResult status)
+{
+ Pst pst;
+ RlcUeDeleteRsp *ueDeleteRsp = NULLP;
+
+ FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_RSP);
+
+ RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
+ if(!ueDeleteRsp)
+ {
+ DU_LOG("\nERROR --> RLC: sendRlcUeDeleteRspToDu(): Memory allocation failed ");
+ return RFAILED;
+ }
+ else
+ {
+ ueDeleteRsp->cellId = cellId;
+ ueDeleteRsp->ueId = ueId;
+ ueDeleteRsp->status = status;
+
+ if(rlcSendUeDeleteRspToDu(&pst, ueDeleteRsp) == ROK)
+ {
+ DU_LOG("\nDEBUG --> RLC: UE Delete response send successfully");
+ }
+ else
+ {
+ DU_LOG("\nERROR --> RLC: SendRlcUeDeleteRspToDu():Failed to send UE Delete response to DU");
+ RLC_FREE_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
+ return RFAILED;
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+*
+* @brief Handles Ue delete Request from DU APP
+*
+* @details
+*
+* Function : RlcProcUeDeleteReq
+*
+* Functionality:
+* Handles Ue delete Request from DU APP
+*
+* @params[in] Post structure pointer
+* RlcUeDelete pointer
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete)
+{
+ uint8_t ret = ROK;
+ RlcCb *gRlcCb = NULLP;
+ RlcUlUeCb *ueCb = NULLP;
+ CauseOfResult status =SUCCESSFUL;
+
+ DU_LOG("\nDEBUG --> RLC: UE Delete request received. CellID[%d] UEID[%d]",ueDelete->cellId, ueDelete->ueId);
+
+ if(ueDelete != NULLP)
+ {
+ gRlcCb = RLC_GET_RLCCB(pst->dstInst);
+ rlcDbmFetchUlUeCb(gRlcCb,ueDelete->ueId, ueDelete->cellId, &ueCb);
+ if(ueCb != NULLP)
+ {
+ if(ueDelete->cellId == ueCb->cellId)
+ {
+ memcpy(&ueCb->ueDeleteInfo.pst, pst, sizeof(Pst));
+ if((rlcChkTmr(gRlcCb, (PTR)ueCb, EVENT_RLC_UE_DELETE_TMR)) == FALSE)
+ {
+ rlcStartTmr(gRlcCb,(PTR)ueCb, EVENT_RLC_UE_DELETE_TMR);
+ }
+ }
+ else
+ {
+ status = CELLID_INVALID;
+ }
+ }
+ else
+ {
+ status = UEID_INVALID;
+ }
+
+ if(status != SUCCESSFUL)
+ {
+ ret = sendRlcUeDeleteRspToDu(ueDelete->cellId, ueDelete->ueId, status);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq():Failed to send UE Delete response to DU");
+ }
+ }
+ RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(RlcUeDelete));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq(): Recieved NULL pointer UE Delete ");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+*
+* @brief Send the Slice Metrics to DU APP
+*
+* @details
+*
+* Function : sendSlicePmToDu
+*
+* Functionality:
+* Handles the sending of Slice Metrics to DU APP
+*
+* @params[in] Post structure pointer
+* SlicePmList *sliceStats pointer
+*
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t sendSlicePmToDu(SlicePmList *sliceStats)
+{
+ Pst pst;
+
+ FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_SLICE_PM_TO_DU);
+
+ if(!sliceStats)
+ {
+ DU_LOG("\nERROR --> RLC: sendSlicePmToDu(): Memory allocation failed ");
+ return RFAILED;
+ }
+ else
+ {
+ if(rlcSendSlicePmToDu(&pst, sliceStats) == ROK)
+ {
+ DU_LOG("\nDEBUG --> RLC: Slice PM send successfully");
+ }
+ else
+ {
+ DU_LOG("\nERROR --> RLC: sendSlicePmToDu():Failed to send Slice PM to DU");
+ RLC_FREE_SHRABL_BUF(pst.region, pst.pool, sliceStats, sizeof(SlicePmList));
+ return RFAILED;
+ }
+ }
+ return ROK;
+}
+
+/**
+ * @brief
+ * Handler for searching the Slice Entry in Slice Metrics structure
+ *
+ * @details
+ * This func finds the slice entry in the SliceMetric record structure and
+ * return the index of the slice sot hat Tput entries can be done
+ *
+ * @param[in] snssaiVal : Snssai Val to be searched
+ * *snssaiIdx : O/P : Index of the Slice in Slice Metrics record
+ * sliceStats : Pointer of Slice metrics record list
+ *
+ * @return bool: True: If slice found in the record
+ * False: If Slice not found; thus parent function will create the
+ * recpord of this snssai
+ *
+ */
+bool rlcFindSliceEntry(SliceIdentifier snssaiVal, uint8_t *snssaiIdx, SlicePmList *sliceStats)
+{
+ uint8_t cntSlices = sliceStats->numSlice;
+
+ for(*snssaiIdx = 0;(*snssaiIdx) < cntSlices; (*snssaiIdx)++)
+ {
+ if((snssaiVal.sst == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sst)&&
+ (snssaiVal.sd == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sd))
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+/*******************************************************************
+*
+* @brief Builds the Slice Performance Metrics structure to be sent to DU
+*
+* @details
+*
+* Function : BuildSliceReportToDu
+*
+* Functionality:
+* Builds the Slice Performance Metrics structure to be sent to DU
+*
+* @params[in] uint8_t snssaiCnt
+*
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t BuildSliceReportToDu(uint8_t snssaiCnt)
+{
+ CmLList *node = NULLP;
+ RlcTptPerSnssai *snssaiNode = NULLP;
+ Direction dir = DIR_UL;
+ SlicePmList *sliceStats = NULLP; /*Slice metric */
+ SliceIdentifier snssaiVal ;
+ uint8_t snssaiIdx = 0;
+
+ if(snssaiCnt == 0)
+ {
+ DU_LOG("\nERROR --> RLC: No SNSSAI to send the SLice PM");
+ return RFAILED;
+ }
+
+ RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
+ if(sliceStats == NULLP)
+ {
+ DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
+ return RFAILED;
+ }
+ RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, snssaiCnt * (sizeof(SlicePm)));
+
+ if(sliceStats->sliceRecord == NULLP)
+ {
+ DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
+ RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
+ return RFAILED;
+ }
+ while(dir < DIR_BOTH)
+ {
+ node = arrTputPerSnssai[dir]->first;
+ if(node == NULLP)
+ {
+ DU_LOG("\nERROR --> RLC: No SNSSAI in list");
+ RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
+ RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, (snssaiCnt * (sizeof(SlicePm))));
+ return RFAILED;
+ }
+
+ while(node)
+ {
+ snssaiIdx = 0;
+ snssaiNode = (RlcTptPerSnssai *)node->node;
+
+ snssaiVal.sst = snssaiNode->snssai->sst;
+ snssaiVal.sd = snssaiNode->snssai->sd[2]+snssaiNode->snssai->sd[1]*10+snssaiNode->snssai->sd[0]*100;
+ if(rlcFindSliceEntry(snssaiVal, &snssaiIdx, sliceStats) == FALSE)
+ {
+ sliceStats->sliceRecord[snssaiIdx].networkSliceIdentifier = snssaiVal;
+ sliceStats->numSlice++;
+ }
+ if(dir == DIR_UL)
+ {
+ sliceStats->sliceRecord[snssaiIdx].ThpUl = snssaiNode->tpt;
+ }
+ else
+ {
+ sliceStats->sliceRecord[snssaiIdx].ThpDl = snssaiNode->tpt;
+ }
+ node = node->next;
+ }
+ dir++;
+ }
+
+ sendSlicePmToDu(sliceStats);
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief sending UE reestablishment response to DU
+ *
+ * @details
+ *
+ * Function : sendRlcUeReestablishRspToDu
+ *
+ * Functionality:
+ * sending UE reestablishment response to DU
+ *
+ * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult status
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t sendRlcUeReestablishRspToDu(uint16_t cellId,uint8_t ueId, CauseOfResult status)
+{
+ Pst pst;
+ RlcUeReestablishRsp *ueReestablishRsp = NULLP;
+
+ FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_REESTABLISH_RSP);
+
+ RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueReestablishRsp, sizeof(RlcUeReestablishRsp));
+ if(!ueReestablishRsp)
+ {
+ DU_LOG("\nERROR --> RLC: sendRlcUeReestablishRspToDu(): Memory allocation failed ");
+ return RFAILED;
+ }
+ else
+ {
+ ueReestablishRsp->cellId = cellId;
+ ueReestablishRsp->ueId = ueId;
+ ueReestablishRsp->status = status;
+
+ if(rlcSendUeReestablishRspToDu(&pst, ueReestablishRsp) == ROK)
+ {
+ DU_LOG("\nDEBUG --> RLC: UE Reestablishment response send successfully");
+ }
+ else
+ {
+ DU_LOG("\nERROR --> RLC: SendRlcUeReestablishRspToDu():Failed to send UE Reestablishment response to DU");
+ RLC_FREE_SHRABL_BUF(pst.region, pst.pool, ueReestablishRsp, sizeof(RlcUeReestablishRsp));
+ return RFAILED;
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+*
+* @brief Handles Ue reestablishment Request from DU APP
+*
+* @details
+*
+* Function : RlcProcUeReestablishReq
+*
+* Functionality:
+* Handles Ue reestablishment Request from DU APP
+*
+* @params[in] Post structure pointer
+* RlcUeReestablishReq pointer
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t RlcProcUeReestablishReq(Pst *pst, RlcUeReestablishReq *ueReestablishReq)
+{
+ uint8_t ret = RFAILED;
+ RlcCb *gRlcCb = NULLP;
+ RlcUlUeCb *ueCb = NULLP;
+ CauseOfResult status =SUCCESSFUL;
+
+ if(ueReestablishReq != NULLP)
+ {
+ gRlcCb = RLC_GET_RLCCB(pst->dstInst);
+ rlcDbmFetchUlUeCb(gRlcCb,ueReestablishReq->ueId, ueReestablishReq->cellId, &ueCb);
+ if(ueCb != NULLP)
+ {
+ if(ueReestablishReq->cellId == ueCb->cellId)
+ {
+ /* TODO :
+ * Step 1: Fill the RlcCfgInfo structure with data from the ueReestablishReq, just as we did in fillRlcCfg function and set
+ * ConfigType = CONFIG_REESTABLISH
+ * Step 2: To finish processing of Ue Reestablishment, call the RlcProcCfgReq function */
+ }
+ else
+ {
+ status = CELLID_INVALID;
+ DU_LOG("\nERROR --> SCH : RlcProcUeReestablishReq(): cell Id[%d] not found", ueReestablishReq->cellId);
+ }
+ }
+ else
+ {
+ status = UEID_INVALID;
+ DU_LOG("\nERROR --> SCH : RlcProcUeReestablishReq(): ue Id[%d] not found", ueReestablishReq->cellId);
+ }
+
+ if(status != SUCCESSFUL)
+ {
+ if(sendRlcUeReestablishRspToDu(ueReestablishReq->cellId, ueReestablishReq->ueId, status) != ROK)
+ {
+ DU_LOG("\nERROR --> RLC: RlcProcUeReestablishReq():Failed to send UE Reestablishment response to DU");
+ }
+ }
+ RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReestablishReq, sizeof(RlcUeDelete));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> RLC: RlcProcUeReestablishReq(): Recieved NULL pointer UE Reestablishment ");
+ }
+ return ret;
+}