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 = dlRrcMsgInfo->rbType;
405 datReqInfo->rlcId.rbId = dlRrcMsgInfo->rbId;
406 datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueId;
407 datReqInfo->rlcId.cellId = dlRrcMsgInfo->cellId;
408 datReqInfo->lcType = dlRrcMsgInfo->lcType;
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, RlcData *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++)
482 if(ulData->pduInfo[idx].commCh)
484 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, cLchUlDat, \
485 sizeof(RguCDatIndInfo));
488 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcProcUlData");
492 memset(cLchUlDat, 0, sizeof(RguCDatIndInfo));
494 cLchUlDat->cellId = ulData->cellId;
495 GET_UE_ID(ulData->rnti, cLchUlDat->rnti);
496 cLchUlDat->lcId = ulData->pduInfo[idx].lcId;
498 /* Copy fixed buffer to message */
499 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &cLchUlDat->pdu) != ROK)
501 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcProcUlData");
502 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, cLchUlDat, \
503 sizeof(RguCDatIndInfo));
507 oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, cLchUlDat->pdu, \
508 ulData->pduInfo[idx].pduLen);
510 rlcProcCommLcUlData(pst, 0, cLchUlDat);
516 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
517 sizeof(RguDDatIndInfo));
520 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
527 /* Copy fixed buffer to message */
528 lcId = ulData->pduInfo[idx].lcId;
529 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, \
530 &dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]) != ROK)
532 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
533 for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
535 ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
537 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
538 sizeof(RguDDatIndInfo));
542 oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
543 dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
544 ulData->pduInfo[idx].pduLen);
546 dLchData[lcId].pdu.numPdu++;
550 /* If any PDU received on dedicated logical channel, copy into RguDDatIndInfo
551 * and call its handler */
556 dLchUlDat->cellId = ulData->cellId;
557 GET_UE_ID(ulData->rnti, dLchUlDat->rnti);
559 for(idx = 0; idx < MAX_NUM_LC; idx++)
561 if(dLchData[idx].pdu.numPdu)
563 memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
567 dLchUlDat->numLch = numDLch;
568 rlcProcDedLcUlData(pst, 0, dLchUlDat);
572 for(pduIdx = 0; pduIdx < ulData->numPdu; pduIdx++)
574 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData->pduInfo[pduIdx].pduBuf, \
575 ulData->pduInfo[pduIdx].pduLen);
577 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcData));
580 }/* End of RlcProcUlData */
582 /*******************************************************************
584 * @brief Handler for extracting common and dedicated channel
585 * Scheduling result report.
589 * Function : RlcProcSchedResultRpt
592 * Handler for extracting common and dedicated channel
593 * Scheduling result report
596 * @return ROK - success
599 * ****************************************************************/
600 uint8_t RlcProcSchedResultRpt(Pst *pst, RlcSchedResultRpt *schRep)
603 uint8_t idx; /* Iterator */
604 uint8_t nmbDLch = 0; /* Number of dedicated logical channles */
605 RguCStaIndInfo *cLchSchInfo; /* Common logical channel scheduling result */
606 RguDStaIndInfo *dLchSchInfo; /* Dedicated logical channel scheduling result */
608 DU_LOG("\nDEBUG --> RLC : Received scheduling report from MAC");
609 for(idx=0; idx < schRep->numLc; idx++)
611 /* If it is common channel, fill status indication information
612 * and trigger the handler for each common lch separately */
613 if(schRep->lcSch[idx].commCh)
615 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, cLchSchInfo, \
616 sizeof(RguCStaIndInfo));
619 DU_LOG("\nERROR --> RLC: RlcProcSchedResultRpt: Memory allocation failed for cLchSchInfo");
623 memset(cLchSchInfo, 0, sizeof(RguCStaIndInfo));
625 cLchSchInfo->cellId = schRep->cellId;
626 cLchSchInfo->lcId = schRep->lcSch[idx].lcId;
627 cLchSchInfo->transId = schRep->slotInfo.sfn;
628 cLchSchInfo->transId = (cLchSchInfo->transId << 16) | schRep->slotInfo.slot;
629 cLchSchInfo->rnti = schRep->rnti;
630 rlcProcCommLcSchedRpt(pst, 0, cLchSchInfo);
635 /* Fill status info structure if at least one dedicated channel
636 * scheduling report is received */
639 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, dLchSchInfo, \
640 sizeof(RguDStaIndInfo));
643 DU_LOG("\nERROR --> RLC: RlcProcSchedResultRpt: Memory allocation failed for dLchSchInfo");
648 dLchSchInfo->cellId = schRep->cellId;
649 dLchSchInfo->nmbOfUeGrantPerTti = 1;
650 /* MAC sends Scheduling report for one UE at a time. Hence filling
651 only the 0th index of staInd */
652 dLchSchInfo->staInd[0].rnti = schRep->rnti;
654 /* Storing sfn/slot into a single 32-bit variable to be used later*/
655 dLchSchInfo->staInd[0].transId = schRep->slotInfo.sfn;
656 dLchSchInfo->staInd[0].transId = \
657 (dLchSchInfo->staInd[0].transId << 16) | schRep->slotInfo.slot;
658 dLchSchInfo->staInd[0].nmbOfTbs = 1;
659 dLchSchInfo->staInd[0].fillCtrlPdu = true;
662 /* Fill logical channel scheduling info */
663 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].lcId = \
664 schRep->lcSch[idx].lcId;
665 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].totBufSize = \
666 schRep->lcSch[idx].bufSize;
671 /* Calling handler for all dedicated channels scheduling*/
676 dLchSchInfo->staInd[0].staIndTb[0].nmbLch = nmbDLch;
677 rlcProcDedLcSchedRpt(pst, 0, dLchSchInfo);
681 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, schRep, sizeof(RlcSchedResultRpt));
686 /*******************************************************************
688 * @brief Handles Ue Reconfig Request from DU APP
692 * Function : RlcProcUeReconfigReq
695 * Handles Ue Reconfig Request from DU APP
697 * @params[in] Post structure pointer
699 * @return ROK - success
702 * ****************************************************************/
703 uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg)
706 RlcCfgInfo *rlcUeCfg = NULLP; //Seed code Rlc cfg struct
707 RlcCb *rlcUeCb = NULLP;
708 RlcCfgCfmInfo cfgRsp;
711 DU_LOG("\nDEBUG --> RLC: UE reconfig request received. CellID[%d] UEID[%d]",ueCfg->cellId, ueCfg->ueId);
713 rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
714 RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
715 if(rlcUeCfg == NULLP)
717 DU_LOG("\nERROR --> RLC: Failed to allocate memory at RlcProcUeReconfigReq()");
722 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
723 ret = fillRlcCfg(rlcUeCb, rlcUeCfg, ueCfg);
726 DU_LOG("\nERROR --> RLC: Failed to fill configuration at RlcProcUeReconfigReq()");
727 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
728 fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
729 SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
733 ret = RlcProcCfgReq(pst, rlcUeCfg);
735 DU_LOG("\nERROR --> RLC: Failed to configure Add/Mod/Del entities at RlcProcUeReconfigReq()");
739 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
743 /* ****************************************************************
745 * @brief Process the DL Data transfer from DU APP
749 * Function : RlcProcDlUserDataTransfer
751 * Functionality: Process the DL transfer from DU APP
753 * @params[in] Post structure
754 * DL RRC Message info
755 * @return ROK - success
758 * ****************************************************************/
759 uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
761 Buffer *mBuf = NULLP;
762 RlcDatReqInfo *datReqInfo = NULLP;
764 if(dlDataMsgInfo->dlMsg == NULLP)
766 DU_LOG("\nERROR --> RLC_DL : Received DL message is NULLP in RlcProcDlUserDataTransfer()");
769 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
772 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed for DatReq in RlcProcDlUserDataTransfer()");
773 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
774 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
778 datReqInfo->rlcId.rbType = RB_TYPE_DRB;
779 datReqInfo->rlcId.rbId = dlDataMsgInfo->rbId;
780 datReqInfo->rlcId.ueId = dlDataMsgInfo->ueId;
781 datReqInfo->rlcId.cellId = dlDataMsgInfo->cellId;
782 datReqInfo->lcType = LCH_DTCH;
783 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
784 mBuf = dlDataMsgInfo->dlMsg;
785 if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
790 /* Free memory allocated by du app */
791 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
792 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
796 /*******************************************************************
798 * @brief sending UE delete response to DU
802 * Function : sendRlcUeDeleteRspToDu
805 * sending UE delete response to DU
807 * @params[in] uint8_t cellId, uint8_t ueId, UeDeleteResult result
809 * @return ROK - success
812 * ****************************************************************/
813 uint8_t sendRlcUeDeleteRspToDu(uint16_t cellId,uint8_t ueId, UeDeleteResult result)
816 RlcUeDeleteRsp *ueDeleteRsp = NULLP;
818 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_RSP);
820 RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
823 DU_LOG("\nERROR --> RLC: sendRlcUeDeleteRspToDu(): Memory allocation failed ");
828 ueDeleteRsp->cellId = cellId;
829 ueDeleteRsp->ueId = ueId;
830 ueDeleteRsp->result = result;
832 if(rlcSendUeDeleteRspToDu(&pst, ueDeleteRsp) == ROK)
834 DU_LOG("\nDEBUG --> RLC: UE Delete response send successfully");
838 DU_LOG("\nERROR --> RLC: SendRlcUeDeleteRspToDu():Failed to send UE Delete response to DU");
839 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
846 /*******************************************************************
848 * @brief Handles Ue delete Request from DU APP
852 * Function : RlcProcUeDeleteReq
855 * Handles Ue delete Request from DU APP
857 * @params[in] Post structure pointer
858 * RlcUeDelete pointer
859 * @return ROK - success
862 * ****************************************************************/
864 uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete)
867 RlcCb *gRlcCb = NULLP;
868 RlcUlUeCb *ueCb = NULLP;
869 UeDeleteResult result=SUCCESSFUL;
871 DU_LOG("\nDEBUG --> RLC: UE Delete request received. CellID[%d] UEID[%d]",ueDelete->cellId, ueDelete->ueId);
873 if(ueDelete != NULLP)
875 gRlcCb = RLC_GET_RLCCB(pst->dstInst);
876 rlcDbmFetchUlUeCb(gRlcCb,ueDelete->ueId, ueDelete->cellId, &ueCb);
879 if(ueDelete->cellId == ueCb->cellId)
881 memcpy(&ueCb->ueDeleteInfo.pst, pst, sizeof(Pst));
882 if((rlcChkTmr(gRlcCb, (PTR)ueCb, EVENT_RLC_UE_DELETE_TMR)) == FALSE)
884 rlcStartTmr(gRlcCb,(PTR)ueCb, EVENT_RLC_UE_DELETE_TMR);
889 result = INVALID_CELLID;
894 result = INVALID_UEID;
897 if(result != SUCCESSFUL)
899 ret = sendRlcUeDeleteRspToDu(ueDelete->cellId, ueDelete->ueId, result);
902 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq():Failed to send UE Delete response to DU");
905 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(RlcUeDelete));
909 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq(): Recieved NULL pointer UE Delete ");
915 /*******************************************************************
917 * @brief Send the Slice Metrics to DU APP
921 * Function : sendSlicePmToDu
924 * Handles the sending of Slice Metrics to DU APP
926 * @params[in] Post structure pointer
927 * SlicePmList *sliceStats pointer
929 * @return ROK - success
932 * ****************************************************************/
933 uint8_t sendSlicePmToDu(SlicePmList *sliceStats)
937 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_SLICE_PM_TO_DU);
941 DU_LOG("\nERROR --> RLC: sendSlicePmToDu(): Memory allocation failed ");
946 if(rlcSendSlicePmToDu(&pst, sliceStats) == ROK)
948 DU_LOG("\nDEBUG --> RLC: Slice PM send successfully");
952 DU_LOG("\nERROR --> RLC: sendSlicePmToDu():Failed to send Slice PM to DU");
953 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, sliceStats, sizeof(SlicePmList));
962 * Handler for searching the Slice Entry in Slice Metrics structure
965 * This func finds the slice entry in the SliceMetric record structure and
966 * return the index of the slice sot hat Tput entries can be done
968 * @param[in] snssaiVal : Snssai Val to be searched
969 * *snssaiIdx : O/P : Index of the Slice in Slice Metrics record
970 * sliceStats : Pointer of Slice metrics record list
972 * @return bool: True: If slice found in the record
973 * False: If Slice not found; thus parent function will create the
974 * recpord of this snssai
977 bool rlcFindSliceEntry(SliceIdentifier snssaiVal, uint8_t *snssaiIdx, SlicePmList *sliceStats)
979 uint8_t cntSlices = sliceStats->numSlice;
981 for(*snssaiIdx = 0;(*snssaiIdx) < cntSlices; (*snssaiIdx)++)
983 if((snssaiVal.sst == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sst)&&
984 (snssaiVal.sd == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sd))
993 /*******************************************************************
995 * @brief Builds the Slice Performance Metrics structure to be sent to DU
999 * Function : BuildSliceReportToDu
1002 * Builds the Slice Performance Metrics structure to be sent to DU
1004 * @params[in] uint8_t snssaiCnt
1006 * @return ROK - success
1009 * ****************************************************************/
1010 uint8_t BuildSliceReportToDu(uint8_t snssaiCnt)
1012 CmLList *node = NULLP;
1013 RlcTptPerSnssai *snssaiNode = NULLP;
1014 Direction dir = DIR_UL;
1015 SlicePmList *sliceStats = NULLP; /*Slice metric */
1016 SliceIdentifier snssaiVal ;
1017 uint8_t snssaiIdx = 0;
1021 DU_LOG("\nERROR --> RLC: No SNSSAI to send the SLice PM");
1025 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1026 if(sliceStats == NULLP)
1028 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
1031 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, snssaiCnt * (sizeof(SlicePm)));
1033 if(sliceStats->sliceRecord == NULLP)
1035 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
1036 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1039 while(dir < DIR_BOTH)
1041 node = arrTputPerSnssai[dir]->first;
1044 DU_LOG("\nERROR --> RLC: No SNSSAI in list");
1045 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1046 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, (snssaiCnt * (sizeof(SlicePm))));
1053 snssaiNode = (RlcTptPerSnssai *)node->node;
1055 snssaiVal.sst = snssaiNode->snssai->sst;
1056 snssaiVal.sd = snssaiNode->snssai->sd[2]+snssaiNode->snssai->sd[1]*10+snssaiNode->snssai->sd[0]*100;
1057 if(rlcFindSliceEntry(snssaiVal, &snssaiIdx, sliceStats) == FALSE)
1059 sliceStats->sliceRecord[snssaiIdx].networkSliceIdentifier = snssaiVal;
1060 sliceStats->numSlice++;
1064 sliceStats->sliceRecord[snssaiIdx].ThpUl = snssaiNode->tpt;
1068 sliceStats->sliceRecord[snssaiIdx].ThpDl = snssaiNode->tpt;
1075 sendSlicePmToDu(sliceStats);
1078 /**********************************************************************
1080 **********************************************************************/