a102debcd8e603f0303955a8d39f64c4243596be
[o-du/l2.git] / src / 5gnrrlc / rlc_msg_hdl.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
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 */
26 #include "rlc_err.h"
27
28
29 /* header/extern include files (.x) */
30 #include "rgu.x"           
31 #include "lkw.x"           /* LKW */
32 #include "ckw.x"           /* CKW */
33 #include "kwu.x"           /* KWU */
34
35 #include "rlc_utils.h"            /* RLC defines */
36 #include "rlc_dl_ul_inf.h"
37 #include "rlc_dl.h"
38 #include "rlc_ul.h"
39 #include "rlc_mac_inf.h"
40 #include "du_app_rlc_inf.h"
41 #include "rlc_upr_inf_api.h"
42 #include "rlc_mgr.h"
43
44 /*******************************************************************
45  *
46  * @brief building and sending UE max retransmission info to DU 
47  *
48  * @details
49  *
50  *    Function : BuildAndSendRlcMaxRetransIndToDu 
51  *
52  *    Functionality:
53  *      Building and sending UE  max retransmission information to DU 
54  *
55  * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult  status 
56  *
57  * @return ROK     - success
58  *         RFAILED - failure
59  *
60  * ****************************************************************/
61 uint8_t BuildAndSendRlcMaxRetransIndToDu(uint16_t cellId,uint8_t ueId, uint8_t lcId, uint8_t lcType)
62 {
63    Pst pst;  
64    RlcMaxRetransInfo *maxRetransInfo = NULLP;
65    
66    FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_MAX_RETRANSMISSION);
67
68    RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, maxRetransInfo, sizeof(RlcMaxRetransInfo));
69    if(!maxRetransInfo)
70    {
71       DU_LOG("\nERROR  -->  RLC: sendRlcMaxRetransIndToDu(): Memory allocation failed ");
72       return RFAILED;
73    }
74    else
75    {
76       maxRetransInfo->cellId = cellId;
77       maxRetransInfo->ueId = ueId;
78       maxRetransInfo->lcId = lcId;
79       maxRetransInfo->lcType = lcType;
80   
81       if(rlcSendMaxRetransIndToDu(&pst, maxRetransInfo) == ROK)
82       {
83          DU_LOG("\nDEBUG  -->  RLC: UE [ %d] max retransmission information sent successfully",ueId);
84       }
85       else
86       {
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));
89          return RFAILED;
90       }
91    }
92    return ROK;
93 }
94
95 /*******************************************************************
96  *
97  * @brief Fills RLC UL UE Cfg Rsp from RlcCRsp 
98  *
99  * @details
100  *
101  *    Function : fillRlcUeCfgRsp
102  *
103  *    Functionality: 
104  *     Fills RLC UL UE Cfg Rsp from RlcCRsp
105  * 
106  *  @params[in]  Pointer to RlcCfgCfm
107  *               Pointer to RlcUeCfgRsp
108  *
109  *  @return ROK/RFAILED
110  * 
111  *****************************************************************/
112
113 uint8_t fillRlcUeCfgRsp(RlcUeCfgRsp *rlcCfgRsp, RlcCfgCfmInfo *rlcCRsp)
114 {
115    uint8_t idx;
116    uint8_t ret = ROK;
117  
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++)
122    {
123       if(rlcCRsp->entCfgCfm[idx].status.status == CKW_CFG_CFM_OK)
124       {
125          rlcCfgRsp->result = RLC_DU_APP_RSP_OK;
126          rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
127          ret = ROK;
128       }
129       else
130       {
131          rlcCfgRsp->result = RLC_DU_APP_RSP_NOK;
132          rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
133          ret = RFAILED;
134          break;
135       }
136    }
137    return ret;
138 }
139
140 /*******************************************************************
141  *
142  * @brief Fills the entity mode and direction compiling to seed code
143  *
144  * @details
145  *
146  *    Function : fillEntModeAndDir
147  *
148  *    Functionality:
149  *      Fills the entity mode and direction compiling to seed code
150  *
151  * @params[in] Pointer to entMode
152  *             Pointer to direction
153  *             RlcMode Param 
154  * @return void
155  * ****************************************************************/
156
157 void fillEntModeAndDir(uint8_t *entMode, uint8_t *direction, RlcMode rlcMode)
158 {
159    switch(rlcMode)
160    {
161       case RLC_AM:
162          *entMode   = RLC_MODE_AM;
163          *direction = RLC_CFG_DIR_BOTH;
164          break;
165       case RLC_UM_BI_DIRECTIONAL:
166          *entMode = RLC_MODE_UM;
167          *direction = RLC_CFG_DIR_BOTH;
168          break;
169       case RLC_UM_UNI_DIRECTIONAL_UL:
170          *entMode = RLC_MODE_UM;
171          *direction = RLC_CFG_DIR_UL;
172          break;
173       case RLC_UM_UNI_DIRECTIONAL_DL:
174          *entMode = RLC_MODE_UM;
175          *direction = RLC_CFG_DIR_DL;
176          break;
177       default : 
178          DU_LOG("\nERROR  -->  RLC: Rlc Mode invalid %d", rlcMode);
179     break;
180    }
181 }
182
183 /*******************************************************************
184  *
185  * @brief fills LC Cfgs to be Added in RLC
186  *
187  * @details
188  *
189  *    Function : fillLcCfg
190  *
191  *    Functionality:
192  *      fills LC Cfgs to be Added in RLC
193  *
194  * @params[in] 
195  *             RlcEntCfgInfo pointer
196  *             RlcBearerCfg pointer
197  *             Config Type 
198  * @return ROK -  SUCCESS
199  *         RFAILED - FAILURE
200  *
201  * ****************************************************************/
202 uint8_t fillLcCfg(RlcCb *gCb, RlcEntCfgInfo *rlcUeCfg, RlcBearerCfg *duRlcUeCfg)
203 {
204    uint8_t lChRbIdx = 0;
205
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)
211    {
212       RLC_ALLOC(gCb, rlcUeCfg->snssai, sizeof(Snssai));
213       if(rlcUeCfg->snssai == NULLP)
214       {
215          DU_LOG("\nERROR  --> RLC : fillLcCfg(): Failed to allocate memory for snssai");
216          return RFAILED;
217       }
218       memcpy(rlcUeCfg->snssai, duRlcUeCfg->snssai, sizeof(Snssai));
219    }
220    fillEntModeAndDir(&rlcUeCfg->entMode, &rlcUeCfg->dir, duRlcUeCfg->rlcMode);
221    switch(rlcUeCfg->entMode)
222    {
223
224       case RLC_MODE_AM:
225          {
226             /* DL AM INFO */
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;
232
233             /* UL AM INFO */
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;
240             break;
241          }
242       case RLC_MODE_UM:
243          {
244             /* UL UM CONFIG */
245             rlcUeCfg->m.umInfo.ul.snLen      = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm; 
246             rlcUeCfg->m.umInfo.ul.reAsmblTmr = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
247
248             /* DL UM CONFIG */
249             rlcUeCfg->m.umInfo.dl.snLen = duRlcUeCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm; 
250             break;
251          }
252       default:
253          break;
254    }/* End of switch(entMode) */
255    return ROK;
256 }
257
258 /*******************************************************************
259  *
260  * @brief fills LC Cfgs to be Added in RLC
261  *
262  * @details
263  *
264  *    Function : fillRlcCfg
265  *
266  *    Functionality:
267  *      fills LC Cfgs to be Add in RLC
268  *
269  * @params[in] 
270  *             RlcEntCfgInfo pointer
271  *             RlcBearerCfg pointer
272  * @return ROK - Success
273  *          RFAILED - Failure
274  *
275  ******************************************************************/
276
277 uint8_t fillRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeCfg *ueCfg)
278 {
279    uint8_t lcIdx;
280    
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++)
286    {
287       if(fillLcCfg(gCb, &rlcUeCfg->entCfg[lcIdx], &ueCfg->rlcLcCfgAdd[lcIdx]) != ROK)
288       {
289           DU_LOG("\nERROR  --> RLC : fillRlcCfg(): Failed to fill LC configuration");
290           return RFAILED;
291       }
292       rlcUeCfg->entCfg[lcIdx].cfgType = CONFIG_ADD; 
293    }
294    return ROK;
295 }
296
297 /*******************************************************************
298  *
299  * @brief updates LC Cfgs to be Added/Mod/Rel in RLC
300  *
301  * @details
302  *
303  *    Function : updateRlcCfg
304  *
305  *    Functionality:
306  *      updates LC Cfgs to be Add/Mod/Del in RLC
307  *
308  * @params[in] 
309  *             RlcEntCfgInfo pointer
310  *             RlcBearerCfg pointer
311  * @return ROK - Success
312  *          RFAILED - Failure
313  *
314  ******************************************************************/
315
316 uint8_t updateRlcCfg(RlcCb *gCb, RlcCfgInfo *rlcUeCfg, RlcUeRecfg *ueRecfg)
317 {
318    uint8_t lcIdx = 0;
319    
320    rlcUeCfg->ueId    = ueRecfg->ueId;
321    rlcUeCfg->cellId  = ueRecfg->cellId;
322    rlcUeCfg->transId = getTransId();
323    
324    rlcUeCfg->numEnt = 0;
325    for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
326    {
327       if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgAdd[lcIdx]) != ROK)
328       {
329           DU_LOG("\nERROR  --> RLC : fillRlcCfg(): Failed to fill LC configuration");
330           return RFAILED;
331       }
332       rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_ADD;
333       rlcUeCfg->numEnt++;
334    }
335    for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
336    {
337       if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgMod[lcIdx]) != ROK)
338       {
339           DU_LOG("\nERROR  --> RLC : fillRlcCfg(): Failed to fill LC configuration");
340           return RFAILED;
341       }
342       rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_MOD;
343       rlcUeCfg->numEnt++;
344    }
345    for(lcIdx = 0; lcIdx < ueRecfg->numLcsToRel; lcIdx++)
346    {
347       if(fillLcCfg(gCb, &rlcUeCfg->entCfg[rlcUeCfg->numEnt], &ueRecfg->rlcLcCfgRel[lcIdx]) != ROK)
348       {
349           DU_LOG("\nERROR  --> RLC : fillRlcCfg(): Failed to fill LC configuration");
350           return RFAILED;
351       }
352       rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CONFIG_DEL;
353       rlcUeCfg->numEnt++;
354    }
355    return ROK;
356 }
357
358 /*******************************************************************
359  *
360  * @brief Fill RlcCfgCfmInfo structure for sending failure response to DU
361  *
362  * @details
363  *
364  *    Function : fillRlcCfgFailureRsp
365  *
366  *    Functionality:
367  *      Fill RlcCfgCfmInfo structure for sending failure response to DU
368  *
369  * @params[in] RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg
370  *             
371  * @return void 
372  *
373  * ****************************************************************/
374 void fillRlcCfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg)
375 {
376    uint8_t cfgIdx =0;
377
378    cfgRsp->ueId = ueCfg->ueId;
379    cfgRsp->cellId = ueCfg->cellId;
380    cfgRsp->numEnt = ueCfg->numLcsToAdd;
381    for(cfgIdx =0; cfgIdx<ueCfg->numLcsToAdd; cfgIdx++)
382    {
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;
387    }
388 }
389
390 /*******************************************************************
391  *
392  * @brief Fill RlcCfgCfmInfo structure for sending failure response to DU
393  *
394  * @details
395  *
396  *    Function : fillRlcRecfgFailureRsp
397  *
398  *    Functionality:
399  *      Fill RlcCfgCfmInfo structure for sending failure response to DU
400  *
401  * @params[in] RlcCfgCfmInfo *cfgRsp, RlcUeCfg *ueCfg
402  *             
403  * @return void 
404  *
405  * ****************************************************************/
406 void fillRlcRecfgFailureRsp(RlcCfgCfmInfo *cfgRsp, RlcUeRecfg *ueRecfg)
407 {
408    uint8_t cfgIdx =0;
409
410    cfgRsp->ueId = ueRecfg->ueId;
411    cfgRsp->cellId = ueRecfg->cellId;
412    cfgRsp->numEnt = 0;
413    for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToAdd; cfgIdx++)
414    {
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;
419       cfgRsp->numEnt++;
420    }
421    for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToMod; cfgIdx++)
422    {
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;
427       cfgRsp->numEnt++;
428    }
429    for(cfgIdx =0; cfgIdx<ueRecfg->numLcsToRel; cfgIdx++)
430    {
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;
435       cfgRsp->numEnt++;
436    }
437 }
438
439 /*******************************************************************
440  *
441  * @brief Handles Ue Create Request from DU APP
442  *
443  * @details
444  *
445  *    Function : RlcProcUeCreateReq
446  *
447  *    Functionality:
448  *      Handles Ue create Request from DU APP
449  *
450  * @params[in] Post structure pointer
451  *             RlcUeCfg pointer 
452  * @return ROK     - success
453  *         RFAILED - failure
454  *
455  * ****************************************************************/
456 uint8_t RlcProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
457 {
458    uint8_t ret = ROK;
459    RlcCb *gCb;
460    RlcCfgInfo *rlcUeCfg = NULLP;
461    RlcCfgCfmInfo cfgRsp;
462    Pst rspPst;
463
464    gCb = RLC_GET_RLCCB(pst->dstInst);
465    RLC_ALLOC(gCb, rlcUeCfg, sizeof(RlcCfgInfo));
466    if(rlcUeCfg == NULLP)
467    {
468       DU_LOG("\nERROR  -->  RLC: Failed to allocate memory at RlcProcUeCreateReq()");
469       ret = RFAILED;
470    }
471    else
472    {
473       memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
474       ret = fillRlcCfg(gCb, rlcUeCfg, ueCfg); 
475       if(ret != ROK)
476       {
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          SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
481
482       }
483       else
484       {
485          ret = RlcProcCfgReq(pst, rlcUeCfg);
486          if(ret != ROK)
487             DU_LOG("\nERROR  -->  RLC: Failed to configure Add/Mod/Del entities at RlcProcUeCreateReq()");
488       }
489    }
490    RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
491    return ret;
492 }
493
494 /*******************************************************************
495 *
496 * @brief filling the structure of rrc delivery msg info
497 *
498 * @details
499 *
500 *    Function : BuildAndSendRrcDeliveryReportToDu
501 *
502 *    Functionality: filling the structure of rrc delivery msg info
503 *
504 * @return ROK     - success
505 *         RFAILED - failure
506 *
507 * ****************************************************************/
508 uint8_t BuildAndSendRrcDeliveryReportToDu( RlcDlRrcMsgInfo *dlRrcMsgInfo )
509 {
510     Pst             pst;
511     RrcDeliveryReport *rrcDelivery;
512
513     DU_LOG("\nINFO  -->  RLC : Filling RRC Delivery Report");
514     RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, rrcDelivery, sizeof(RrcDeliveryReport));
515
516     if(rrcDelivery)
517     {
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;
523
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);
528     }
529     else
530     {
531        DU_LOG("\nERROR  -->  RLC : Memory allocation failed");
532     }
533
534    return ROK;
535 }
536 /* ****************************************************************
537  *
538  * @brief Process the DL RRC Message from DU APP
539  *
540  * @details
541  *
542  *    Function : RlcProcDlRrcMsgTransfer
543  *
544  *    Functionality: Process the DL RRC Message from DU APP
545  *
546  * @params[in] Post structure
547  *             DL RRC Message info
548  * @return ROK     - success
549  *         RFAILED - failure
550  *
551  * ****************************************************************/
552 uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
553 {
554    Buffer        *mBuf;
555    RlcDatReqInfo *datReqInfo;
556
557    RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
558    if(!datReqInfo)
559    {
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));
563       return RFAILED;
564    }
565
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);
572
573    /* Copy fixed buffer to message */
574    if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &mBuf) != ROK)
575    {
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));
580       return RFAILED;
581    }
582    oduCpyFixBufToMsg(dlRrcMsgInfo->rrcMsg, mBuf, dlRrcMsgInfo->msgLen);
583
584    if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
585    {
586       return RFAILED;
587    }
588
589    /* RRC Delivery report is only send when RRC Delivery status report is true in DL RRC Message */
590    if(dlRrcMsgInfo->deliveryStaRpt)
591    {
592       BuildAndSendRrcDeliveryReportToDu(dlRrcMsgInfo);
593    }
594
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));
599    return ROK;
600 }
601
602 /*******************************************************************
603  *
604  * @brief Process UL data from UE
605  *
606  * @details
607  *
608  *    Function : RlcProcUlData
609  *
610  *    Functionality:
611  *       This function receives the PDU from MAC.
612  *       seggregates common and dedicated logical channel
613  *       PDU and call respective handler.
614  *
615  * @params[in]
616  * @return ROK     - success
617  *         RFAILED - failure
618  *
619  * ****************************************************************/
620 uint8_t RlcProcUlData(Pst *pst, RlcUlData *ulData)
621 {
622    uint8_t         ret = ROK;
623    uint8_t         idx, pduIdx;
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 */
629
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++)
633    {
634       dLchData[idx].lcId = idx;
635       dLchData[idx].pdu.numPdu = 0;
636    }
637    dLchPduPres = FALSE;
638
639    /* Seggregate PDUs received on common and dedicated channels
640     * and call common channel's handler */
641    for(idx = 0; idx< ulData->numPdu; idx++)
642    {
643       if(!dLchPduPres)
644       {
645          RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
646                sizeof(RguDDatIndInfo));
647          if(!dLchUlDat)
648          {
649             DU_LOG("\nERROR  -->  RLC : Memory allocation failed at RlcMacProcUlData");
650             ret = RFAILED;
651             break;
652          }
653          dLchPduPres = TRUE;
654       }
655
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)
660       {
661          DU_LOG("\nERROR  -->  RLC : Memory allocation failed at RlcMacProcUlData");
662          for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
663          {
664             ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
665          }
666          RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
667                sizeof(RguDDatIndInfo));
668          ret = RFAILED;
669          break;
670       }
671       oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
672             dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
673             ulData->pduInfo[idx].pduLen);
674
675       dLchData[lcId].pdu.numPdu++;
676    }
677
678    /* If any PDU received on dedicated logical channel, copy into RguDDatIndInfo
679     * and call its handler */
680    if(ret == ROK)
681    {
682       if(dLchPduPres)
683       {
684          dLchUlDat->cellId = ulData->cellId;
685          GET_UE_ID(ulData->rnti, dLchUlDat->rnti);
686
687          for(idx = 0; idx < MAX_NUM_LC; idx++)
688          {
689             if(dLchData[idx].pdu.numPdu)
690             {
691                memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
692                numDLch++;
693             }
694          }
695          dLchUlDat->numLch = numDLch;
696          rlcProcDedLcUlData(pst, 0, dLchUlDat);
697       }
698    }
699
700    for(pduIdx = 0; pduIdx < ulData->numPdu; pduIdx++)
701    {
702       RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData->pduInfo[pduIdx].pduBuf, \
703             ulData->pduInfo[pduIdx].pduLen);
704    }
705    RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcUlData));
706    return ROK;
707
708 }/* End of RlcProcUlData */
709
710 /*******************************************************************
711  *
712  * @brief Handler for extracting common and dedicated channel
713  *      Scheduling result report.
714  *
715  * @details
716  *
717  *    Function : RlcProcSchedResultRpt
718  *
719  *    Functionality:
720  *     Handler for extracting common and dedicated channel
721  *      Scheduling result report
722  *
723  * @params[in]
724  * @return ROK     - success
725  *         RFAILED - failure
726  *
727  * ****************************************************************/
728 uint8_t RlcProcSchedResultRpt(Pst *pst, RlcSchedResultRpt *schRep)
729 {
730    uint8_t ret = ROK;
731    uint8_t idx;                     /* Iterator */
732    uint8_t nmbDLch = 0;                 /* Number of dedicated logical channles */
733    RguDStaIndInfo   *dLchSchInfo;  /* Dedicated logical channel scheduling result */
734
735    DU_LOG("\nDEBUG  -->  RLC : Received scheduling report from MAC");
736    for(idx=0; idx < schRep->numLc; idx++)
737    {
738       /* Fill status info structure if at least one channel's scheduling report is received */
739       if(nmbDLch == 0)
740       {
741          RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, dLchSchInfo, \
742                sizeof(RguDStaIndInfo));
743          if(!dLchSchInfo)
744          {
745             DU_LOG("\nERROR  -->  RLC: RlcProcSchedResultRpt: Memory allocation failed for dLchSchInfo");
746             ret = RFAILED;
747             break;
748          }
749
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;
755
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; 
762       }
763
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;
769       nmbDLch++;
770    }
771
772    /* Calling handler for all dedicated channels scheduling*/
773    if(ret == ROK)
774    {
775       if(nmbDLch)
776       {
777          dLchSchInfo->staInd[0].staIndTb[0].nmbLch = nmbDLch;
778          rlcProcDedLcSchedRpt(pst, 0, dLchSchInfo);
779       }
780    }
781
782    RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, schRep, sizeof(RlcSchedResultRpt));
783    return ret;
784 }
785
786
787 /*******************************************************************
788  *
789  * @brief Handles Ue Reconfig Request from DU APP
790  *
791  * @details
792  *
793  *    Function : RlcProcUeReconfigReq
794  *
795  *    Functionality:
796  *      Handles Ue Reconfig Request from DU APP
797  *
798  * @params[in] Post structure pointer
799  *             RlcUeCfg pointer 
800  * @return ROK     - success
801  *         RFAILED - failure
802  *
803  * ****************************************************************/
804 uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeRecfg *ueRecfg)
805 {
806    uint8_t ret = ROK;
807    RlcCfgInfo *rlcUeCfg = NULLP; //Seed code Rlc cfg struct
808    RlcCb *rlcUeCb = NULLP;
809    RlcCfgCfmInfo cfgRsp; 
810    Pst rspPst;
811    
812    DU_LOG("\nDEBUG  -->  RLC: UE reconfig request received. CellID[%d] UEID[%d]",ueRecfg->cellId, ueRecfg->ueId);
813
814    rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
815    RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
816    if(rlcUeCfg == NULLP)
817    {
818       DU_LOG("\nERROR  -->  RLC: Failed to allocate memory at RlcProcUeReconfigReq()");
819       ret = RFAILED;
820    }
821    else
822    {
823       memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
824       ret = updateRlcCfg(rlcUeCb, rlcUeCfg, ueRecfg);
825       if(ret != ROK)
826       {
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          SendRlcUeCfgRspToDu(&rspPst, &cfgRsp);
831       }
832       else
833       {
834          ret = RlcProcCfgReq(pst, rlcUeCfg);
835          if(ret != ROK)
836             DU_LOG("\nERROR  -->  RLC: Failed to configure Add/Mod/Del entities at RlcProcUeReconfigReq()");
837       }
838    }
839    
840    RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueRecfg, sizeof(RlcUeRecfg));
841    return ret;
842 }
843
844 /* ****************************************************************
845  *
846  * @brief Process the DL Data transfer from DU APP
847  *
848  * @details
849  *
850  *    Function : RlcProcDlUserDataTransfer
851  *
852  *    Functionality: Process the DL transfer from DU APP
853  *
854  * @params[in] Post structure
855  *             DL RRC Message info
856  * @return ROK     - success
857  *         RFAILED - failure
858  *
859  * ****************************************************************/
860 uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
861 {
862    Buffer        *mBuf = NULLP;
863    RlcDatReqInfo *datReqInfo = NULLP;
864
865    if(dlDataMsgInfo->dlMsg == NULLP)
866    {
867       DU_LOG("\nERROR  -->  RLC_DL : Received DL message is NULLP in RlcProcDlUserDataTransfer()");
868       return RFAILED;
869    }
870    RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
871    if(!datReqInfo)
872    {
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));
876       return RFAILED;
877    }
878
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)
887    {
888       return RFAILED;
889    }
890     
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));
894    return ROK;
895 }
896
897 /*******************************************************************
898  *
899  * @brief sending UE delete response to DU 
900  *
901  * @details
902  *
903  *    Function : sendRlcUeDeleteRspToDu 
904  *
905  *    Functionality:
906  *      sending UE delete response to DU 
907  *
908  * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult  status 
909  *
910  * @return ROK     - success
911  *         RFAILED - failure
912  *
913  * ****************************************************************/
914 uint8_t sendRlcUeDeleteRspToDu(uint16_t cellId,uint8_t ueId, CauseOfResult  status)
915 {
916    Pst pst;  
917    RlcUeDeleteRsp *ueDeleteRsp = NULLP;
918    
919    FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_RSP);
920
921    RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueDeleteRsp, sizeof(RlcUeDeleteRsp));
922    if(!ueDeleteRsp)
923    {
924       DU_LOG("\nERROR  -->  RLC: sendRlcUeDeleteRspToDu(): Memory allocation failed ");
925       return RFAILED;
926    }
927    else
928    {
929       ueDeleteRsp->cellId = cellId;
930       ueDeleteRsp->ueId = ueId;
931       ueDeleteRsp->status = status;
932   
933       if(rlcSendUeDeleteRspToDu(&pst, ueDeleteRsp) == ROK)
934       {
935          DU_LOG("\nDEBUG  -->  RLC: UE Delete response send successfully");
936       }
937       else
938       {
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));
941          return RFAILED;
942       }
943    }
944    return ROK;
945 }
946
947 /*******************************************************************
948 *
949 * @brief Handles Ue delete Request from DU APP
950 *
951 * @details
952 *
953 *    Function : RlcProcUeDeleteReq
954 *
955 *    Functionality:
956 *      Handles Ue delete Request from DU APP
957 *
958 * @params[in] Post structure pointer
959 *             RlcUeDelete pointer
960 * @return ROK     - success
961 *         RFAILED - failure
962 *
963 * ****************************************************************/
964
965 uint8_t RlcProcUeDeleteReq(Pst *pst, RlcUeDelete *ueDelete)
966 {
967    uint8_t ret = ROK;
968    RlcCb *gRlcCb = NULLP;
969    RlcUlUeCb *ueCb = NULLP;
970    CauseOfResult  status =SUCCESSFUL;
971
972    DU_LOG("\nDEBUG  -->  RLC: UE Delete request received. CellID[%d] UEID[%d]",ueDelete->cellId, ueDelete->ueId);
973
974    if(ueDelete != NULLP)
975    {
976       gRlcCb = RLC_GET_RLCCB(pst->dstInst);
977       rlcDbmFetchUlUeCb(gRlcCb,ueDelete->ueId, ueDelete->cellId, &ueCb);
978       if(ueCb != NULLP)
979       {
980          if(ueDelete->cellId == ueCb->cellId)
981          {
982             memcpy(&ueCb->ueDeleteInfo.pst, pst, sizeof(Pst));
983             if((rlcChkTmr(gRlcCb, (PTR)ueCb, EVENT_RLC_UE_DELETE_TMR)) == FALSE)
984             {
985                rlcStartTmr(gRlcCb,(PTR)ueCb, EVENT_RLC_UE_DELETE_TMR);
986             }
987          }
988          else
989          {
990             status = CELLID_INVALID;
991          }
992       }
993       else
994       {
995          status = UEID_INVALID;
996       }
997
998       if(status != SUCCESSFUL)
999       {
1000          ret = sendRlcUeDeleteRspToDu(ueDelete->cellId, ueDelete->ueId, status);
1001          if(ret != ROK)
1002          {
1003             DU_LOG("\nERROR  -->  RLC: RlcProcUeDeleteReq():Failed to send UE Delete response to DU");
1004          }
1005       }
1006       RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(RlcUeDelete));
1007    }
1008    else
1009    {
1010       DU_LOG("\nERROR  -->  RLC: RlcProcUeDeleteReq(): Recieved NULL pointer UE Delete ");
1011       ret = RFAILED;
1012    }
1013    return ret;
1014 }
1015
1016 /*******************************************************************
1017 *
1018 * @brief Send the Slice Metrics to  DU APP
1019 *
1020 * @details
1021 *
1022 *    Function : sendSlicePmToDu
1023 *
1024 *    Functionality:
1025 *      Handles the sending of Slice Metrics to  DU APP
1026 *
1027 * @params[in] Post structure pointer
1028 *             SlicePmList *sliceStats pointer
1029 *
1030 * @return ROK     - success
1031 *         RFAILED - failure
1032 *
1033 * ****************************************************************/
1034 uint8_t sendSlicePmToDu(SlicePmList *sliceStats)
1035 {
1036    Pst pst;  
1037    
1038    FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_SLICE_PM_TO_DU);
1039
1040    if(!sliceStats)
1041    {
1042       DU_LOG("\nERROR  -->  RLC: sendSlicePmToDu(): Memory allocation failed ");
1043       return RFAILED;
1044    }
1045    else
1046    {
1047       if(rlcSendSlicePmToDu(&pst, sliceStats) == ROK)
1048       {
1049          DU_LOG("\nDEBUG  -->  RLC: Slice PM send successfully");
1050       }
1051       else
1052       {
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));
1055          return RFAILED;
1056       }
1057    }
1058    return ROK;
1059 }
1060
1061 /**
1062  * @brief 
1063  *    Handler for searching the Slice Entry in Slice Metrics structure
1064  *
1065  * @details
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
1068  *
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
1072  *
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
1076  *   
1077  */
1078 bool rlcFindSliceEntry(SliceIdentifier snssaiVal, uint8_t *snssaiIdx, SlicePmList *sliceStats)
1079 {
1080    uint8_t cntSlices = sliceStats->numSlice;
1081
1082    for(*snssaiIdx = 0;(*snssaiIdx) < cntSlices; (*snssaiIdx)++)
1083    {
1084       if((snssaiVal.sst == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sst)&&
1085             (snssaiVal.sd == sliceStats->sliceRecord[*snssaiIdx].networkSliceIdentifier.sd))
1086       {
1087          return TRUE;
1088       }
1089    }
1090    return FALSE;
1091 }
1092
1093
1094 /*******************************************************************
1095 *
1096 * @brief Builds the Slice Performance Metrics structure to be sent to DU
1097 *
1098 * @details
1099 *
1100 *    Function : BuildSliceReportToDu
1101 *
1102 *    Functionality:
1103 *      Builds the Slice Performance Metrics structure to be sent to DU
1104 *
1105 * @params[in] uint8_t snssaiCnt
1106 *             
1107 * @return ROK     - success
1108 *         RFAILED - failure
1109 *
1110 * ****************************************************************/
1111 uint8_t BuildSliceReportToDu(uint8_t snssaiCnt)
1112 {
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;
1119
1120    if(snssaiCnt == 0)
1121    {
1122       DU_LOG("\nERROR  -->  RLC: No SNSSAI to send the SLice PM");
1123       return RFAILED;
1124    }
1125
1126    RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1127    if(sliceStats == NULLP)
1128    {
1129       DU_LOG("\nERROR  -->  RLC: Memory Allocation Failed");
1130       return RFAILED;
1131    }
1132    RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats->sliceRecord, snssaiCnt * (sizeof(SlicePm)));
1133
1134    if(sliceStats->sliceRecord == NULLP)
1135    {
1136       DU_LOG("\nERROR  -->  RLC: Memory Allocation Failed");
1137       RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, sliceStats, sizeof(SlicePmList));
1138       return RFAILED;
1139    }
1140    while(dir < DIR_BOTH)
1141    {
1142       node = arrTputPerSnssai[dir]->first;
1143       if(node == NULLP)
1144       {
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))));
1148          return RFAILED;
1149       }
1150
1151       while(node)
1152       {
1153          snssaiIdx = 0;
1154          snssaiNode = (RlcTptPerSnssai *)node->node;
1155
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)
1159          {
1160             sliceStats->sliceRecord[snssaiIdx].networkSliceIdentifier = snssaiVal;
1161             sliceStats->numSlice++;
1162          }
1163          if(dir == DIR_UL)
1164          {
1165             sliceStats->sliceRecord[snssaiIdx].ThpUl = snssaiNode->tpt;
1166          }
1167          else
1168          {
1169             sliceStats->sliceRecord[snssaiIdx].ThpDl = snssaiNode->tpt;
1170          }
1171          node = node->next;
1172       }
1173       dir++;
1174    }
1175    
1176    sendSlicePmToDu(sliceStats);
1177    return ROK;
1178 }
1179
1180 /*******************************************************************
1181  *
1182  * @brief sending UE reestablishment response to DU 
1183  *
1184  * @details
1185  *
1186  *    Function : sendRlcUeReestablishRspToDu 
1187  *
1188  *    Functionality:
1189  *      sending UE reestablishment response to DU 
1190  *
1191  * @params[in] uint8_t cellId, uint8_t ueId, CauseOfResult  status 
1192  *
1193  * @return ROK     - success
1194  *         RFAILED - failure
1195  *
1196  * ****************************************************************/
1197 uint8_t sendRlcUeReestablishRspToDu(uint16_t cellId,uint8_t ueId, CauseOfResult  status)
1198 {
1199    Pst pst;  
1200    RlcUeReestablishRsp *ueReestablishRsp = NULLP;
1201    
1202    FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RLC_UE_REESTABLISH_RSP);
1203
1204    RLC_ALLOC_SHRABL_BUF(pst.region, pst.pool, ueReestablishRsp, sizeof(RlcUeReestablishRsp));
1205    if(!ueReestablishRsp)
1206    {
1207       DU_LOG("\nERROR  -->  RLC: sendRlcUeReestablishRspToDu(): Memory allocation failed ");
1208       return RFAILED;
1209    }
1210    else
1211    {
1212       ueReestablishRsp->cellId = cellId;
1213       ueReestablishRsp->ueId = ueId;
1214       ueReestablishRsp->status = status;
1215   
1216       if(rlcSendUeReestablishRspToDu(&pst, ueReestablishRsp) == ROK)
1217       {
1218          DU_LOG("\nDEBUG  -->  RLC: UE Reestablishment response send successfully");
1219       }
1220       else
1221       {
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));
1224          return RFAILED;
1225       }
1226    }
1227    return ROK;
1228 }
1229
1230 /*******************************************************************
1231 *
1232 * @brief Handles Ue reestablishment Request from DU APP
1233 *
1234 * @details
1235 *
1236 *    Function : RlcProcUeReestablishReq
1237 *
1238 *    Functionality:
1239 *      Handles Ue reestablishment Request from DU APP
1240 *
1241 * @params[in] Post structure pointer
1242 *             RlcUeReestablishReq pointer
1243 * @return ROK     - success
1244 *         RFAILED - failure
1245 *
1246 * ****************************************************************/
1247
1248 uint8_t RlcProcUeReestablishReq(Pst *pst, RlcUeReestablishReq *ueReestablishReq)
1249 {
1250    uint8_t ret = RFAILED;
1251    RlcCb *gRlcCb = NULLP;
1252    RlcUlUeCb *ueCb = NULLP;
1253    CauseOfResult  status =SUCCESSFUL;
1254
1255    if(ueReestablishReq != NULLP)
1256    {
1257       gRlcCb = RLC_GET_RLCCB(pst->dstInst);
1258       rlcDbmFetchUlUeCb(gRlcCb,ueReestablishReq->ueId, ueReestablishReq->cellId, &ueCb);
1259       if(ueCb != NULLP)
1260       {
1261          if(ueReestablishReq->cellId == ueCb->cellId)
1262          {
1263             /* TODO : 
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 */
1267          }
1268          else
1269          {
1270             status = CELLID_INVALID;
1271             DU_LOG("\nERROR  -->  SCH : RlcProcUeReestablishReq(): cell Id[%d] not found", ueReestablishReq->cellId);
1272          }
1273       }
1274       else
1275       {
1276          status = UEID_INVALID;
1277          DU_LOG("\nERROR  -->  SCH : RlcProcUeReestablishReq(): ue Id[%d] not found", ueReestablishReq->cellId);
1278       }
1279
1280       if(status != SUCCESSFUL)
1281       {
1282          if(sendRlcUeReestablishRspToDu(ueReestablishReq->cellId, ueReestablishReq->ueId, status)  != ROK)
1283          {
1284             DU_LOG("\nERROR  -->  RLC: RlcProcUeReestablishReq():Failed to send UE Reestablishment response to DU");
1285          }
1286       }
1287       RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueReestablishReq, sizeof(RlcUeDelete));
1288    }
1289    else
1290    {
1291       DU_LOG("\nERROR  -->  RLC: RlcProcUeReestablishReq(): Recieved NULL pointer UE Reestablishment ");
1292    }
1293    return ret;
1294 }
1295 /**********************************************************************
1296   End of file
1297  **********************************************************************/