JIRA ID = ODUHIGH-298 RB configuration at MAC/SCH/RLC for ue modification
[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    ueCb->ueCfg.cellId = ueCfg->cellId;
206    ueCb->ueCfg.crnti = ueCfg->crnti;
207    if(ueCfg->macCellGrpCfgPres == true)
208    {
209       memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg)); 
210       ueCb->ueCfg.macCellGrpCfgPres = true;
211    }
212
213    if(ueCfg->phyCellGrpCfgPres == true)
214    {
215       memcpy(&ueCb->ueCfg.phyCellGrpCfg ,  &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
216       ueCb->ueCfg.phyCellGrpCfgPres = true;
217    }
218
219    if(ueCfg->spCellCfgPres == true)
220    {
221       memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
222       ueCb->ueCfg.spCellCfgPres = true;
223    }
224    ueCb->state = SCH_UE_STATE_ACTIVE;
225    if(ueCfg->ambrCfg != NULLP)
226    {
227       SCH_ALLOC(ueCb->ueCfg.ambrCfg , sizeof(SchAmbrCfg));
228       memcpy(&ueCb->ueCfg.ambrCfg->ulBr , &ueCfg->ambrCfg->ulBr, sizeof(SchAmbrCfg));
229    }
230    
231    memcpy(&ueCb->ueCfg.dlModInfo,  &ueCfg->dlModInfo , sizeof(SchModulationInfo));
232    memcpy(&ueCb->ueCfg.ulModInfo,  &ueCfg->ulModInfo , sizeof(SchModulationInfo));
233
234    //Updating SchUlCb and SchDlCb DB in SchUeCb
235    for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
236    {
237       if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
238       {
239          fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
240          ueCb->ulInfo.numUlLc++;
241          fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
242          ueCb->dlInfo.numDlLc++;
243       }
244       else
245       {
246          for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
247          {
248             if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
249             {
250                if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
251                {
252                   fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
253                   fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
254                   break;
255                }
256                if(ueCfg->schLcCfg[ueLcIdx].configType == CONFIG_DEL)
257                {
258                   memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
259                   ueCb->ulInfo.numUlLc--;
260                   updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead 
261                   memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
262                   ueCb->dlInfo.numDlLc--;
263                   updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
264                   break;
265                }
266             }
267          }/*End of inner for loop */
268       }
269    }/* End of outer for loop */
270    return ROK;
271 }
272
273 /*******************************************************************
274  *
275  * @brief Function to get SCH Cell Cb
276  *
277  * @details
278  *
279  *    Function : getSchCellCb
280  *
281  *    Functionality: Function to get SCH Cell Cb
282  *
283  * @params[in] event, SchUeCfg pointer 
284  * @return schUeCb pointer  - success
285  *         NULLP - failure
286  *
287  * ****************************************************************/
288
289 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
290 {
291    uint8_t      idx;
292    SchCellCb    *cellCb = NULLP;
293    SchUeCfgRsp  cfgRsp;
294    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
295
296    /* Search of cell cb */
297    for(idx = 0; idx < MAX_NUM_CELL; idx++)
298    {
299       cellCb = schCb[inst].cells[idx];
300       if(cellCb->cellId == ueCfg->cellId)
301          break;
302    }
303    if(idx == MAX_NUM_CELL)
304    {
305       DU_LOG("\nERROR  -->  SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
306       SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
307       return NULLP;
308    }
309
310    /* Check if max number of UE configured */
311    if(cellCb->numActvUe > MAX_NUM_UE)
312    {
313       DU_LOG("\nERROR  -->  SCH :  Max number of UE [%d] already configured", MAX_NUM_UE);
314       SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
315       return NULLP;
316    }
317    return cellCb;
318 }
319
320
321 /*******************************************************************
322  *
323  * @brief Function to Add Ue Config Request from MAC
324  *
325  * @details
326  *
327  *    Function : MacSchAddUeConfigReq
328  *
329  *    Functionality: Function to Add Ue config request from MAC
330  *
331  * @params[in] 
332  * @return ROK     - success
333  *         RFAILED - failure
334  *
335  * ****************************************************************/
336 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
337 {
338    uint8_t ueIdx, lcIdx, ret = ROK;
339    SchCellCb    *cellCb = NULLP;
340    SchUeCb      *ueCb = NULLP;
341    SchUeCfgRsp  cfgRsp;
342    Inst         inst = pst->dstInst - 1;
343    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
344
345    if(!ueCfg)
346    {
347       DU_LOG("\nERROR  -->  SCH :  Adding UE Config Request failed at MacSchAddUeConfigReq()");
348       return RFAILED;
349    }
350    DU_LOG("\nDEBUG  -->  SCH :  Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
351    cellCb = getSchCellCb(pst->event, inst, ueCfg);
352
353    /* Search if UE already configured */
354    GET_UE_IDX(ueCfg->crnti, ueIdx);
355    ueCb = &cellCb->ueCb[ueIdx -1];
356    if(ueCb)
357    {
358       if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
359       {
360          DU_LOG("\nDEBUG  -->  SCH : CRNTI %d already configured ", ueCfg->crnti);
361          SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
362          return ROK;
363       }
364    }
365    else
366    {
367       DU_LOG("\nERROR  -->  SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
368       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
369       return RFAILED;
370    }
371
372    /* Fill received Ue Configuration in UeCb */
373    memset(ueCb, 0, sizeof(SchUeCb));
374    GET_UE_IDX(ueCfg->crnti, ueIdx);
375    ueCb->ueIdx = ueIdx;
376    ueCb->crnti = ueCfg->crnti;
377    ueCb->state = SCH_UE_STATE_ACTIVE;
378    ret = fillSchUeCb(ueCb, ueCfg);
379    if(ret == ROK)
380    {
381       cellCb->numActvUe++;
382       SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
383       ueCb->cellCb = cellCb;
384       ueCb->srRcvd = false;
385       for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
386          ueCb->bsrInfo[lcIdx].dataVol = 0;
387
388       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
389    }
390    return ret;
391 }
392
393 /*******************************************************************
394 *
395 * @brief Fills PUSCH UL allocation
396 *
397 * @details
398 *
399 *    Function : schFillPuschAlloc
400 *
401 *    Functionality: fills PUSCH info
402 *
403 * @params[in]
404 * @return ROK     - success
405 *         RFAILED - failure
406 *
407 * ****************************************************************/
408 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
409 {
410   uint16_t puschSlot      = 0;
411   uint16_t startRb        = 0;
412   uint8_t  numRb          = 0;
413   uint8_t  numPdschSymbols= 14;
414   uint16_t tbSize         = 0;
415   uint8_t  buffer         = 5;
416   uint8_t  idx            = 0;
417   SchCellCb *cellCb       = ueCb->cellCb;
418   SchUlSlotInfo *schUlSlotInfo = NULLP;
419   uint8_t k2=0, startSymb=0 , symbLen=0;
420   
421   if(ueCb->ueCfg.spCellCfgPres == true)
422   {
423      k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
424      startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
425      symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
426   }
427   puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
428
429   startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
430   tbSize  = schCalcTbSize(dataVol + buffer); /*  2 bytes header + some buffer */
431   numRb   = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, numPdschSymbols);
432   /* increment PUSCH PRB */
433
434   cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
435
436   puschInfo->crnti             = ueCb->crnti; 
437   puschInfo->harqProcId        = SCH_HARQ_PROC_ID;
438   puschInfo->resAllocType      = SCH_ALLOC_TYPE_1;
439   puschInfo->fdAlloc.startPrb  = startRb;
440   puschInfo->fdAlloc.numPrb    = numRb;
441   puschInfo->tdAlloc.startSymb = startSymb;
442   puschInfo->tdAlloc.numSymb   = symbLen;
443   puschInfo->tbInfo.qamOrder   = ueCb->ueCfg.ulModInfo.modOrder;
444   puschInfo->tbInfo.mcs        = ueCb->ueCfg.ulModInfo.mcsIndex;
445   puschInfo->tbInfo.mcsTable   = ueCb->ueCfg.ulModInfo.mcsTable;
446   puschInfo->tbInfo.ndi        = 1; /* new transmission */
447   puschInfo->tbInfo.rv         = 0;
448   puschInfo->tbInfo.tbSize     = tbSize;
449   puschInfo->dmrsMappingType   = DMRS_MAP_TYPE_A;  /* Setting Type-A */
450   puschInfo->nrOfDmrsSymbols   = NUM_DMRS_SYMBOLS;
451   puschInfo->dmrsAddPos        = DMRS_ADDITIONAL_POS;
452
453   /* Update pusch in cell */
454   for(idx=startSymb; idx<symbLen; idx++)
455   {
456      cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
457   }
458
459   schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
460
461   SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
462   if(!schUlSlotInfo->schPuschInfo)
463   {
464      DU_LOG("\nERROR  -->  SCH: Memory allocation failed in schAllocMsg3Pusch");
465      return RFAILED;
466   }
467   memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
468
469   return ROK;
470 }
471
472 /*******************************************************************
473  *
474  * @brief Fills DCI for UL grant
475  *
476  * @details
477  *
478  *    Function : schFillUlDci
479  *
480  *    Functionality: fills DCI for UL grant in response to BSR
481  *
482  * @params[in]
483  * @return ROK     - success
484  *         RFAILED - failure
485  *
486  * ****************************************************************/
487 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
488 {
489    SchCellCb         *cellCb  = ueCb->cellCb;
490    SchControlRsrcSet coreset1 ;
491   
492    memset(&coreset1, 0, sizeof(SchControlRsrcSet));
493    if(ueCb->ueCfg.spCellCfgPres == true)
494    {
495      coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
496    }
497    
498    dciInfo->cellId = cellCb->cellId;
499    dciInfo->crnti  = ueCb->crnti;
500
501    /* fill bwp cfg */
502    dciInfo->bwpCfg.subcarrierSpacing  = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
503    dciInfo->bwpCfg.cyclicPrefix       = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
504    dciInfo->bwpCfg.freqAlloc.startPrb = 0;
505    dciInfo->bwpCfg.freqAlloc.numPrb   = MAX_NUM_RB; /* whole of BW */
506
507    /*fill coreset cfg */
508    //Considering number of RBs in coreset1 is same as coreset0
509    dciInfo->coresetCfg.coreSetSize      = coresetIdxTable[0][1];
510    //Considering coreset1 also starts from same symbol as coreset0
511    dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
512    dciInfo->coresetCfg.durationSymbols  = coreset1.duration;
513    memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
514    
515    dciInfo->coresetCfg.cceRegMappingType   = coreset1.cceRegMappingType; /* non-interleaved */
516    dciInfo->coresetCfg.regBundleSize       = 6; /* must be 6 for non-interleaved */
517    dciInfo->coresetCfg.interleaverSize     = 0; /* NA for non-interleaved */
518    dciInfo->coresetCfg.coreSetType         = 1; /* non PBCH coreset */
519    dciInfo->coresetCfg.shiftIndex          = cellCb->cellCfg.phyCellId;
520    dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
521    dciInfo->coresetCfg.cceIndex            = 0; /* 0-3 for UL and 4-7 for DL */
522    dciInfo->coresetCfg.aggregationLevel    = 4; /* same as for sib1 */
523    
524    dciInfo->formatType = FORMAT0_0;
525    
526    /* fill UL grant */
527    dciInfo->format.format0_0.resourceAllocType   = puschInfo.resAllocType;
528    dciInfo->format.format0_0.freqAlloc.startPrb  = puschInfo.fdAlloc.startPrb;
529    dciInfo->format.format0_0.freqAlloc.numPrb    = puschInfo.fdAlloc.numPrb;
530    dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
531    dciInfo->format.format0_0.timeAlloc.numSymb   = puschInfo.tdAlloc.numSymb;
532    dciInfo->format.format0_0.rowIndex            = 0; /* row Index */
533    dciInfo->format.format0_0.mcs                 = puschInfo.tbInfo.mcs;
534    dciInfo->format.format0_0.harqProcId          = puschInfo.harqProcId;
535    dciInfo->format.format0_0.puschHopFlag        = FALSE; /* disabled */
536    dciInfo->format.format0_0.freqHopFlag         = FALSE; /* disabled */
537    dciInfo->format.format0_0.ndi                 = puschInfo.tbInfo.ndi; /* new transmission */
538    dciInfo->format.format0_0.rv                  = puschInfo.tbInfo.rv;
539    dciInfo->format.format0_0.tpcCmd              = 0; //Sphoorthi TODO: check
540    dciInfo->format.format0_0.sUlCfgd             = FALSE; /* SUL not configured */
541    
542    /* Fill DCI Structure */
543    dciInfo->dciInfo.rnti                              = ueCb->crnti;
544    dciInfo->dciInfo.scramblingId                      = cellCb->cellCfg.phyCellId;
545    dciInfo->dciInfo.scramblingRnti                    = 0;
546    dciInfo->dciInfo.cceIndex                          = 0; /* 0-3 for UL and 4-7 for DL */
547    dciInfo->dciInfo.aggregLevel                       = 4;
548    dciInfo->dciInfo.beamPdcchInfo.numPrgs             = 1;
549    dciInfo->dciInfo.beamPdcchInfo.prgSize             = 1;
550    dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces     = 0;
551    dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx        = 0;
552    dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0]   = 0;
553    dciInfo->dciInfo.txPdcchPower.powerValue           = 0;
554    dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
555    dciInfo->dciInfo.pdschCfg                          = NULLP; /* No DL data being sent */
556
557    return ROK;
558 }
559
560 /*******************************************************************
561  *
562  * @brief Function to Modify Ue Config request from MAC
563  *
564  * @details
565  *
566  *    Function : MacSchModUeConfigReq
567  *
568  *    Functionality: Function to modify Ue Config request from MAC
569  *
570  * @params[in] 
571  * @return ROK     - success
572  *         RFAILED - failure
573  *
574  * ****************************************************************/
575 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
576 {
577    uint8_t ueIdx, lcIdx, ret = ROK;
578    SchCellCb    *cellCb = NULLP;
579    SchUeCb      *ueCb = NULLP;
580    SchUeCfgRsp  cfgRsp;
581    Inst         inst = pst->dstInst - 1;
582    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
583
584    if(!ueCfg)
585    {
586       DU_LOG("\nERROR  -->  SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
587       return RFAILED;
588    }
589    DU_LOG("\nDEBUG  -->  SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
590    cellCb = getSchCellCb(pst->event, inst, ueCfg);
591
592    /* Search if UE already configured */
593    GET_UE_IDX(ueCfg->crnti, ueIdx);
594    ueCb = &cellCb->ueCb[ueIdx -1];
595    
596    if(!ueCb)
597    {
598       DU_LOG("\nERROR  -->  SCH : SchUeCb not found at MacSchModUeConfigReq() ");
599       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
600       return RFAILED;
601    }
602    if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
603    {
604       /* Found the UeCb to Reconfig */
605       ret = fillSchUeCb(ueCb, ueCfg);
606       if(ret == ROK)
607       {
608          ueCb->cellCb = cellCb;
609          ueCb->srRcvd = false;
610          for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
611             ueCb->bsrInfo[lcIdx].dataVol = 0;
612
613          SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
614       }
615    }
616    return ret;
617 }
618
619 /**********************************************************************
620   End of file
621  **********************************************************************/