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"
44 /*******************************************************************
46 * @brief building and sending UE max retransmission info to DU
50 * Function : BuildAndSendRlcMaxRetransIndToDu
53 * Building and sending UE max retransmission information to DU
55 * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult status
57 * @return ROK - success
60 * ****************************************************************/
61 uint8_t BuildAndSendRlcMaxRetransIndToDu(uint16_t cellId,uint8_t ueId, uint8_t lcId, uint8_t lcType)
64 RlcMaxRetransInfo *maxRetransInfo = NULLP;
66 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_MAX_RETRANSMISSION);
68 RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, maxRetransInfo, sizeof(RlcMaxRetransInfo));
71 DU_LOG("\nERROR --> RLC: sendRlcMaxRetransIndToDu(): Memory allocation failed ");
76 maxRetransInfo->cellId = cellId;
77 maxRetransInfo->ueId = ueId;
78 maxRetransInfo->lcId = lcId;
79 maxRetransInfo->lcType = lcType;
81 if(rlcSendMaxRetransIndToDu(&pst, maxRetransInfo) == ROK)
83 DU_LOG("\nDEBUG --> RLC: UE [ %d] max retransmission information sent successfully",ueId);
87 DU_LOG("\nERROR --> RLC: SendRlcMaxRetransIndToDu(): fail to send UeId's[%d] maximum retransmission information", ueId);
88 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, maxRetransInfo, sizeof(RlcMaxRetransInfo));
95 /*******************************************************************
97 * @brief Fills RLC UL UE Cfg Rsp from RlcCRsp
101 * Function : fillRlcUeCreateRsp
104 * Fills RLC UL UE Cfg Rsp from RlcCRsp
106 * @params[in] Pointer to RlcCfgCfm
107 * Pointer to RlcUeCreateRsp
109 * @return ROK/RFAILED
111 *****************************************************************/
113 uint8_t fillRlcUeCreateRsp(RlcUeCreateRsp *rlcCfgRsp, RlcCfgCfmInfo *rlcCRsp)
118 rlcCfgRsp->cellId = rlcCRsp->cellId;
119 rlcCfgRsp->ueId = rlcCRsp->ueId;
120 rlcCfgRsp->result = RLC_DU_APP_RSP_OK;
121 for(idx = 0; idx < rlcCRsp->numEnt; idx++)
123 if(rlcCRsp->entCfgCfm[idx].status.status == CKW_CFG_CFM_OK)
125 rlcCfgRsp->result = RLC_DU_APP_RSP_OK;
126 rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
131 rlcCfgRsp->result = RLC_DU_APP_RSP_NOK;
132 rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
140 /*******************************************************************
142 * @brief Fills the entity mode and direction compiling to seed code
146 * Function : fillEntModeAndDir
149 * Fills the entity mode and direction compiling to seed code
151 * @params[in] Pointer to entMode
152 * Pointer to direction
155 * ****************************************************************/
157 void fillEntModeAndDir(uint8_t *entMode, uint8_t *direction, RlcMode rlcMode)
162 *entMode = RLC_MODE_AM;
163 *direction = RLC_CFG_DIR_BOTH;
165 case RLC_UM_BI_DIRECTIONAL:
166 *entMode = RLC_MODE_UM;
167 *direction = RLC_CFG_DIR_BOTH;
169 case RLC_UM_UNI_DIRECTIONAL_UL:
170 *entMode = RLC_MODE_UM;
171 *direction = RLC_CFG_DIR_UL;
173 case RLC_UM_UNI_DIRECTIONAL_DL:
174 *entMode = RLC_MODE_UM;
175 *direction = RLC_CFG_DIR_DL;
178 DU_LOG("\nERROR --> RLC: Rlc Mode invalid %d", rlcMode);
183 /*******************************************************************
185 * @brief fills LC Cfgs to be Added in RLC
189 * Function : fillLcCfg
192 * fills LC Cfgs to be Added in RLC
195 * RlcEntCfgInfo pointer
196 * RlcBearerCfg pointer
198 * @return ROK - SUCCESS
201 * ****************************************************************/
202 uint8_t fillLcCfg(RlcCb *gCb, RlcEntCfgInfo *rlcUeCfg, RlcBearerCfg *duRlcUeCfg)
204 uint8_t lChRbIdx = 0;
206 rlcUeCfg->rbId = duRlcUeCfg->rbId;
207 rlcUeCfg->rbType = duRlcUeCfg->rbType; // SRB or DRB
208 rlcUeCfg->lCh[lChRbIdx].lChId = duRlcUeCfg->lcId;
209 rlcUeCfg->lCh[lChRbIdx].type = duRlcUeCfg->lcType;
210 if(duRlcUeCfg->snssai)
212 RLC_ALLOC(gCb, rlcUeCfg->snssai, sizeof(Snssai));
213 if(rlcUeCfg->snssai == NULLP)
215 DU_LOG("\nERROR --> RLC : fillLcCfg(): Failed to allocate memory for snssai");
218 memcpy(rlcUeCfg->snssai, duRlcUeCfg->snssai, sizeof(Snssai));
220 fillEntModeAndDir(&rlcUeCfg->entMode, &rlcUeCfg->dir, duRlcUeCfg->rlcMode);
221 switch(rlcUeCfg->entMode)
227 rlcUeCfg->m.amInfo.dl.snLen = duRlcUeCfg->u.amCfg->dlAmCfg.snLenDl;
228 rlcUeCfg->m.amInfo.dl.pollRetxTmr = duRlcUeCfg->u.amCfg->dlAmCfg.pollRetxTmr;
229 rlcUeCfg->m.amInfo.dl.pollPdu = duRlcUeCfg->u.amCfg->dlAmCfg.pollPdu;
230 rlcUeCfg->m.amInfo.dl.pollByte = duRlcUeCfg->u.amCfg->dlAmCfg.pollByte;
231 rlcUeCfg->m.amInfo.dl.maxRetx = duRlcUeCfg->u.amCfg->dlAmCfg.maxRetxTh;
234 lChRbIdx++; //lChRbIdx = 1, indicates UL AM
235 rlcUeCfg->lCh[lChRbIdx].lChId = duRlcUeCfg->lcId;
236 rlcUeCfg->lCh[lChRbIdx].type = duRlcUeCfg->lcType;
237 rlcUeCfg->m.amInfo.ul.snLen = duRlcUeCfg->u.amCfg->ulAmCfg.snLenUl;
238 rlcUeCfg->m.amInfo.ul.staProhTmr = duRlcUeCfg->u.amCfg->ulAmCfg.statProhTmr;
239 rlcUeCfg->m.amInfo.ul.reAsmblTmr = duRlcUeCfg->u.amCfg->ulAmCfg.reAssemTmr;
245 rlcUeCfg->m.umInfo.ul.snLen = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
246 rlcUeCfg->m.umInfo.ul.reAsmblTmr = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
249 rlcUeCfg->m.umInfo.dl.snLen = duRlcUeCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
254 }/* End of switch(entMode) */
258 /*******************************************************************
260 * @brief fills LC Cfgs to be Added in RLC
264 * Function : fillRlcCfg
267 * fills LC Cfgs to be Add in RLC
270 * RlcEntCfgInfo pointer
271 * RlcBearerCfg pointer
272 * @return ROK - Success
275 ******************************************************************/
277 uint8_t fillRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeCreate *ueCfg)
281 rlcUeCfg->ueId = ueCfg->ueId;
282 rlcUeCfg->cellId = ueCfg->cellId;
283 rlcUeCfg->numEnt = ueCfg->numLcsToAdd;
284 rlcUeCfg->transId = getTransId();
285 for(lcIdx = 0; lcIdx < rlcUeCfg->numEnt; lcIdx++)
287 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[lcIdx], &ueCfg->rlcLcCfgAdd[lcIdx]) != ROK)
289 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
292 rlcUeCfg->entCfg[lcIdx].cfgType = CONFIG_ADD;
297 /*******************************************************************
299 * @brief updates LC Cfgs to be Added/Mod/Rel in RLC
303 * Function : updateRlcCfg
306 * updates LC Cfgs to be Add/Mod/Del in RLC
309 * RlcEntCfgInfo pointer
310 * RlcBearerCfg pointer
311 * @return ROK - Success
314 ******************************************************************/
316 uint8_t updateRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeRecfg *ueRecfg)
320 rlcUeCfg->ueId = ueRecfg->ueId;
321 rlcUeCfg->cellId = ueRecfg->cellId;
322 rlcUeCfg->transId = getTransId();
324 rlcUeCfg->numEnt = 0;
325 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
327 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgAdd[lcIdx]) != ROK)
329 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
332 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_ADD;
335 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
337 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgMod[lcIdx]) != ROK)
339 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
342 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_MOD;
345 for(lcIdx = 0; lcIdx < ueRecfg->numLcsToRel; lcIdx++)
347 if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgRel[lcIdx]) != ROK)
349 DU_LOG("\nERROR --> RLC : fillRlcCfg(): Failed to fill LC configuration");
352 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_DEL;
358 /*******************************************************************
360 * @brief Fill RlcCfgCfmInfo structure for sending failure response to DU
364 * Function : fillRlcCfgFailureRsp
367 * Fill RlcCfgCfmInfo structure for sending failure response to DU
369 * @params[in] RlcCfgCfmInfo *cfgRsp, RlcUeCreate *ueCfg
373 * ****************************************************************/
374 void fillRlcCfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeCreate *ueCfg)
378 cfgRsp->ueId = ueCfg->ueId;
379 cfgRsp->cellId = ueCfg->cellId;
380 cfgRsp->numEnt = ueCfg->numLcsToAdd;
381 for(cfgIdx =0; cfgIdx<ueCfg->numLcsToAdd; cfgIdx++)
383 cfgRsp->entCfgCfm[cfgIdx].rbId = ueCfg->rlcLcCfgAdd[cfgIdx].rbId;
384 cfgRsp->entCfgCfm[cfgIdx].rbType = ueCfg->rlcLcCfgAdd[cfgIdx].rbType;
385 cfgRsp->entCfgCfm[cfgIdx].status.status = RLC_DU_APP_RSP_NOK;
386 cfgRsp->entCfgCfm[cfgIdx].status.reason = CKW_CFG_REAS_NONE;
390 /*******************************************************************
392 * @brief Fill RlcCfgCfmInfo structure for sending failure response to DU
396 * Function : fillRlcRecfgFailureRsp
399 * Fill RlcCfgCfmInfo structure for sending failure response to DU
401 * @params[in] RlcCfgCfmInfo *cfgRsp, RlcUeCreate *ueCfg
405 * ****************************************************************/
406 void fillRlcRecfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeRecfg *ueRecfg)
410 cfgRsp->ueId = ueRecfg->ueId;
411 cfgRsp->cellId = ueRecfg->cellId;
413 for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToAdd; cfgIdx++)
415 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbId = ueRecfg->rlcLcCfgAdd[cfgIdx].rbId;
416 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbType = ueRecfg->rlcLcCfgAdd[cfgIdx].rbType;
417 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.status = RLC_DU_APP_RSP_NOK;
418 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.reason = CKW_CFG_REAS_NONE;
421 for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToMod; cfgIdx++)
423 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbId = ueRecfg->rlcLcCfgMod[cfgIdx].rbId;
424 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbType = ueRecfg->rlcLcCfgMod[cfgIdx].rbType;
425 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.status = RLC_DU_APP_RSP_NOK;
426 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.reason = CKW_CFG_REAS_NONE;
429 for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToRel; cfgIdx++)
431 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbId = ueRecfg->rlcLcCfgRel[cfgIdx].rbId;
432 cfgRsp->entCfgCfm[cfgRsp->numEnt].rbType = ueRecfg->rlcLcCfgRel[cfgIdx].rbType;
433 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.status = RLC_DU_APP_RSP_NOK;
434 cfgRsp->entCfgCfm[cfgRsp->numEnt].status.reason = CKW_CFG_REAS_NONE;
439 /*******************************************************************
441 * @brief Handles Ue Create Request from DU APP
445 * Function : RlcProcUeCreateReq
448 * Handles Ue create Request from DU APP
450 * @params[in] Post structure pointer
451 * RlcUeCreate pointer
452 * @return ROK - success
455 * ****************************************************************/
456 uint8_t RlcProcUeCreateReq(Pst *pst, RlcUeCreate *ueCfg)
460 RlcCfgInfo *rlcUeCfg = NULLP;
461 RlcCfgCfmInfo cfgRsp;
464 gCb = RLC_GET_RLCCB(pst->dstInst);
465 RLC_ALLOC(gCb, rlcUeCfg, sizeof(RlcCfgInfo));
466 if(rlcUeCfg == NULLP)
468 DU_LOG("\nERROR --> RLC: Failed to allocate memory at RlcProcUeCreateReq()");
473 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
474 ret = fillRlcCfg(gCb, rlcUeCfg, ueCfg);
477 DU_LOG("\nERROR --> RLC: Failed to fill configuration at RlcProcUeCreateReq()");
478 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_CREATE_RSP);
479 fillRlcCfgFailureRsp(&cfgRsp, ueCfg);
480 SendRlcUeCreateRspToDu(&rspPst, &cfgRsp);
485 ret = RlcProcCfgReq(pst, rlcUeCfg);
487 DU_LOG("\nERROR --> RLC: Failed to configure Add/Mod/Del entities at RlcProcUeCreateReq()");
490 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCreate));
494 /*******************************************************************
496 * @brief filling the structure of rrc delivery msg info
500 * Function : BuildAndSendRrcDeliveryReportToDu
502 * Functionality: filling the structure of rrc delivery msg info
504 * @return ROK - success
507 * ****************************************************************/
508 uint8_t BuildAndSendRrcDeliveryReportToDu( RlcDlRrcMsgInfo *dlRrcMsgInfo )
511 RrcDeliveryReport *rrcDelivery;
513 DU_LOG("\nINFO --> RLC : Filling RRC Delivery Report");
514 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, rrcDelivery, sizeof(RrcDeliveryReport));
518 rrcDelivery->cellId = dlRrcMsgInfo->cellId;
519 rrcDelivery->ueId = dlRrcMsgInfo->ueId;
520 rrcDelivery->srbId = dlRrcMsgInfo->lcId ;
521 rrcDelivery->rrcDeliveryStatus.deliveryStatus = PDCP_SN;
522 rrcDelivery->rrcDeliveryStatus.triggeringMessage = PDCP_SN;
524 /* Sending UL RRC Message transfeer to DU APP */
525 memset(&pst, 0, sizeof(Pst));
526 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RRC_DELIVERY_MSG_TRANS_TO_DU);
527 rlcSendRrcDeliveryReportToDu(&pst, rrcDelivery);
531 DU_LOG("\nERROR --> RLC : Memory allocation failed");
536 /* ****************************************************************
538 * @brief Process the DL RRC Message from DU APP
542 * Function : RlcProcDlRrcMsgTransfer
544 * Functionality: Process the DL RRC Message from DU APP
546 * @params[in] Post structure
547 * DL RRC Message info
548 * @return ROK - success
551 * ****************************************************************/
552 uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
555 RlcDatReqInfo *datReqInfo;
557 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
560 DU_LOG("\nERROR --> RLC : Memory allocation failed in RlcProcDlRrcMsgTransfer");
561 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
562 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
566 datReqInfo->rlcId.rbType = RB_TYPE_SRB;
567 datReqInfo->rlcId.rbId = dlRrcMsgInfo->lcId;
568 datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueId;
569 datReqInfo->rlcId.cellId = dlRrcMsgInfo->cellId;
570 datReqInfo->lcType = LCH_DCCH;
571 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
573 /* Copy fixed buffer to message */
574 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &mBuf) != ROK)
576 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
577 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
578 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
579 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
582 oduCpyFixBufToMsg(dlRrcMsgInfo->rrcMsg, mBuf, dlRrcMsgInfo->msgLen);
584 if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
589 /* RRC Delivery report is only send when RRC Delivery status report is true in DL RRC Message */
590 if(dlRrcMsgInfo->deliveryStaRpt)
592 BuildAndSendRrcDeliveryReportToDu(dlRrcMsgInfo);
595 /* Free memory allocated by du app */
596 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
597 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
598 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
602 /*******************************************************************
604 * @brief Process UL data from UE
608 * Function : RlcProcUlData
611 * This function receives the PDU from MAC.
612 * seggregates common and dedicated logical channel
613 * PDU and call respective handler.
616 * @return ROK - success
619 * ****************************************************************/
620 uint8_t RlcProcUlData(Pst *pst, RlcUlData *ulData)
624 uint8_t lcId; /* Logical Channel */
625 uint8_t numDLch = 0; /* Number of dedicated logical channel */
626 bool dLchPduPres; /* PDU received on dedicated logical channel */
627 RguLchDatInd dLchData[MAX_NUM_LC]; /* PDU info on dedicated logical channel */
628 RguDDatIndInfo *dLchUlDat; /* UL data on dedicated logical channel */
630 /* Initializing dedicated logical channel Database */
631 DU_LOG("\nDEBUG --> RLC: Received UL Data request from MAC");
632 for(idx = 0; idx < MAX_NUM_LC; idx++)
634 dLchData[idx].lcId = idx;
635 dLchData[idx].pdu.numPdu = 0;
639 /* Seggregate PDUs received on common and dedicated channels
640 * and call common channel's handler */
641 for(idx = 0; idx< ulData->numPdu; idx++)
645 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
646 sizeof(RguDDatIndInfo));
649 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
656 /* Copy fixed buffer to message */
657 lcId = ulData->pduInfo[idx].lcId;
658 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, \
659 &dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]) != ROK)
661 DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
662 for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
664 ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
666 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
667 sizeof(RguDDatIndInfo));
671 oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
672 dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
673 ulData->pduInfo[idx].pduLen);
675 dLchData[lcId].pdu.numPdu++;
678 /* If any PDU received on dedicated logical channel, copy into RguDDatIndInfo
679 * and call its handler */
684 dLchUlDat->cellId = ulData->cellId;
685 GET_UE_ID(ulData->rnti, dLchUlDat->rnti);
687 for(idx = 0; idx < MAX_NUM_LC; idx++)
689 if(dLchData[idx].pdu.numPdu)
691 memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
695 dLchUlDat->numLch = numDLch;
696 rlcProcDedLcUlData(pst, 0, dLchUlDat);
700 for(pduIdx = 0; pduIdx < ulData->numPdu; pduIdx++)
702 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData->pduInfo[pduIdx].pduBuf, \
703 ulData->pduInfo[pduIdx].pduLen);
705 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcUlData));
708 }/* End of RlcProcUlData */
710 /*******************************************************************
712 * @brief Handler for extracting common and dedicated channel
713 * Scheduling result report.
717 * Function : RlcProcSchedResultRpt
720 * Handler for extracting common and dedicated channel
721 * Scheduling result report
724 * @return ROK - success
727 * ****************************************************************/
728 uint8_t RlcProcSchedResultRpt(Pst *pst, RlcSchedResultRpt *schRep)
731 uint8_t idx; /* Iterator */
732 uint8_t nmbDLch = 0; /* Number of dedicated logical channles */
733 RguDStaIndInfo *dLchSchInfo; /* Dedicated logical channel scheduling result */
735 DU_LOG("\nDEBUG --> RLC : Received scheduling report from MAC");
736 for(idx=0; idx < schRep->numLc; idx++)
738 /* Fill status info structure if at least one channel's scheduling report is received */
741 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, dLchSchInfo, \
742 sizeof(RguDStaIndInfo));
745 DU_LOG("\nERROR --> RLC: RlcProcSchedResultRpt: Memory allocation failed for dLchSchInfo");
750 dLchSchInfo->cellId = schRep->cellId;
751 dLchSchInfo->nmbOfUeGrantPerTti = 1;
752 /* MAC sends Scheduling report for one UE at a time. Hence filling
753 only the 0th index of staInd */
754 dLchSchInfo->staInd[0].rnti = schRep->rnti;
756 /* Storing sfn/slot into a single 32-bit variable to be used later*/
757 dLchSchInfo->staInd[0].transId = schRep->slotInfo.sfn;
758 dLchSchInfo->staInd[0].transId = \
759 (dLchSchInfo->staInd[0].transId << 16) | schRep->slotInfo.slot;
760 dLchSchInfo->staInd[0].nmbOfTbs = 1;
761 dLchSchInfo->staInd[0].fillCtrlPdu = true;
764 /* Fill logical channel scheduling info */
765 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].lcId = \
766 schRep->lcSch[idx].lcId;
767 dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].totBufSize = \
768 schRep->lcSch[idx].bufSize;
772 /* Calling handler for all dedicated channels scheduling*/
777 dLchSchInfo->staInd[0].staIndTb[0].nmbLch = nmbDLch;
778 rlcProcDedLcSchedRpt(pst, 0, dLchSchInfo);
782 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, schRep, sizeof(RlcSchedResultRpt));
787 /*******************************************************************
789 * @brief Handles Ue Reconfig Request from DU APP
793 * Function : RlcProcUeReconfigReq
796 * Handles Ue Reconfig Request from DU APP
798 * @params[in] Post structure pointer
800 * @return ROK - success
803 * ****************************************************************/
804 uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeRecfg *ueRecfg)
807 RlcCfgInfo *rlcUeCfg = NULLP; //Seed code Rlc cfg struct
808 RlcCb *rlcUeCb = NULLP;
809 RlcCfgCfmInfo cfgRsp;
812 DU_LOG("\nDEBUG --> RLC: UE reconfig request received. CellID[%d] UEID[%d]",ueRecfg->cellId, ueRecfg->ueId);
814 rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
815 RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
816 if(rlcUeCfg == NULLP)
818 DU_LOG("\nERROR --> RLC: Failed to allocate memory at RlcProcUeReconfigReq()");
823 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
824 ret = updateRlcCfg(rlcUeCb, rlcUeCfg, ueRecfg);
827 DU_LOG("\nERROR --> RLC: Failed to fill configuration at RlcProcUeReconfigReq()");
828 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
829 fillRlcRecfgFailureRsp(&cfgRsp, ueRecfg);
830 SendRlcUeReconfigRspToDu(&rspPst, &cfgRsp);
834 ret = RlcProcCfgReq(pst, rlcUeCfg);
836 DU_LOG("\nERROR --> RLC: Failed to configure Add/Mod/Del entities at RlcProcUeReconfigReq()");
840 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(RlcUeRecfg));
844 /* ****************************************************************
846 * @brief Process the DL Data transfer from DU APP
850 * Function : RlcProcDlUserDataTransfer
852 * Functionality: Process the DL transfer from DU APP
854 * @params[in] Post structure
855 * DL RRC Message info
856 * @return ROK - success
859 * ****************************************************************/
860 uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
862 Buffer *mBuf = NULLP;
863 RlcDatReqInfo *datReqInfo = NULLP;
865 if(dlDataMsgInfo->dlMsg == NULLP)
867 DU_LOG("\nERROR --> RLC_DL : Received DL message is NULLP in RlcProcDlUserDataTransfer()");
870 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
873 DU_LOG("\nERROR --> RLC_DL : Memory allocation failed for DatReq in RlcProcDlUserDataTransfer()");
874 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
875 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
879 datReqInfo->rlcId.rbType = RB_TYPE_DRB;
880 datReqInfo->rlcId.rbId = dlDataMsgInfo->rbId;
881 datReqInfo->rlcId.ueId = dlDataMsgInfo->ueId;
882 datReqInfo->rlcId.cellId = dlDataMsgInfo->cellId;
883 datReqInfo->lcType = LCH_DTCH;
884 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
885 mBuf = dlDataMsgInfo->dlMsg;
886 if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
891 /* Free memory allocated by du app */
892 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
893 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
897 /*******************************************************************
899 * @brief sending UE delete response to DU
903 * Function : sendRlcUeDeleteRspToDu
906 * sending UE delete response to DU
908 * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult status
910 * @return ROK - success
913 * ****************************************************************/
914 uint8_t sendRlcUeDeleteRspToDu(uint16_t cellId,uint8_t ueId, CauseOfResult status)
917 RlcUeDeleteRsp *ueDeleteRsp = NULLP;
919 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_RSP);
921 RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
924 DU_LOG("\nERROR --> RLC: sendRlcUeDeleteRspToDu(): Memory allocation failed ");
929 ueDeleteRsp->cellId = cellId;
930 ueDeleteRsp->ueId = ueId;
931 ueDeleteRsp->status = status;
933 if(rlcSendUeDeleteRspToDu(&pst, ueDeleteRsp) == ROK)
935 DU_LOG("\nDEBUG --> RLC: UE Delete response send successfully");
939 DU_LOG("\nERROR --> RLC: SendRlcUeDeleteRspToDu():Failed to send UE Delete response to DU");
940 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
947 /*******************************************************************
949 * @brief Handles Ue delete Request from DU APP
953 * Function : RlcProcUeDeleteReq
956 * Handles Ue delete Request from DU APP
958 * @params[in] Post structure pointer
959 * RlcUeDelete pointer
960 * @return ROK - success
963 * ****************************************************************/
965 uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete)
968 RlcCb *gRlcCb = NULLP;
969 RlcUlUeCb *ueCb = NULLP;
970 CauseOfResult status =SUCCESSFUL;
972 DU_LOG("\nDEBUG --> RLC: UE Delete request received. CellID[%d] UEID[%d]",ueDelete->cellId, ueDelete->ueId);
974 if(ueDelete != NULLP)
976 gRlcCb = RLC_GET_RLCCB(pst->dstInst);
977 rlcDbmFetchUlUeCb(gRlcCb,ueDelete->ueId, ueDelete->cellId, &ueCb);
980 if(ueDelete->cellId == ueCb->cellId)
982 memcpy(&ueCb->ueDeleteInfo.pst, pst, sizeof(Pst));
983 if((rlcChkTmr(gRlcCb, (PTR)ueCb, EVENT_RLC_UE_DELETE_TMR)) == FALSE)
985 rlcStartTmr(gRlcCb,(PTR)ueCb, EVENT_RLC_UE_DELETE_TMR);
990 status = CELLID_INVALID;
995 status = UEID_INVALID;
998 if(status != SUCCESSFUL)
1000 ret = sendRlcUeDeleteRspToDu(ueDelete->cellId, ueDelete->ueId, status);
1003 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq():Failed to send UE Delete response to DU");
1006 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(RlcUeDelete));
1010 DU_LOG("\nERROR --> RLC: RlcProcUeDeleteReq(): Recieved NULL pointer UE Delete ");
1016 /*******************************************************************
1018 * @brief Send the Slice Metrics to DU APP
1022 * Function : sendSlicePmToDu
1025 * Handles the sending of Slice Metrics to DU APP
1027 * @params[in] Post structure pointer
1028 * SlicePmList *sliceStats pointer
1030 * @return ROK - success
1033 * ****************************************************************/
1034 uint8_t sendSlicePmToDu(SlicePmList *sliceStats)
1038 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_SLICE_PM_TO_DU);
1042 DU_LOG("\nERROR --> RLC: sendSlicePmToDu(): Memory allocation failed ");
1047 if(rlcSendSlicePmToDu(&pst, sliceStats) == ROK)
1049 DU_LOG("\nDEBUG --> RLC: Slice PM send successfully");
1053 DU_LOG("\nERROR --> RLC: sendSlicePmToDu():Failed to send Slice PM to DU");
1054 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, sliceStats, sizeof(SlicePmList));
1063 * Handler for searching the Slice Entry in Slice Metrics structure
1066 * This func finds the slice entry in the SliceMetric record structure and
1067 * return the index of the slice sot hat Tput entries can be done
1069 * @param[in] snssaiVal : Snssai Val to be searched
1070 * *snssaiIdx : O/P : Index of the Slice in Slice Metrics record
1071 * sliceStats : Pointer of Slice metrics record list
1073 * @return bool: True: If slice found in the record
1074 * False: If Slice not found; thus parent function will create the
1075 * recpord of this snssai
1078 bool rlcFindSliceEntry(SliceIdentifier snssaiVal, uint8_t *snssaiIdx, SlicePmList *sliceStats)
1080 uint8_t cntSlices = sliceStats->numSlice;
1082 for(*snssaiIdx = 0;(*snssaiIdx) < cntSlices; (*snssaiIdx)++)
1084 if((snssaiVal.sst == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sst)&&
1085 (snssaiVal.sd == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sd))
1094 /*******************************************************************
1096 * @brief Builds the Slice Performance Metrics structure to be sent to DU
1100 * Function : BuildSliceReportToDu
1103 * Builds the Slice Performance Metrics structure to be sent to DU
1105 * @params[in] uint8_t snssaiCnt
1107 * @return ROK - success
1110 * ****************************************************************/
1111 uint8_t BuildSliceReportToDu(uint8_t snssaiCnt)
1113 CmLList *node = NULLP;
1114 RlcTptPerSnssai *snssaiNode = NULLP;
1115 Direction dir = DIR_UL;
1116 SlicePmList *sliceStats = NULLP; /*Slice metric */
1117 SliceIdentifier snssaiVal ;
1118 uint8_t snssaiIdx = 0;
1122 DU_LOG("\nERROR --> RLC: No SNSSAI to send the SLice PM");
1126 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1127 if(sliceStats == NULLP)
1129 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
1132 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, snssaiCnt * (sizeof(SlicePm)));
1134 if(sliceStats->sliceRecord == NULLP)
1136 DU_LOG("\nERROR --> RLC: Memory Allocation Failed");
1137 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1140 while(dir < DIR_BOTH)
1142 node = arrTputPerSnssai[dir]->first;
1145 DU_LOG("\nERROR --> RLC: No SNSSAI in list");
1146 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1147 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, (snssaiCnt * (sizeof(SlicePm))));
1154 snssaiNode = (RlcTptPerSnssai *)node->node;
1156 snssaiVal.sst = snssaiNode->snssai->sst;
1157 snssaiVal.sd = snssaiNode->snssai->sd[2]+snssaiNode->snssai->sd[1]*10+snssaiNode->snssai->sd[0]*100;
1158 if(rlcFindSliceEntry(snssaiVal, &snssaiIdx, sliceStats) == FALSE)
1160 sliceStats->sliceRecord[snssaiIdx].networkSliceIdentifier = snssaiVal;
1161 sliceStats->numSlice++;
1165 sliceStats->sliceRecord[snssaiIdx].ThpUl = snssaiNode->tpt;
1169 sliceStats->sliceRecord[snssaiIdx].ThpDl = snssaiNode->tpt;
1176 sendSlicePmToDu(sliceStats);
1180 /*******************************************************************
1182 * @brief sending UE reestablishment response to DU
1186 * Function : sendRlcUeReestablishRspToDu
1189 * sending UE reestablishment response to DU
1191 * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult status
1193 * @return ROK - success
1196 * ****************************************************************/
1197 uint8_t sendRlcUeReestablishRspToDu(uint16_t cellId,uint8_t ueId, CauseOfResult status)
1200 RlcUeReestablishRsp *ueReestablishRsp = NULLP;
1202 FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_REESTABLISH_RSP);
1204 RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueReestablishRsp, sizeof(RlcUeReestablishRsp));
1205 if(!ueReestablishRsp)
1207 DU_LOG("\nERROR --> RLC: sendRlcUeReestablishRspToDu(): Memory allocation failed ");
1212 ueReestablishRsp->cellId = cellId;
1213 ueReestablishRsp->ueId = ueId;
1214 ueReestablishRsp->status = status;
1216 if(rlcSendUeReestablishRspToDu(&pst, ueReestablishRsp) == ROK)
1218 DU_LOG("\nDEBUG --> RLC: UE Reestablishment response send successfully");
1222 DU_LOG("\nERROR --> RLC: SendRlcUeReestablishRspToDu():Failed to send UE Reestablishment response to DU");
1223 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, ueReestablishRsp, sizeof(RlcUeReestablishRsp));
1230 /*******************************************************************
1232 * @brief Handles Ue reestablishment Request from DU APP
1236 * Function : RlcProcUeReestablishReq
1239 * Handles Ue reestablishment Request from DU APP
1241 * @params[in] Post structure pointer
1242 * RlcUeReestablishReq pointer
1243 * @return ROK - success
1246 * ****************************************************************/
1248 uint8_t RlcProcUeReestablishReq(Pst *pst, RlcUeReestablishReq *ueReestablishReq)
1250 uint8_t ret = RFAILED;
1251 RlcCb *gRlcCb = NULLP;
1252 RlcUlUeCb *ueCb = NULLP;
1253 CauseOfResult status =SUCCESSFUL;
1255 if(ueReestablishReq != NULLP)
1257 gRlcCb = RLC_GET_RLCCB(pst->dstInst);
1258 rlcDbmFetchUlUeCb(gRlcCb,ueReestablishReq->ueId, ueReestablishReq->cellId, &ueCb);
1261 if(ueReestablishReq->cellId == ueCb->cellId)
1264 * Step 1: Fill the RlcCfgInfo structure with data from the ueReestablishReq, just as we did in fillRlcCfg function and set
1265 * ConfigType = CONFIG_REESTABLISH
1266 * Step 2: To finish processing of Ue Reestablishment, call the RlcProcCfgReq function */
1270 status = CELLID_INVALID;
1271 DU_LOG("\nERROR --> SCH : RlcProcUeReestablishReq(): cell Id[%d] not found", ueReestablishReq->cellId);
1276 status = UEID_INVALID;
1277 DU_LOG("\nERROR --> SCH : RlcProcUeReestablishReq(): ue Id[%d] not found", ueReestablishReq->cellId);
1280 if(status != SUCCESSFUL)
1282 if(sendRlcUeReestablishRspToDu(ueReestablishReq->cellId, ueReestablishReq->ueId, status) != ROK)
1284 DU_LOG("\nERROR --> RLC: RlcProcUeReestablishReq():Failed to send UE Reestablishment response to DU");
1287 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReestablishReq, sizeof(RlcUeDelete));
1291 DU_LOG("\nERROR --> RLC: RlcProcUeReestablishReq(): Recieved NULL pointer UE Reestablishment ");
1295 /**********************************************************************
1297 **********************************************************************/