<JIRA ID: ODUHIGH-368 : Slice information associated during PDU session establishment...
[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 SchUeDeleteRspFunc SchUeDeleteRspOpts[] =
41 {
42    packSchUeDeleteRsp,      /* LC */
43    MacProcSchUeDeleteRsp,   /* TC */
44    packSchUeDeleteRsp       /* LWLC */
45 };
46
47 SchCellDeleteRspFunc SchCellDeleteRspOpts[]=
48 {
49    packSchCellDeleteRsp,      /* LC */
50    MacProcSchCellDeleteRsp,   /* TC */
51    packSchCellDeleteRsp       /* LWLC */
52 };
53 /*******************************************************************
54  *
55  * @brief Fill and send UE cfg response to MAC
56  *
57  * @details
58  *
59  *    Function : SchSendUeCfgRspToMac
60  *
61  *    Functionality: Fill and send UE cfg response to MAC
62  *
63  * @params[in] 
64  * @return ROK     - success
65  *         RFAILED - failure
66  *
67  * ****************************************************************/
68 void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
69       SchMacRsp result, SchUeCfgRsp *cfgRsp)
70 {
71    Pst rspPst;
72
73    cfgRsp->cellId = ueCfg->cellId;
74    cfgRsp->crnti = ueCfg->crnti;
75    GET_UE_IDX(ueCfg->crnti, cfgRsp->ueIdx);
76    cfgRsp->rsp = result;   
77
78    /* Filling response post */
79    memset(&rspPst, 0, sizeof(Pst));
80    FILL_PST_SCH_TO_MAC(rspPst, inst);
81    if(event == EVENT_ADD_UE_CONFIG_REQ_TO_SCH)
82    {
83       rspPst.event = EVENT_UE_CONFIG_RSP_TO_MAC;
84       DU_LOG("\nINFO  -->  SCH :  Sending UE Config response to MAC");
85    }
86    else if(event == EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH)
87    {
88       rspPst.event = EVENT_UE_RECONFIG_RSP_TO_MAC;
89       DU_LOG("\nINFO  -->  SCH :  Sending UE Reconfig response to MAC");
90    }
91    SchUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
92 }
93
94 /*******************************************************************
95  
96  *
97  * @brief Function to fill Dl Lc Context in SCH Ue Cb
98  *
99  * @details
100  *
101  *    Function : fillSchDlLcCtxt
102  *
103  *    Functionality: Function to fill Dl Lc Context in SCH Ue Cb
104  *
105  * @params[in] SchDlLcCtxt pointer,
106  *             SchLcCfg pointer
107  * @return void
108  *
109  * ****************************************************************/
110
111 void fillSchDlLcCtxt(SchDlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
112 {
113    ueCbLcCfg->lcId = lcCfg->lcId;
114    ueCbLcCfg->lcp = lcCfg->dlLcCfg.lcp;
115    ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
116    ueCbLcCfg->bo = 0;
117    if(lcCfg->drbQos)
118    {
119      ueCbLcCfg->pduSessionId = lcCfg->drbQos->pduSessionId;
120    }
121    if(lcCfg->snssai)
122    {
123      if(ueCbLcCfg->snssai == NULLP)/*In CONFIG_MOD case, no need to allocate SNSSAI memory*/
124      {
125         SCH_ALLOC(ueCbLcCfg->snssai, sizeof(SchSnssai));
126      }
127      memcpy(ueCbLcCfg->snssai, lcCfg->snssai,sizeof(SchSnssai));
128    }
129 }
130
131 /*******************************************************************
132  *
133  * @brief Function to fill Ul Lc Context in SCH Ue Cb
134  *
135  * @details
136  *
137  *    Function : fillSchUlLcCtxt
138  *
139  *    Functionality: Function to fill Ul Lc Context in SCH Ue Cb
140  *
141  * @params[in] SchUlLcCtxt pointer,
142  *             SchLcCfg pointer
143  * @return void
144  *
145  * ****************************************************************/
146
147 void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
148 {
149    ueCbLcCfg->lcId = lcCfg->lcId;
150    ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
151    ueCbLcCfg->priority = lcCfg->ulLcCfg.priority;
152    ueCbLcCfg->lcGroup = lcCfg->ulLcCfg.lcGroup;
153    ueCbLcCfg->schReqId = lcCfg->ulLcCfg.schReqId;
154    ueCbLcCfg->pbr     = lcCfg->ulLcCfg.pbr;
155    ueCbLcCfg->bsd     = lcCfg->ulLcCfg.bsd;
156
157    if(lcCfg->drbQos)
158    {
159       ueCbLcCfg->pduSessionId = lcCfg->drbQos->pduSessionId;
160    }
161    if(lcCfg->snssai)
162    {
163      /*In CONFIG_MOD case, no need to allocate SNSSAI memory again*/
164      if(ueCbLcCfg->snssai == NULLP)
165      {
166         SCH_ALLOC(ueCbLcCfg->snssai, sizeof(SchSnssai));
167      }
168      memcpy(ueCbLcCfg->snssai, lcCfg->snssai,sizeof(SchSnssai));
169    }
170 }
171
172 /*******************************************************************
173  *
174  * @brief Function to update Sch Ul Lc Cb
175  *
176  * @details
177  *
178  *    Function : updateSchUlCb
179  *
180  *    Functionality: Function to update SCH Ul Lc Cb
181  *
182  * @returns void
183  *
184  * ****************************************************************/
185
186 void updateSchUlCb(uint8_t delIdx, SchUlCb *ulInfo)
187 {
188    uint8_t lcIdx = 0;
189
190    for(lcIdx = delIdx; lcIdx < ulInfo->numUlLc; lcIdx++)
191    {
192       memcpy(&ulInfo->ulLcCtxt[lcIdx], &ulInfo->ulLcCtxt[lcIdx+1], sizeof(SchUlLcCtxt));
193       memset(&ulInfo->ulLcCtxt[lcIdx+1], 0, sizeof(SchUlLcCtxt));
194    }
195    /*Leakage of Last Index*/
196    /*Last index of ulLcCtxt(before deletion) should be void*/
197    if(ulInfo->ulLcCtxt[ulInfo->numUlLc].snssai != NULLP)
198    {
199       DU_LOG("ERROR  --> SCH: updateSchUlCb Last index:%d (Before Deletion) memory is leaking",\
200             ulInfo->numUlLc);
201       SCH_FREE(ulInfo->ulLcCtxt[ulInfo->numUlLc].snssai, sizeof(Snssai));
202    }
203    else
204    {
205       DU_LOG("INFO  --> SCH: updateSchUlCb Last index:%d (before deletion) memory is freed successfully",\
206             ulInfo->numUlLc);
207
208    }
209 }
210
211 /*******************************************************************
212  *
213  * @brief Function to update SCH Dl Lc Cb
214  *
215  * @details
216  *
217  *    Function : updateSchDlCb
218  *
219  *    Functionality: Function to update SCH DL Lc Cb
220  *
221  * @returns void
222  *
223  * ****************************************************************/
224
225 void updateSchDlCb(uint8_t delIdx, SchDlCb *dlInfo)
226 {
227    uint8_t lcIdx = 0;
228
229    for(lcIdx = delIdx; lcIdx < dlInfo->numDlLc; lcIdx++)
230    {
231       memcpy(&dlInfo->dlLcCtxt[lcIdx], &dlInfo->dlLcCtxt[lcIdx+1], sizeof(SchDlLcCtxt));
232       memset(&dlInfo->dlLcCtxt[lcIdx+1], 0, sizeof(SchDlLcCtxt));
233    }
234    /*Leakage of Last Index*/
235    /*Last index of ulLcCtxt(before deletion) should be void*/
236    if(dlInfo->dlLcCtxt[dlInfo->numDlLc].snssai != NULLP)
237    {
238       DU_LOG("ERROR  --> SCH: updateSchDlCb Last index:%d (before deletion) memory is leaking: Delete the S-NSSAI memory",\
239             dlInfo->numDlLc);
240       SCH_FREE(dlInfo->dlLcCtxt[dlInfo->numDlLc].snssai, sizeof(Snssai));
241    }
242    else
243    {
244       DU_LOG("INFO  --> SCH: updateSchDlCb Last index:%d (before deletion) memory is freed successfully",\
245             dlInfo->numDlLc);
246    }
247 }
248
249 /*******************************************************************
250  *
251  * @brief Function to fill SchUeCb
252  *
253  * @details
254  *
255  *    Function : fillSchUeCb
256  *
257  *    Functionality: Function to fill SchUeCb
258  *
259  * @params[in] SchUeCb pointer,
260  *             SchUeCfg pointer
261  * @return ROK/RFAILED
262  *
263  * ****************************************************************/
264
265 uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
266 {
267    uint8_t   lcIdx, ueLcIdx;
268    SchPdschCfgCmn pdschCfg;
269    SchPucchDlDataToUlAck *dlDataToUlAck;
270
271    ueCb->ueCfg.cellId = ueCfg->cellId;
272    ueCb->ueCfg.crnti = ueCfg->crnti;
273    if(ueCfg->macCellGrpCfgPres == true)
274    {
275       memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg)); 
276       ueCb->ueCfg.macCellGrpCfgPres = true;
277    }
278
279    if(ueCfg->phyCellGrpCfgPres == true)
280    {
281       memcpy(&ueCb->ueCfg.phyCellGrpCfg ,  &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
282       ueCb->ueCfg.phyCellGrpCfgPres = true;
283    }
284
285    if(ueCfg->spCellCfgPres == true)
286    {
287       memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
288       ueCb->ueCfg.spCellCfgPres = true;
289       dlDataToUlAck = ueCfg->spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck;
290       if(ueCb->cellCb)
291       {
292          if(dlDataToUlAck)
293          {
294             BuildK0K1Table(ueCb->cellCb, &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl, false, pdschCfg,\
295                   ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
296                   dlDataToUlAck->dlDataToUlAckList);
297             BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\
298                   ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
299                   NULLP, &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl);
300          }
301       }
302    }
303
304    ueCb->state = SCH_UE_STATE_ACTIVE;
305    if(ueCfg->ambrCfg)
306    {
307       SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
308       ueCb->ueCfg.ambrCfg =  ueCfg->ambrCfg;
309    }
310    memcpy(&ueCb->ueCfg.dlModInfo,  &ueCfg->dlModInfo , sizeof(SchModulationInfo));
311    memcpy(&ueCb->ueCfg.ulModInfo,  &ueCfg->ulModInfo , sizeof(SchModulationInfo));
312
313    //Updating SchUlCb and SchDlCb DB in SchUeCb
314    for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
315    {
316       if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
317       {
318          fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
319          ueCb->ulInfo.numUlLc++;
320          fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
321          ueCb->dlInfo.numDlLc++;
322       }
323       else
324       {
325          for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
326          {
327             if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
328             {
329                if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
330                {
331                   fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
332                   break;
333                }
334                /*BUG: ueCfg using lcIdx (Looping around numLCs in ueCfg whereas
335                 * ueLcIdx Loops around numUlLc in SCH UL DB*/
336                if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL)
337                {
338                   memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
339                   ueCb->ulInfo.numUlLc--;
340                   updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead
341
342                   break;
343                }
344             }
345          }/*End of inner for loop */
346
347          for(ueLcIdx = 0; ueLcIdx < ueCb->dlInfo.numDlLc; ueLcIdx++) //searching for Lc to be Mod
348          {
349             if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
350             {
351                if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
352                {
353                   fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
354                   break;
355                }
356                if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL)
357                {
358                   memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
359                   ueCb->dlInfo.numDlLc--;
360                   updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
361                   break;
362                }
363             }
364          }/*End of inner for loop */
365       }
366
367       SCH_FREE(ueCfg->schLcCfg[lcIdx].drbQos, sizeof(SchDrbQosInfo));
368       SCH_FREE(ueCfg->schLcCfg[lcIdx].snssai, sizeof(SchSnssai));
369
370    }/* End of outer for loop */
371    return ROK;
372 }
373
374 /*******************************************************************
375  *
376  * @brief Function to get SCH Cell Cb
377  *
378  * @details
379  *
380  *    Function : getSchCellCb
381  *
382  *    Functionality: Function to get SCH Cell Cb
383  *
384  * @params[in] event, SchUeCfg pointer 
385  * @return schUeCb pointer  - success
386  *         NULLP - failure
387  *
388  * ****************************************************************/
389
390 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
391 {
392    uint8_t      idx;
393    SchCellCb    *cellCb = NULLP;
394    SchUeCfgRsp  cfgRsp;
395    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
396
397    /* Search of cell cb */
398    for(idx = 0; idx < MAX_NUM_CELL; idx++)
399    {
400       cellCb = schCb[inst].cells[idx];
401       if(cellCb->cellId == ueCfg->cellId)
402          break;
403    }
404    if(idx == MAX_NUM_CELL)
405    {
406       DU_LOG("\nERROR  -->  SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
407       SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
408       return NULLP;
409    }
410
411    /* Check if max number of UE configured */
412    if(cellCb->numActvUe > MAX_NUM_UE)
413    {
414       DU_LOG("\nERROR  -->  SCH :  Max number of UE [%d] already configured", MAX_NUM_UE);
415       SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
416       return NULLP;
417    }
418    return cellCb;
419 }
420
421
422 /*******************************************************************
423  *
424  * @brief Function to Add Ue Config Request from MAC
425  *
426  * @details
427  *
428  *    Function : MacSchAddUeConfigReq
429  *
430  *    Functionality: Function to Add Ue config request from MAC
431  *
432  * @params[in] 
433  * @return ROK     - success
434  *         RFAILED - failure
435  *
436  * ****************************************************************/
437 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
438 {
439    uint8_t ueIdx, lcIdx, ret = ROK;
440    SchCellCb    *cellCb = NULLP;
441    SchUeCb      *ueCb = NULLP;
442    SchUeCfgRsp  cfgRsp;
443    Inst         inst = pst->dstInst - 1;
444    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
445   
446 #ifdef CALL_FLOW_DEBUG_LOG
447    DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_ADD_UE_CONFIG_REQ_TO_SCH\n");
448 #endif
449
450    if(!ueCfg)
451    {
452       DU_LOG("\nERROR  -->  SCH :  Adding UE Config Request failed at MacSchAddUeConfigReq()");
453       return RFAILED;
454    }
455    DU_LOG("\nDEBUG  -->  SCH :  Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
456    cellCb = getSchCellCb(pst->event, inst, ueCfg);
457
458    /* Search if UE already configured */
459    GET_UE_IDX(ueCfg->crnti, ueIdx);
460    ueCb = &cellCb->ueCb[ueIdx -1];
461    if(ueCb)
462    {
463       if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
464       {
465          DU_LOG("\nDEBUG  -->  SCH : CRNTI %d already configured ", ueCfg->crnti);
466          SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
467          return ROK;
468       }
469    }
470    else
471    {
472       DU_LOG("\nERROR  -->  SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
473       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
474       return RFAILED;
475    }
476
477    /* Fill received Ue Configuration in UeCb */
478    memset(ueCb, 0, sizeof(SchUeCb));
479    GET_UE_IDX(ueCfg->crnti, ueIdx);
480    ueCb->ueIdx = ueIdx;
481    ueCb->crnti = ueCfg->crnti;
482    ueCb->state = SCH_UE_STATE_ACTIVE;
483    ret = fillSchUeCb(ueCb, ueCfg);
484    if(ret == ROK)
485    {
486       cellCb->numActvUe++;
487       SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
488       ueCb->cellCb = cellCb;
489       ueCb->srRcvd = false;
490       for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
491          ueCb->bsrInfo[lcIdx].dataVol = 0;
492
493       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
494    }
495    return ret;
496 }
497
498 /*******************************************************************
499 *
500 * @brief Fills PUSCH UL allocation
501 *
502 * @details
503 *
504 *    Function : schFillPuschAlloc
505 *
506 *    Functionality: fills PUSCH info
507 *
508 * @params[in]
509 * @return ROK     - success
510 *         RFAILED - failure
511 *
512 * ****************************************************************/
513 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
514 {
515   uint16_t puschSlot      = 0;
516   uint16_t startRb        = 0;
517   uint8_t  numRb          = 0;
518   uint16_t tbSize         = 0;
519   uint8_t  buffer         = 5;
520   uint8_t  idx            = 0;
521   SchCellCb *cellCb       = ueCb->cellCb;
522   SchUlSlotInfo *schUlSlotInfo = NULLP;
523   uint8_t k2=0, startSymb=0 , symbLen=11;
524   
525   if(ueCb->ueCfg.spCellCfgPres == true)
526   {
527      k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
528      startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
529      symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
530   }
531   puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
532
533   startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
534   tbSize  = schCalcTbSize(dataVol + buffer); /*  2 bytes header + some buffer */
535   numRb   = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
536   /* increment PUSCH PRB */
537
538   cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
539
540   puschInfo->crnti             = ueCb->crnti; 
541   puschInfo->harqProcId        = SCH_HARQ_PROC_ID;
542   puschInfo->resAllocType      = SCH_ALLOC_TYPE_1;
543   puschInfo->fdAlloc.startPrb  = startRb;
544   puschInfo->fdAlloc.numPrb    = numRb;
545   puschInfo->tdAlloc.startSymb = startSymb;
546   puschInfo->tdAlloc.numSymb   = symbLen;
547   puschInfo->tbInfo.qamOrder   = ueCb->ueCfg.ulModInfo.modOrder;
548   puschInfo->tbInfo.mcs        = ueCb->ueCfg.ulModInfo.mcsIndex;
549   puschInfo->tbInfo.mcsTable   = ueCb->ueCfg.ulModInfo.mcsTable;
550   puschInfo->tbInfo.ndi        = 1; /* new transmission */
551   puschInfo->tbInfo.rv         = 0;
552   puschInfo->tbInfo.tbSize     = tbSize;
553   puschInfo->dmrsMappingType   = DMRS_MAP_TYPE_A;  /* Setting Type-A */
554   puschInfo->nrOfDmrsSymbols   = NUM_DMRS_SYMBOLS;
555   puschInfo->dmrsAddPos        = DMRS_ADDITIONAL_POS;
556
557   /* Update pusch in cell */
558   for(idx=startSymb; idx<symbLen; idx++)
559   {
560      cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
561   }
562
563   schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
564
565   SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
566   if(!schUlSlotInfo->schPuschInfo)
567   {
568      DU_LOG("\nERROR  -->  SCH: Memory allocation failed in schAllocMsg3Pusch");
569      return RFAILED;
570   }
571   memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
572
573   return ROK;
574 }
575
576 /*******************************************************************
577  *
578  * @brief Fills DCI for UL grant
579  *
580  * @details
581  *
582  *    Function : schFillUlDci
583  *
584  *    Functionality: fills DCI for UL grant in response to BSR
585  *
586  * @params[in]
587  * @return ROK     - success
588  *         RFAILED - failure
589  *
590  * ****************************************************************/
591 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
592 {
593    SchCellCb         *cellCb  = ueCb->cellCb;
594    SchControlRsrcSet coreset1 ;
595   
596    memset(&coreset1, 0, sizeof(SchControlRsrcSet));
597    if(ueCb->ueCfg.spCellCfgPres == true)
598    {
599      coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
600    }
601    
602    dciInfo->cellId = cellCb->cellId;
603    dciInfo->crnti  = ueCb->crnti;
604
605    /* fill bwp cfg */
606    dciInfo->bwpCfg.subcarrierSpacing  = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
607    dciInfo->bwpCfg.cyclicPrefix       = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
608    dciInfo->bwpCfg.freqAlloc.startPrb = 0;
609    dciInfo->bwpCfg.freqAlloc.numPrb   = MAX_NUM_RB; /* whole of BW */
610
611    /*fill coreset cfg */
612    //Considering number of RBs in coreset1 is same as coreset0
613    dciInfo->coresetCfg.coreSetSize      = coresetIdxTable[0][1];
614    //Considering coreset1 also starts from same symbol as coreset0
615    dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
616    dciInfo->coresetCfg.durationSymbols  = coreset1.duration;
617    memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
618    
619    dciInfo->coresetCfg.cceRegMappingType   = coreset1.cceRegMappingType; /* non-interleaved */
620    dciInfo->coresetCfg.regBundleSize       = 6; /* must be 6 for non-interleaved */
621    dciInfo->coresetCfg.interleaverSize     = 0; /* NA for non-interleaved */
622    dciInfo->coresetCfg.coreSetType         = 1; /* non PBCH coreset */
623    dciInfo->coresetCfg.shiftIndex          = cellCb->cellCfg.phyCellId;
624    dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
625    dciInfo->coresetCfg.cceIndex            = 0; /* 0-3 for UL and 4-7 for DL */
626    dciInfo->coresetCfg.aggregationLevel    = 4; /* same as for sib1 */
627    
628    dciInfo->formatType = FORMAT0_0;
629    
630    /* fill UL grant */
631    dciInfo->format.format0_0.resourceAllocType   = puschInfo.resAllocType;
632    dciInfo->format.format0_0.freqAlloc.startPrb  = puschInfo.fdAlloc.startPrb;
633    dciInfo->format.format0_0.freqAlloc.numPrb    = puschInfo.fdAlloc.numPrb;
634    dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
635    dciInfo->format.format0_0.timeAlloc.numSymb   = puschInfo.tdAlloc.numSymb;
636    dciInfo->format.format0_0.rowIndex            = 0; /* row Index */
637    dciInfo->format.format0_0.mcs                 = puschInfo.tbInfo.mcs;
638    dciInfo->format.format0_0.harqProcId          = puschInfo.harqProcId;
639    dciInfo->format.format0_0.puschHopFlag        = FALSE; /* disabled */
640    dciInfo->format.format0_0.freqHopFlag         = FALSE; /* disabled */
641    dciInfo->format.format0_0.ndi                 = puschInfo.tbInfo.ndi; /* new transmission */
642    dciInfo->format.format0_0.rv                  = puschInfo.tbInfo.rv;
643    dciInfo->format.format0_0.tpcCmd              = 0; //Sphoorthi TODO: check
644    dciInfo->format.format0_0.sUlCfgd             = FALSE; /* SUL not configured */
645    
646    /* Fill DCI Structure */
647    dciInfo->dciInfo.rnti                              = ueCb->crnti;
648    dciInfo->dciInfo.scramblingId                      = cellCb->cellCfg.phyCellId;
649    dciInfo->dciInfo.scramblingRnti                    = 0;
650    dciInfo->dciInfo.cceIndex                          = 0; /* 0-3 for UL and 4-7 for DL */
651    dciInfo->dciInfo.aggregLevel                       = 4;
652    dciInfo->dciInfo.beamPdcchInfo.numPrgs             = 1;
653    dciInfo->dciInfo.beamPdcchInfo.prgSize             = 1;
654    dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces     = 0;
655    dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx        = 0;
656    dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0]   = 0;
657    dciInfo->dciInfo.txPdcchPower.powerValue           = 0;
658    dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
659    dciInfo->dciInfo.pdschCfg                          = NULLP; /* No DL data being sent */
660
661    return ROK;
662 }
663
664 /*******************************************************************
665  *
666  * @brief Function to Modify Ue Config request from MAC
667  *
668  * @details
669  *
670  *    Function : MacSchModUeConfigReq
671  *
672  *    Functionality: Function to modify Ue Config request from MAC
673  *
674  * @params[in] 
675  * @return ROK     - success
676  *         RFAILED - failure
677  *
678  * ****************************************************************/
679 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
680 {
681    uint8_t ueIdx, lcIdx, ret = ROK;
682    SchCellCb    *cellCb = NULLP;
683    SchUeCb      *ueCb = NULLP;
684    SchUeCfgRsp  cfgRsp;
685    Inst         inst = pst->dstInst - 1;
686    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
687   
688 #ifdef CALL_FLOW_DEBUG_LOG
689    DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH\n");
690 #endif
691
692    if(!ueCfg)
693    {
694       DU_LOG("\nERROR  -->  SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
695       return RFAILED;
696    }
697    DU_LOG("\nDEBUG  -->  SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
698    cellCb = getSchCellCb(pst->event, inst, ueCfg);
699
700    /* Search if UE already configured */
701    GET_UE_IDX(ueCfg->crnti, ueIdx);
702    ueCb = &cellCb->ueCb[ueIdx -1];
703    
704    if(!ueCb)
705    {
706       DU_LOG("\nERROR  -->  SCH : SchUeCb not found at MacSchModUeConfigReq() ");
707       SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
708       return RFAILED;
709    }
710    if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
711    {
712       /* Found the UeCb to Reconfig */
713       ret = fillSchUeCb(ueCb, ueCfg);
714       if(ret == ROK)
715       {
716          ueCb->cellCb = cellCb;
717          ueCb->srRcvd = false;
718          for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
719             ueCb->bsrInfo[lcIdx].dataVol = 0;
720
721          SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
722       }
723    }
724    return ret;
725 }
726
727 /*******************************************************************
728 *
729 * @brief Fill and send UE delete response to MAC
730 *
731 * @details
732 *
733 *    Function :  SchSendUeDeleteRspToMac
734 *
735 *    Functionality: Fill and send UE delete response to MAC
736 *
737 * @params[in] Inst inst, SchUeDelete  *ueDelete, SchMacRsp result, 
738 *              ErrorCause cause
739 * @return ROK     - success
740 *         RFAILED - failure
741 *
742 * ****************************************************************/
743 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete  *ueDelete, SchMacRsp result, ErrorCause cause)
744 {
745     Pst rspPst;
746     SchUeDeleteRsp  delRsp;
747     
748     memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
749     delRsp.cellId = ueDelete->cellId;
750     delRsp.crnti = ueDelete->crnti;
751     delRsp.rsp = result; 
752     delRsp.cause = cause; 
753
754     /* Filling response post */
755     memset(&rspPst, 0, sizeof(Pst));
756     FILL_PST_SCH_TO_MAC(rspPst, inst);
757     rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
758     SchUeDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
759 }
760
761 /*******************************************************************
762 *
763 * @brief Function to delete Sch Pucch ResrcCfg
764 *
765 * @details
766 *
767 *    Function : deleteSchPucchResrcCfg 
768 *
769 *    Functionality: Function to delete Sch Pucch ResrcCfg
770 *
771 * @params[in] SchPucchResrcCfg *resrc
772 * @return void 
773 *
774 * ****************************************************************/
775
776 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
777 {
778    uint8_t rsrcIdx=0;
779    for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
780    {
781       switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
782       {
783          case PUCCH_FORMAT_0:
784          {
785             SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
786             sizeof(SchPucchFormat0));
787             break;
788          }
789          case PUCCH_FORMAT_1:
790          {
791             SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
792             sizeof(SchPucchFormat1));
793             break;
794          }
795          case PUCCH_FORMAT_2:
796          {
797             SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
798             sizeof(SchPucchFormat2_3));
799             break;
800          }
801          case PUCCH_FORMAT_3:
802          {
803             SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
804             sizeof(SchPucchFormat2_3));
805             break;
806          }
807          case PUCCH_FORMAT_4:
808          {
809             SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
810             sizeof(SchPucchFormat4));
811             break;
812          }
813       }
814    }
815 }
816
817 /*******************************************************************
818 *
819 * @brief Function to delete SCH Pdsch ServCellCfg
820 *
821 * @details
822 *
823 *    Function : deleteSchPdschServCellCfg
824 *
825 *    Functionality: Function to delete SCH Pdsch ServCellCfg
826 *
827 * @params[in] SchPdschServCellCfg *pdschServCellCfg
828 * @return void 
829 *
830 * ****************************************************************/
831
832 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
833 {
834    SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
835    SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
836    SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
837    SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
838 }
839
840 /*******************************************************************
841 *
842 * @brief Function to  delete SCH UeCb
843 *
844 * @details
845 *
846 *    Function : deleteSchUeCb 
847 *
848 *    Functionality: Function to delete SCH UeCb
849 *
850 * @params[in]
851 * @return ROK     - success
852 *         RFAILED - failure
853 *
854 * ****************************************************************/
855 void deleteSchUeCb(SchUeCb *ueCb) 
856 {
857    uint8_t timeDomRsrcIdx = 0, ueLcIdx = 0;
858    SchPucchCfg *pucchCfg = NULLP;
859    SchPdschConfig *pdschCfg = NULLP;
860
861    if(ueCb)
862    {
863       SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
864       if(ueCb->ueCfg.spCellCfgPres)
865       {
866          if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
867          {
868             pdschCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg;
869             for(timeDomRsrcIdx = 0; timeDomRsrcIdx < pdschCfg->numTimeDomRsrcAlloc; timeDomRsrcIdx++)
870                SCH_FREE(pdschCfg->timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
871          }
872
873          if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres == true)
874          {
875             pucchCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg;
876             SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
877             if(pucchCfg->resrc)
878             {
879                deleteSchPucchResrcCfg(pucchCfg->resrc);
880                SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
881             }
882             SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
883             SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
884             SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
885             SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
886             SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
887             SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
888             SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));  
889             SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
890             SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
891          }
892          SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.bwpInactivityTmr, sizeof(uint8_t));
893          deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg);
894       }
895       /*Need to Free the memory allocated for S-NSSAI*/
896       for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++)
897       {
898          SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(SchSnssai));
899       }
900       for(ueLcIdx = 0; ueLcIdx < ueCb->dlInfo.numDlLc; ueLcIdx++)
901       {
902          SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(SchSnssai));
903       }
904       memset(ueCb, 0, sizeof(SchUeCb));
905    }
906 }
907
908 /*******************************************************************
909 *
910 * @brief Function for Ue Delete request from MAC to SCH
911 *
912 * @details
913 *
914 *    Function : MacSchUeDeleteReq 
915 *
916 *    Functionality: Function for Ue Delete request from MAC to SCH
917 *
918 * @params[in] Pst *pst, SchUeDelete  *ueDelete
919 * @return ROK     - success
920 *         RFAILED - failure
921 *
922 * ****************************************************************/
923 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete  *ueDelete)
924 {
925     uint8_t idx=0, ueIdx=0, ret=ROK;
926     ErrorCause result;
927     SchCellCb    *cellCb = NULLP;
928     Inst         inst = pst->dstInst - 1;
929    
930 #ifdef CALL_FLOW_DEBUG_LOG
931     DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_UE_DELETE_REQ_TO_SCH\n");
932 #endif
933
934     if(!ueDelete)
935     {
936        DU_LOG("\nERROR  -->  SCH : MacSchUeDeleteReq(): Ue Delete request failed");
937        ret = RFAILED;
938     }
939     DU_LOG("\nDEBUG  -->  SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
940     
941     cellCb = schCb[inst].cells[idx];
942
943     if(cellCb->cellId != ueDelete->cellId)
944     {
945        DU_LOG("\nERROR  -->  SCH : MacSchUeDeleteReq(): cell Id is not available");
946        result =  INVALID_CELLID;
947     }
948     else
949     {
950        GET_UE_IDX(ueDelete->crnti, ueIdx);
951        if(( cellCb->ueCb[ueIdx-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueIdx-1].state == SCH_UE_STATE_ACTIVE))
952        {
953           deleteSchUeCb(&cellCb->ueCb[ueIdx-1]);
954           cellCb->numActvUe--;
955           result = NOT_APPLICABLE;
956        }
957        else
958        {
959           DU_LOG("\nERROR  -->  SCH : MacSchUeDeleteReq(): SchUeCb not found");
960           result =  INVALID_UEIDX;
961        }
962     }
963     
964     if(result == NOT_APPLICABLE)
965     {
966        SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, result);
967     }
968     else
969     {
970        SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, result);
971        ret = RFAILED;
972     }
973     return ret;
974 }
975
976 /*******************************************************************
977  *
978  * @brief Fill and send Cell delete response to MAC
979  *
980  * @details
981  *
982  *    Function :  SchSendCellDeleteRspToMac
983  *
984  *    Functionality: Fill and send Cell delete response to MAC
985  *
986  * @params[in] SchCellDelete  *ueDelete, Inst inst, SchMacRsp result
987  * @return ROK     - success
988  *         RFAILED - failure
989  *
990  * ****************************************************************/
991 uint8_t SchSendCellDeleteRspToMac(SchCellDelete  *ueDelete, Inst inst, SchMacRsp result)
992 {
993    Pst rspPst;
994    uint8_t ret=0;
995    
996    SchCellDeleteRsp  delRsp;
997
998    DU_LOG("\nINFO   --> SCH : Filling Cell Delete response");
999    memset(&delRsp, 0, sizeof(SchCellDeleteRsp));
1000    delRsp.cellId = ueDelete->cellId;
1001    delRsp.rsp = result;
1002
1003    /* Filling response post */
1004    memset(&rspPst, 0, sizeof(Pst));
1005    FILL_PST_SCH_TO_MAC(rspPst, inst);
1006    rspPst.event = EVENT_CELL_DELETE_RSP_TO_MAC;
1007    ret =  SchCellDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
1008    if(ret == RFAILED)
1009    {
1010       DU_LOG("\nERROR  -->  SCH : SchSendCellDeleteRspToMac(): failed to send the Cell Delete response");
1011       return ret;
1012    }
1013    return ret;
1014 }
1015
1016 /*******************************************************************
1017  *
1018  * @brief Function for cellCb Deletion 
1019  *
1020  * @details
1021  *
1022  *    Function : deleteSchCellCb 
1023  *
1024  *    Functionality: Function for cellCb Deletion 
1025  *
1026  * @params[in] SchCellDelete  *cellDelete
1027  * @return ROK     - success
1028  *         RFAILED - failure
1029  *
1030  * ****************************************************************/
1031 void deleteSchCellCb(SchCellCb *cellCb)
1032 {
1033    uint8_t idx=0;
1034    if(cellCb->schDlSlotInfo)
1035    {
1036       for(idx=0; idx<cellCb->numSlots; idx++)
1037       {
1038          if(cellCb->schDlSlotInfo[idx])
1039          {
1040             SCH_FREE(cellCb->schDlSlotInfo[idx], sizeof(SchDlSlotInfo));
1041          }
1042       }
1043       SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*));
1044    }
1045    if(cellCb->schUlSlotInfo)
1046    {
1047       for(idx=0; idx<cellCb->numSlots; idx++)
1048       {
1049          if(cellCb->schUlSlotInfo[idx])
1050          {
1051             SCH_FREE(cellCb->schUlSlotInfo[idx], sizeof(SchUlSlotInfo));  
1052          }
1053       }
1054       SCH_FREE(cellCb->schUlSlotInfo,  cellCb->numSlots * sizeof(SchUlSlotInfo*));
1055    }
1056    memset(cellCb, 0, sizeof(SchCellCb));
1057
1058 }
1059
1060 /*******************************************************************
1061  *
1062  * @brief Function for cell Delete request from MAC to SCH
1063  *
1064  * @details
1065  *
1066  *    Function : MacSchCellDeleteReq
1067  *
1068  *    Functionality: Function for cell Delete request from MAC to SCH
1069  *
1070  * @params[in] Pst *pst, SchCellDelete  *cellDelete
1071  * @return ROK     - success
1072  *         RFAILED - failure
1073  *
1074  * ****************************************************************/
1075
1076 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete  *cellDelete)
1077 {
1078    uint8_t   cellIdx=0, ret = RFAILED;
1079    Inst      inst = pst->dstInst - 1;
1080    SchMacRsp result= RSP_OK;
1081    
1082 #ifdef CALL_FLOW_DEBUG_LOG
1083    DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_CELL_DELETE_REQ_TO_SCH\n");
1084 #endif   
1085
1086    if(!cellDelete)
1087    {
1088       DU_LOG("\nERROR  -->  SCH : MacSchCellDeleteReq(): Ue Delete request failed");
1089    }
1090    else
1091    {
1092       GET_CELL_IDX(cellDelete->cellId, cellIdx);
1093       if(schCb[inst].cells[cellIdx] == NULLP)
1094       { 
1095          DU_LOG("\nERROR  -->  SCH : MacSchCellDeleteReq(): cell Id[%d] is not available", cellDelete->cellId);
1096          result = RSP_NOK;
1097       }
1098       else
1099       {
1100          if(schCb[inst].cells[cellIdx]->cellId == cellDelete->cellId)
1101          {
1102             deleteSchCellCb(schCb[inst].cells[cellIdx]);
1103             result = RSP_OK;
1104             ret = ROK;
1105             SCH_FREE(schCb[inst].cells[cellIdx], sizeof(SchCellCb));
1106             DU_LOG("\nINFO   -->  SCH : Sending Cell Delete response to MAC");
1107          }
1108          else
1109          {
1110             DU_LOG("\nERROR  -->  SCH : MacSchCellDeleteReq(): cell Id[%d] is not available",cellDelete->cellId);
1111             result = RSP_NOK;
1112          }
1113       }
1114
1115       if(SchSendCellDeleteRspToMac(cellDelete, inst, result)!=ROK)
1116       {
1117          DU_LOG("\nERROR  -->  SCH : MacSchCellDeleteReq(): failed to send Cell Delete response");
1118          ret =  RFAILED;
1119       }
1120
1121    }
1122    return ret;   
1123 }
1124
1125 /**********************************************************************
1126   End of file
1127  **********************************************************************/