bb76ede8ca2812bf0acee55bd87e17bc8c37f50f
[o-du/l2.git] / src / 5gnrsch / sch_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 SCH */
19
20 #include "common_def.h"
21 #include "tfu.h"
22 #include "lrg.h"
23
24 #include "tfu.x"
25 #include "lrg.x"
26 #include "du_log.h"
27 #include "du_app_mac_inf.h"
28 #include "mac_sch_interface.h"
29 #include "sch.h"
30 #include "sch_utils.h"
31
32 /* local defines */
33 SchUeCfgRspFunc SchUeCfgRspOpts[] =
34 {
35    packSchUeCfgRsp,      /* LC */
36    MacProcSchUeCfgRsp,   /* TC */
37    packSchUeCfgRsp       /* LWLC */
38 };
39
40
41 /*******************************************************************
42  *
43  * @brief Fill and send UE cfg response to MAC
44  *
45  * @details
46  *
47  *    Function : SchSendUeCfgRspToMac
48  *
49  *    Functionality: Fill and send UE cfg response to MAC
50  *
51  * @params[in] 
52  * @return ROK     - success
53  *         RFAILED - failure
54  *
55  * ****************************************************************/
56 void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
57       SchMacRsp result, SchUeCfgRsp *cfgRsp)
58 {
59    Pst rspPst;
60
61    cfgRsp->cellId = ueCfg->cellId;
62    cfgRsp->crnti = ueCfg->crnti;
63    GET_UE_IDX(ueCfg->crnti, cfgRsp->ueIdx);
64    cfgRsp->rsp = result;   
65
66    /* Filling response post */
67    memset(&rspPst, 0, sizeof(Pst));
68    FILL_PST_SCH_TO_MAC(rspPst, inst);
69    if(event == EVENT_ADD_UE_CONFIG_REQ_TO_SCH)
70    {
71       rspPst.event = EVENT_UE_CONFIG_RSP_TO_MAC;
72       DU_LOG("\nSCH: Sending UE Config response to MAC");
73    }
74    else if(event == EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH)
75    {
76       rspPst.event = EVENT_UE_RECONFIG_RSP_TO_MAC;
77       DU_LOG("\nSCH: Sending UE Reconfig response to MAC");
78    }
79    SchUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
80 }
81
82 /*******************************************************************
83  
84  *
85  * @brief Function to fill Dl Lc Context in SCH Ue Cb
86  *
87  * @details
88  *
89  *    Function : fillSchDlLcCtxt
90  *
91  *    Functionality: Function to fill Dl Lc Context in SCH Ue Cb
92  *
93  * @params[in] SchDlLcCtxt pointer,
94  *             SchLcCfg pointer
95  * @return void
96  *
97  * ****************************************************************/
98
99 void fillSchDlLcCtxt(SchDlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
100 {
101    ueCbLcCfg->lcId = lcCfg->lcId;
102    ueCbLcCfg->lcp = lcCfg->dlLcCfg.lcp;
103    ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
104    ueCbLcCfg->bo = 0;
105 }
106
107 /*******************************************************************
108  *
109  * @brief Function to fill Ul Lc Context in SCH Ue Cb
110  *
111  * @details
112  *
113  *    Function : fillSchUlLcCtxt
114  *
115  *    Functionality: Function to fill Ul Lc Context in SCH Ue Cb
116  *
117  * @params[in] SchUlLcCtxt pointer,
118  *             SchLcCfg pointer
119  * @return void
120  *
121  * ****************************************************************/
122
123 void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
124 {
125    ueCbLcCfg->lcId = lcCfg->lcId;
126    ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
127    ueCbLcCfg->priority = lcCfg->ulLcCfg.priority;
128    ueCbLcCfg->lcGroup = lcCfg->ulLcCfg.lcGroup;
129    ueCbLcCfg->schReqId = lcCfg->ulLcCfg.schReqId;
130    ueCbLcCfg->pbr     = lcCfg->ulLcCfg.pbr;
131    ueCbLcCfg->bsd     = lcCfg->ulLcCfg.bsd;
132
133 }
134
135 /*******************************************************************
136  *
137  * @brief Function to update Sch Ul Lc Cb
138  *
139  * @details
140  *
141  *    Function : updateSchUlCb
142  *
143  *    Functionality: Function to update SCH Ul Lc Cb
144  *
145  * @returns void
146  *
147  * ****************************************************************/
148
149 void updateSchUlCb(uint8_t delIdx, SchUlCb *ulInfo)
150 {
151    uint8_t lcIdx = 0;
152
153    for(lcIdx = delIdx; lcIdx < ulInfo->numUlLc; lcIdx++)
154    {
155       memcpy(&ulInfo->ulLcCtxt[lcIdx], &ulInfo->ulLcCtxt[lcIdx+1], sizeof(SchUlLcCtxt));
156       memset(&ulInfo->ulLcCtxt[lcIdx+1], 0, sizeof(SchUlLcCtxt));
157    }
158 }
159
160 /*******************************************************************
161  *
162  * @brief Function to update SCH Dl Lc Cb
163  *
164  * @details
165  *
166  *    Function : updateSchDlCb
167  *
168  *    Functionality: Function to update SCH DL Lc Cb
169  *
170  * @returns void
171  *
172  * ****************************************************************/
173
174 void updateSchDlCb(uint8_t delIdx, SchDlCb *dlInfo)
175 {
176    uint8_t lcIdx = 0;
177
178    for(lcIdx = delIdx; lcIdx < dlInfo->numDlLc; lcIdx++)
179    {
180       memcpy(&dlInfo->dlLcCtxt[lcIdx], &dlInfo->dlLcCtxt[lcIdx+1], sizeof(SchDlLcCtxt));
181       memset(&dlInfo->dlLcCtxt[lcIdx+1], 0, sizeof(SchDlLcCtxt));
182    }
183 }
184
185 /*******************************************************************
186  *
187  * @brief Function to fill SchUeCb
188  *
189  * @details
190  *
191  *    Function : fillSchUeCb
192  *
193  *    Functionality: Function to fill SchUeCb
194  *
195  * @params[in] SchUeCb pointer,
196  *             SchUeCfg pointer
197  * @return ROK/RFAILED
198  *
199  * ****************************************************************/
200
201 uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
202 {
203    uint8_t   lcIdx, ueLcIdx;
204
205    memset(&ueCb->ueCfg, 0, sizeof(SchUeCfg));
206    memcpy(&ueCb->ueCfg, ueCfg, sizeof(SchUeCfg));
207    ueCb->state = SCH_UE_STATE_ACTIVE;
208
209    for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
210    {
211       if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
212       {
213          fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
214          ueCb->ulInfo.numUlLc++;
215          fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
216          ueCb->dlInfo.numDlLc++;
217       }
218       else
219       {
220          for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
221          {
222             if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
223             {
224                if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
225                {
226                   fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
227                   fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
228                   break;
229                }
230                if(ueCfg->schLcCfg[ueLcIdx].configType == CONFIG_DEL)
231                {
232                   memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
233                   ueCb->ulInfo.numUlLc--;
234                   updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead 
235                   memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
236                   ueCb->dlInfo.numDlLc--;
237                   updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
238                   break;
239                }
240             }
241          }/*End of inner for loop */
242       }
243    }/* End of outer for loop */
244    return ROK;
245 }
246
247 /*******************************************************************
248  *
249  * @brief Function to get SCH Cell Cb
250  *
251  * @details
252  *
253  *    Function : getSchCellCb
254  *
255  *    Functionality: Function to get SCH Cell Cb
256  *
257  * @params[in] event, SchUeCfg pointer 
258  * @return schUeCb pointer  - success
259  *         NULLP - failure
260  *
261  * ****************************************************************/
262
263 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
264 {
265    uint8_t      idx;
266    SchCellCb    *cellCb = NULLP;
267    SchUeCfgRsp  cfgRsp;
268    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
269
270    /* Search of cell cb */
271    for(idx = 0; idx < MAX_NUM_CELL; idx++)
272    {
273       cellCb = schCb[inst].cells[idx];
274       if(cellCb->cellId == ueCfg->cellId)
275          break;
276    }
277    if(idx == MAX_NUM_CELL)
278    {
279       DU_LOG("\nSCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
280       SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
281       return NULLP;
282    }
283
284    /* Check if max number of UE configured */
285    if(cellCb->numActvUe > MAX_NUM_UE)
286    {
287       DU_LOG("SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
288       SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
289       return NULLP;
290    }
291    return cellCb;
292 }
293
294
295 /*******************************************************************
296  *
297  * @brief Function to Add Ue Config Request from MAC
298  *
299  * @details
300  *
301  *    Function : MacSchAddUeConfigReq
302  *
303  *    Functionality: Function to Add Ue config request from MAC
304  *
305  * @params[in] 
306  * @return ROK     - success
307  *         RFAILED - failure
308  *
309  * ****************************************************************/
310 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
311 {
312    uint8_t ueIdx, lcIdx, ret = ROK;
313    SchCellCb    *cellCb = NULLP;
314    SchUeCb      *ueCb = NULLP;
315    SchUeCfgRsp  cfgRsp;
316    Inst         inst = pst->dstInst - 1;
317    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
318
319    if(!ueCfg)
320    {
321       DU_LOG("\nSCH : Adding UE Config Request failed at MacSchAddUeConfigReq()");
322       return RFAILED;
323    }
324    DU_LOG("\nSCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
325    cellCb = getSchCellCb(pst->event, inst, ueCfg);
326
327    /* Search if UE already configured */
328    GET_UE_IDX(ueCfg->crnti, ueIdx);
329    ueCb = &cellCb->ueCb[ueIdx -1];
330    if(ueCb)
331    {
332       if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
333       {
334          DU_LOG("\n SCH : CRNTI %d already configured ", ueCfg->crnti);
335          SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
336          return ROK;
337       }
338    }
339    else
340    {
341       DU_LOG("\n SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
342       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
343       return RFAILED;
344    }
345
346    /* Fill received Ue Configuration in UeCb */
347    memset(ueCb, 0, sizeof(SchUeCb));
348    GET_UE_IDX(ueCfg->crnti, ueIdx);
349    ueCb->ueIdx = ueIdx;
350    ueCb->crnti = ueCfg->crnti;
351    ueCb->state = SCH_UE_STATE_ACTIVE;
352    ret = fillSchUeCb(ueCb, ueCfg);
353    if(ret == ROK)
354    {
355       cellCb->numActvUe++;
356       SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
357       ueCb->cellCb = cellCb;
358       ueCb->srRcvd = false;
359       for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
360          ueCb->bsrInfo[lcIdx].dataVol = 0;
361
362       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
363    }
364    return ret;
365 }
366
367 /*******************************************************************
368 *
369 * @brief Fills PUSCH UL allocation
370 *
371 * @details
372 *
373 *    Function : schFillPuschAlloc
374 *
375 *    Functionality: fills PUSCH info
376 *
377 * @params[in]
378 * @return ROK     - success
379 *         RFAILED - failure
380 *
381 * ****************************************************************/
382 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
383 {
384   uint16_t puschSlot      = 0;
385   uint16_t startRb        = 0;
386   uint8_t  numRb          = 0;
387   uint8_t  mcs            = 4;
388   uint8_t  numPdschSymbols= 14;
389   uint16_t tbSize         = 0;
390   uint8_t  buffer         = 5;
391   uint8_t  idx            = 0;
392   SchCellCb *cellCb       = ueCb->cellCb;
393   SchUlSlotInfo *schUlSlotInfo = NULLP;
394   uint8_t  k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
395   uint8_t  startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
396   uint8_t  symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
397
398   puschSlot = (pdcchSlot + k2) % SCH_NUM_SLOTS;
399
400   startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
401   tbSize  = schCalcTbSize(dataVol + buffer); /*  2 bytes header + some buffer */
402   numRb   = schCalcNumPrb(tbSize, mcs, numPdschSymbols);
403   /* increment PUSCH PRB */
404
405   cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
406
407   puschInfo->crnti             = ueCb->crnti; 
408   puschInfo->harqProcId        = SCH_HARQ_PROC_ID;
409   puschInfo->resAllocType      = SCH_ALLOC_TYPE_1;
410   puschInfo->fdAlloc.startPrb  = startRb;
411   puschInfo->fdAlloc.numPrb    = numRb;
412   puschInfo->tdAlloc.startSymb = startSymb;
413   puschInfo->tdAlloc.numSymb   = symbLen;
414   puschInfo->tbInfo.mcs        = mcs;
415   puschInfo->tbInfo.ndi        = 1; /* new transmission */
416   puschInfo->tbInfo.rv         = 0;
417   puschInfo->tbInfo.tbSize     = tbSize;
418   puschInfo->dmrsMappingType   = DMRS_MAP_TYPE_A;  /* Setting Type-A */
419   puschInfo->nrOfDmrsSymbols   = NUM_DMRS_SYMBOLS;
420   puschInfo->dmrsAddPos        = DMRS_ADDITIONAL_POS;
421
422   /* Update pusch in cell */
423   for(idx=startSymb; idx<symbLen; idx++)
424   {
425      cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
426   }
427
428   schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
429
430   SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
431   if(!schUlSlotInfo->schPuschInfo)
432   {
433      DU_LOG("SCH: Memory allocation failed in schAllocMsg3Pusch");
434      return RFAILED;
435   }
436   memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
437
438   return ROK;
439 }
440
441 /*******************************************************************
442  *
443  * @brief Fills DCI for UL grant
444  *
445  * @details
446  *
447  *    Function : schFillUlDci
448  *
449  *    Functionality: fills DCI for UL grant in response to BSR
450  *
451  * @params[in]
452  * @return ROK     - success
453  *         RFAILED - failure
454  *
455  * ****************************************************************/
456 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
457 {
458    SchCellCb         *cellCb  = ueCb->cellCb;
459    SchControlRsrcSet coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
460
461    dciInfo->cellId = cellCb->cellId;
462    dciInfo->crnti  = ueCb->crnti;
463
464    /* fill bwp cfg */
465    dciInfo->bwpCfg.subcarrierSpacing  = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
466    dciInfo->bwpCfg.cyclicPrefix       = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
467    dciInfo->bwpCfg.freqAlloc.startPrb = 0;
468    dciInfo->bwpCfg.freqAlloc.numPrb   = MAX_NUM_RB; /* whole of BW */
469
470    /*fill coreset cfg */
471    //Considering number of RBs in coreset1 is same as coreset0
472    dciInfo->coresetCfg.coreSetSize      = coresetIdxTable[0][1];
473    //Considering coreset1 also starts from same symbol as coreset0
474    dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
475    dciInfo->coresetCfg.durationSymbols  = coreset1.duration;
476    memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
477    
478    dciInfo->coresetCfg.cceRegMappingType   = coreset1.cceRegMappingType; /* non-interleaved */
479    dciInfo->coresetCfg.regBundleSize       = 6; /* must be 6 for non-interleaved */
480    dciInfo->coresetCfg.interleaverSize     = 0; /* NA for non-interleaved */
481    dciInfo->coresetCfg.coreSetType         = 1; /* non PBCH coreset */
482    dciInfo->coresetCfg.shiftIndex          = cellCb->cellCfg.phyCellId;
483    dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
484    dciInfo->coresetCfg.cceIndex            = 0; /* 0-3 for UL and 4-7 for DL */
485    dciInfo->coresetCfg.aggregationLevel    = 4; /* same as for sib1 */
486    
487    dciInfo->formatType = FORMAT0_0;
488    
489    /* fill UL grant */
490    dciInfo->format.format0_0.resourceAllocType   = puschInfo.resAllocType;
491    dciInfo->format.format0_0.freqAlloc.startPrb  = puschInfo.fdAlloc.startPrb;
492    dciInfo->format.format0_0.freqAlloc.numPrb    = puschInfo.fdAlloc.numPrb;
493    dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
494    dciInfo->format.format0_0.timeAlloc.numSymb   = puschInfo.tdAlloc.numSymb;
495    dciInfo->format.format0_0.rowIndex            = 0; /* row Index */
496    dciInfo->format.format0_0.mcs                 = puschInfo.tbInfo.mcs;
497    dciInfo->format.format0_0.harqProcId          = puschInfo.harqProcId;
498    dciInfo->format.format0_0.puschHopFlag        = FALSE; /* disabled */
499    dciInfo->format.format0_0.freqHopFlag         = FALSE; /* disabled */
500    dciInfo->format.format0_0.ndi                 = puschInfo.tbInfo.ndi; /* new transmission */
501    dciInfo->format.format0_0.rv                  = puschInfo.tbInfo.rv;
502    dciInfo->format.format0_0.tpcCmd              = 0; //Sphoorthi TODO: check
503    dciInfo->format.format0_0.sUlCfgd             = FALSE; /* SUL not configured */
504    
505    /* Fill DCI Structure */
506    dciInfo->dciInfo.rnti                              = ueCb->crnti;
507    dciInfo->dciInfo.scramblingId                      = cellCb->cellCfg.phyCellId;
508    dciInfo->dciInfo.scramblingRnti                    = 0;
509    dciInfo->dciInfo.cceIndex                          = 0; /* 0-3 for UL and 4-7 for DL */
510    dciInfo->dciInfo.aggregLevel                       = 4;
511    dciInfo->dciInfo.beamPdcchInfo.numPrgs             = 1;
512    dciInfo->dciInfo.beamPdcchInfo.prgSize             = 1;
513    dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces     = 0;
514    dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx        = 0;
515    dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0]   = 0;
516    dciInfo->dciInfo.txPdcchPower.powerValue           = 0;
517    dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
518    dciInfo->dciInfo.pdschCfg                          = NULLP; /* No DL data being sent */
519
520    return ROK;
521 }
522
523 /*******************************************************************
524  *
525  * @brief Function to Modify Ue Config request from MAC
526  *
527  * @details
528  *
529  *    Function : MacSchModUeConfigReq
530  *
531  *    Functionality: Function to modify Ue Config request from MAC
532  *
533  * @params[in] 
534  * @return ROK     - success
535  *         RFAILED - failure
536  *
537  * ****************************************************************/
538 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
539 {
540    uint8_t ueIdx, lcIdx, ret = ROK;
541    SchCellCb    *cellCb = NULLP;
542    SchUeCb      *ueCb = NULLP;
543    SchUeCfgRsp  cfgRsp;
544    Inst         inst = pst->dstInst - 1;
545    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
546
547    if(!ueCfg)
548    {
549       DU_LOG("\nSCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
550       return RFAILED;
551    }
552    DU_LOG("\nSCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
553    cellCb = getSchCellCb(pst->event, inst, ueCfg);
554
555    /* Search if UE already configured */
556    GET_UE_IDX(ueCfg->crnti, ueIdx);
557    ueCb = &cellCb->ueCb[ueIdx -1];
558    
559    if(!ueCb)
560    {
561       DU_LOG("\n SCH : SchUeCb not found at MacSchModUeConfigReq() ");
562       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
563       return RFAILED;
564    }
565    if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
566    {
567       /* Found the UeCb to Reconfig */
568       ret = fillSchUeCb(ueCb, ueCfg);
569       if(ret == ROK)
570       {
571          ueCb->cellCb = cellCb;
572          ueCb->srRcvd = false;
573          for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
574             ueCb->bsrInfo[lcIdx].dataVol = 0;
575
576          SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
577       }
578    }
579    return ret;
580 }
581
582 /**********************************************************************
583   End of file
584  **********************************************************************/