New Fixes for cell bring up post cell down for CLA
[o-du/l2.git] / src / 5gnrmac / mac_cfg_hdl.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 stores handler for MAC and SCH configuration requests */
19 /* header include files (.h) */
20 #include "common_def.h"
21 #include "lrg.h"
22 #include "lrg.x"
23 #include "du_app_mac_inf.h"
24 #include "mac_sch_interface.h"
25 #include "lwr_mac_upr_inf.h"
26 #include "mac.h"
27 #include "rlc_mac_inf.h"
28 #include "mac_upr_inf_api.h"
29 #include "lwr_mac.h"
30 #include "lwr_mac_fsm.h"
31 #include "mac_utils.h"
32 #include "lwr_mac_phy.h"
33
34 uint8_t ssbPeriodicity[6] = {5, 10, 20, 40, 80, 160};
35
36 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg  *macCellCfg);
37
38 packMacCellCfgConfirm packMacCellCfmOpts[] =
39 {
40    packMacCellCfgCfm,      /* packing for loosely coupled */
41    duHandleMacCellCfgCfm,      /* packing for tightly coupled */
42    packMacCellCfgCfm,    /* packing for light weight loosly coupled */
43 };
44
45 SchCellCfgFunc SchCellCfgOpts[] =
46 {
47    packSchCellCfg,   /* packing for loosely coupled */
48    SchHdlCellCfgReq, /* packing for tightly coupled */
49    packSchCellCfg    /* packing for light weight loosly coupled */
50 };
51
52 MacSchCellDeleteReqFunc macSchCellDeleteReqOpts[]=
53 {
54    packMacSchCellDeleteReq,    /* packing for loosely coupled */
55    MacSchCellDeleteReq,        /* packing for tightly coupled */
56    packMacSchCellDeleteReq     /* packing for light weight loosely coupled */
57 };
58
59 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
60 {
61    packDuMacCellDeleteRsp,   /* packing for loosely coupled */
62    DuProcMacCellDeleteRsp,   /* packing for tightly coupled */
63    packDuMacCellDeleteRsp   /* packing for light weight loosly coupled */
64 };
65
66 /**
67  * @brief Layer Manager  Configuration request handler for Scheduler
68  *
69  * @details
70  *
71  *     Function : MacSchGenCfgReq
72  *
73  *     This function receives general configurations for Scheduler
74  *     from DU APP and forwards to Scheduler.
75  *
76  *  @param[in]  Pst *pst, the post structure
77  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
78  *  @return 
79  *      -# ROK
80  **/
81 uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
82 {
83    printf("\nReceived Scheduler gen config at MAC");
84    pst->dstInst = DEFAULT_CELLS + 1;
85    SchProcGenCfgReq(pst, cfg);
86
87    return ROK;
88 }
89
90 /**
91  * @brief Layer Manager Configuration response from Scheduler
92  *
93  * @details
94  *
95  *     Function : SchSendCfgCfm
96  *
97  *     This function sends general configurations response from
98  *     Scheduler to DU APP.
99  *
100  *  @param[in]  Pst *pst, the post structure
101  *  @param[in]  RgMngmt *cfm, the configuration confirm structure
102  *  @return 
103  *      -# ROK
104  **/
105 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt  *cfm)
106 {
107    DU_LOG("\nDEBUG  -->  Sending Scheduler config confirm to DU APP");
108    pst->dstEnt = ENTDUAPP;
109    pst->dstInst = 0;
110    pst->srcInst = 0;
111    pst->selector = ODU_SELECTOR_LC;
112    RgMiLrgSchCfgCfm(pst, cfm);
113
114    return ROK;
115 }
116
117 /**
118  * @brief Layer Manager Configuration request handler.
119  *
120  * @details
121  *
122  *     Function : MacProcCellCfgReq
123  *
124  *     This function handles the gNB and cell configuration
125  *     request received from DU APP.
126  *     This API unapcks and forwards the config towards SCH
127  *
128  *  @param[in]  Pst           *pst
129  *  @param[in]  MacCellCfg    *macCellCfg
130  *  @return  
131  *      -# ROK
132  **/
133 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
134 {
135    Pst cfmPst;
136    uint16_t cellIdx;
137    uint8_t ret = ROK;
138    MacCellCb     *macCellCb;
139
140    memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
141
142    MAC_ALLOC(macCellCb, sizeof(MacCellCb));
143    if(macCellCb == NULLP)
144    {
145       DU_LOG("\nERROR  -->  MAC : macCellCb is NULL at handling of macCellCfg\n");
146       return RFAILED;
147    }
148    memset(macCellCb, 0, sizeof(MacCellCb));
149
150    GET_CELL_IDX(macCellCfg->cellId, cellIdx);
151    macCb.macCell[cellIdx] = macCellCb;
152    macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
153    memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
154
155    MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
156          macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
157    if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
158    {
159       DU_LOG("\nERROR  -->  MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
160       return RFAILED;
161    }
162    memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
163          macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
164
165    /* Send cell cfg to scheduler */
166    ret = MacSchCellCfgReq(pst, macCellCfg);
167    if(ret != ROK)
168    {
169       MacCellCfgCfm macCellCfgCfm;
170       macCellCfgCfm.rsp = RSP_NOK;
171       macCellCfgCfm.cellId = macCellCfg->cellId;
172       /* Fill Pst */
173       FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
174       cfmPst.selector  = ODU_SELECTOR_LC;
175
176       ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
177    }
178    else
179    {
180       if(macCellCfg->prachCfg.fdm[0].numUnusedRootSeq != 0)
181       {
182          MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg->prachCfg.fdm[0].unsuedRootSeq,
183                macCellCfg->prachCfg.fdm[0].numUnusedRootSeq* sizeof(uint8_t));
184       }
185       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg->sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1PduLen);
186       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
187    }
188    return ret;
189 } /* end of MacProcCellCfgReq */
190
191 /**
192  * @brief Layer Manager Configuration request handler.
193  *
194  * @details
195  *
196  *     Function : MacSchCellCfgReq
197  *
198  *     This function sends cell configuration to SCH
199  *
200  *  @param[in]  Pst           *pst
201  *  @param[in]  MacCellCfg    *macCellCfg
202  *  @return  
203  *      -# ROK
204  **/
205 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
206 {
207    SchCellCfg schCellCfg;
208    Pst        cfgPst;
209    uint8_t    ret =0;
210
211    memset(&cfgPst, 0, sizeof(Pst));
212    memset(&schCellCfg, 0, sizeof(SchCellCfg));
213    schCellCfg.cellId = macCellCfg->cellId;
214    schCellCfg.phyCellId = macCellCfg->phyCellId;
215    schCellCfg.numerology = macCellCfg->numerology;
216    schCellCfg.dupMode = macCellCfg->dupType;
217    schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
218    schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
219    schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
220
221    /* fill ssb scheduler parameters */
222    schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
223    schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
224    schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
225    schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
226    schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
227    for(uint8_t idx=0; idx<SSB_MASK_SIZE; idx++)
228    {
229       schCellCfg.ssbSchCfg.nSSBMask[idx] = macCellCfg->ssbCfg.ssbMask[idx];
230    }
231
232    /* fill SIB1 scheduler parameters */
233    schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
234    schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
235    schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
236    schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
237    schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
238
239    /* fill RACH config params */
240    schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
241    schCellCfg.schRachCfg.prachSubcSpacing = \
242                                             macCellCfg->prachCfg.prachSubcSpacing;
243    schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
244    schCellCfg.schRachCfg.msg1Fdm       = macCellCfg->prachCfg.msg1Fdm;
245    schCellCfg.schRachCfg.rootSeqLen    = macCellCfg->prachCfg.rootSeqLen;
246    schCellCfg.schRachCfg.rootSeqIdx    = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
247    schCellCfg.schRachCfg.numRootSeq    = macCellCfg->prachCfg.fdm[0].numRootSeq;
248    schCellCfg.schRachCfg.k1            = macCellCfg->prachCfg.fdm[0].k1;
249    schCellCfg.schRachCfg.ssbPerRach    = macCellCfg->prachCfg.ssbPerRach;
250    schCellCfg.schRachCfg.prachMultCarrBand = \
251                                              macCellCfg->prachCfg.prachMultCarrBand;
252    schCellCfg.schRachCfg.raContResTmr  = macCellCfg->prachCfg.raContResTmr;
253    schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
254    schCellCfg.schRachCfg.raRspWindow   = macCellCfg->prachCfg.raRspWindow;
255
256    /* fill initial DL BWP */
257    schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
258    schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
259    schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
260    schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
261    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
262       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
263    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
264       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
265    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
266       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
267    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
268       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
269    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
270       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
271    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
272       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
273    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
274       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
275    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
276       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
277    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
278       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
279    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
280       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
281    schCellCfg.schInitialDlBwp.pdschCommon.k0 = macCellCfg->initialDlBwp.pdschCommon.k0;
282    schCellCfg.schInitialDlBwp.pdschCommon.mappingType =
283       macCellCfg->initialDlBwp.pdschCommon.mappingType;
284    schCellCfg.schInitialDlBwp.pdschCommon.startSymbol =
285       macCellCfg->initialDlBwp.pdschCommon.startSymbol;
286    schCellCfg.schInitialDlBwp.pdschCommon.lengthSymbol =
287       macCellCfg->initialDlBwp.pdschCommon.lengthSymbol;
288
289    /* fill initial UL BWP */
290    schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
291    schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
292    schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
293    schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
294    schCellCfg.schInitialUlBwp.puschCommon.k2 = macCellCfg->initialUlBwp.puschCommon.k2;
295    schCellCfg.schInitialUlBwp.puschCommon.mappingType =
296       macCellCfg->initialUlBwp.puschCommon.mappingType;
297    schCellCfg.schInitialUlBwp.puschCommon.startSymbol =
298       macCellCfg->initialUlBwp.puschCommon.startSymbol;
299    schCellCfg.schInitialUlBwp.puschCommon.lengthSymbol =
300       macCellCfg->initialUlBwp.puschCommon.lengthSymbol;
301 #ifdef NR_TDD
302    memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
303 #endif
304
305    FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
306
307    ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
308    return ret;
309 } /* end of MacSchCellCfgReq */
310
311
312 /*******************************************************************
313  *
314  * @brief Sends Cell config confirm to DU APP
315  *
316  * @details
317  *
318  *    Function : MacSendCellCfgCfm
319  *
320  *    Functionality:
321  *      Sends Cell config confirm to DU APP
322  *
323  * @params[in] Response status
324  * @return void
325  *
326  * ****************************************************************/
327 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
328 {
329    Pst pst;
330    uint16_t   cellIdx;
331    MacCellCfgCfm macCellCfgCfm;
332
333    memset(&pst, 0, sizeof(Pst));
334
335    GET_CELL_IDX(cellId, cellIdx);
336    macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
337    macCellCfgCfm.rsp = response;
338
339    /* Fill Pst */
340    FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
341    pst.selector  = ODU_SELECTOR_LC;
342
343    (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
344 }
345
346
347 /**
348  * @brief Layer Manager Configuration response handler.
349  *
350  * @details
351  *
352  *     Function : MacProcSchCellCfgCfm
353  *
354  *     This function processes cell configuration to SCH
355  *
356  *  @param[in]  Pst           *pst
357  *  @param[in]  SchCellCfgCfm *schCellCfgCfm
358  *  @return  int
359  *      -# ROK
360  **/
361 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
362 {
363    uint16_t *cellId = NULLP;
364
365    if(schCellCfgCfm->rsp == RSP_OK)
366    {
367       cellId = &schCellCfgCfm->cellId;
368 #ifdef INTEL_TIMER_MODE
369       sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
370 #else
371       sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
372 #endif
373    }
374    else
375    {
376       MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
377    }
378    return ROK;
379 }
380
381 /*******************************************************************
382  *
383  * @brief MAC handler for config response from PHY
384  *
385  * @details
386  *
387  *    Function : fapiMacConfigRsp
388  *
389  *    Functionality:
390  *     Processes config response from PHY and sends cell config
391  *     confirm to DU APP
392  *
393  * @params[in]
394  * @return void
395  *
396  * ****************************************************************/
397 void fapiMacConfigRsp(uint16_t cellId)
398 {
399    /* TODO : Processing of config response from PHY */
400
401    /* Send cell config cfm to DU APP */
402    MacSendCellCfgCfm(cellId, RSP_OK);
403 }
404
405 /*******************************************************************
406  *
407  * @brief Fill and Send Cell Delete response from MAC to DU APP
408  *
409  * @details
410  *
411  *    Function : MacSendCellDeleteRsp
412  *
413  *    Functionality: Fill and Send Cell Delete response from MAC to DUAPP
414  *
415  * @params[in] MAC Cell delete result
416  *             SCH Cell delete response
417  * @return ROK     - success
418  *         RFAILED - failure
419  *
420  * ****************************************************************/
421 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
422 {
423    MacCellDeleteRsp *deleteRsp=NULLP;
424    Pst            rspPst;
425
426    MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
427    if(!deleteRsp)
428    {
429       DU_LOG("\nERROR  -->  MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
430       return RFAILED;
431    }
432
433    /* Filling CELL delete response */
434    
435    memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
436    deleteRsp->cellId = cellId;
437    deleteRsp->result = result;
438
439    /* Fill Post structure and send CELL delete response*/
440    memset(&rspPst, 0, sizeof(Pst));
441    FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
442    return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
443 }
444
445 /*******************************************************************
446  *
447  * @brief  Processes CELL delete response from scheduler
448  *
449  * @details
450  *
451  *    Function : MacProcSchCellDeleteRsp
452  *
453  *    Functionality:
454  *      Processes CELL delete from scheduler
455  *
456  * @params[in] Pst : Post structure
457  *             schCellDelRsp : Scheduler CELL delete respons
458  * @return ROK     - success
459  *         RFAILED - failure
460  *
461  * * ****************************************************************/
462 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
463 {
464    uint8_t  ret = ROK;
465    uint16_t cellIdx=0;
466    CellDeleteStatus status;
467
468    if(schCellDelRsp)
469    {
470       if(schCellDelRsp->rsp == RSP_OK)
471       {
472          DU_LOG("\nINFO   -->  MAC : SCH CELL Delete response for cellId[%d] is successful ", \
473          schCellDelRsp->cellId);
474          GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
475          if(macCb.macCell[cellIdx])
476          {
477             if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
478             {
479                memset(macCb.macCell[cellIdx], 0, sizeof(MacCellCb));
480                status  = SUCCESSFUL_RSP;
481                MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
482             }
483             else
484             {
485                 DU_LOG("ERROR  -->  MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
486                 status = CELL_ID_INVALID;
487                 ret = RFAILED;
488             }
489          }
490          else
491          {
492             DU_LOG("ERROR  -->  MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
493             status = CELL_ID_INVALID;
494             ret = RFAILED;
495          }
496       }
497       else
498       {
499          DU_LOG("ERROR  -->  MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
500          status = CELL_ID_INVALID;
501          ret = RFAILED;
502       }
503       if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
504       {
505          DU_LOG("\nERROR  -->  MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
506          ret = RFAILED;
507       }
508
509    }
510    else
511    {
512       DU_LOG("\nERROR  -->  MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
513       ret = RFAILED;
514    }
515    return ret;
516 }
517
518 /*******************************************************************
519  *
520  * @brief Sends Cell delete req to Scheduler
521  *
522  * @details
523  *
524  *    Function : sendCellDelReqToSch
525  *
526  *    Functionality: sends Cell delete req to Scheduler
527  *
528  * @params[in]  SchCellDelete *schCellDel
529  * @return ROK     - success
530  *         RFAILED - failure
531  *
532  * ****************************************************************/
533
534 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
535 {
536    Pst schPst;
537    FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
538    return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
539 }
540
541 /*******************************************************************
542  *
543  * @brief Handles CELL Delete requst from DU APP
544  *
545  * @details
546  *
547  *    Function : MacProcCellDeleteReq
548  *
549  *    Functionality: Handles CELL Delete requst from DU APP
550  *
551  * @params[in] Pst *pst, MacCellDelete *cellDelete
552  * @return ROK     - success
553  *         RFAILED - failure
554  *
555  *
556  * ****************************************************************/
557 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
558 {
559    uint8_t ret = ROK, cellIdx=0;
560    SchCellDelete schCellDelete;
561
562    DU_LOG("\nINFO   -->  MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
563
564    if(cellDelete)
565    {
566       GET_CELL_IDX(cellDelete->cellId, cellIdx);
567       if(macCb.macCell[cellIdx])
568       {
569          if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
570          {
571             memset(&schCellDelete, 0, sizeof(SchCellDelete));
572             schCellDelete.cellId =  cellDelete->cellId;
573             ret = sendCellDelReqToSch(&schCellDelete);
574             if(ret != ROK)
575             {
576                DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
577                ret = RFAILED;
578             }
579          }
580          else
581          {
582             DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
583             cellDelete->cellId);
584             ret = RFAILED;
585          }
586       }
587       else
588       {
589          DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
590                cellDelete->cellId);
591          ret = RFAILED;
592       }
593
594       if(ret == RFAILED)
595       {
596           DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Sending failure response to DU");
597           if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
598           {
599              DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
600              cellDelete->cellId);
601           }
602
603       }
604       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
605    }
606    else
607    {
608       DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
609       ret = RFAILED;
610    }
611    return ret;
612 }
613
614 /**********************************************************************
615   End of file
616  **********************************************************************/