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 switch(rlcUeCfg->entMode)
175 rlcUeCfg->m.amInfo.dl.snLen = duRlcUeCfg->u.amCfg->dlAmCfg.snLenDl;
176 rlcUeCfg->m.amInfo.dl.pollRetxTmr = duRlcUeCfg->u.amCfg->dlAmCfg.pollRetxTmr;
177 rlcUeCfg->m.amInfo.dl.pollPdu = duRlcUeCfg->u.amCfg->dlAmCfg.pollPdu;
178 rlcUeCfg->m.amInfo.dl.pollByte = duRlcUeCfg->u.amCfg->dlAmCfg.pollByte;
179 rlcUeCfg->m.amInfo.dl.maxRetx = duRlcUeCfg->u.amCfg->dlAmCfg.maxRetxTh;
182 lChRbIdx++; //lChRbIdx = 1, indicates UL AM
183 rlcUeCfg->lCh[lChRbIdx].lChId = duRlcUeCfg->lcId;
184 rlcUeCfg->lCh[lChRbIdx].type = duRlcUeCfg->lcType;
185 rlcUeCfg->m.amInfo.ul.snLen = duRlcUeCfg->u.amCfg->ulAmCfg.snLenUl;
186 rlcUeCfg->m.amInfo.ul.staProhTmr = duRlcUeCfg->u.amCfg->ulAmCfg.statProhTmr;
187 rlcUeCfg->m.amInfo.ul.reAsmblTmr = duRlcUeCfg->u.amCfg->ulAmCfg.reAssemTmr;
193 rlcUeCfg->m.umInfo.ul.snLen = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
194 rlcUeCfg->m.umInfo.ul.reAsmblTmr = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
197 rlcUeCfg->m.umInfo.dl.snLen = duRlcUeCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
202 }/* End of switch(entMode) */
206 /*******************************************************************
208 * @brief fills LC Cfgs to be Added in RLC
212 * Function : fillRlcCfg
215 * fills LC Cfgs to be Add in RLC
218 * RlcEntCfgInfo pointer
219 * RlcBearerCfg pointer
220 * @return ROK - Success
223 ******************************************************************/
225 uint8_t fillRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeCfg *ueCfg)
229 rlcUeCfg->ueId = ueCfg->ueId;
230 rlcUeCfg->cellId = ueCfg->cellId;
231 rlcUeCfg->numEnt = ueCfg->numLcsToAdd;
232 rlcUeCfg->transId = getTransId();
233 for(lcIdx = 0; lcIdx < rlcUeCfg->numEnt; lcIdx++)
235 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[lcIdx], &ueCfg->rlcLcCfgAdd[lcIdx]) != ROK)
237 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
240 rlcUeCfg->entCfg[lcIdx].cfgType = CONFIG_ADD;
245 /*******************************************************************
247 * @brief updates LC Cfgs to be Added/Mod/Rel in RLC
251 * Function : updateRlcCfg
254 * updates LC Cfgs to be Add/Mod/Del in RLC
257 * RlcEntCfgInfo pointer
258 * RlcBearerCfg pointer
259 * @return ROK - Success
262 ******************************************************************/
264 uint8_t updateRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeRecfg *ueRecfg)
268 rlcUeCfg->ueId = ueRecfg->ueId;
269 rlcUeCfg->cellId = ueRecfg->cellId;
270 rlcUeCfg->transId = getTransId();
272 rlcUeCfg->numEnt = 0;
273 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
275 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgAdd[lcIdx]) != ROK)
277 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
280 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_ADD;
283 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
285 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgMod[lcIdx]) != ROK)
287 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
290 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_MOD;
293 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToRel; lcIdx++)
295 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgRel[lcIdx]) != ROK)
297 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
300 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_DEL;
306 /*******************************************************************
308 * @brief Fill RlcCfgCfmInfo structure for sending failure response to DU
312 * Function : fillRlcCfgFailureRsp
315 * Fill RlcCfgCfmInfo structure for sending failure response to DU
317 * @params[in] RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg
321 * ****************************************************************/
322 void fillRlcCfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg)
326 cfgRsp->ueId = ueCfg->ueId;
327 cfgRsp->cellId = ueCfg->cellId;
328 cfgRsp->numEnt = ueCfg->numLcsToAdd;
329 for(cfgIdx =0; cfgIdx<ueCfg->numLcsToAdd; cfgIdx++)
331 cfgRsp->entCfgCfm[cfgIdx].rbId = ueCfg->rlcLcCfgAdd[cfgIdx].rbId;
332 cfgRsp->entCfgCfm[cfgIdx].rbType = ueCfg->rlcLcCfgAdd[cfgIdx].rbType;
333 cfgRsp->entCfgCfm[cfgIdx].status.status = RLC_DU_APP_RSP_NOK;
334 cfgRsp->entCfgCfm[cfgIdx].status.reason = CKW_CFG_REAS_NONE;
338 /*******************************************************************
340 * @brief Fill RlcCfgCfmInfo structure for sending failure response to DU
344 * Function : fillRlcRecfgFailureRsp
347 * Fill RlcCfgCfmInfo structure for sending failure response to DU
349 * @params[in] RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg
353 * ****************************************************************/
354 void fillRlcRecfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeRecfg *ueRecfg)
358 cfgRsp->ueId = ueRecfg->ueId;
359 cfgRsp->cellId = ueRecfg->cellId;
361 for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToAdd; cfgIdx++)
363 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbId = ueRecfg->rlcLcCfgAdd[cfgIdx].rbId;
364 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbType = ueRecfg->rlcLcCfgAdd[cfgIdx].rbType;
365 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.status = RLC_DU_APP_RSP_NOK;
366 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.reason = CKW_CFG_REAS_NONE;
369 for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToMod; cfgIdx++)
371 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbId = ueRecfg->rlcLcCfgMod[cfgIdx].rbId;
372 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbType = ueRecfg->rlcLcCfgMod[cfgIdx].rbType;
373 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.status = RLC_DU_APP_RSP_NOK;
374 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.reason = CKW_CFG_REAS_NONE;
377 for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToRel; cfgIdx++)
379 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbId = ueRecfg->rlcLcCfgRel[cfgIdx].rbId;
380 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbType = ueRecfg->rlcLcCfgRel[cfgIdx].rbType;
381 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.status = RLC_DU_APP_RSP_NOK;
382 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.reason = CKW_CFG_REAS_NONE;
387 /*******************************************************************
389 * @brief Handles Ue Create Request from DU APP
393 * Function : RlcProcUeCreateReq
396 * Handles Ue create Request from DU APP
398 * @params[in] Post structure pointer
400 * @return ROK - success
403 * ****************************************************************/
404 uint8_t RlcProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
408 RlcCfgInfo *rlcUeCfg = NULLP;
409 RlcCfgCfmInfo cfgRsp;
412 gCb = RLC_GET_RLCCB(pst->dstInst);
413 RLC_ALLOC(gCb, rlcUeCfg, sizeof(RlcCfgInfo));
414 if(rlcUeCfg == NULLP)
416 DU_LOG("\nERROR --> RLC: Failed to allocate memory at RlcProcUeCreateReq()");
421 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
422 ret = fillRlcCfg(gCb, rlcUeCfg, ueCfg);
425 DU_LOG("\nERROR --> RLC: Failed to fill configuration at RlcProcUeCreateReq()");
426 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_CREATE_RSP);
427 fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
428 SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
433 ret = RlcProcCfgReq(pst, rlcUeCfg);
435 DU_LOG("\nERROR --> RLC: Failed to configure Add/Mod/Del entities at RlcProcUeCreateReq()");
438 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
442 /*******************************************************************
444 * @brief filling the structure of rrc delivery msg info
448 * Function : BuildAndSendRrcDeliveryReportToDu
450 * Functionality: filling the structure of rrc delivery msg info
452 * @return ROK - success
455 * ****************************************************************/
456 uint8_t BuildAndSendRrcDeliveryReportToDu( RlcDlRrcMsgInfo *dlRrcMsgInfo )
459 RrcDeliveryReport *rrcDelivery;
461 DU_LOG("\nINFO --> RLC : Filling RRC Delivery Report");
462 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, rrcDelivery, sizeof(RrcDeliveryReport));
466 rrcDelivery->cellId = dlRrcMsgInfo->cellId;
467 rrcDelivery->ueId = dlRrcMsgInfo->ueId;
468 rrcDelivery->srbId = dlRrcMsgInfo->lcId ;
469 rrcDelivery->rrcDeliveryStatus.deliveryStatus = PDCP_SN;
470 rrcDelivery->rrcDeliveryStatus.triggeringMessage = PDCP_SN;
472 /* Sending UL RRC Message transfeer to DU APP */
473 memset(&pst, 0, sizeof(Pst));
474 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RRC_DELIVERY_MSG_TRANS_TO_DU);
475 rlcSendRrcDeliveryReportToDu(&pst, rrcDelivery);
479 DU_LOG("\nERROR --> RLC : Memory allocation failed");
484 /* ****************************************************************
486 * @brief Process the DL RRC Message from DU APP
490 * Function : RlcProcDlRrcMsgTransfer
492 * Functionality: Process the DL RRC Message from DU APP
494 * @params[in] Post structure
495 * DL RRC Message info
496 * @return ROK - success
499 * ****************************************************************/
500 uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
503 RlcDatReqInfo *datReqInfo;
505 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
508 DU_LOG("\nERROR --> RLC : Memory allocation failed in RlcProcDlRrcMsgTransfer");
509 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
510 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
514 datReqInfo->rlcId.rbType = RB_TYPE_SRB;
515 datReqInfo->rlcId.rbId = dlRrcMsgInfo->lcId;
516 datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueId;
517 datReqInfo->rlcId.cellId = dlRrcMsgInfo->cellId;
518 datReqInfo->lcType = LCH_DCCH;
519 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
521 /* Copy fixed buffer to message */
522 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &mBuf) != ROK)
524 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
525 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
526 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
527 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
530 oduCpyFixBufToMsg(dlRrcMsgInfo->rrcMsg, mBuf, dlRrcMsgInfo->msgLen);
532 if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
537 /* RRC Delivery report is only send when RRC Delivery status report is true in DL RRC Message */
538 if(dlRrcMsgInfo->deliveryStaRpt)
540 BuildAndSendRrcDeliveryReportToDu(dlRrcMsgInfo);
543 /* Free memory allocated by du app */
544 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
545 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
546 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
550 /*******************************************************************
552 * @brief Process UL data from UE
556 * Function : RlcProcUlData
559 * This function receives the PDU from MAC.
560 * seggregates common and dedicated logical channel
561 * PDU and call respective handler.
564 * @return ROK - success
567 * ****************************************************************/
568 uint8_t RlcProcUlData(Pst *pst, RlcUlData *ulData)
572 uint8_t lcId; /* Logical Channel */
573 uint8_t numDLch = 0; /* Number of dedicated logical channel */
574 bool dLchPduPres; /* PDU received on dedicated logical channel */
575 RguLchDatInd dLchData[MAX_NUM_LC]; /* PDU info on dedicated logical channel */
576 RguDDatIndInfo *dLchUlDat; /* UL data on dedicated logical channel */
578 /* Initializing dedicated logical channel Database */
579 DU_LOG("\nDEBUG --> RLC: Received UL Data request from MAC");
580 for(idx = 0; idx < MAX_NUM_LC; idx++)
582 dLchData[idx].lcId = idx;
583 dLchData[idx].pdu.numPdu = 0;
587 /* Seggregate PDUs received on common and dedicated channels
588 * and call common channel's handler */
589 for(idx = 0; idx< ulData->numPdu; idx++)
593 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
594 sizeof(RguDDatIndInfo));
597 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
604 /* Copy fixed buffer to message */
605 lcId = ulData->pduInfo[idx].lcId;
606 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, \
607 &dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]) != ROK)
609 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
610 for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
612 ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
614 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
615 sizeof(RguDDatIndInfo));
619 oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
620 dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
621 ulData->pduInfo[idx].pduLen);
623 dLchData[lcId].pdu.numPdu++;
626 /* If any PDU received on dedicated logical channel, copy into RguDDatIndInfo
627 * and call its handler */
632 dLchUlDat->cellId = ulData->cellId;
633 GET_UE_ID(ulData->rnti, dLchUlDat->rnti);
635 for(idx = 0; idx < MAX_NUM_LC; idx++)
637 if(dLchData[idx].pdu.numPdu)
639 memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
643 dLchUlDat->numLch = numDLch;
644 rlcProcDedLcUlData(pst, 0, dLchUlDat);
648 for(pduIdx = 0; pduIdx < ulData->numPdu; pduIdx++)
650 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData->pduInfo[pduIdx].pduBuf, \
651 ulData->pduInfo[pduIdx].pduLen);
653 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcUlData));
656 }/* End of RlcProcUlData */
658 /*******************************************************************
660 * @brief Handler for extracting common and dedicated channel
661 * Scheduling result report.
665 * Function : RlcProcSchedResultRpt
668 * Handler for extracting common and dedicated channel
669 * Scheduling result report
672 * @return ROK - success
675 * ****************************************************************/
676 uint8_t RlcProcSchedResultRpt(Pst *pst, RlcSchedResultRpt *schRep)
679 uint8_t idx; /* Iterator */
680 uint8_t nmbDLch = 0; /* Number of dedicated logical channles */
681 RguDStaIndInfo *dLchSchInfo; /* Dedicated logical channel scheduling result */
683 DU_LOG("\nDEBUG --> RLC : Received scheduling report from MAC");
684 for(idx=0; idx < schRep->numLc; idx++)
686 /* Fill status info structure if at least one channel's scheduling report is received */
689 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, dLchSchInfo, \
690 sizeof(RguDStaIndInfo));
693 DU_LOG("\nERROR --> RLC: RlcProcSchedResultRpt: Memory allocation failed for dLchSchInfo");
698 dLchSchInfo->cellId = schRep->cellId;
699 dLchSchInfo->nmbOfUeGrantPerTti = 1;
700 /* MAC sends Scheduling report for one UE at a time. Hence filling
701 only the 0th index of staInd */
702 dLchSchInfo->staInd[0].rnti = schRep->rnti;
704 /* Storing sfn/slot into a single 32-bit variable to be used later*/
705 dLchSchInfo->staInd[0].transId = schRep->slotInfo.sfn;
706 dLchSchInfo->staInd[0].transId = \
707 (dLchSchInfo->staInd[0].transId << 16) | schRep->slotInfo.slot;
708 dLchSchInfo->staInd[0].nmbOfTbs = 1;
709 dLchSchInfo->staInd[0].fillCtrlPdu = true;
712 /* Fill logical channel scheduling info */
713 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].lcId = \
714 schRep->lcSch[idx].lcId;
715 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].totBufSize = \
716 schRep->lcSch[idx].bufSize;
720 /* Calling handler for all dedicated channels scheduling*/
725 dLchSchInfo->staInd[0].staIndTb[0].nmbLch = nmbDLch;
726 rlcProcDedLcSchedRpt(pst, 0, dLchSchInfo);
730 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, schRep, sizeof(RlcSchedResultRpt));
735 /*******************************************************************
737 * @brief Handles Ue Reconfig Request from DU APP
741 * Function : RlcProcUeReconfigReq
744 * Handles Ue Reconfig Request from DU APP
746 * @params[in] Post structure pointer
748 * @return ROK - success
751 * ****************************************************************/
752 uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeRecfg *ueRecfg)
755 RlcCfgInfo *rlcUeCfg = NULLP; //Seed code Rlc cfg struct
756 RlcCb *rlcUeCb = NULLP;
757 RlcCfgCfmInfo cfgRsp;
760 DU_LOG("\nDEBUG --> RLC: UE reconfig request received. CellID[%d] UEID[%d]",ueRecfg->cellId, ueRecfg->ueId);
762 rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
763 RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
764 if(rlcUeCfg == NULLP)
766 DU_LOG("\nERROR --> RLC: Failed to allocate memory at RlcProcUeReconfigReq()");
771 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
772 ret = updateRlcCfg(rlcUeCb, rlcUeCfg, ueRecfg);
775 DU_LOG("\nERROR --> RLC: Failed to fill configuration at RlcProcUeReconfigReq()");
776 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
777 fillRlcRecfgFailureRsp(&cfgRsp, ueRecfg);
778 SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
782 ret = RlcProcCfgReq(pst, rlcUeCfg);
784 DU_LOG("\nERROR --> RLC: Failed to configure Add/Mod/Del entities at RlcProcUeReconfigReq()");
788 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(RlcUeRecfg));
792 /* ****************************************************************
794 * @brief Process the DL Data transfer from DU APP
798 * Function : RlcProcDlUserDataTransfer
800 * Functionality: Process the DL transfer from DU APP
802 * @params[in] Post structure
803 * DL RRC Message info
804 * @return ROK - success
807 * ****************************************************************/
808 uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
810 Buffer *mBuf = NULLP;
811 RlcDatReqInfo *datReqInfo = NULLP;
813 if(dlDataMsgInfo->dlMsg == NULLP)
815 DU_LOG("\nERROR --> RLC_DL : Received DL message is NULLP in RlcProcDlUserDataTransfer()");
818 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
821 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed for DatReq in RlcProcDlUserDataTransfer()");
822 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
823 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
827 datReqInfo->rlcId.rbType = RB_TYPE_DRB;
828 datReqInfo->rlcId.rbId = dlDataMsgInfo->rbId;
829 datReqInfo->rlcId.ueId = dlDataMsgInfo->ueId;
830 datReqInfo->rlcId.cellId = dlDataMsgInfo->cellId;
831 datReqInfo->lcType = LCH_DTCH;
832 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
833 mBuf = dlDataMsgInfo->dlMsg;
834 if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
839 /* Free memory allocated by du app */
840 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
841 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
845 /*******************************************************************
847 * @brief sending UE delete response to DU
851 * Function : sendRlcUeDeleteRspToDu
854 * sending UE delete response to DU
856 * @params[in] uint8_t cellId, uint8_t ueId, UeDeleteResult result
858 * @return ROK - success
861 * ****************************************************************/
862 uint8_t sendRlcUeDeleteRspToDu(uint16_t cellId,uint8_t ueId, UeDeleteResult result)
865 RlcUeDeleteRsp *ueDeleteRsp = NULLP;
867 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_RSP);
869 RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
872 DU_LOG("\nERROR --> RLC: sendRlcUeDeleteRspToDu(): Memory allocation failed ");
877 ueDeleteRsp->cellId = cellId;
878 ueDeleteRsp->ueId = ueId;
879 ueDeleteRsp->result = result;
881 if(rlcSendUeDeleteRspToDu(&pst, ueDeleteRsp) == ROK)
883 DU_LOG("\nDEBUG --> RLC: UE Delete response send successfully");
887 DU_LOG("\nERROR --> RLC: SendRlcUeDeleteRspToDu():Failed to send UE Delete response to DU");
888 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
895 /*******************************************************************
897 * @brief Handles Ue delete Request from DU APP
901 * Function : RlcProcUeDeleteReq
904 * Handles Ue delete Request from DU APP
906 * @params[in] Post structure pointer
907 * RlcUeDelete pointer
908 * @return ROK - success
911 * ****************************************************************/
913 uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete)
916 RlcCb *gRlcCb = NULLP;
917 RlcUlUeCb *ueCb = NULLP;
918 UeDeleteResult result=SUCCESSFUL;
920 DU_LOG("\nDEBUG --> RLC: UE Delete request received. CellID[%d] UEID[%d]",ueDelete->cellId, ueDelete->ueId);
922 if(ueDelete != NULLP)
924 gRlcCb = RLC_GET_RLCCB(pst->dstInst);
925 rlcDbmFetchUlUeCb(gRlcCb,ueDelete->ueId, ueDelete->cellId, &ueCb);
928 if(ueDelete->cellId == ueCb->cellId)
930 memcpy(&ueCb->ueDeleteInfo.pst, pst, sizeof(Pst));
931 if((rlcChkTmr(gRlcCb, (PTR)ueCb, EVENT_RLC_UE_DELETE_TMR)) == FALSE)
933 rlcStartTmr(gRlcCb,(PTR)ueCb, EVENT_RLC_UE_DELETE_TMR);
938 result = INVALID_CELLID;
943 result = INVALID_UEID;
946 if(result != SUCCESSFUL)
948 ret = sendRlcUeDeleteRspToDu(ueDelete->cellId, ueDelete->ueId, result);
951 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq():Failed to send UE Delete response to DU");
954 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(RlcUeDelete));
958 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq(): Recieved NULL pointer UE Delete ");
964 /*******************************************************************
966 * @brief Send the Slice Metrics to DU APP
970 * Function : sendSlicePmToDu
973 * Handles the sending of Slice Metrics to DU APP
975 * @params[in] Post structure pointer
976 * SlicePmList *sliceStats pointer
978 * @return ROK - success
981 * ****************************************************************/
982 uint8_t sendSlicePmToDu(SlicePmList *sliceStats)
986 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_SLICE_PM_TO_DU);
990 DU_LOG("\nERROR --> RLC: sendSlicePmToDu(): Memory allocation failed ");
995 if(rlcSendSlicePmToDu(&pst, sliceStats) == ROK)
997 DU_LOG("\nDEBUG --> RLC: Slice PM send successfully");
1001 DU_LOG("\nERROR --> RLC: sendSlicePmToDu():Failed to send Slice PM to DU");
1002 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, sliceStats, sizeof(SlicePmList));
1011 * Handler for searching the Slice Entry in Slice Metrics structure
1014 * This func finds the slice entry in the SliceMetric record structure and
1015 * return the index of the slice sot hat Tput entries can be done
1017 * @param[in] snssaiVal : Snssai Val to be searched
1018 * *snssaiIdx : O/P : Index of the Slice in Slice Metrics record
1019 * sliceStats : Pointer of Slice metrics record list
1021 * @return bool: True: If slice found in the record
1022 * False: If Slice not found; thus parent function will create the
1023 * recpord of this snssai
1026 bool rlcFindSliceEntry(SliceIdentifier snssaiVal, uint8_t *snssaiIdx, SlicePmList *sliceStats)
1028 uint8_t cntSlices = sliceStats->numSlice;
1030 for(*snssaiIdx = 0;(*snssaiIdx) < cntSlices; (*snssaiIdx)++)
1032 if((snssaiVal.sst == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sst)&&
1033 (snssaiVal.sd == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sd))
1042 /*******************************************************************
1044 * @brief Builds the Slice Performance Metrics structure to be sent to DU
1048 * Function : BuildSliceReportToDu
1051 * Builds the Slice Performance Metrics structure to be sent to DU
1053 * @params[in] uint8_t snssaiCnt
1055 * @return ROK - success
1058 * ****************************************************************/
1059 uint8_t BuildSliceReportToDu(uint8_t snssaiCnt)
1061 CmLList *node = NULLP;
1062 RlcTptPerSnssai *snssaiNode = NULLP;
1063 Direction dir = DIR_UL;
1064 SlicePmList *sliceStats = NULLP; /*Slice metric */
1065 SliceIdentifier snssaiVal ;
1066 uint8_t snssaiIdx = 0;
1070 DU_LOG("\nERROR --> RLC: No SNSSAI to send the SLice PM");
1074 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1075 if(sliceStats == NULLP)
1077 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
1080 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, snssaiCnt * (sizeof(SlicePm)));
1082 if(sliceStats->sliceRecord == NULLP)
1084 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
1085 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1088 while(dir < DIR_BOTH)
1090 node = arrTputPerSnssai[dir]->first;
1093 DU_LOG("\nERROR --> RLC: No SNSSAI in list");
1094 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1095 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, (snssaiCnt * (sizeof(SlicePm))));
1102 snssaiNode = (RlcTptPerSnssai *)node->node;
1104 snssaiVal.sst = snssaiNode->snssai->sst;
1105 snssaiVal.sd = snssaiNode->snssai->sd[2]+snssaiNode->snssai->sd[1]*10+snssaiNode->snssai->sd[0]*100;
1106 if(rlcFindSliceEntry(snssaiVal, &snssaiIdx, sliceStats) == FALSE)
1108 sliceStats->sliceRecord[snssaiIdx].networkSliceIdentifier = snssaiVal;
1109 sliceStats->numSlice++;
1113 sliceStats->sliceRecord[snssaiIdx].ThpUl = snssaiNode->tpt;
1117 sliceStats->sliceRecord[snssaiIdx].ThpDl = snssaiNode->tpt;
1124 sendSlicePmToDu(sliceStats);
1127 /**********************************************************************
1129 **********************************************************************/