DL throughput calculation for UM [Issue-ID: ODUHIGH-319]
[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 "kw_env.h"        /* RLC environment options */
26 #include "kw.h"            /* RLC defines */
27 #include "kw_udx.h"
28 #include "kw_ul.h"
29 #include "kw_dl.h"
30
31 /* header/extern include files (.x) */
32 #include "rgu.x"           
33 #include "lkw.x"           /* LKW */
34 #include "ckw.x"           /* CKW */
35 #include "kwu.x"           /* KWU */
36 #include "kw_err.h"
37 #include "kw.x"
38 #include "kw_udx.x"
39 #include "kw_dl.x"
40 #include "kw_ul.x"
41
42 #include "rlc_mac_inf.h"
43 #include "du_app_rlc_inf.h"
44 #include "rlc_utils.h"
45 #include "rlc_upr_inf_api.h"
46 /*******************************************************************
47  *
48  * @brief Fills RLC UL UE Cfg Rsp from RlcCRsp 
49  *
50  * @details
51  *
52  *    Function : fillRlcUeCfgRsp
53  *
54  *    Functionality: 
55  *     Fills RLC UL UE Cfg Rsp from RlcCRsp
56  * 
57  *  @params[in]  Pointer to RlcCfgCfm
58  *               Pointer to RlcUeCfgRsp
59  *
60  *  @return ROK/RFAILED
61  * 
62  *****************************************************************/
63
64 uint8_t fillRlcUeCfgRsp(RlcUeCfgRsp *rlcCfgRsp, RlcCfgCfmInfo *rlcCRsp)
65 {
66    uint8_t idx;
67    uint8_t ret = ROK;
68  
69    rlcCfgRsp->cellId = rlcCRsp->cellId;
70    rlcCfgRsp->ueIdx  = rlcCRsp->ueId;
71    for(idx = 0; idx < rlcCRsp->numEnt; idx++)
72    {
73       if(rlcCRsp->entCfgCfm[idx].status.status == CKW_CFG_CFM_OK)
74       {
75          rlcCfgRsp->result = RLC_DU_APP_RSP_OK;
76          rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
77          ret = ROK;
78       }
79       else
80       {
81          rlcCfgRsp->result = RLC_DU_APP_RSP_NOK;
82          rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
83          ret = RFAILED;
84          break;
85       }
86    }
87    return ret;
88 }
89
90 /*******************************************************************
91  *
92  * @brief Fills the entity mode and direction compiling to seed code
93  *
94  * @details
95  *
96  *    Function : fillEntModeAndDir
97  *
98  *    Functionality:
99  *      Fills the entity mode and direction compiling to seed code
100  *
101  * @params[in] Pointer to entMode
102  *             Pointer to direction
103  *             RlcMode Param 
104  * @return void
105  * ****************************************************************/
106
107 void fillEntModeAndDir(uint8_t *entMode, uint8_t *direction, RlcMode rlcMode)
108 {
109    switch(rlcMode)
110    {
111       case RLC_AM:
112          *entMode   = RLC_MODE_AM;
113          *direction = RLC_CFG_DIR_BOTH;
114          break;
115       case RLC_UM_BI_DIRECTIONAL:
116          *entMode = RLC_MODE_UM;
117          *direction = RLC_CFG_DIR_BOTH;
118          break;
119       case RLC_UM_UNI_DIRECTIONAL_UL:
120          *entMode = RLC_MODE_UM;
121          *direction = RLC_CFG_DIR_UL;
122          break;
123       case RLC_UM_UNI_DIRECTIONAL_DL:
124          *entMode = RLC_MODE_UM;
125          *direction = RLC_CFG_DIR_DL;
126          break;
127       default : 
128          DU_LOG("\nERROR  -->  RLC: Rlc Mode invalid %d", rlcMode);
129     break;
130    }
131 }
132
133 /*******************************************************************
134  *
135  * @brief fills LC Cfgs to be Added in RLC
136  *
137  * @details
138  *
139  *    Function : fillLcCfg
140  *
141  *    Functionality:
142  *      fills LC Cfgs to be Added in RLC
143  *
144  * @params[in] 
145  *             RlcEntCfgInfo pointer
146  *             RlcBearerCfg pointer
147  *             Config Type 
148  * @return void
149  *
150  * ****************************************************************/
151 void fillLcCfg(RlcEntCfgInfo *rlcUeCfg, RlcBearerCfg *duRlcUeCfg, uint8_t cfgType)
152 {
153    uint8_t lChRbIdx = 0;
154
155    rlcUeCfg->rbId                  = duRlcUeCfg->rbId;
156    rlcUeCfg->rbType                = duRlcUeCfg->rbType;   // SRB or DRB
157    rlcUeCfg->lCh[lChRbIdx].lChId   = duRlcUeCfg->lcId;   
158    rlcUeCfg->lCh[lChRbIdx].type    = duRlcUeCfg->lcType;
159    fillEntModeAndDir(&rlcUeCfg->entMode, &rlcUeCfg->dir, duRlcUeCfg->rlcMode);
160    rlcUeCfg->cfgType               = cfgType;
161    switch(rlcUeCfg->entMode)
162    {
163
164       case RLC_MODE_AM:
165          {
166             /* DL AM INFO */
167             rlcUeCfg->m.amInfo.dl.snLen       = duRlcUeCfg->u.amCfg->dlAmCfg.snLenDl; 
168             rlcUeCfg->m.amInfo.dl.pollRetxTmr = duRlcUeCfg->u.amCfg->dlAmCfg.pollRetxTmr;
169             rlcUeCfg->m.amInfo.dl.pollPdu     = duRlcUeCfg->u.amCfg->dlAmCfg.pollPdu; 
170             rlcUeCfg->m.amInfo.dl.pollByte    = duRlcUeCfg->u.amCfg->dlAmCfg.pollByte; 
171             rlcUeCfg->m.amInfo.dl.maxRetx     = duRlcUeCfg->u.amCfg->dlAmCfg.maxRetxTh;
172
173             /* UL AM INFO */
174             lChRbIdx++;   //lChRbIdx = 1, indicates UL AM
175             rlcUeCfg->lCh[lChRbIdx].lChId    = duRlcUeCfg->lcId;   
176             rlcUeCfg->lCh[lChRbIdx].type     = duRlcUeCfg->lcType;
177             rlcUeCfg->m.amInfo.ul.snLen      = duRlcUeCfg->u.amCfg->ulAmCfg.snLenUl; 
178             rlcUeCfg->m.amInfo.ul.staProhTmr = duRlcUeCfg->u.amCfg->ulAmCfg.statProhTmr;
179             rlcUeCfg->m.amInfo.ul.reAsmblTmr   = duRlcUeCfg->u.amCfg->ulAmCfg.reAssemTmr * RLC_REASSEMBLY_TMR_BASE;
180             break;
181          }
182       case RLC_MODE_UM:
183          {
184             /* UL UM CONFIG */
185             rlcUeCfg->m.umInfo.ul.snLen      = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm; 
186             rlcUeCfg->m.umInfo.ul.reAsmblTmr = duRlcUeCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr * RLC_REASSEMBLY_TMR_BASE;
187
188             /* DL UM CONFIG */
189             rlcUeCfg->m.umInfo.dl.snLen = duRlcUeCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm; 
190             break;
191          }
192       default:
193          break;
194    }/* End of switch(entMode) */
195 }
196
197 /*******************************************************************
198  *
199  * @brief fills LC Cfgs to be Added in RLC
200  *
201  * @details
202  *
203  *    Function : fillRlcCfg
204  *
205  *    Functionality:
206  *      fills LC Cfgs to be Add/Mod/Del in RLC
207  *
208  * @params[in] 
209  *             RlcEntCfgInfo pointer
210  *             RlcBearerCfg pointer
211  * @return void
212  *
213  ******************************************************************/
214
215 void fillRlcCfg(RlcCfgInfo *rlcUeCfg, RlcUeCfg *ueCfg)
216 {
217    uint8_t lcIdx;
218    
219    rlcUeCfg->ueId    = ueCfg->ueIdx;
220    rlcUeCfg->cellId  = ueCfg->cellId;
221    rlcUeCfg->numEnt  = ueCfg->numLcs;
222    rlcUeCfg->transId = getTransId();
223
224    for(lcIdx = 0; lcIdx < rlcUeCfg->numEnt; lcIdx++)
225    {
226       fillLcCfg(&rlcUeCfg->entCfg[lcIdx], &ueCfg->rlcLcCfg[lcIdx], ueCfg->rlcLcCfg[lcIdx].configType);
227    }
228 }
229
230 /*******************************************************************
231  *
232  * @brief Handles Ue Create Request from DU APP
233  *
234  * @details
235  *
236  *    Function : RlcProcUeCreateReq
237  *
238  *    Functionality:
239  *      Handles Ue create Request from DU APP
240  *
241  * @params[in] Post structure pointer
242  *             RlcUeCfg pointer 
243  * @return ROK     - success
244  *         RFAILED - failure
245  *
246  * ****************************************************************/
247 uint8_t RlcProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
248 {
249    uint8_t ret = ROK;
250    RlcCfgInfo *rlcUeCfg = NULLP;
251
252    RlcCb *rlcUeCb = NULLP;
253    rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
254    RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
255    if(rlcUeCfg == NULLP)
256    {
257       DU_LOG("\nERROR  -->  RLC: Failed to allocate memory at RlcProcUeCreateReq()");
258       ret = RFAILED;
259    }
260    else
261    {
262       memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
263       fillRlcCfg(rlcUeCfg, ueCfg); 
264       ret = RlcProcCfgReq(pst, rlcUeCfg);
265       if(ret != ROK)
266          DU_LOG("\nERROR  -->  RLC: Failed to configure Add/Mod/Del entities at RlcProcUeCreateReq()");
267
268    }
269    RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
270    return ret;
271 }
272
273 /*******************************************************************
274 *
275 * @brief filling the structure of rrc delivery msg info
276 *
277 * @details
278 *
279 *    Function : BuildAndSendRrcDeliveryReportToDu
280 *
281 *    Functionality: filling the structure of rrc delivery msg info
282 *
283 * @return ROK     - success
284 *         RFAILED - failure
285 *
286 * ****************************************************************/
287 uint8_t BuildAndSendRrcDeliveryReportToDu( RlcDlRrcMsgInfo *dlRrcMsgInfo )
288 {
289     Pst             pst;
290     RrcDeliveryReport *rrcDelivery;
291
292     DU_LOG("\nINFO  -->  RLC : Filling RRC Delivery Report");
293     RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL, rrcDelivery, sizeof(RrcDeliveryReport));
294
295     if(rrcDelivery)
296     {
297        rrcDelivery->cellId = dlRrcMsgInfo->cellId;
298        rrcDelivery->ueIdx  = dlRrcMsgInfo->ueIdx;
299        rrcDelivery->srbId  = dlRrcMsgInfo->lcId ;
300        rrcDelivery->rrcDeliveryStatus.deliveryStatus    = PDCP_SN;
301        rrcDelivery->rrcDeliveryStatus.triggeringMessage = PDCP_SN;
302
303        /* Sending UL RRC Message transfeer to DU APP */
304        memset(&pst, 0, sizeof(Pst));
305        FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_RRC_DELIVERY_MSG_TRANS_TO_DU);
306        rlcSendRrcDeliveryReportToDu(&pst, rrcDelivery);
307     }
308     else
309     {
310        DU_LOG("\nERROR  -->  RLC : Memory allocation failed");
311     }
312
313    return ROK;
314 }
315 /* ****************************************************************
316  *
317  * @brief Process the DL RRC Message from DU APP
318  *
319  * @details
320  *
321  *    Function : RlcProcDlRrcMsgTransfer
322  *
323  *    Functionality: Process the DL RRC Message from DU APP
324  *
325  * @params[in] Post structure
326  *             DL RRC Message info
327  * @return ROK     - success
328  *         RFAILED - failure
329  *
330  * ****************************************************************/
331 uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
332 {
333    Buffer        *mBuf;
334    RlcDatReqInfo *datReqInfo;
335
336    RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
337    if(!datReqInfo)
338    {
339       DU_LOG("\nERROR  -->  RLC : Memory allocation failed in RlcProcDlRrcMsgTransfer");
340       RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
341       RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
342       return RFAILED;
343    }
344
345    datReqInfo->rlcId.rbType = dlRrcMsgInfo->rbType;
346    datReqInfo->rlcId.rbId = dlRrcMsgInfo->rbId;
347    datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueIdx;
348    datReqInfo->rlcId.cellId = dlRrcMsgInfo->cellId;
349    datReqInfo->lcType = dlRrcMsgInfo->lcType;
350    datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
351
352    /* Copy fixed buffer to message */
353    if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &mBuf) != ROK)
354    {
355       DU_LOG("\nERROR  -->  RLC : Memory allocation failed at RlcMacProcUlData");
356       RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
357       RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
358       RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
359       return RFAILED;
360    }
361    oduCpyFixBufToMsg(dlRrcMsgInfo->rrcMsg, mBuf, dlRrcMsgInfo->msgLen);
362
363    if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
364    {
365       return RFAILED;
366    }
367
368    /* RRC Delivery report is only send when RRC Delivery status report is true in DL RRC Message */
369    if(dlRrcMsgInfo->deliveryStaRpt)
370    {
371       BuildAndSendRrcDeliveryReportToDu(dlRrcMsgInfo);
372    }
373
374    /* Free memory allocated by du app */
375    RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
376    RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
377    RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
378    return ROK;
379 }
380
381 /*******************************************************************
382  *
383  * @brief Process UL data from UE
384  *
385  * @details
386  *
387  *    Function : RlcProcUlData
388  *
389  *    Functionality:
390  *       This function receives the PDU from MAC.
391  *       seggregates common and dedicated logical channel
392  *       PDU and call respective handler.
393  *
394  * @params[in]
395  * @return ROK     - success
396  *         RFAILED - failure
397  *
398  * ****************************************************************/
399 uint8_t RlcProcUlData(Pst *pst, RlcData *ulData)
400 {
401    uint8_t         ret = ROK;
402    uint8_t         idx, pduIdx;
403    uint8_t         lcId;                    /* Logical Channel */
404    uint8_t         numDLch = 0;             /* Number of dedicated logical channel */
405    bool            dLchPduPres;             /* PDU received on dedicated logical channel */
406    RguLchDatInd    dLchData[MAX_NUM_LC];    /* PDU info on dedicated logical channel */
407    RguDDatIndInfo  *dLchUlDat;              /* UL data on dedicated logical channel */
408    RguCDatIndInfo  *cLchUlDat;              /* UL data on common logical channel */
409
410    /* Initializing dedicated logical channel Database */
411    DU_LOG("\nDEBUG  -->  RLC: Received UL Data request from MAC");
412    for(idx = 0; idx < MAX_NUM_LC; idx++)
413    {
414       dLchData[idx].lcId = idx;
415       dLchData[idx].pdu.numPdu = 0;
416    }
417    dLchPduPres = FALSE;
418
419    /* Seggregate PDUs received on common and dedicated channels
420     * and call common channel's handler */
421    for(idx = 0; idx< ulData->numPdu; idx++)
422    {
423       if(ulData->pduInfo[idx].commCh)
424       {
425          RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, cLchUlDat, \
426             sizeof(RguCDatIndInfo));
427          if(!cLchUlDat)
428          {
429             DU_LOG("\nERROR  -->  RLC : Memory allocation failed at RlcProcUlData");
430             ret = RFAILED;
431             break;
432          }
433          memset(cLchUlDat, 0, sizeof(RguCDatIndInfo));
434
435          cLchUlDat->cellId = ulData->cellId;
436          GET_UE_IDX(ulData->rnti, cLchUlDat->rnti);
437          cLchUlDat->lcId   = ulData->pduInfo[idx].lcId;
438
439          /* Copy fixed buffer to message */
440          if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &cLchUlDat->pdu) != ROK)
441          {
442             DU_LOG("\nERROR  -->  RLC : Memory allocation failed at RlcProcUlData");
443             RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, cLchUlDat, \
444                sizeof(RguCDatIndInfo));
445             ret = RFAILED;
446             break;
447          }
448          oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, cLchUlDat->pdu, \
449             ulData->pduInfo[idx].pduLen);
450
451          rlcProcCommLcUlData(pst, 0, cLchUlDat);
452       }
453       else
454       {
455          if(!dLchPduPres)
456          {
457             RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
458                sizeof(RguDDatIndInfo));
459             if(!dLchUlDat)
460             {
461                DU_LOG("\nERROR  -->  RLC : Memory allocation failed at RlcMacProcUlData");
462                ret = RFAILED;
463                break;
464             }
465             dLchPduPres = TRUE;
466          }
467
468          /* Copy fixed buffer to message */
469          lcId = ulData->pduInfo[idx].lcId;
470          if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, \
471                   &dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]) != ROK)
472          {
473             DU_LOG("\nERROR  -->  RLC : Memory allocation failed at RlcMacProcUlData");
474             for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
475             {
476                ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
477             }
478             RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
479                sizeof(RguDDatIndInfo));
480             ret = RFAILED;
481             break;
482          }
483          oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
484                dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
485                ulData->pduInfo[idx].pduLen);
486
487          dLchData[lcId].pdu.numPdu++;
488       }
489    }
490
491    /* If any PDU received on dedicated logical channel, copy into RguDDatIndInfo
492     * and call its handler */
493    if(ret == ROK)
494    {
495       if(dLchPduPres)
496       {
497          dLchUlDat->cellId = ulData->cellId;
498          GET_UE_IDX(ulData->rnti, dLchUlDat->rnti);
499
500          for(idx = 0; idx < MAX_NUM_LC; idx++)
501          {
502             if(dLchData[idx].pdu.numPdu)
503             {
504                memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
505                numDLch++;
506             }
507          }
508          dLchUlDat->numLch = numDLch;
509          rlcProcDedLcUlData(pst, 0, dLchUlDat);
510       }
511    }
512
513    for(pduIdx = 0; pduIdx < ulData->numPdu; pduIdx++)
514    {
515       RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData->pduInfo[pduIdx].pduBuf, \
516          ulData->pduInfo[pduIdx].pduLen);
517    }
518    RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcData));
519    return ROK;
520
521 }/* End of RlcProcUlData */
522
523 /*******************************************************************
524  *
525  * @brief Handler for extracting common and dedicated channel
526  *      Scheduling result report.
527  *
528  * @details
529  *
530  *    Function : RlcProcSchedResultRpt
531  *
532  *    Functionality:
533  *     Handler for extracting common and dedicated channel
534  *      Scheduling result report
535  *
536  * @params[in]
537  * @return ROK     - success
538  *         RFAILED - failure
539  *
540  * ****************************************************************/
541 uint8_t RlcProcSchedResultRpt(Pst *pst, RlcSchedResultRpt *schRep)
542 {
543    uint8_t ret = ROK;
544    uint8_t idx;                     /* Iterator */
545    uint8_t nmbDLch = 0;                 /* Number of dedicated logical channles */
546    RguCStaIndInfo   *cLchSchInfo;    /* Common logical channel scheduling result */
547    RguDStaIndInfo   *dLchSchInfo;  /* Dedicated logical channel scheduling result */
548
549    DU_LOG("\nDEBUG  -->  RLC : Received scheduling report from MAC");
550    for(idx=0; idx < schRep->numLc; idx++)
551    {
552       /* If it is common channel, fill status indication information
553        * and trigger the handler for each common lch separately */
554       if(schRep->lcSch[idx].commCh)
555       {
556           RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, cLchSchInfo, \
557              sizeof(RguCStaIndInfo));
558           if(!cLchSchInfo)
559           {
560              DU_LOG("\nERROR  -->  RLC: RlcProcSchedResultRpt: Memory allocation failed for cLchSchInfo");
561              ret = RFAILED;
562              break;
563           }
564           memset(cLchSchInfo, 0, sizeof(RguCStaIndInfo));
565
566           cLchSchInfo->cellId  = schRep->cellId;
567           cLchSchInfo->lcId    = schRep->lcSch[idx].lcId;
568           cLchSchInfo->transId = schRep->slotInfo.sfn;
569           cLchSchInfo->transId = (cLchSchInfo->transId << 16) | schRep->slotInfo.slot;
570           cLchSchInfo->rnti = schRep->rnti;
571           rlcProcCommLcSchedRpt(pst, 0, cLchSchInfo);
572
573       }
574       else
575       {
576           /* Fill status info structure if at least one dedicated channel
577            * scheduling report is received */
578           if(nmbDLch == 0)
579           {
580              RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, dLchSchInfo, \
581                 sizeof(RguDStaIndInfo));
582              if(!dLchSchInfo)
583              {
584                 DU_LOG("\nERROR  -->  RLC: RlcProcSchedResultRpt: Memory allocation failed for dLchSchInfo");
585                 ret = RFAILED;
586                 break;
587              }
588
589              dLchSchInfo->cellId = schRep->cellId;
590              dLchSchInfo->nmbOfUeGrantPerTti = 1;
591              /* MAC sends Scheduling report for one UE at a time. Hence filling
592              only the 0th index of staInd */
593              dLchSchInfo->staInd[0].rnti = schRep->rnti;
594
595              /* Storing sfn/slot into a single 32-bit variable to be used later*/
596              dLchSchInfo->staInd[0].transId = schRep->slotInfo.sfn;
597              dLchSchInfo->staInd[0].transId = \
598                 (dLchSchInfo->staInd[0].transId << 16) | schRep->slotInfo.slot; 
599              dLchSchInfo->staInd[0].nmbOfTbs = 1;
600              dLchSchInfo->staInd[0].fillCtrlPdu = true; 
601           }
602
603           /* Fill logical channel scheduling info */
604           dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].lcId = \
605              schRep->lcSch[idx].lcId;
606           dLchSchInfo->staInd[0].staIndTb[0].lchStaInd[nmbDLch].totBufSize = \
607              schRep->lcSch[idx].bufSize;
608           nmbDLch++;
609       }
610    }
611
612    /* Calling handler for all dedicated channels scheduling*/
613    if(ret == ROK)
614    {
615       if(nmbDLch)
616       {
617          dLchSchInfo->staInd[0].staIndTb[0].nmbLch = nmbDLch;
618          rlcProcDedLcSchedRpt(pst, 0, dLchSchInfo);
619       }
620    }
621
622    RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, schRep, sizeof(RlcSchedResultRpt));
623    return ret;
624 }
625
626
627 /*******************************************************************
628  *
629  * @brief Handles Ue Reconfig Request from DU APP
630  *
631  * @details
632  *
633  *    Function : RlcProcUeReconfigReq
634  *
635  *    Functionality:
636  *      Handles Ue Reconfig Request from DU APP
637  *
638  * @params[in] Post structure pointer
639  *             RlcUeCfg pointer 
640  * @return ROK     - success
641  *         RFAILED - failure
642  *
643  * ****************************************************************/
644 uint8_t RlcProcUeReconfigReq(Pst *pst, RlcUeCfg *ueCfg)
645 {
646    uint8_t ret = ROK;
647    RlcCfgInfo *rlcUeCfg = NULLP; //Seed code Rlc cfg struct
648    RlcCb *rlcUeCb = NULLP;
649     
650    DU_LOG("\nDEBUG  -->  RLC: UE reconfig request received. CellID[%d] UEIDX[%d]",ueCfg->cellId, ueCfg->ueIdx);
651
652    rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
653    RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
654    if(rlcUeCfg == NULLP)
655    {
656       DU_LOG("\nERROR  -->  RLC: Failed to allocate memory at RlcProcUeReconfigReq()");
657       ret = RFAILED;
658    }
659    else
660    {
661       memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
662       fillRlcCfg(rlcUeCfg, ueCfg);
663       ret = RlcProcCfgReq(pst, rlcUeCfg);
664       if(ret != ROK)
665          DU_LOG("\nERROR  -->  RLC: Failed to configure Add/Mod/Del entities at RlcProcUeReconfigReq()");
666    }
667    
668    RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
669    return ret;
670 }
671
672 /* ****************************************************************
673  *
674  * @brief Process the DL Data transfer from DU APP
675  *
676  * @details
677  *
678  *    Function : RlcProcDlUserDataTransfer
679  *
680  *    Functionality: Process the DL transfer from DU APP
681  *
682  * @params[in] Post structure
683  *             DL RRC Message info
684  * @return ROK     - success
685  *         RFAILED - failure
686  *
687  * ****************************************************************/
688 uint8_t RlcProcDlUserDataTransfer(Pst *pst, RlcDlUserDataInfo *dlDataMsgInfo)
689 {
690    Buffer        *mBuf = NULLP;
691    RlcDatReqInfo *datReqInfo = NULLP;
692
693    if(dlDataMsgInfo->dlMsg == NULLP)
694    {
695       DU_LOG("\nERROR  -->  RLC_DL : Received DL message is NULLP in RlcProcDlUserDataTransfer()");
696       return RFAILED;
697    }
698    RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
699    if(!datReqInfo)
700    {
701       DU_LOG("\nERROR  -->  RLC_DL : Memory allocation failed for DatReq in RlcProcDlUserDataTransfer()");
702       ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
703       RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
704       return RFAILED;
705    }
706
707    datReqInfo->rlcId.rbType = RB_TYPE_DRB;
708    datReqInfo->rlcId.rbId   = dlDataMsgInfo->rbId;
709    datReqInfo->rlcId.ueId   = dlDataMsgInfo->ueIdx;
710    datReqInfo->rlcId.cellId = dlDataMsgInfo->cellId;
711    datReqInfo->lcType       = LCH_DTCH;
712    datReqInfo->sduId        = ++(rlcCb[pst->dstInst]->dlSduId);
713    mBuf = dlDataMsgInfo->dlMsg;
714    if(rlcProcDlData(pst, datReqInfo, mBuf) != ROK)
715    {
716       return RFAILED;
717    }
718     
719    /* Free memory allocated by du app */
720    RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RlcDatReqInfo));
721    RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
722    return ROK;
723 }
724 /**********************************************************************
725          End of file
726 **********************************************************************/