[JIRA ID:ODUHIGH-255]- Fix for DL RRC Msg in Ue context setup Req
[o-du/l2.git] / src / du_app / du_ue_mgr.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 /* This file contains UE management handling functionality for DU APP */
19 #include "common_def.h"
20 #include "lrg.h"
21 #include "lrg.x"
22 #include "ckw.h"
23 #include "ckw.x"
24 #include "kwu.h"
25 #include "kwu.x"
26 #include "lkw.h"
27 #include "lkw.x"
28 #include "legtp.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
31 #include "du_cfg.h"
32 #include "du_utils.h"
33 #include "du_mgr.h"
34 #include "du_f1ap_msg_hdl.h"
35 #include "du_ue_mgr.h"
36
37 #ifdef EGTP_TEST
38 uint32_t sduId = 0;
39 #endif
40
41 DuMacDlCcchInd packMacDlCcchIndOpts[] =
42 {
43    packMacDlCcchInd,   /* Loose coupling */
44    MacProcDlCcchInd,    /* TIght coupling */
45    packMacDlCcchInd    /* Light weight-loose coupling */
46 };
47
48 DuMacUeCreateReq packMacUeCreateReqOpts[] =
49 {
50    packDuMacUeCreateReq,       /* Loose coupling */
51    MacProcUeCreateReq,          /* TIght coupling */
52    packDuMacUeCreateReq       /* Light weight-loose coupling */
53 };
54
55 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
56 {
57    packDuRlcUeCreateReq,       /* Loose coupling */
58    RlcProcUeCreateReq,          /* TIght coupling */
59    packDuRlcUeCreateReq       /* Light weight-loose coupling */
60 };
61
62 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
63 {
64    packDlRrcMsgToRlc,          /* Loose coupling */ 
65    RlcProcDlRrcMsgTransfer,       /* Tight coupling */
66    packDlRrcMsgToRlc           /* Light weight-loose coupling */
67 };
68
69 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
70 {
71    packDuRlcUeReconfigReq,       /* Loose coupling */
72    RlcProcUeReconfigReq,       /* TIght coupling */
73    packDuRlcUeReconfigReq       /* Light weight-loose coupling */
74 };
75
76 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
77 {
78    packDuMacUeReconfigReq,       /* Loose coupling */
79    MacProcUeReconfigReq,       /* TIght coupling */
80    packDuMacUeReconfigReq     /* Light weight-loose coupling */
81 };
82 /*******************************************************************
83  *
84  * @brief Handles EGTP data from CU 
85  *
86  * @details
87  *
88  *    Function : duHdlEgtpData
89  *
90  *    Functionality: 
91  *      Processes EGTP header and sends data to RLC
92  *
93  * @params[in]  Pointer to EGTP Message 
94  * @return ROK     - success
95  *         RFAILED - failure
96  *
97  * ****************************************************************/
98 uint8_t duHdlEgtpDlData(EgtpMsg  *egtpMsg)
99 {
100
101    /* TODO : Extract RbId/UeID/CellID/SduId from database
102       using tunnel id in egtp header */
103
104    DU_LOG("\nDU_APP : Processing DL data");
105 #ifdef EGTP_TEST
106    Pst pst;
107    KwuDatReqInfo datReqInfo;
108
109    datReqInfo.rlcId.rbId = RB_ID;
110    datReqInfo.rlcId.rbType = CM_LTE_DRB;
111    datReqInfo.rlcId.ueId = UE_ID;
112    datReqInfo.rlcId.cellId = NR_CELL_ID;
113
114    datReqInfo.sduId = ++sduId;
115    datReqInfo.lcType = CM_LTE_LCH_DTCH;
116
117    /* Filling pst and Sending to RLC DL */
118    pst.selector  = ODU_SELECTOR_LWLC;
119    pst.srcEnt    = ENTDUAPP;
120    pst.dstEnt    = ENTRLC;
121    pst.dstInst   = RLC_DL_INST;
122    pst.dstProcId = DU_PROC;
123    pst.srcProcId = DU_PROC;
124    pst.region    = duCb.init.region;
125
126    cmPkKwuDatReq(&pst, &datReqInfo, egtpMsg->msg);
127 #else
128    //duBuildAndSendDlRrcMsgToRlc();
129 #endif
130    return ROK;
131 }
132
133 /******************************************************************
134  *
135  * @brief Builds and Sends DL CCCH Ind to MAC
136  *
137  * @details
138  *
139  *    Function : duBuildAndSendDlCcchInd 
140  *
141  *    Functionality: Builds and sends DL CCCH Ind Msg to MAC
142  *
143  * @params[in] dlCcchMsg - uint8_t*
144  * @return ROK     - success
145  *         RFAILED - failure
146  *
147  * ****************************************************************/
148 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
149       DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
150 {
151    uint8_t  ret                  = ROK;
152    uint16_t idx2;
153    DlCcchIndInfo *dlCcchIndInfo = NULLP;
154    Pst pst;
155
156    DU_LOG("\nDU APP : Building and Sending DL CCCH Ind to MAC");
157
158    DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
159
160    if(!dlCcchIndInfo)
161    {
162       DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
163       return RFAILED;
164    }
165
166    dlCcchIndInfo->cellId = *cellId;
167    dlCcchIndInfo->crnti = *crnti;
168    dlCcchIndInfo->msgType = msgType;
169    dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
170
171    DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
172    if(!dlCcchIndInfo->dlCcchMsg)
173    {
174       DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
175       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
176       return RFAILED;
177    }
178    for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
179    {
180       dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
181    }
182    DU_FREE(dlCcchMsg, dlCcchMsgSize);
183
184    /* Fill Pst */
185    FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
186    ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
187    if(ret != ROK)
188    {
189       DU_LOG("\nDU_APP : Failure in sending DL CCCH to MAC");
190       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
191             dlCcchIndInfo->dlCcchMsgLen);
192       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
193             sizeof(DlCcchIndInfo));
194       ret = RFAILED; 
195    }
196
197    return ret;
198
199 }
200
201 /*******************************************************************
202  *
203  * @brief Build and Send DL RRC Message transfer to RLC
204  *
205  * @details
206  *
207  *    Function : duBuildAndSendDlRrcMsgToRlc
208  *
209  *    Functionality:
210  *      Build and Send DL RRC Message transfer to RLC
211  *
212  * @params[in] Cell ID
213  *             UE Index
214  *             Logical Channgel ID
215  *             RRC Message
216  *             RRC Message Length
217  * @return ROK     - success
218  *         RFAILED - failure
219  *
220  * ****************************************************************/
221 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
222 {
223    Pst     pst;
224    uint8_t ret;
225    uint8_t lcIdx;
226    RlcDlRrcMsgInfo  *dlRrcMsgInfo = NULLP;
227
228    if(!f1DlRrcMsg)
229    {
230       DU_LOG("\nDU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
231       return RFAILED;
232    }
233
234    DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
235    if(!dlRrcMsgInfo)
236    {
237       DU_LOG("\nDU APP : Memory allocation failed for dlRrcMsgInfo in \
238          duBuildAndSendDlRrcMsgToRlc");
239       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
240       return RFAILED;
241    }
242    
243    /* Filling up the RRC msg info */
244    dlRrcMsgInfo->cellId = cellId;
245    dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
246    for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
247    {
248       if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
249       {
250          dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
251          dlRrcMsgInfo->rbId   = ueCfg.rlcLcCfg[lcIdx].rbId;
252          dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
253          dlRrcMsgInfo->lcId   = ueCfg.rlcLcCfg[lcIdx].lcId;
254          break;
255       }
256    }
257    dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
258    dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
259    dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
260    dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
261
262    /* Filling post structure and sending msg */ 
263    FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
264    DU_LOG("\nDU_APP: Sending Dl RRC Msg to RLC \n");
265    ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
266    if(ret != ROK)
267    {
268       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
269       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
270       return RFAILED;
271    }
272
273    return ROK;
274
275
276
277
278 /******************************************************************
279  *
280  * @brief Process DL RRC Msg recevied from F1AP
281  *
282  * @details
283  *
284  *    Function : duProcDlRrcMsg
285  *
286  *    Functionality: Process DL RRC Msg recevied from F1AP
287  *
288  * @params[in] dlCcchMsg - uint8_t*
289  * @return ROK     - success
290  *         RFAILED - failure
291  *
292  * ****************************************************************/
293
294 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
295 {
296    uint8_t ueIdx, ret;
297    uint16_t crnti, cellId, cellIdx;
298    bool ueCcchCtxtFound = false;
299    bool ueFound = false;
300
301    ret = ROK;
302
303    if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
304    {
305       for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
306       {
307          if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
308          {
309             ueCcchCtxtFound = true;
310             crnti  = duCb.ueCcchCtxt[ueIdx].crnti;
311             cellId = duCb.ueCcchCtxt[ueIdx].cellId;
312             break;
313          }
314       }
315    }
316    if(ueCcchCtxtFound)
317    {
318       ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
319       if(ret == RFAILED)
320       {
321          DU_LOG("\nDU_APP: Falied to build DlCcch Ind at procDlRrcMsgTrans()");
322       }
323       else
324       {
325          if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
326          {
327             ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
328             if(ret == RFAILED)
329             {
330                DU_LOG("\nDU_APP: Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
331                      duCb.ueCcchCtxt[ueIdx].cellId);
332             }
333          }
334          else
335          {
336             DU_LOG("\nDU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
337             ret = RFAILED;
338          }
339       }
340    }
341    else
342    {
343       for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
344       {
345          for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
346          {
347             if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
348                   && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
349             {
350                ueFound = true;
351                ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
352                      duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
353                break; 
354             }
355          }
356          if(ueFound)
357             break;
358       }
359       if(!ueFound)
360          ret = RFAILED;
361    }
362    return ret;
363 }
364
365 /******************************************************************
366  *
367  * @brief Generates GNB DU Ue F1AP ID
368  *
369  * @details
370  *
371  *    Function : genGnbDuUeF1apId
372  *
373  *    Functionality: Generates GNB DU Ue F1AP ID
374  *
375  * @params[in] void
376  * @return gnbDuF1apId
377  *
378  * ****************************************************************/
379 uint32_t genGnbDuUeF1apId()
380 {
381    static uint32_t gnbDuUeF1apId = 0;
382
383    return ++gnbDuUeF1apId;
384 }
385
386 /******************************************************************
387  *
388  * @brief Processes UL CCCH Ind recvd from MAC
389  *
390  * @details
391  *
392  *    Function : duProcUlCcchInd
393  *
394  *    Functionality: Processes UL CCCH Ind recvd from MAC
395  *
396  * @params[in] UlCcchIndInfo *ulCcchIndInfo
397  * @return ROK     - success
398  *         RFAILED - failure
399  *
400  * ****************************************************************/
401 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
402 {
403
404    uint8_t ret = ROK;
405    uint32_t gnbDuUeF1apId = 0;
406
407    gnbDuUeF1apId = genGnbDuUeF1apId();
408
409    /* Store Ue mapping */
410    duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
411    duCb.ueCcchCtxt[duCb.numUe].crnti         = ulCcchIndInfo->crnti;
412    duCb.ueCcchCtxt[duCb.numUe].cellId        = ulCcchIndInfo->cellId;
413
414    duCb.numUe++;
415
416    ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
417             ulCcchIndInfo->ulCcchMsg));
418    if(ret != ROK)
419    {
420       DU_LOG("\nDU_APP : BuildAndSendInitialRrcMsgTransfer failed");
421    }
422
423    DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
424    DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
425
426    return ret;
427
428 }
429
430 /******************************************************************
431  *
432  * @brief Fills Default UL LC Cfg
433  *
434  * @details
435  *
436  *    Function : fillDefaultUlLcCfg
437  *
438  *    Functionality: Fills Default UL LC Cfg
439  *
440  * @params[in]  UlLcCfg *ulLcCfg 
441  * @return void
442  *****************************************************************/
443 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
444 {
445    ulLcCfg->priority = LC_PRIORITY_1;
446    ulLcCfg->lcGroup =  0;
447    ulLcCfg->schReqId = 0;
448    ulLcCfg->pbr = PBR_KBPS_INFINITY;
449    ulLcCfg->bsd = BSD_MS_1000;
450 }
451
452 /******************************************************************
453  *
454  * @brief Fills Initial DL Bandwidth Part
455  *
456  * @details
457  *
458  *    Function : fillDefaultInitDlBwp
459  *
460  *    Functionality: Fills Initial DL Bandwidth Part
461  *
462  * @params[in]  InitialDlBwp *initDlBwp
463  * @return void
464  *
465  *****************************************************************/
466 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
467 {
468    uint8_t idx = 0;
469    uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
470    uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
471
472
473    if(initDlBwp)
474    {
475       /* Filling PDCCH Config */
476       initDlBwp->pdcchPresent = TRUE;
477       if(initDlBwp->pdcchPresent)
478       {
479          initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
480          memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
481          if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
482          {
483             initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
484                PDCCH_CTRL_RSRC_SET_ONE_ID;
485             memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
486                FREQ_DOM_RSRC_SIZE); 
487             coreset0EndPrb = CORESET0_END_PRB;
488             coreset1StartPrb = coreset0EndPrb +6;
489             coreset1NumPrb = CORESET1_NUM_PRB;
490             /* calculate the PRBs */
491             freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
492             memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
493                FREQ_DOM_RSRC_SIZE);
494
495             initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
496                PDCCH_CTRL_RSRC_SET_ONE_DURATION;
497             initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
498                CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
499             initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
500                ALL_CONTIGUOUS_RBS;
501             initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
502                SCRAMBLING_ID;
503          }
504          initDlBwp->pdcchCfg.numCRsetToRel = 0;
505          /* Filling Serach Space */
506          initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
507          memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
508          if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
509          {
510             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
511                PDCCH_SRCH_SPC_TWO_ID;
512             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
513                PDCCH_CTRL_RSRC_SET_ONE_ID;
514             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
515                mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
516             memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
517                MONITORING_SYMB_WITHIN_SLOT_SIZE);
518             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
519                PDCCH_SYMBOL_WITHIN_SLOT;
520             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
521                AGGREGATIONLEVEL_N8; 
522             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
523                AGGREGATIONLEVEL_N8; 
524             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
525                AGGREGATIONLEVEL_N4; 
526             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
527                AGGREGATIONLEVEL_N2; 
528             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
529                AGGREGATIONLEVEL_N1;
530             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
531                SEARCHSPACETYPE_PR_UE_SPECIFIC;
532             initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
533                PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
534
535             initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
536
537          }
538       }
539       /* Filling PDSCH Config */
540       initDlBwp->pdschPresent = TRUE;
541       if(initDlBwp->pdschPresent)
542       {
543          initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
544          initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
545          initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
546          initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
547             MAPPING_TYPEA;
548          initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL; 
549          initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
550          initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
551             calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
552          initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
553          initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
554          initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
555          initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
556       }
557    }
558
559 }
560
561 /******************************************************************
562  *
563  * @brief Fills Initial UL Bandwidth Part
564  *
565  * @details
566  *
567  *    Function : fillDefaultInitUlBwp
568  *
569  *    Functionality: Fills Initial UL Bandwidth Part
570  *
571  * @params[in]  InitialUlBwp *initUlBwp
572  * @return void
573  *
574  *****************************************************************/
575 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
576 {
577    uint8_t idx;
578    if(initUlBwp)
579    {
580       initUlBwp->pucchPresent = FALSE;
581
582       /*Filling PUSCH Config */
583       initUlBwp->puschPresent = TRUE;
584       if(initUlBwp->puschPresent)
585       {
586          initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
587          initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0; 
588          initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
589             scramblingId0 = SCRAMBLING_ID; 
590          initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
591          initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
592          idx = 0;
593          if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
594          {
595             initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
596             initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
597                MAPPING_TYPEA;
598             initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
599             initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
600             initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
601                calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
602          }
603          initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
604       }
605    }
606    else
607    {
608       DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
609    }
610
611 }
612 /******************************************************************
613  *
614  * @brief Fills SpCell Group Info
615  *
616  * @details
617  *
618  *    Function : fillDefaultSpCellGrpInfo
619  *
620  *    Functionality: Fills Sp Cell Group Info
621  *
622  * @params[in]  SpCellCfg *spCell
623  * @return void
624  *
625  *****************************************************************/
626 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
627 {
628    if(spCell)
629    {
630       spCell->servCellIdx = SERV_CELL_IDX;
631       /* Filling Initial Dl Bwp */
632       fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
633
634       spCell->servCellCfg.numDlBwpToAdd    = 0; 
635       spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
636       spCell->servCellCfg.defaultDlBwpId   = ACTIVE_DL_BWP_ID;
637       spCell->servCellCfg.bwpInactivityTmr = NULLP;
638       spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
639       spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
640       spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
641       spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
642       spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
643          NUM_HARQ_PROC_FOR_PDSCH_N_16;
644       /* Filling Initial UL Bwp*/
645       fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
646       spCell->servCellCfg.numUlBwpToAdd     = 0; 
647       spCell->servCellCfg.firstActvUlBwpId  = ACTIVE_DL_BWP_ID; 
648    }
649    else
650    {
651       DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
652    }
653 }
654
655 /******************************************************************
656  *
657  * @brief Fills Physical Cell Group Info
658  *
659  * @details
660  *
661  *    Function : fillDefaultPhyCellGrpInfo
662  *
663  *    Functionality: Fills Physical Cell Group Info
664  *
665  * @params[in]  PhyCellGrpCfg *cellGrp
666  * @return void
667  *
668  *****************************************************************/
669 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
670 {
671    if(cellGrp)
672    {
673       cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
674       cellGrp->pNrFr1 = P_NR_FR1;
675    }
676    else
677    {
678       DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
679    }
680 }
681
682 /******************************************************************
683  *
684  * @brief Fills Mac Cell Group Info
685  *
686  * @details
687  *
688  *    Function : fillDefaultMacCellGrpInfo
689  *
690  *    Functionality: Fills Mac Cell Group Info
691  *
692  * @params[in]  MacCellGrpCfg *cellGrp
693  * @return void
694  *
695  *****************************************************************/
696 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
697 {
698    uint8_t idx;
699
700    if(cellGrp)
701    {
702       /* Filling Scheduling Request Config */
703       cellGrp->schReqCfg.addModListCount = 1;
704       if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
705       {
706          for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
707          {
708             cellGrp->schReqCfg.addModList[idx].schedReqId    = SCH_REQ_ID;
709             cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
710             cellGrp->schReqCfg.addModList[idx].srTransMax    = SR_TRANS_MAX_N_16;
711          }
712       }
713       cellGrp->schReqCfg.relListCount = 0;
714
715       /* Filling Tag config */
716       cellGrp->tagCfg.addModListCount = 1;
717       if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
718       {
719          for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
720          {
721             cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
722             cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
723          }
724       }
725       cellGrp->tagCfg.relListCount = 0;
726
727       /* Filling BSR config */
728       cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
729       cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
730       cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
731
732       /* Filling PHR config */
733       cellGrp->phrCfgSetupPres = true;
734       cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
735       cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
736       cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
737       cellGrp->phrCfg.multiplePHR   = false;
738       cellGrp->phrCfg.dummy         = false;
739       cellGrp->phrCfg.phrType2OtherCell = false;
740       cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;  
741
742    }
743    else
744    {
745       DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
746    }
747 }
748
749 /******************************************************************
750  *
751  * @brief Function to fill Mac Lc Cfg for SRB1
752  *
753  * @details
754  *
755  *    Function : fillMacSrb1LcCfg
756  *
757  *    Functionality: Function to fill Mac Lc cfg for SRB1
758  *
759  * @params[in]  LcCfg *lcCfg, LcCfg *ueSetReqDb
760  * @return void
761  *****************************************************************/
762
763 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
764 {
765    macLcCfg->lcId   = SRB1_LCID;
766    macLcCfg->configType = CONFIG_ADD;
767    macLcCfg->drbQos = NULLP;
768    macLcCfg->snssai = NULLP;
769    macLcCfg->ulLcCfgPres = true;
770    fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
771 }
772
773 /******************************************************************
774  *
775  * @brief Function to fill the Lc cfg from ueSetupReqDb
776  *
777  * @details
778  *
779  *    Function : fillMacLcCfgToAddMod
780  *
781  *    Functionality: Function to fill the Lc cfg from ueSetupReqDb
782  *
783  * @params[in]  LcCfg *lcCfg, LcCfg *ueSetReqDb
784  * @return ROK/RFAILED
785  *
786  *****************************************************************/
787
788 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
789 {
790    uint8_t ret = ROK; 
791    lcCfg->lcId = ueSetReqDb->lcId;
792    lcCfg->configType = ueSetReqDb->configType;
793    /* Filling DRBQOS */
794    if(ueSetReqDb->drbQos)
795    {
796       if(!lcCfg->drbQos)
797       {
798          DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
799          if(!lcCfg->drbQos)
800          {
801             DU_LOG("\nDU APP: Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
802             return RFAILED;
803          }
804       }
805       if(ret == ROK)
806       {
807          memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
808       }
809    }
810    else
811    {
812       lcCfg->drbQos = NULLP;
813    }
814
815    if(ret == ROK)
816    {
817       if(ueSetReqDb->snssai)
818       {
819          if(!lcCfg->snssai)
820          {
821             DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
822             if(!lcCfg->snssai)
823             {
824                DU_LOG("\nDU APP: Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
825                ret = RFAILED;
826             }
827          }
828          if(ret == ROK)
829          {
830             /* Filling SNSSAI */
831             memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
832          }
833          else
834          {
835             lcCfg->snssai = NULLP;
836             if(lcCfg->drbQos)
837             {
838                DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
839                lcCfg->drbQos = NULLP;
840             }
841             return ret;
842          }
843       }
844       else
845          lcCfg->snssai = NULLP;
846    }
847    lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
848    memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
849    memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
850    return ret;
851 }
852
853 /******************************************************************
854  *
855  * @brief Function to copy the Bit rate from ueSetupReqDb
856  *
857  * @details
858  *
859  *    Function : fillAmbr
860  *
861  *    Functionality: Function to copy bit Rate from ueSetupReqDb
862  *
863  * @params[in]  AmbrCfg **macAmbr, AmbrCfg  *ueDbAmbr
864  * @return ROK/RFAILED
865  *
866  *****************************************************************/
867
868 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
869 {
870    if(ueDbAmbr)
871    {
872       if(*macAmbr == NULLP)
873       {
874          DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
875          if(*macAmbr == NULLP)
876          {
877             DU_LOG("\nDUAPP: Memory Alloc Failed at fillAmbr()");
878             return RFAILED;
879          }
880       }
881       memset(*macAmbr, 0, sizeof(AmbrCfg));
882       (*macAmbr)->ulBr = ueDbAmbr->ulBr;
883       (*macAmbr)->dlBr = ueDbAmbr->dlBr;
884    }
885    else
886    {
887       *macAmbr = NULLP;
888    }
889    return ROK;
890 }
891
892 /******************************************************************
893  *
894  * @brief Builds and Send UE ReConfig Request to MAC
895  *
896  * @details
897  *
898  *    Function : sendUeReCfgReqToMac
899  *
900  *    Functionality: Builds and Send UE ReConfig Request to MAC
901  *
902  * @Params[in]  MacUeCfg pointer
903  * @return ROK     - success
904  *         RFAILED - failure
905  *
906  * ****************************************************************/
907
908 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
909 {
910    uint8_t ret = ROK;
911    Pst pst;
912    
913    /* Fill Pst */
914    FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
915    
916    if(macUeCfg)
917    {
918       /* Processing one Ue at a time to MAC */
919       DU_LOG("\nDU_APP: Sending Ue Reconfig Request to MAC");
920       ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
921       if(ret == RFAILED)
922       {
923          DU_LOG("\nDU_APP: Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
924          DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
925       }
926    }
927    else
928    {
929       DU_LOG("\n DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
930       ret = RFAILED;
931    }
932    return ret;
933 }
934
935 /******************************************************************
936  *
937  * @brief Function to return Drb LcId
938  *
939  * @details
940  *
941  *    Function : getDrbLcId
942  *
943  *    Functionality: Function to return Drb LcId
944  *
945  * Returns: lcId - SUCCESS
946  *         RFAILED - FAILURE
947  *****************************************************************/
948
949 uint8_t getDrbLcId(uint32_t *drbBitMap)
950 {
951    uint8_t bitMask = 1, bitPos = 0;
952    bitPos = MIN_DRB_LCID;
953
954    while(bitPos <= MAX_DRB_LCID)
955    {
956       if((*drbBitMap & (bitMask << bitPos)) == 0)
957       {
958          *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
959          return bitPos;
960       }
961       else
962       {
963          bitPos++;
964       }
965    }
966    DU_LOG("\nDU_APP: Max LC Reached in getDrbLcId()");
967    return RFAILED;
968 }
969
970 /******************************************************************
971  *
972  * @brief Fills MacUeCfg structure
973  *
974  * @details
975  *
976  *    Function : fillMacUeCfg
977  *
978  *    Functionality: Fills MacUeCfg
979  *
980  * @params[in]  cellId, ueIdx, crnti, 
981  *              DuUeCfg  pointer,
982  *              MacUeCfg pointer
983  * @return ROK/RFAILED
984  *
985  *****************************************************************/
986 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
987    DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
988 {
989    uint8_t ret, dbIdx, lcIdx, cellIdx;
990    bool lcIdFound = false;
991    MacUeCfg *duMacDb = NULLP;
992
993    ret =ROK;
994
995    if(!ueCfgDb)
996    {
997       macUeCfg->cellId       = cellId;
998       macUeCfg->ueIdx        = ueIdx;
999       macUeCfg->crnti        = crnti;
1000       fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1001       fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1002       fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1003       macUeCfg->ambrCfg = NULLP;
1004       fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1005       macUeCfg->numLcs++;
1006    }
1007    else
1008    {
1009       /* Fetching MacDb from DuUeCb */
1010       GET_CELL_IDX(cellId, cellIdx);
1011       duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1012       /* Fetching MaUeCfg List for ADD/MOD/DEL */
1013       macUeCfg->cellId       = cellId;
1014       macUeCfg->ueIdx        = ueIdx;
1015       macUeCfg->crnti        = crnti;
1016       ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1017       if(ret == ROK)
1018       {
1019          if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1020          {
1021             fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1022                &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1023          }
1024          if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1025          {
1026             fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1027                NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1028          }
1029          ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
1030       }
1031
1032       /* Filling LC Context */
1033       for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1034       {
1035          if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1036          {
1037             /* Filling default UL LC config in MAC if not present */
1038             ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1039             fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1040          }
1041          for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1042          {
1043             if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1044             {
1045                lcIdFound = true;
1046                if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1047                      (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1048                {
1049                   ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1050                   ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1051                }
1052             }
1053             else
1054                lcIdFound = false;
1055          }
1056          if(!lcIdFound)
1057          {
1058             /* ADD/DEL CONFIG */
1059             ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1060          }
1061          if(ret == ROK)
1062          {
1063             macUeCfg->numLcs++;
1064          }
1065          else
1066          {
1067             DU_LOG("\n DU_APP: Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx); 
1068             break;
1069          }
1070       }/*End of Outer FOR loop */
1071    }
1072    return ret;
1073 }
1074
1075 /******************************************************************
1076  *
1077  * @brief Fills Rlc AM Information
1078  *
1079  * @details
1080  *
1081  *    Function : fillDefaultAmInfo
1082  *
1083  *    Functionality: Fills Rlc AM Information
1084  *
1085  * @params[in]  AmBearerCfg *amCfg
1086  * @return void
1087  *
1088  *****************************************************************/
1089 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1090 {
1091    /* DL AM */
1092    amCfg->dlAmCfg.snLenDl     = AM_SIZE_12;
1093    amCfg->dlAmCfg.pollRetxTmr = POLL_RETX_TMR_45MS;
1094    amCfg->dlAmCfg.pollPdu     = POLL_PDU_TMR_INFINITY;
1095    amCfg->dlAmCfg.pollByte    = POLL_BYTES_INFINITY;
1096    amCfg->dlAmCfg.maxRetxTh   = RETX_TH_8;   
1097  
1098    /* UL AM */
1099    amCfg->ulAmCfg.snLenUl     = AM_SIZE_12;
1100    amCfg->ulAmCfg.reAssemTmr  = RE_ASM_40MS; 
1101    amCfg->ulAmCfg.statProhTmr = PROH_35MS;
1102 }
1103
1104 /******************************************************************
1105  *
1106  * @brief Fills RLC UM Bi Directional Information
1107  *
1108  * @details
1109  *
1110  *    Function : fillDefaultUmBiInfo
1111  *
1112  *    Functionality: Fills RLC UM Bi Directional Information
1113  *
1114  * @params[in]  UmBiDirBearerCfg *umBiDirCfg
1115  * @return void
1116  *
1117  *****************************************************************/
1118 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1119 {
1120    /* UL UM BI DIR INFO */
1121    umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1122    umBiDirCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
1123
1124    /* DL UM BI DIR INFO */
1125    umBiDirCfg->dlUmCfg.snLenDlUm  = UM_SIZE_12;
1126 }
1127
1128 /******************************************************************
1129  *
1130  * @brief Fills RLC UM Uni Directional UL Information
1131  *
1132  * @details
1133  *
1134  *    Function : fillDefaultUmUlInfo
1135  *
1136  *    Functionality: Fills RLC UM Uni Directional Info
1137  *
1138  * @params[in]  UmUniDirUlBearerCfg *UmUlCfg
1139  * @return void
1140  *
1141  *****************************************************************/
1142 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1143 {
1144    UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1145    UmUlCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
1146 }
1147
1148 /******************************************************************
1149  *
1150  * @brief Fills RLC UM Uni Directional DL Information
1151  *
1152  * @details
1153  *
1154  *    Function : fillDefaultUmDlInfo
1155  *
1156  *    Functionality: Fills RLC UM Uni Directional DL Info
1157  *
1158  * @params[in]  UmUniDirDlBearerCfg *UmDlCfg
1159  * @return void
1160  *
1161  *****************************************************************/
1162 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1163 {
1164    UmDlCfg->dlUmCfg.snLenDlUm  = UM_SIZE_12;
1165 }
1166
1167 /******************************************************************
1168  *
1169  * @brief Builds Rlc Mode Default Configuration
1170  *
1171  * @details
1172  *
1173  *    Function : fillDefaultRlcModeCfg
1174  *
1175  *    Functionality: Builds Rlc Mode Default Configuration
1176  *
1177  * @params[in]  rlcMode, RlcBearerCfg *lcCfg
1178  * @return ROK/RFAILED
1179  *
1180  *****************************************************************/
1181
1182 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1183 {
1184
1185    if(lcCfg)
1186    {
1187       switch(rlcMode)
1188       {
1189          case RLC_AM :
1190             {
1191                if(!lcCfg->u.amCfg)
1192                {
1193                  DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1194                  if(lcCfg->u.amCfg)
1195                     fillDefaultAmInfo(lcCfg->u.amCfg);
1196                  else
1197                  {
1198                     DU_LOG("\n DU_APP: Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1199                     return RFAILED;
1200                  }
1201                }
1202                break;
1203             }
1204          case RLC_UM_BI_DIRECTIONAL :
1205             {
1206                if(!lcCfg->u.umBiDirCfg)
1207                {
1208                  DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1209                  if(lcCfg->u.umBiDirCfg)
1210                     fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1211                  else
1212                  {
1213                     DU_LOG("\n DU_APP: Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1214                     return RFAILED;
1215                  }
1216                }
1217                break;
1218             }
1219          case RLC_UM_UNI_DIRECTIONAL_UL :
1220             {
1221                if(!lcCfg->u.umUniDirUlCfg)
1222                {
1223                   DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1224                   if(lcCfg->u.umUniDirUlCfg)
1225                     fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1226                   else
1227                   {
1228                      DU_LOG("\n DU_APP: Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1229                      return RFAILED;
1230                   }
1231                }
1232                break;
1233             }
1234          case RLC_UM_UNI_DIRECTIONAL_DL :
1235             {
1236                if(!lcCfg->u.umUniDirDlCfg)
1237                {
1238                   DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1239                   if(lcCfg->u.umUniDirDlCfg)
1240                    fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1241                   else
1242                   {
1243                      DU_LOG("\n DU_APP: Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1244                      return RFAILED;
1245                   }
1246                }
1247                break;
1248             }
1249          default:
1250             DU_LOG("\nDUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1251             return RFAILED;
1252       }
1253
1254    }
1255    else
1256    {
1257       DU_LOG("\nDUAPP: Received Lc Config is NULL");
1258       return RFAILED;
1259    }
1260    return ROK;
1261 }
1262
1263 /*******************************************************************
1264  *
1265  * @brief Function to fill Rlc Lc Cfg for SRB1
1266  *
1267  * @details
1268  *
1269  *    Function : fillRlcSrb1LcCfg
1270  *
1271  *    Functionality: 
1272  *     Function to fill Rlc Lc Cfg for SRB1
1273  * 
1274  *  @params[in]     Pointer to RlcBearerCfg
1275  *  @return ROK/RFAILED
1276  * 
1277  *****************************************************************/
1278
1279 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1280 {
1281    uint8_t ret = ROK;
1282
1283    rlcLcCfg->rbId   = SRB1_LCID;
1284    rlcLcCfg->rbType = RB_TYPE_SRB;
1285    rlcLcCfg->lcId   = SRB1_LCID;
1286    rlcLcCfg->lcType = LCH_DCCH;
1287    rlcLcCfg->rlcMode = RLC_AM;
1288    rlcLcCfg->configType = CONFIG_ADD;
1289    ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1290    return ret;
1291 }
1292
1293 /*******************************************************************
1294  *
1295  * @brief Processes UE ReConfig Req to RLC UL
1296  *
1297  * @details
1298  *
1299  *    Function : sendUeReCfgReqToRlc
1300  *
1301  *    Functionality: 
1302  *     Processes UE Reconfig Req to RLC UL
1303  * 
1304  *  @params[in]     Pointer to RlcUeCfg
1305  *  @return ROK     - success
1306  *          RFAILED - failure
1307  * 
1308  *****************************************************************/
1309
1310 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1311 {
1312    uint8_t ret;
1313    Pst pst;
1314    
1315    FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1316    if(rlcUeCfg)
1317    {
1318       /* Processing one Ue at a time to RLC */
1319       DU_LOG("\nDU_APP: Sending Ue Reconfig Request to RLC UL");
1320       ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1321       if(ret == RFAILED)
1322       {
1323          DU_LOG("\nDU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1324          DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1325       }
1326    }
1327    else
1328    {
1329       DU_LOG("\n DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1330       ret = RFAILED;
1331    }
1332    return ret;
1333 }
1334
1335 /******************************************************************
1336  *
1337  * @brief Fills RlcBearerCfg structure
1338  *
1339  * @details
1340  *
1341  *    Function : fillRlcUeCfg
1342  *
1343  *    Functionality: Fills Rlc Bearer Cfg
1344  *
1345  *
1346  *****************************************************************/
1347 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1348    DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1349 {
1350    uint8_t ret, dbIdx, lcIdx, cellIdx;
1351    bool lcIdFound = false;
1352    RlcUeCfg *duRlcDb = NULLP;
1353
1354    ret = ROK;
1355    if(!ueCfgDb)
1356    {
1357       /* Initial RB being Added */ 
1358       rlcUeCfg->cellId       = cellId;
1359       rlcUeCfg->ueIdx        = ueIdx;
1360       ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1361       if(ret == ROK)
1362          rlcUeCfg->numLcs++;
1363       else
1364          memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1365    }
1366    else
1367    {
1368       /* Fetch RlcDb from DuUeCb */ 
1369       GET_CELL_IDX(cellId, cellIdx);
1370       duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1371       /*Filling RlcUeCfg */
1372       rlcUeCfg->cellId       = cellId;
1373       rlcUeCfg->ueIdx        = ueIdx;
1374       for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1375       {
1376          ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1377          if(ret == RFAILED)
1378          {
1379             DU_LOG("\n DU_APP: Failed to fill Rlc Mode at fillRlcUeCfg()");
1380             memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1381             return ret;
1382          }
1383          /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1384          for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1385          { 
1386             if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1387             {
1388                lcIdFound = true;
1389                if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1390                      (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1391                {
1392                   /* MOD */ 
1393                   ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1394                   memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1395                }
1396             }
1397             else
1398                lcIdFound = false;
1399          }
1400          if(!lcIdFound)
1401          {
1402             /* ADD/ DEL Config Type */
1403             memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1404          }
1405          rlcUeCfg->numLcs++;
1406       }
1407    }
1408    return ret;
1409 }
1410
1411 /******************************************************************
1412  *
1413  * @brief creates UE context
1414  *
1415  * @details
1416  *
1417  *    Function : duCreateUeCb
1418  *
1419  *    Functionality: Creates UE Conetxt
1420  *
1421  * @params[in] UeCcchCtxt Pointer
1422  *             UeIdx Pointer
1423  *
1424  * @return ROK     - success
1425  *         RFAILED - failure
1426  * ****************************************************************/
1427 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1428 {
1429    uint8_t cellIdx = 0;
1430    uint8_t ret     = ROK;
1431    uint8_t ueIdx;
1432
1433    for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1434    {
1435       if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1436       {
1437          GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1438          DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1439
1440          duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb        = NULLP;
1441          duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti         = ueCcchCtxt->crnti;
1442          duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1443          duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1444          duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap     = NULLP;
1445          duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState       = UE_ACTIVE;
1446
1447          /* Filling Mac Ue Config */ 
1448          memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1449          ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1450                 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1451          if(ret == RFAILED)
1452             DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
1453          
1454          /* Filling Rlc Ue Config */
1455          memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1456          ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1457                 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1458          if(ret == RFAILED)
1459             DU_LOG("\nDU_APP: Failed to send UE create request to RLC");
1460
1461          duCb.actvCellLst[cellIdx]->numActvUes++;
1462          memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1463       }
1464    }
1465    return ret;
1466 }
1467
1468 /******************************************************************
1469  *
1470  * @brief Builds and Send UE Create Request to MAC
1471  *
1472  * @details
1473  *
1474  *    Function : duBuildAndSendUeCreateReqToMac
1475  *
1476  *    Functionality: Builds and Send UE Create Request to MAC
1477  *
1478  * @Params[in]  cellId,
1479  *              ueIdx
1480  * @return ROK     - success
1481  *         RFAILED - failure
1482  *
1483  * ****************************************************************/
1484
1485 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1486    uint16_t crnti, MacUeCfg *duMacUeCfg)
1487 {
1488    uint8_t  ret = ROK;
1489    MacUeCfg *macUeCfg = NULLP;
1490    Pst       pst;
1491    memset(&pst, 0, sizeof(Pst));
1492
1493
1494    ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1495    if(ret == RFAILED)
1496    {
1497       DU_LOG("\nDU APP: Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1498       return RFAILED;
1499    }
1500    /* Fill Pst */
1501    FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1502
1503    /* Copying ueCb to a sharable buffer */
1504    DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1505    if(macUeCfg)
1506    {
1507       memset(macUeCfg, 0, sizeof(MacUeCfg));
1508       memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1509       DU_LOG("\nDU_APP: Sending UE create request to MAC");
1510
1511       /* Processing one Ue at a time to MAC */
1512       ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1513       if(ret == RFAILED)
1514       {
1515          DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1516          DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1517       }
1518    }
1519    else
1520    {
1521       DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1522       ret = RFAILED;
1523    }
1524    return ret;
1525 }
1526
1527 /*******************************************************************
1528  *
1529  * @brief To update DuUeCb Mac Cfg
1530  *
1531  * @details
1532  *
1533  *    Function : duUpdateMacCfg
1534  *    Functionality:  update DuUeCb MAC Cfg
1535  *
1536  * @params[in] DuUeCb Pointer
1537  *             F1UeContextSetupDb pointer 
1538  * @return ROK     - success
1539  *         RFAILED - failure
1540  *
1541  * ****************************************************************/
1542 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb) 
1543 {
1544    uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1545    ret = ROK;
1546
1547    /*Filling Cell Group Cfg*/
1548    ret =  procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1549    if(ret == ROK)
1550    {
1551       if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1552       {
1553          fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1554                &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1555       }
1556       if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1557       {
1558          fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1559                NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1560       }
1561       ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1562    }
1563    /* Filling LC Context */
1564    for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1565    {
1566       numLcs = macUeCfg->numLcs;
1567       for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1568       {
1569          if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId ==  macUeCfg->lcCfgList[lcIdx].lcId)
1570          {
1571             if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1572             {
1573                ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1574             }
1575             else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1576             {
1577                /* Free memory at matched  lcIdx index */
1578                freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1579                macUeCfg->numLcs--;
1580                for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1581                {
1582                   /* moving all elements one index ahead */
1583                   ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1584                   freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1585                   if(ret == RFAILED)
1586                   {
1587                      DU_LOG("\nDU_APP: Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1588                      break;
1589                   }
1590                }
1591             }
1592          }
1593       } 
1594       if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1595       {
1596          ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1597          if(ret == RFAILED)
1598          {
1599             DU_LOG("\nDU_APP: Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1600             break;
1601          }
1602          macUeCfg->numLcs++;
1603       }
1604                 
1605    }
1606    return ret;
1607 }
1608
1609 /******************************************************************
1610  *
1611  * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1612  *
1613  * @details
1614  *
1615  *    Function : fillRlcCfgToAddMod
1616  *
1617  *    Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1618  *
1619  *
1620  *****************************************************************/
1621
1622 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1623 {
1624    lcCfg->configType = f1UeDbLcCfg->configType;
1625    lcCfg->rbId       = f1UeDbLcCfg->rbId;
1626    lcCfg->rbType     = f1UeDbLcCfg->rbType;
1627    lcCfg->lcId       = f1UeDbLcCfg->lcId;
1628    lcCfg->lcType     = f1UeDbLcCfg->lcType;
1629    lcCfg->rlcMode    = f1UeDbLcCfg->rlcMode;
1630    switch(lcCfg->rlcMode)
1631    {
1632       case RLC_AM :
1633       {
1634          if(!lcCfg->u.amCfg)
1635          {
1636             DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1637             if(!lcCfg->u.amCfg)
1638                return RFAILED;
1639          }
1640          /* DL AM */
1641          lcCfg->u.amCfg->dlAmCfg.snLenDl     = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;    
1642          lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1643          lcCfg->u.amCfg->dlAmCfg.pollPdu     = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1644          lcCfg->u.amCfg->dlAmCfg.pollByte    = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;   
1645          lcCfg->u.amCfg->dlAmCfg.maxRetxTh   = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;   
1646  
1647          /* UL AM */
1648          lcCfg->u.amCfg->ulAmCfg.snLenUl     = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1649          lcCfg->u.amCfg->ulAmCfg.reAssemTmr  = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr; 
1650          lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1651          break;
1652       }
1653       case RLC_UM_BI_DIRECTIONAL :
1654       {
1655          if(!lcCfg->u.umBiDirCfg)
1656          {
1657             DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1658             if(!lcCfg->u.umBiDirCfg)
1659                 return RFAILED;
1660          }
1661          /* UL UM BI DIR INFO */
1662          lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm  = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;  
1663          lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1664          /* DL UM BI DIR INFO */
1665          lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm  = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1666          break;
1667       }
1668       case RLC_UM_UNI_DIRECTIONAL_UL :
1669       {
1670          if(!lcCfg->u.umUniDirUlCfg)
1671          {
1672             DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1673             if(!lcCfg->u.umUniDirUlCfg)
1674                return RFAILED;
1675          }
1676          lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm  = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;  
1677          lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1678          break;
1679
1680       }
1681       case RLC_UM_UNI_DIRECTIONAL_DL :
1682       {
1683          if(!lcCfg->u.umUniDirDlCfg)
1684          {
1685             DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1686             if(!lcCfg->u.umUniDirDlCfg)
1687                return RFAILED;
1688          }
1689          lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm  = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1690          break;
1691       }
1692       default:
1693          DU_LOG("\nDU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1694          return RFAILED;
1695    }
1696    return ROK;
1697 }
1698
1699 /*******************************************************************
1700  *
1701  * @brief To update DuUeCb Rlc Lc Cfg
1702  *
1703  * @details
1704  *
1705  *    Function : duUpdateRlcLcCfg
1706  *    Functionality:  update DuUeCb Rlc Lc Cfg
1707  *
1708  * @params[in] DuUeCb Pointer
1709  *             F1UeContextSetupDb pointer 
1710  * @return ROK     - success
1711  *         RFAILED - failure
1712  *
1713  * ****************************************************************/
1714
1715 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1716 {
1717    uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1718
1719    ret = ROK;
1720    for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1721    {
1722       numLcs = rlcUeCfg->numLcs;
1723       for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1724       {
1725          if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1726          {
1727             if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1728             {
1729                ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1730             }
1731             else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1732             {
1733                /* Free memory at matched lcIdx index */
1734                freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1735                rlcUeCfg->numLcs--;
1736                for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1737                {
1738                   ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1739                   freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1740                   if(ret == RFAILED)
1741                   {
1742                      DU_LOG("\nDU_APP: Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1743                      break;
1744                   }
1745                }
1746             }
1747          }
1748       }
1749       if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1750       {
1751          ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1752          if(ret == ROK)
1753             rlcUeCfg->numLcs++;
1754       }
1755    }
1756    return ret;
1757 }
1758
1759
1760 /*******************************************************************
1761  *
1762  * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
1763  * 
1764  *
1765  * @details
1766  *
1767  *    Function : duUpdateDuUeCbCfg
1768  *
1769  *    Functionality: update DuUeCb Mac and Rlc Ue Cfg
1770  *
1771  * @params[in] ueIdx, cellIdx 
1772  * @return ROK     - success
1773  *         RFAILED - failure
1774  *
1775  * ****************************************************************/
1776
1777 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
1778 {
1779    uint8_t ret = ROK, cellIdx = 0, crnti=0;
1780    DuUeCb *ueCb = NULLP;
1781
1782    GET_CELL_IDX(cellId, cellIdx);
1783    
1784    if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
1785          macUeCfgState == UE_RECFG_COMPLETE) &&
1786       (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
1787          rlcUeCfgState == UE_RECFG_COMPLETE))
1788    {
1789       ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
1790
1791       /*Filling RLC Ue Cfg */
1792       ueCb->rlcUeCfg.cellId = cellId;
1793       ueCb->rlcUeCfg.ueIdx  = ueIdx;
1794       ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
1795       if(ret == ROK)
1796       {
1797          /*Filling MAC Ue Cfg */
1798          GET_CRNTI(crnti, ueIdx);
1799          ueCb->macUeCfg.cellId = cellId;
1800          ueCb->macUeCfg.ueIdx  = ueIdx;
1801          ueCb->macUeCfg.crnti  = crnti;
1802          ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
1803          if(ret == RFAILED)
1804             DU_LOG("\nDU APP: Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
1805       }
1806       else
1807          DU_LOG("\nDU APP: Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
1808    }
1809    else
1810       ret = RFAILED;
1811    return ret;
1812 }
1813
1814 /*******************************************************************
1815  *
1816  * @brief Handle UE config response from MAC
1817  *
1818  * @details
1819  *
1820  *    Function : DuProcMacUeCfgRsp
1821  *
1822  *    Functionality: Handle UE Config response from MAC
1823  *
1824  * @params[in] Pointer to MacUeCfgRsp and Pst 
1825  * @return ROK     - success
1826  *         RFAILED - failure
1827  *
1828  * ****************************************************************/
1829 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
1830 {
1831    uint8_t ret = ROK;
1832
1833    if(cfgRsp)
1834    {
1835       if(cfgRsp->result == MAC_DU_APP_RSP_OK)
1836       {
1837          if(pst->event == EVENT_MAC_UE_CREATE_RSP)
1838          {
1839             DU_LOG("\nDU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1840             duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1841                macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
1842          }
1843          else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
1844          {
1845             DU_LOG("\nDU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1846             duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1847                macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
1848             if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
1849                BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
1850          }
1851       }
1852       else
1853       {
1854          DU_LOG("\nDU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
1855          if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
1856          {
1857             //TODO: Send the failure case in Ue Context Setup Response
1858          }
1859          ret = RFAILED;
1860       }
1861       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
1862    }
1863    else
1864    {
1865       DU_LOG("\nDU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
1866       ret = RFAILED;
1867    }
1868    return ret;
1869 }
1870
1871
1872 /*******************************************************************
1873  *
1874  * @brief Processes UE create Req to RLC UL
1875  *
1876  * @details
1877  *
1878  *    Function : duBuildAndSendUeCreateReqToRlc
1879  *
1880  *    Functionality: 
1881  *     Processes UE create Req to RLC UL
1882  * 
1883  *  @params[in]  cellId,
1884  *               ueIdx,
1885  *               Pointer to RlcUeCfg
1886  *  @return ROK     - success
1887  *          RFAILED - failure
1888  * 
1889  *****************************************************************/
1890
1891 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
1892    RlcUeCfg *duRlcUeCfg)
1893 {
1894    uint8_t  ret = ROK;
1895    RlcUeCfg *rlcUeCfg = NULLP;
1896    Pst       pst;
1897   
1898    ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
1899    if(ret == RFAILED)
1900    {
1901       DU_LOG("\nDU_APP: Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
1902       return ret;
1903    }
1904
1905    FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
1906    /* Copying ueCfg to a sharable buffer */
1907    DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
1908    if(rlcUeCfg)
1909    {
1910       memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1911       memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
1912       /* Processing one Ue at a time to RLC */
1913       DU_LOG("\nDU_APP: Sending UE create request to RLC UL");
1914       ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
1915       if(ret == RFAILED)
1916       {
1917          DU_LOG("\nDU_APP : Failure in sending Ue Create Req to RLC");
1918          DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1919          ret = RFAILED;
1920       }
1921    }
1922    else
1923    {
1924       DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
1925       ret = RFAILED;
1926    }
1927    return ret;
1928 }
1929
1930 /*******************************************************************
1931  *
1932  * @brief Processes UE create Rsp received from RLC UL
1933  *
1934  * @details
1935  *
1936  
1937  *    Function : DuProcRlcUeCfgRsp
1938  *
1939  *    Functionality: 
1940  *     Processes UE create Rsp received from RLC UL
1941  * 
1942  *  @params[in]  Post structure
1943  *               Pointer to RlcCfgCfm
1944  *  @return ROK     - success
1945  *          RFAILED - failure
1946  * 
1947  *****************************************************************/
1948 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
1949 {
1950    uint8_t ret = ROK;
1951
1952    if(cfgRsp)
1953    {
1954       if(cfgRsp->result == RLC_DU_APP_RSP_OK)
1955       {
1956          if(pst->event == EVENT_RLC_UE_CREATE_RSP)
1957          {
1958             DU_LOG("\nDU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
1959             duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1960                rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
1961          }
1962          else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
1963          {
1964             DU_LOG("\nDU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
1965             duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1966                rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
1967             if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
1968                BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
1969          }
1970       }
1971       else
1972       {
1973          DU_LOG("\nDU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
1974             pst->event, cfgRsp->ueIdx, cfgRsp->reason);
1975          if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
1976          {
1977             //TODO: update failure case in ue Context setup Response
1978          }
1979          ret = RFAILED;
1980       }
1981       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
1982    }
1983    else
1984    {
1985       DU_LOG("\nDU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
1986       ret = RFAILED;
1987    }
1988    return ret;
1989 }
1990
1991
1992
1993 /*******************************************************************
1994  *
1995  * @brief Builds and Send Ue Reconfig Req to RLC
1996  *
1997  * @details
1998  *
1999  *    Function : duBuildAndSendUeReCfgReqToRLC
2000  *
2001  *    Functionality: Builds and Send Ue Reconfig Req to RLC
2002  *
2003  * @params[in] cellId, crnti
2004  *             DuUeCfg *ueCfgDb
2005  *             RlcUeCfg *rlcUeCfg
2006  * @return ROK     - success
2007  *         RFAILED - failure
2008  *
2009  * ****************************************************************/
2010
2011 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2012 {
2013    uint8_t ret = ROK, ueIdx = 0;
2014    RlcUeCfg *rlcUeCfg = NULLP;
2015
2016    GET_UE_IDX(crnti, ueIdx);
2017    DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2018    if(rlcUeCfg)
2019    {
2020       memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2021       ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2022       if(ret == RFAILED)
2023          DU_LOG("\nDU APP: Failed at duBuildAndSendUeReCfgReqToRlc()");
2024       else
2025          ret = sendUeReCfgReqToRlc(rlcUeCfg);
2026    }
2027    else
2028    {
2029       DU_LOG("\nDU APP: Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2030       ret = RFAILED;
2031    }
2032    return ret;
2033 }
2034
2035 /*******************************************************************
2036  *
2037  * @brief Builds and Send Ue Reconfig Req to MAC
2038  *
2039  * @details
2040  *
2041  *    Function : duBuildAndSendUeReCfgReqToMac
2042  *
2043  *    Functionality: Builds and Send Ue Reconfig Req to MAC
2044  *
2045  * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2046  *             DuUeCfg *ueCfgDb
2047  *             MacUeCfg    *macUeCfg
2048  * @return ROK     - success
2049  *         RFAILED - failure
2050  *
2051  * ****************************************************************/
2052
2053 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2054 {
2055    uint8_t ret, ueIdx = 0;
2056    MacUeCfg *macUeCfg = NULLP;
2057
2058    ret = ROK;
2059    GET_UE_IDX(crnti, ueIdx);
2060
2061    DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2062    if(macUeCfg)
2063    {
2064       memset(macUeCfg, 0, sizeof(MacUeCfg));
2065       ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2066       if(ret == RFAILED)
2067          DU_LOG("\nDU_APP: Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2068       else
2069          ret = sendUeReCfgReqToMac(macUeCfg);
2070    }
2071    else
2072    {
2073       DU_LOG("\nDU_APP: Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2074       ret = RFAILED;
2075    }
2076    return ret;
2077 }
2078
2079 /*******************************************************************
2080  *
2081  * @brief Build and Send Ue context setup request
2082  *
2083  * @details
2084  *
2085  
2086  *    Function : duBuildAndSendUeContextSetupReq
2087  *
2088  *    Functionality: 
2089  *     Build and Send Ue context setup request
2090  * 
2091  *  @params[in]  cellId, crnti, DuUeCfg pointer
2092  *  @return ROK     - success
2093  *          RFAILED - failure
2094  * 
2095  *****************************************************************/
2096
2097 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2098 {
2099    uint8_t ret = ROK;
2100
2101    DU_LOG("\nDU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2102    /* Filling RLC Ue Reconfig */ 
2103    ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2104    if(ret == RFAILED)
2105       DU_LOG("\nDU_APP: Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2106    
2107    /* Filling MAC Ue Reconfig */
2108    ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2109    if(ret == RFAILED)
2110       DU_LOG("\nDU_APP: Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2111
2112    return ret;
2113 }
2114
2115 /*******************************************************************
2116  *
2117  * @brief Processes DL Rsp received from RLC DL
2118  *
2119  * @details
2120  *
2121  
2122  *    Function : DuProcRlcDlRrcMsgRsp
2123  *
2124  *    Functionality: 
2125  *     Processes UE Rsp received from RLC DL
2126  * 
2127  *  @params[in]  Post structure
2128  *               Pointer to RlcCfgCfm
2129  *  @return ROK     - success
2130  *          RFAILED - failure
2131  * 
2132  *****************************************************************/
2133 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2134 {
2135    uint8_t ret = ROK, ueIdx = 0;
2136    DuUeCb *ueCb = NULLP;
2137
2138    if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2139    {
2140       GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2141       ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2142       if(ueCb->f1UeDb)
2143       {
2144         ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2145         if(ret == RFAILED)
2146            DU_LOG("\nDUAPP: Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2147       }
2148    }
2149    else
2150       DU_LOG("\nDUAPP: Failed to transmit DL RRC Msg");
2151
2152    DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2153    return ret;
2154 }
2155 /*******************************************************************
2156  *
2157  * @brief Process UE context setup request from CU
2158  *
2159  * @details
2160  *
2161  *    Function : duProcUeContextSetupRequest
2162  *
2163  *    Functionality: Process UE context setup request from CU
2164  *
2165  * @params[in] F1AP message
2166  * @return ROK     - success
2167  *         RFAILED - failure
2168  *
2169  * ****************************************************************/
2170
2171 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2172 {
2173    uint8_t ret, cellId;
2174    
2175    ret = ROK;
2176    if(ueCb)
2177    {
2178       cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2179       /* Send DL RRC msg for security Mode */
2180       if(ueCb->f1UeDb->dlRrcMsg)
2181       {
2182          if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2183          {
2184             /* Sending DL RRC Message to RLC */
2185             ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2186             if(ret == RFAILED)
2187             {
2188                DU_LOG("\nDU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2189                DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2190                   ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2191                DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2192             }
2193          }
2194       }
2195       else
2196       {
2197          ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2198          if(ret == RFAILED)
2199          {
2200             DU_LOG("\nDU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2201          }
2202       }
2203    }
2204    else
2205    {
2206       //TODO: To send the failure cause in UeContextSetupRsp
2207       DU_LOG("DU_APP: Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2208    }
2209    return ret;
2210 }
2211
2212 /**********************************************************************
2213   End of file
2214  ***********************************************************************/