Merge "O1 IP PORT configuration for CM .[Issue-Id: ODUHIGH-196]"
[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("\nINFO  -->  SCH :  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("\nINFO  -->  SCH :  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("\nERROR  -->  SCH : 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("\nERROR  -->  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("\nERROR  -->  SCH :  Adding UE Config Request failed at MacSchAddUeConfigReq()");
322       return RFAILED;
323    }
324    DU_LOG("\nDEBUG  -->  SCH :  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("\nDEBUG  -->  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("\nERROR  -->  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  numPdschSymbols= 14;
388   uint16_t tbSize         = 0;
389   uint8_t  buffer         = 5;
390   uint8_t  idx            = 0;
391   SchCellCb *cellCb       = ueCb->cellCb;
392   SchUlSlotInfo *schUlSlotInfo = NULLP;
393   uint8_t  k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
394   uint8_t  startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
395   uint8_t  symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
396
397   puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
398
399   startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
400   tbSize  = schCalcTbSize(dataVol + buffer); /*  2 bytes header + some buffer */
401   numRb   = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, numPdschSymbols);
402   /* increment PUSCH PRB */
403
404   cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
405
406   puschInfo->crnti             = ueCb->crnti; 
407   puschInfo->harqProcId        = SCH_HARQ_PROC_ID;
408   puschInfo->resAllocType      = SCH_ALLOC_TYPE_1;
409   puschInfo->fdAlloc.startPrb  = startRb;
410   puschInfo->fdAlloc.numPrb    = numRb;
411   puschInfo->tdAlloc.startSymb = startSymb;
412   puschInfo->tdAlloc.numSymb   = symbLen;
413   puschInfo->tbInfo.qamOrder   = ueCb->ueCfg.ulModInfo.modOrder;
414   puschInfo->tbInfo.mcs        = ueCb->ueCfg.ulModInfo.mcsIndex;
415   puschInfo->tbInfo.mcsTable   = ueCb->ueCfg.ulModInfo.mcsTable;
416   puschInfo->tbInfo.ndi        = 1; /* new transmission */
417   puschInfo->tbInfo.rv         = 0;
418   puschInfo->tbInfo.tbSize     = tbSize;
419   puschInfo->dmrsMappingType   = DMRS_MAP_TYPE_A;  /* Setting Type-A */
420   puschInfo->nrOfDmrsSymbols   = NUM_DMRS_SYMBOLS;
421   puschInfo->dmrsAddPos        = DMRS_ADDITIONAL_POS;
422
423   /* Update pusch in cell */
424   for(idx=startSymb; idx<symbLen; idx++)
425   {
426      cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
427   }
428
429   schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
430
431   SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
432   if(!schUlSlotInfo->schPuschInfo)
433   {
434      DU_LOG("\nERROR  -->  SCH: Memory allocation failed in schAllocMsg3Pusch");
435      return RFAILED;
436   }
437   memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
438
439   return ROK;
440 }
441
442 /*******************************************************************
443  *
444  * @brief Fills DCI for UL grant
445  *
446  * @details
447  *
448  *    Function : schFillUlDci
449  *
450  *    Functionality: fills DCI for UL grant in response to BSR
451  *
452  * @params[in]
453  * @return ROK     - success
454  *         RFAILED - failure
455  *
456  * ****************************************************************/
457 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
458 {
459    SchCellCb         *cellCb  = ueCb->cellCb;
460    SchControlRsrcSet coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
461
462    dciInfo->cellId = cellCb->cellId;
463    dciInfo->crnti  = ueCb->crnti;
464
465    /* fill bwp cfg */
466    dciInfo->bwpCfg.subcarrierSpacing  = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
467    dciInfo->bwpCfg.cyclicPrefix       = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
468    dciInfo->bwpCfg.freqAlloc.startPrb = 0;
469    dciInfo->bwpCfg.freqAlloc.numPrb   = MAX_NUM_RB; /* whole of BW */
470
471    /*fill coreset cfg */
472    //Considering number of RBs in coreset1 is same as coreset0
473    dciInfo->coresetCfg.coreSetSize      = coresetIdxTable[0][1];
474    //Considering coreset1 also starts from same symbol as coreset0
475    dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
476    dciInfo->coresetCfg.durationSymbols  = coreset1.duration;
477    memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
478    
479    dciInfo->coresetCfg.cceRegMappingType   = coreset1.cceRegMappingType; /* non-interleaved */
480    dciInfo->coresetCfg.regBundleSize       = 6; /* must be 6 for non-interleaved */
481    dciInfo->coresetCfg.interleaverSize     = 0; /* NA for non-interleaved */
482    dciInfo->coresetCfg.coreSetType         = 1; /* non PBCH coreset */
483    dciInfo->coresetCfg.shiftIndex          = cellCb->cellCfg.phyCellId;
484    dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
485    dciInfo->coresetCfg.cceIndex            = 0; /* 0-3 for UL and 4-7 for DL */
486    dciInfo->coresetCfg.aggregationLevel    = 4; /* same as for sib1 */
487    
488    dciInfo->formatType = FORMAT0_0;
489    
490    /* fill UL grant */
491    dciInfo->format.format0_0.resourceAllocType   = puschInfo.resAllocType;
492    dciInfo->format.format0_0.freqAlloc.startPrb  = puschInfo.fdAlloc.startPrb;
493    dciInfo->format.format0_0.freqAlloc.numPrb    = puschInfo.fdAlloc.numPrb;
494    dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
495    dciInfo->format.format0_0.timeAlloc.numSymb   = puschInfo.tdAlloc.numSymb;
496    dciInfo->format.format0_0.rowIndex            = 0; /* row Index */
497    dciInfo->format.format0_0.mcs                 = puschInfo.tbInfo.mcs;
498    dciInfo->format.format0_0.harqProcId          = puschInfo.harqProcId;
499    dciInfo->format.format0_0.puschHopFlag        = FALSE; /* disabled */
500    dciInfo->format.format0_0.freqHopFlag         = FALSE; /* disabled */
501    dciInfo->format.format0_0.ndi                 = puschInfo.tbInfo.ndi; /* new transmission */
502    dciInfo->format.format0_0.rv                  = puschInfo.tbInfo.rv;
503    dciInfo->format.format0_0.tpcCmd              = 0; //Sphoorthi TODO: check
504    dciInfo->format.format0_0.sUlCfgd             = FALSE; /* SUL not configured */
505    
506    /* Fill DCI Structure */
507    dciInfo->dciInfo.rnti                              = ueCb->crnti;
508    dciInfo->dciInfo.scramblingId                      = cellCb->cellCfg.phyCellId;
509    dciInfo->dciInfo.scramblingRnti                    = 0;
510    dciInfo->dciInfo.cceIndex                          = 0; /* 0-3 for UL and 4-7 for DL */
511    dciInfo->dciInfo.aggregLevel                       = 4;
512    dciInfo->dciInfo.beamPdcchInfo.numPrgs             = 1;
513    dciInfo->dciInfo.beamPdcchInfo.prgSize             = 1;
514    dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces     = 0;
515    dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx        = 0;
516    dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0]   = 0;
517    dciInfo->dciInfo.txPdcchPower.powerValue           = 0;
518    dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
519    dciInfo->dciInfo.pdschCfg                          = NULLP; /* No DL data being sent */
520
521    return ROK;
522 }
523
524 /*******************************************************************
525  *
526  * @brief Function to Modify Ue Config request from MAC
527  *
528  * @details
529  *
530  *    Function : MacSchModUeConfigReq
531  *
532  *    Functionality: Function to modify Ue Config request from MAC
533  *
534  * @params[in] 
535  * @return ROK     - success
536  *         RFAILED - failure
537  *
538  * ****************************************************************/
539 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
540 {
541    uint8_t ueIdx, lcIdx, ret = ROK;
542    SchCellCb    *cellCb = NULLP;
543    SchUeCb      *ueCb = NULLP;
544    SchUeCfgRsp  cfgRsp;
545    Inst         inst = pst->dstInst - 1;
546    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
547
548    if(!ueCfg)
549    {
550       DU_LOG("\nERROR  -->  SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
551       return RFAILED;
552    }
553    DU_LOG("\nDEBUG  -->  SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
554    cellCb = getSchCellCb(pst->event, inst, ueCfg);
555
556    /* Search if UE already configured */
557    GET_UE_IDX(ueCfg->crnti, ueIdx);
558    ueCb = &cellCb->ueCb[ueIdx -1];
559    
560    if(!ueCb)
561    {
562       DU_LOG("\nERROR  -->  SCH : SchUeCb not found at MacSchModUeConfigReq() ");
563       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
564       return RFAILED;
565    }
566    if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
567    {
568       /* Found the UeCb to Reconfig */
569       ret = fillSchUeCb(ueCb, ueCfg);
570       if(ret == ROK)
571       {
572          ueCb->cellCb = cellCb;
573          ueCb->srRcvd = false;
574          for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
575             ueCb->bsrInfo[lcIdx].dataVol = 0;
576
577          SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
578       }
579    }
580    return ret;
581 }
582
583 /**********************************************************************
584   End of file
585  **********************************************************************/