1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* header include files (.h) */
20 #include "common_def.h"
21 #include "rgu.h" /* RGU interface includes*/
22 #include "lkw.h" /* LKW defines */
23 #include "ckw.h" /* CKW defines */
24 #include "kwu.h" /* KWU defines */
25 #include "rlc_env.h" /* RLC environment options */
29 /* header/extern include files (.x) */
31 #include "lkw.x" /* LKW */
32 #include "ckw.x" /* CKW */
33 #include "kwu.x" /* KWU */
35 #include "rlc_utils.h" /* RLC defines */
36 #include "rlc_dl_ul_inf.h"
39 #include "rlc_mac_inf.h"
40 #include "du_app_rlc_inf.h"
41 #include "rlc_upr_inf_api.h"
43 /*******************************************************************
45 * @brief Fills RLC UL UE Cfg Rsp from RlcCRsp
49 * Function : fillRlcUeCfgRsp
52 * Fills RLC UL UE Cfg Rsp from RlcCRsp
54 * @params[in] Pointer to RlcCfgCfm
55 * Pointer to RlcUeCfgRsp
59 *****************************************************************/
61 uint8_t fillRlcUeCfgRsp(RlcUeCfgRsp *rlcCfgRsp, RlcCfgCfmInfo *rlcCRsp)
66 rlcCfgRsp->cellId = rlcCRsp->cellId;
67 rlcCfgRsp->ueId = rlcCRsp->ueId;
68 rlcCfgRsp->result = RLC_DU_APP_RSP_OK;
69 for(idx = 0; idx < rlcCRsp->numEnt; idx++)
71 if(rlcCRsp->entCfgCfm[idx].status.status == CKW_CFG_CFM_OK)
73 rlcCfgRsp->result = RLC_DU_APP_RSP_OK;
74 rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
79 rlcCfgRsp->result = RLC_DU_APP_RSP_NOK;
80 rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
88 /*******************************************************************
90 * @brief Fills the entity mode and direction compiling to seed code
94 * Function : fillEntModeAndDir
97 * Fills the entity mode and direction compiling to seed code
99 * @params[in] Pointer to entMode
100 * Pointer to direction
103 * ****************************************************************/
105 void fillEntModeAndDir(uint8_t *entMode, uint8_t *direction, RlcMode rlcMode)
110 *entMode = RLC_MODE_AM;
111 *direction = RLC_CFG_DIR_BOTH;
113 case RLC_UM_BI_DIRECTIONAL:
114 *entMode = RLC_MODE_UM;
115 *direction = RLC_CFG_DIR_BOTH;
117 case RLC_UM_UNI_DIRECTIONAL_UL:
118 *entMode = RLC_MODE_UM;
119 *direction = RLC_CFG_DIR_UL;
121 case RLC_UM_UNI_DIRECTIONAL_DL:
122 *entMode = RLC_MODE_UM;
123 *direction = RLC_CFG_DIR_DL;
126 DU_LOG("\nERROR --> RLC: Rlc Mode invalid %d", rlcMode);
131 /*******************************************************************
133 * @brief fills LC Cfgs to be Added in RLC
137 * Function : fillLcCfg
140 * fills LC Cfgs to be Added in RLC
143 * RlcEntCfgInfo pointer
144 * RlcBearerCfg pointer
146 * @return ROK - SUCCESS
149 * ****************************************************************/
150 uint8_t fillLcCfg(RlcCb *gCb, RlcEntCfgInfo *rlcUeCfg, RlcBearerCfg *duRlcUeCfg)
152 uint8_t lChRbIdx = 0;
154 rlcUeCfg->rbId = duRlcUeCfg->rbId;
155 rlcUeCfg->rbType = duRlcUeCfg->rbType; // SRB or DRB
156 rlcUeCfg->lCh[lChRbIdx].lChId = duRlcUeCfg->lcId;
157 rlcUeCfg->lCh[lChRbIdx].type = duRlcUeCfg->lcType;
158 if(duRlcUeCfg->snssai)
160 RLC_ALLOC(gCb, rlcUeCfg->snssai, sizeof(Snssai));
161 if(rlcUeCfg->snssai == NULLP)
163 DU_LOG("\nERROR --> RLC : fillLcCfg(): Failed to allocate memory for snssai");
166 memcpy(rlcUeCfg->snssai, duRlcUeCfg->snssai, sizeof(Snssai));
168 fillEntModeAndDir(&rlcUeCfg->entMode, &rlcUeCfg->dir, duRlcUeCfg->rlcMode);
169 rlcUeCfg->cfgType = duRlcUeCfg->configType;
170 switch(rlcUeCfg->entMode)
176 rlcUeCfg->m.amInfo.dl.snLen = duRlcUeCfg->u.amCfg->dlAmCfg.snLenDl;
177 rlcUeCfg->m.amInfo.dl.pollRetxTmr = duRlcUeCfg->u.amCfg->dlAmCfg.pollRetxTmr;
178 rlcUeCfg->m.amInfo.dl.pollPdu = duRlcUeCfg->u.amCfg->dlAmCfg.pollPdu;
179 rlcUeCfg->m.amInfo.dl.pollByte = duRlcUeCfg->u.amCfg->dlAmCfg.pollByte;
180 rlcUeCfg->m.amInfo.dl.maxRetx = duRlcUeCfg->u.amCfg->dlAmCfg.maxRetxTh;
183 lChRbIdx++; //lChRbIdx = 1, indicates UL AM
184 rlcUeCfg->lCh[lChRbIdx].lChId = duRlcUeCfg->lcId;
185 rlcUeCfg->lCh[lChRbIdx].type = duRlcUeCfg->lcType;
186 rlcUeCfg->m.amInfo.ul.snLen = duRlcUeCfg->u.amCfg->ulAmCfg.snLenUl;
187 rlcUeCfg->m.amInfo.ul.staProhTmr = duRlcUeCfg->u.amCfg->ulAmCfg.statProhTmr;
188 rlcUeCfg->m.amInfo.ul.reAsmblTmr = duRlcUeCfg->u.amCfg->ulAmCfg.reAssemTmr;
194 rlcUeCfg->m.umInfo.ul.snLen = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
195 rlcUeCfg->m.umInfo.ul.reAsmblTmr = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
198 rlcUeCfg->m.umInfo.dl.snLen = duRlcUeCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
203 }/* End of switch(entMode) */
207 /*******************************************************************
209 * @brief fills LC Cfgs to be Added in RLC
213 * Function : fillRlcCfg
216 * fills LC Cfgs to be Add/Mod/Del in RLC
219 * RlcEntCfgInfo pointer
220 * RlcBearerCfg pointer
221 * @return ROK - Success
224 ******************************************************************/
226 uint8_t fillRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeCfg *ueCfg)
230 rlcUeCfg->ueId = ueCfg->ueId;
231 rlcUeCfg->cellId = ueCfg->cellId;
232 rlcUeCfg->numEnt = ueCfg->numLcs;
233 rlcUeCfg->transId = getTransId();
235 for(lcIdx = 0; lcIdx < rlcUeCfg->numEnt; lcIdx++)
237 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[lcIdx], &ueCfg->rlcLcCfg[lcIdx]) != ROK)
239 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
246 /*******************************************************************
248 * @brief Fill RlcCfgCfmInfo structure for sending failure response to DU
252 * Function : fillRlcCfgFailureRsp
255 * Fill RlcCfgCfmInfo structure for sending failure response to DU
257 * @params[in] RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg
261 * ****************************************************************/
262 void fillRlcCfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg)
266 cfgRsp->ueId = ueCfg->ueId;
267 cfgRsp->cellId = ueCfg->cellId;
268 cfgRsp->numEnt = ueCfg->numLcs;
269 for(cfgIdx =0; cfgIdx<ueCfg->numLcs; cfgIdx++)
271 cfgRsp->entCfgCfm[cfgIdx].rbId = ueCfg->rlcLcCfg[cfgIdx].rbId;
272 cfgRsp->entCfgCfm[cfgIdx].rbType = ueCfg->rlcLcCfg[cfgIdx].rbType;
273 cfgRsp->entCfgCfm[cfgIdx].status.status = RLC_DU_APP_RSP_NOK;
274 cfgRsp->entCfgCfm[cfgIdx].status.reason = CKW_CFG_REAS_NONE;
277 /*******************************************************************
279 * @brief Handles Ue Create Request from DU APP
283 * Function : RlcProcUeCreateReq
286 * Handles Ue create Request from DU APP
288 * @params[in] Post structure pointer
290 * @return ROK - success
293 * ****************************************************************/
294 uint8_t RlcProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
298 RlcCfgInfo *rlcUeCfg = NULLP;
299 RlcCfgCfmInfo cfgRsp;
302 gCb = RLC_GET_RLCCB(pst->dstInst);
303 RLC_ALLOC(gCb, rlcUeCfg, sizeof(RlcCfgInfo));
304 if(rlcUeCfg == NULLP)
306 DU_LOG("\nERROR --> RLC: Failed to allocate memory at RlcProcUeCreateReq()");
311 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
312 ret = fillRlcCfg(gCb, rlcUeCfg, ueCfg);
315 DU_LOG("\nERROR --> RLC: Failed to fill configuration at RlcProcUeCreateReq()");
316 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_CREATE_RSP);
317 fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
318 SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
323 ret = RlcProcCfgReq(pst, rlcUeCfg);
325 DU_LOG("\nERROR --> RLC: Failed to configure Add/Mod/Del entities at RlcProcUeCreateReq()");
328 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
332 /*******************************************************************
334 * @brief filling the structure of rrc delivery msg info
338 * Function : BuildAndSendRrcDeliveryReportToDu
340 * Functionality: filling the structure of rrc delivery msg info
342 * @return ROK - success
345 * ****************************************************************/
346 uint8_t BuildAndSendRrcDeliveryReportToDu( RlcDlRrcMsgInfo *dlRrcMsgInfo )
349 RrcDeliveryReport *rrcDelivery;
351 DU_LOG("\nINFO --> RLC : Filling RRC Delivery Report");
352 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, rrcDelivery, sizeof(RrcDeliveryReport));
356 rrcDelivery->cellId = dlRrcMsgInfo->cellId;
357 rrcDelivery->ueId = dlRrcMsgInfo->ueId;
358 rrcDelivery->srbId = dlRrcMsgInfo->lcId ;
359 rrcDelivery->rrcDeliveryStatus.deliveryStatus = PDCP_SN;
360 rrcDelivery->rrcDeliveryStatus.triggeringMessage = PDCP_SN;
362 /* Sending UL RRC Message transfeer to DU APP */
363 memset(&pst, 0, sizeof(Pst));
364 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RRC_DELIVERY_MSG_TRANS_TO_DU);
365 rlcSendRrcDeliveryReportToDu(&pst, rrcDelivery);
369 DU_LOG("\nERROR --> RLC : Memory allocation failed");
374 /* ****************************************************************
376 * @brief Process the DL RRC Message from DU APP
380 * Function : RlcProcDlRrcMsgTransfer
382 * Functionality: Process the DL RRC Message from DU APP
384 * @params[in] Post structure
385 * DL RRC Message info
386 * @return ROK - success
389 * ****************************************************************/
390 uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
393 RlcDatReqInfo *datReqInfo;
395 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
398 DU_LOG("\nERROR --> RLC : Memory allocation failed in RlcProcDlRrcMsgTransfer");
399 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
400 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
404 datReqInfo->rlcId.rbType = RB_TYPE_SRB;
405 datReqInfo->rlcId.rbId = dlRrcMsgInfo->lcId;
406 datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueId;
407 datReqInfo->rlcId.cellId = dlRrcMsgInfo->cellId;
408 datReqInfo->lcType = LCH_DCCH;
409 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
411 /* Copy fixed buffer to message */
412 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &mBuf) != ROK)
414 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
415 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
416 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
417 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
420 oduCpyFixBufToMsg(dlRrcMsgInfo->rrcMsg, mBuf, dlRrcMsgInfo->msgLen);
422 if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
427 /* RRC Delivery report is only send when RRC Delivery status report is true in DL RRC Message */
428 if(dlRrcMsgInfo->deliveryStaRpt)
430 BuildAndSendRrcDeliveryReportToDu(dlRrcMsgInfo);
433 /* Free memory allocated by du app */
434 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
435 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
436 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
440 /*******************************************************************
442 * @brief Process UL data from UE
446 * Function : RlcProcUlData
449 * This function receives the PDU from MAC.
450 * seggregates common and dedicated logical channel
451 * PDU and call respective handler.
454 * @return ROK - success
457 * ****************************************************************/
458 uint8_t RlcProcUlData(Pst *pst, RlcUlData *ulData)
462 uint8_t lcId; /* Logical Channel */
463 uint8_t numDLch = 0; /* Number of dedicated logical channel */
464 bool dLchPduPres; /* PDU received on dedicated logical channel */
465 RguLchDatInd dLchData[MAX_NUM_LC]; /* PDU info on dedicated logical channel */
466 RguDDatIndInfo *dLchUlDat; /* UL data on dedicated logical channel */
467 RguCDatIndInfo *cLchUlDat; /* UL data on common logical channel */
469 /* Initializing dedicated logical channel Database */
470 DU_LOG("\nDEBUG --> RLC: Received UL Data request from MAC");
471 for(idx = 0; idx < MAX_NUM_LC; idx++)
473 dLchData[idx].lcId = idx;
474 dLchData[idx].pdu.numPdu = 0;
478 /* Seggregate PDUs received on common and dedicated channels
479 * and call common channel's handler */
480 for(idx = 0; idx< ulData->numPdu; idx++)
484 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
485 sizeof(RguDDatIndInfo));
488 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
495 /* Copy fixed buffer to message */
496 lcId = ulData->pduInfo[idx].lcId;
497 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, \
498 &dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]) != ROK)
500 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
501 for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
503 ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
505 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
506 sizeof(RguDDatIndInfo));
510 oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
511 dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
512 ulData->pduInfo[idx].pduLen);
514 dLchData[lcId].pdu.numPdu++;
517 /* If any PDU received on dedicated logical channel, copy into RguDDatIndInfo
518 * and call its handler */
523 dLchUlDat->cellId = ulData->cellId;
524 GET_UE_ID(ulData->rnti, dLchUlDat->rnti);
526 for(idx = 0; idx < MAX_NUM_LC; idx++)
528 if(dLchData[idx].pdu.numPdu)
530 memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
534 dLchUlDat->numLch = numDLch;
535 rlcProcDedLcUlData(pst, 0, dLchUlDat);
539 for(pduIdx = 0; pduIdx < ulData->numPdu; pduIdx++)
541 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData->pduInfo[pduIdx].pduBuf, \
542 ulData->pduInfo[pduIdx].pduLen);
544 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcUlData));
547 }/* End of RlcProcUlData */
549 /*******************************************************************
551 * @brief Handler for extracting common and dedicated channel
552 * Scheduling result report.
556 * Function : RlcProcSchedResultRpt
559 * Handler for extracting common and dedicated channel
560 * Scheduling result report
563 * @return ROK - success
566 * ****************************************************************/
567 uint8_t RlcProcSchedResultRpt(Pst *pst, RlcSchedResultRpt *schRep)
570 uint8_t idx; /* Iterator */
571 uint8_t nmbDLch = 0; /* Number of dedicated logical channles */
572 RguCStaIndInfo *cLchSchInfo; /* Common logical channel scheduling result */
573 RguDStaIndInfo *dLchSchInfo; /* Dedicated logical channel scheduling result */
575 DU_LOG("\nDEBUG --> RLC : Received scheduling report from MAC");
576 for(idx=0; idx < schRep->numLc; idx++)
578 /* Fill status info structure if at least one channel's scheduling report is received */
581 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, dLchSchInfo, \
582 sizeof(RguDStaIndInfo));
585 DU_LOG("\nERROR --> RLC: RlcProcSchedResultRpt: Memory allocation failed for dLchSchInfo");
590 dLchSchInfo->cellId = schRep->cellId;
591 dLchSchInfo->nmbOfUeGrantPerTti = 1;
592 /* MAC sends Scheduling report for one UE at a time. Hence filling
593 only the 0th index of staInd */
594 dLchSchInfo->staInd[0].rnti = schRep->rnti;
596 /* Storing sfn/slot into a single 32-bit variable to be used later*/
597 dLchSchInfo->staInd[0].transId = schRep->slotInfo.sfn;
598 dLchSchInfo->staInd[0].transId = \
599 (dLchSchInfo->staInd[0].transId << 16) | schRep->slotInfo.slot;
600 dLchSchInfo->staInd[0].nmbOfTbs = 1;
601 dLchSchInfo->staInd[0].fillCtrlPdu = true;
604 /* Fill logical channel scheduling info */
605 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].lcId = \
606 schRep->lcSch[idx].lcId;
607 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].totBufSize = \
608 schRep->lcSch[idx].bufSize;
612 /* Calling handler for all dedicated channels scheduling*/
617 dLchSchInfo->staInd[0].staIndTb[0].nmbLch = nmbDLch;
618 rlcProcDedLcSchedRpt(pst, 0, dLchSchInfo);
622 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, schRep, sizeof(RlcSchedResultRpt));
627 /*******************************************************************
629 * @brief Handles Ue Reconfig Request from DU APP
633 * Function : RlcProcUeReconfigReq
636 * Handles Ue Reconfig Request from DU APP
638 * @params[in] Post structure pointer
640 * @return ROK - success
643 * ****************************************************************/
644 uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg)
647 RlcCfgInfo *rlcUeCfg = NULLP; //Seed code Rlc cfg struct
648 RlcCb *rlcUeCb = NULLP;
649 RlcCfgCfmInfo cfgRsp;
652 DU_LOG("\nDEBUG --> RLC: UE reconfig request received. CellID[%d] UEID[%d]",ueCfg->cellId, ueCfg->ueId);
654 rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
655 RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
656 if(rlcUeCfg == NULLP)
658 DU_LOG("\nERROR --> RLC: Failed to allocate memory at RlcProcUeReconfigReq()");
663 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
664 ret = fillRlcCfg(rlcUeCb, rlcUeCfg, ueCfg);
667 DU_LOG("\nERROR --> RLC: Failed to fill configuration at RlcProcUeReconfigReq()");
668 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
669 fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
670 SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
674 ret = RlcProcCfgReq(pst, rlcUeCfg);
676 DU_LOG("\nERROR --> RLC: Failed to configure Add/Mod/Del entities at RlcProcUeReconfigReq()");
680 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
684 /* ****************************************************************
686 * @brief Process the DL Data transfer from DU APP
690 * Function : RlcProcDlUserDataTransfer
692 * Functionality: Process the DL transfer from DU APP
694 * @params[in] Post structure
695 * DL RRC Message info
696 * @return ROK - success
699 * ****************************************************************/
700 uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
702 Buffer *mBuf = NULLP;
703 RlcDatReqInfo *datReqInfo = NULLP;
705 if(dlDataMsgInfo->dlMsg == NULLP)
707 DU_LOG("\nERROR --> RLC_DL : Received DL message is NULLP in RlcProcDlUserDataTransfer()");
710 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
713 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed for DatReq in RlcProcDlUserDataTransfer()");
714 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
715 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
719 datReqInfo->rlcId.rbType = RB_TYPE_DRB;
720 datReqInfo->rlcId.rbId = dlDataMsgInfo->rbId;
721 datReqInfo->rlcId.ueId = dlDataMsgInfo->ueId;
722 datReqInfo->rlcId.cellId = dlDataMsgInfo->cellId;
723 datReqInfo->lcType = LCH_DTCH;
724 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
725 mBuf = dlDataMsgInfo->dlMsg;
726 if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
731 /* Free memory allocated by du app */
732 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
733 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
737 /*******************************************************************
739 * @brief sending UE delete response to DU
743 * Function : sendRlcUeDeleteRspToDu
746 * sending UE delete response to DU
748 * @params[in] uint8_t cellId, uint8_t ueId, UeDeleteResult result
750 * @return ROK - success
753 * ****************************************************************/
754 uint8_t sendRlcUeDeleteRspToDu(uint16_t cellId,uint8_t ueId, UeDeleteResult result)
757 RlcUeDeleteRsp *ueDeleteRsp = NULLP;
759 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_RSP);
761 RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
764 DU_LOG("\nERROR --> RLC: sendRlcUeDeleteRspToDu(): Memory allocation failed ");
769 ueDeleteRsp->cellId = cellId;
770 ueDeleteRsp->ueId = ueId;
771 ueDeleteRsp->result = result;
773 if(rlcSendUeDeleteRspToDu(&pst, ueDeleteRsp) == ROK)
775 DU_LOG("\nDEBUG --> RLC: UE Delete response send successfully");
779 DU_LOG("\nERROR --> RLC: SendRlcUeDeleteRspToDu():Failed to send UE Delete response to DU");
780 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
787 /*******************************************************************
789 * @brief Handles Ue delete Request from DU APP
793 * Function : RlcProcUeDeleteReq
796 * Handles Ue delete Request from DU APP
798 * @params[in] Post structure pointer
799 * RlcUeDelete pointer
800 * @return ROK - success
803 * ****************************************************************/
805 uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete)
808 RlcCb *gRlcCb = NULLP;
809 RlcUlUeCb *ueCb = NULLP;
810 UeDeleteResult result=SUCCESSFUL;
812 DU_LOG("\nDEBUG --> RLC: UE Delete request received. CellID[%d] UEID[%d]",ueDelete->cellId, ueDelete->ueId);
814 if(ueDelete != NULLP)
816 gRlcCb = RLC_GET_RLCCB(pst->dstInst);
817 rlcDbmFetchUlUeCb(gRlcCb,ueDelete->ueId, ueDelete->cellId, &ueCb);
820 if(ueDelete->cellId == ueCb->cellId)
822 memcpy(&ueCb->ueDeleteInfo.pst, pst, sizeof(Pst));
823 if((rlcChkTmr(gRlcCb, (PTR)ueCb, EVENT_RLC_UE_DELETE_TMR)) == FALSE)
825 rlcStartTmr(gRlcCb,(PTR)ueCb, EVENT_RLC_UE_DELETE_TMR);
830 result = INVALID_CELLID;
835 result = INVALID_UEID;
838 if(result != SUCCESSFUL)
840 ret = sendRlcUeDeleteRspToDu(ueDelete->cellId, ueDelete->ueId, result);
843 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq():Failed to send UE Delete response to DU");
846 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(RlcUeDelete));
850 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq(): Recieved NULL pointer UE Delete ");
856 /*******************************************************************
858 * @brief Send the Slice Metrics to DU APP
862 * Function : sendSlicePmToDu
865 * Handles the sending of Slice Metrics to DU APP
867 * @params[in] Post structure pointer
868 * SlicePmList *sliceStats pointer
870 * @return ROK - success
873 * ****************************************************************/
874 uint8_t sendSlicePmToDu(SlicePmList *sliceStats)
878 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_SLICE_PM_TO_DU);
882 DU_LOG("\nERROR --> RLC: sendSlicePmToDu(): Memory allocation failed ");
887 if(rlcSendSlicePmToDu(&pst, sliceStats) == ROK)
889 DU_LOG("\nDEBUG --> RLC: Slice PM send successfully");
893 DU_LOG("\nERROR --> RLC: sendSlicePmToDu():Failed to send Slice PM to DU");
894 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, sliceStats, sizeof(SlicePmList));
903 * Handler for searching the Slice Entry in Slice Metrics structure
906 * This func finds the slice entry in the SliceMetric record structure and
907 * return the index of the slice sot hat Tput entries can be done
909 * @param[in] snssaiVal : Snssai Val to be searched
910 * *snssaiIdx : O/P : Index of the Slice in Slice Metrics record
911 * sliceStats : Pointer of Slice metrics record list
913 * @return bool: True: If slice found in the record
914 * False: If Slice not found; thus parent function will create the
915 * recpord of this snssai
918 bool rlcFindSliceEntry(SliceIdentifier snssaiVal, uint8_t *snssaiIdx, SlicePmList *sliceStats)
920 uint8_t cntSlices = sliceStats->numSlice;
922 for(*snssaiIdx = 0;(*snssaiIdx) < cntSlices; (*snssaiIdx)++)
924 if((snssaiVal.sst == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sst)&&
925 (snssaiVal.sd == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sd))
934 /*******************************************************************
936 * @brief Builds the Slice Performance Metrics structure to be sent to DU
940 * Function : BuildSliceReportToDu
943 * Builds the Slice Performance Metrics structure to be sent to DU
945 * @params[in] uint8_t snssaiCnt
947 * @return ROK - success
950 * ****************************************************************/
951 uint8_t BuildSliceReportToDu(uint8_t snssaiCnt)
953 CmLList *node = NULLP;
954 RlcTptPerSnssai *snssaiNode = NULLP;
955 Direction dir = DIR_UL;
956 SlicePmList *sliceStats = NULLP; /*Slice metric */
957 SliceIdentifier snssaiVal ;
958 uint8_t snssaiIdx = 0;
962 DU_LOG("\nERROR --> RLC: No SNSSAI to send the SLice PM");
966 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
967 if(sliceStats == NULLP)
969 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
972 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, snssaiCnt * (sizeof(SlicePm)));
974 if(sliceStats->sliceRecord == NULLP)
976 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
977 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
980 while(dir < DIR_BOTH)
982 node = arrTputPerSnssai[dir]->first;
985 DU_LOG("\nERROR --> RLC: No SNSSAI in list");
986 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
987 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, (snssaiCnt * (sizeof(SlicePm))));
994 snssaiNode = (RlcTptPerSnssai *)node->node;
996 snssaiVal.sst = snssaiNode->snssai->sst;
997 snssaiVal.sd = snssaiNode->snssai->sd[2]+snssaiNode->snssai->sd[1]*10+snssaiNode->snssai->sd[0]*100;
998 if(rlcFindSliceEntry(snssaiVal, &snssaiIdx, sliceStats) == FALSE)
1000 sliceStats->sliceRecord[snssaiIdx].networkSliceIdentifier = snssaiVal;
1001 sliceStats->numSlice++;
1005 sliceStats->sliceRecord[snssaiIdx].ThpUl = snssaiNode->tpt;
1009 sliceStats->sliceRecord[snssaiIdx].ThpDl = snssaiNode->tpt;
1016 sendSlicePmToDu(sliceStats);
1019 /**********************************************************************
1021 **********************************************************************/