[Epic-ID: ODUHIGH-462][Task-ID: ODUHIGH-471] Storing drx configuration in cell
[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 MacDuSliceCfgRspFunc macDuSliceCfgRspOpts[] =
67 {
68    packDuMacSliceCfgRsp,   /* packing for loosely coupled */
69    DuProcMacSliceCfgRsp,   /* packing for tightly coupled */
70    packDuMacSliceCfgRsp   /* packing for light weight loosly coupled */
71 };
72
73 MacDuSliceReCfgRspFunc macDuSliceReCfgRspOpts[] =
74 {
75    packDuMacSliceReCfgRsp,   /* packing for loosely coupled */
76    DuProcMacSliceReCfgRsp,   /* packing for tightly coupled */
77    packDuMacSliceReCfgRsp   /* packing for light weight loosly coupled */
78 };
79
80 MacSchPagingIndFunc macSchPagingIndOpts[] = 
81 {
82    packMacSchPagingInd,   /* packing for loosely coupled */
83    MacSchPagingInd,       /* packing for tightly coupled */
84    packMacSchPagingInd    /* packing for light weight loosely coupled */
85 };
86
87 /**
88  * @brief Layer Manager  Configuration request handler for Scheduler
89  *
90  * @details
91  *
92  *     Function : MacSchGenCfgReq
93  *
94  *     This function receives general configurations for Scheduler
95  *     from DU APP and forwards to Scheduler.
96  *
97  *  @param[in]  Pst *pst, the post structure
98  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
99  *  @return 
100  *      -# ROK
101  **/
102 uint8_t MacSchGenCfgReq(Pst *pst, RgMngmt *cfg)
103 {
104    Pst schPst;
105
106    printf("\nReceived Scheduler gen config at MAC");
107    memset(&schPst, 0, sizeof(Pst));
108    FILL_PST_MAC_TO_SCH(schPst, EVENT_SCH_GEN_CFG);
109    SchProcGenCfgReq(&schPst, cfg);
110
111    return ROK;
112 }
113
114 /**
115  * @brief Layer Manager Configuration response from Scheduler
116  *
117  * @details
118  *
119  *     Function : SchSendCfgCfm
120  *
121  *     This function sends general configurations response from
122  *     Scheduler to DU APP.
123  *
124  *  @param[in]  Pst *pst, the post structure
125  *  @param[in]  RgMngmt *cfm, the configuration confirm structure
126  *  @return 
127  *      -# ROK
128  **/
129 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt  *cfm)
130 {
131    DU_LOG("\nDEBUG  -->  Sending Scheduler config confirm to DU APP");
132    pst->dstEnt = ENTDUAPP;
133    pst->dstInst = 0;
134    pst->srcInst = 0;
135    pst->selector = ODU_SELECTOR_LC;
136    RgMiLrgSchCfgCfm(pst, cfm);
137
138    return ROK;
139 }
140
141 /**
142  * @brief Layer Manager Configuration request handler.
143  *
144  * @details
145  *
146  *     Function : MacProcCellCfgReq
147  *
148  *     This function handles the gNB and cell configuration
149  *     request received from DU APP.
150  *     This API unapcks and forwards the config towards SCH
151  *
152  *  @param[in]  Pst           *pst
153  *  @param[in]  MacCellCfg    *macCellCfg
154  *  @return  
155  *      -# ROK
156  **/
157 uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
158 {
159    Pst cfmPst;
160    uint16_t cellIdx;
161    uint8_t ret = ROK, sliceIdx = 0;
162    MacCellCb     *macCellCb;
163
164    memset((uint8_t *)&cfmPst, 0, sizeof(Pst));
165
166    MAC_ALLOC(macCellCb, sizeof(MacCellCb));
167    if(macCellCb == NULLP)
168    {
169       DU_LOG("\nERROR  -->  MAC : macCellCb is NULL at handling of macCellCfg\n");
170       return RFAILED;
171    }
172    memset(macCellCb, 0, sizeof(MacCellCb));
173
174    GET_CELL_IDX(macCellCfg->cellId, cellIdx);
175    macCb.macCell[cellIdx] = macCellCb;
176    macCb.macCell[cellIdx]->cellId = macCellCfg->cellId;
177    memcpy(&macCb.macCell[cellIdx]->macCellCfg, macCellCfg, sizeof(MacCellCfg));
178
179    MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
180          macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
181    if(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu == NULLP)
182    {
183       DU_LOG("\nERROR  -->  MAC : macCellCb is NULL at handling of sib1Pdu of macCellCfg\n");
184       return RFAILED;
185    }
186    memcpy(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, macCellCfg->sib1Cfg.sib1Pdu, \
187          macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
188    
189    macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice = macCellCfg->plmnInfoList.numSupportedSlice;
190    MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice\
191          * sizeof(Snssai*));
192    if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai == NULLP)
193    {
194       DU_LOG("\nERROR  --> MAC: Memory allocation failed at MacProcCellCfgReq");
195       return RFAILED;
196    }
197
198    if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
199    {
200       for(sliceIdx=0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
201       {
202          if(macCellCfg->plmnInfoList.snssai[sliceIdx])
203          {
204             MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
205             if(!macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx])
206             {
207                DU_LOG("\nERROR  --> MAC: Memory allocation failed at MacProcCellCfgReq");
208                return RFAILED;
209             }
210             memcpy(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],\
211             sizeof(Snssai));
212          }
213       }
214    }
215
216    /* Send cell cfg to scheduler */
217    ret = MacSchCellCfgReq(pst, macCellCfg);
218    if(ret != ROK)
219    {
220       MacCellCfgCfm macCellCfgCfm;
221       macCellCfgCfm.rsp = RSP_NOK;
222       macCellCfgCfm.cellId = macCellCfg->cellId;
223       /* Fill Pst */
224       FILL_PST_MAC_TO_DUAPP(cfmPst, EVENT_MAC_CELL_CONFIG_CFM);
225       cfmPst.selector  = ODU_SELECTOR_LC;
226
227       ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
228    }
229    else
230    {
231       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macCellCfg ,sizeof(MacCellCfg));
232    }
233    return ret;
234 } /* end of MacProcCellCfgReq */
235
236 /**
237  * @brief Layer Manager Configuration request handler.
238  *
239  * @details
240  *
241  *     Function : MacSchCellCfgReq
242  *
243  *     This function sends cell configuration to SCH
244  *
245  *  @param[in]  Pst           *pst
246  *  @param[in]  MacCellCfg    *macCellCfg
247  *  @return  
248  *      -# ROK
249  **/
250 uint8_t MacSchCellCfgReq(Pst *pst, MacCellCfg *macCellCfg)
251 {
252    SchCellCfg schCellCfg;
253    Pst        cfgPst;
254    uint8_t    ssbMaskIdx = 0, rsrcListIdx = 0, ret=0, sliceIdx=0;
255
256    memset(&cfgPst, 0, sizeof(Pst));
257    memset(&schCellCfg, 0, sizeof(SchCellCfg));
258    schCellCfg.cellId = macCellCfg->cellId;
259    schCellCfg.phyCellId = macCellCfg->phyCellId;
260    schCellCfg.numerology = macCellCfg->numerology;
261    schCellCfg.dupMode = macCellCfg->dupType;
262    schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
263    schCellCfg.dlFreq = macCellCfg->dlCarrCfg.freq;
264    schCellCfg.ulFreq = macCellCfg->ulCarrCfg.freq;
265
266    /* fill ssb scheduler parameters */
267    schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
268    schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
269    schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
270    schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
271    schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
272    for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
273    {
274       schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
275    }
276    schCellCfg.ssbSchCfg.totNumSsb = countSetBits(schCellCfg.ssbSchCfg.nSSBMask[0]);
277
278    /* fill SIB1 scheduler parameters */
279    schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen;
280    schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod;
281    schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex;
282    schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex;
283    schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs;
284    schCellCfg.sib1SchCfg.pageCfg.numPO  =  macCellCfg->sib1Cfg.pagingCfg.numPO;
285    schCellCfg.sib1SchCfg.pageCfg.poPresent = macCellCfg->sib1Cfg.pagingCfg.poPresent;
286
287    if(schCellCfg.sib1SchCfg.pageCfg.poPresent)
288    {
289       memcpy(schCellCfg.sib1SchCfg.pageCfg.pagingOcc, macCellCfg->sib1Cfg.pagingCfg.pagingOcc, MAX_PO_PER_PF);
290    }
291
292    /* fill RACH config params */
293    schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
294    schCellCfg.schRachCfg.prachSubcSpacing = \
295                                             macCellCfg->prachCfg.prachSubcSpacing;
296    schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
297    schCellCfg.schRachCfg.msg1Fdm       = macCellCfg->prachCfg.msg1Fdm;
298    schCellCfg.schRachCfg.rootSeqLen    = macCellCfg->prachCfg.rootSeqLen;
299    schCellCfg.schRachCfg.rootSeqIdx    = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
300    schCellCfg.schRachCfg.numRootSeq    = macCellCfg->prachCfg.fdm[0].numRootSeq;
301    schCellCfg.schRachCfg.k1            = macCellCfg->prachCfg.fdm[0].k1;
302    schCellCfg.schRachCfg.totalNumRaPreamble = macCellCfg->prachCfg.totalNumRaPreamble;
303    schCellCfg.schRachCfg.ssbPerRach    = macCellCfg->prachCfg.ssbPerRach;
304    schCellCfg.schRachCfg.numCbPreamblePerSsb = macCellCfg->prachCfg.numCbPreamblePerSsb;
305    schCellCfg.schRachCfg.prachMultCarrBand = macCellCfg->prachCfg.prachMultCarrBand;
306    schCellCfg.schRachCfg.raContResTmr  = macCellCfg->prachCfg.raContResTmr;
307    schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
308    schCellCfg.schRachCfg.raRspWindow   = macCellCfg->prachCfg.raRspWindow;
309
310    /* fill initial DL BWP */
311    schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
312    schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
313    schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
314    schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
315    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
316       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
317    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
318       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
319    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
320       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
321    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
322       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
323    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
324       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
325    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
326       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
327    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
328       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
329    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
330       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
331    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
332       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
333    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
334       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
335    schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
336    for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
337    {
338       schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 = 
339          macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
340       schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
341          macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
342       schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
343          macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
344       schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
345          macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
346    }
347
348    /* fill initial UL BWP */
349    schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
350    schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
351    schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
352    schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
353    schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
354       macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
355    for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
356    {
357       schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 = 
358          macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
359       schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
360          macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
361       schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
362          macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
363       schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
364          macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
365    }
366
367    if(macCellCfg->plmnInfoList.snssai) 
368    {
369       schCellCfg.plmnInfoList.numSliceSupport = macCellCfg->plmnInfoList.numSupportedSlice;
370       MAC_ALLOC(schCellCfg.plmnInfoList.snssai, schCellCfg.plmnInfoList.numSliceSupport * sizeof(Snssai*));
371       if(!schCellCfg.plmnInfoList.snssai)
372       {
373          DU_LOG("\nERROR  --> MAC: Memory allocation failed at MacSchCellCfgReq");
374          return RFAILED;
375       }
376       for(sliceIdx=0; sliceIdx<schCellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
377       {
378          if(macCellCfg->plmnInfoList.snssai[sliceIdx])
379          {
380             MAC_ALLOC(schCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
381             if(!schCellCfg.plmnInfoList.snssai[sliceIdx])
382             {
383                DU_LOG("\nERROR  --> MAC: Memory allocation failed at MacSchCellCfgReq");
384                return RFAILED;
385             }
386             memcpy(schCellCfg.plmnInfoList.snssai[sliceIdx], macCellCfg->plmnInfoList.snssai[sliceIdx],  sizeof(Snssai));
387          }
388       }
389    }
390 #ifdef NR_DRX
391    /* Drx configuration */
392
393    schCellCfg.drxInfo.drxOnDurationTimer.onDurationTimerValInMs = macCellCfg->drxInfo.drxOnDurationTimer.onDurationTimerValInMs;
394    if(!macCellCfg->drxInfo.drxOnDurationTimer.onDurationTimerValInMs)
395       schCellCfg.drxInfo.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
396       macCellCfg->drxInfo.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
397    else
398       schCellCfg.drxInfo.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
399       macCellCfg->drxInfo.drxOnDurationTimer.onDurationtimerValue.milliSeconds;
400    schCellCfg.drxInfo.drxInactivityTimer = macCellCfg->drxInfo.drxInactivityTimer;
401    schCellCfg.drxInfo.drxHarqRttTimerDl = macCellCfg->drxInfo.drxHarqRttTimerDl;
402    schCellCfg.drxInfo.drxHarqRttTimerUl = macCellCfg->drxInfo.drxHarqRttTimerUl;
403    schCellCfg.drxInfo.drxRetransmissionTimerDl = macCellCfg->drxInfo.drxRetransmissionTimerDl;
404    schCellCfg.drxInfo.drxRetransmissionTimerUl = macCellCfg->drxInfo.drxRetransmissionTimerUl;
405    schCellCfg.drxInfo.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = macCellCfg->drxInfo.drxLongCycleStartOffset.\
406                                                                               drxLongCycleStartOffsetChoice;
407    schCellCfg.drxInfo.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = macCellCfg->drxInfo.drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
408    schCellCfg.drxInfo.shortDrx.drxShortCycle = macCellCfg->drxInfo.shortDrx.drxShortCycle;
409    schCellCfg.drxInfo.shortDrx.drxShortCycleTimer = macCellCfg->drxInfo.shortDrx.drxShortCycleTimer;
410    schCellCfg.drxInfo.drxSlotOffset = macCellCfg->drxInfo.drxSlotOffset;
411 #endif
412
413 #ifdef NR_TDD
414    memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
415 #endif
416
417    FILL_PST_MAC_TO_SCH(cfgPst, EVENT_SCH_CELL_CFG);
418
419    ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
420    return ret;
421 } /* end of MacSchCellCfgReq */
422
423
424 /*******************************************************************
425  *
426  * @brief Sends Cell config confirm to DU APP
427  *
428  * @details
429  *
430  *    Function : MacSendCellCfgCfm
431  *
432  *    Functionality:
433  *      Sends Cell config confirm to DU APP
434  *
435  * @params[in] Response status
436  * @return void
437  *
438  * ****************************************************************/
439 void MacSendCellCfgCfm(uint16_t cellId, uint8_t response)
440 {
441    Pst pst;
442    uint16_t   cellIdx;
443    MacCellCfgCfm macCellCfgCfm;
444
445    memset(&pst, 0, sizeof(Pst));
446
447    GET_CELL_IDX(cellId, cellIdx);
448    macCellCfgCfm.cellId = macCb.macCell[cellIdx]->macCellCfg.cellId;
449    macCellCfgCfm.rsp = response;
450
451    /* Fill Pst */
452    FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_CONFIG_CFM);
453    pst.selector  = ODU_SELECTOR_LC;
454
455    (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
456 }
457
458
459 /**
460  * @brief Layer Manager Configuration response handler.
461  *
462  * @details
463  *
464  *     Function : MacProcSchCellCfgCfm
465  *
466  *     This function processes cell configuration to SCH
467  *
468  *  @param[in]  Pst           *pst
469  *  @param[in]  SchCellCfgCfm *schCellCfgCfm
470  *  @return  int
471  *      -# ROK
472  **/
473 uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm)
474 {
475    uint16_t *cellId = NULLP;
476
477 #ifdef CALL_FLOW_DEBUG_LOG
478    DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_SCH_CELL_CFG_CFM\n");
479 #endif
480
481    if(schCellCfgCfm->rsp == RSP_OK)
482    {
483       cellId = &schCellCfgCfm->cellId;
484 #ifdef INTEL_TIMER_MODE
485       sendToLowerMac(UL_IQ_SAMPLE, 0, (void *)cellId);
486 #else
487       sendToLowerMac(CONFIG_REQUEST, 0, (void *)cellId);
488 #endif
489    }
490    else
491    {
492       MacSendCellCfgCfm(schCellCfgCfm->cellId, RSP_NOK);
493    }
494    return ROK;
495 }
496
497 /*******************************************************************
498  *
499  * @brief MAC handler for config response from PHY
500  *
501  * @details
502  *
503  *    Function : fapiMacConfigRsp
504  *
505  *    Functionality:
506  *     Processes config response from PHY and sends cell config
507  *     confirm to DU APP
508  *
509  * @params[in]
510  * @return void
511  *
512  * ****************************************************************/
513 void fapiMacConfigRsp(uint16_t cellId)
514 {
515    /* TODO : Processing of config response from PHY */
516
517    /* Send cell config cfm to DU APP */
518    MacSendCellCfgCfm(cellId, RSP_OK);
519 }
520
521 /*******************************************************************
522  *
523  * @brief Fill and Send Cell Delete response from MAC to DU APP
524  *
525  * @details
526  *
527  *    Function : MacSendCellDeleteRsp
528  *
529  *    Functionality: Fill and Send Cell Delete response from MAC to DUAPP
530  *
531  * @params[in] MAC Cell delete result
532  *             SCH Cell delete response
533  * @return ROK     - success
534  *         RFAILED - failure
535  *
536  * ****************************************************************/
537 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
538 {
539    MacCellDeleteRsp *deleteRsp=NULLP;
540    Pst            rspPst;
541
542    MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
543    if(!deleteRsp)
544    {
545       DU_LOG("\nERROR  -->  MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
546       return RFAILED;
547    }
548
549    /* Filling CELL delete response */
550    
551    memset(deleteRsp, 0, sizeof(MacCellDeleteRsp));
552    deleteRsp->cellId = cellId;
553    deleteRsp->result = result;
554
555    /* Fill Post structure and send CELL delete response*/
556    memset(&rspPst, 0, sizeof(Pst));
557    FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
558    return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
559 }
560
561 /*******************************************************************
562  *
563  * @brief  Processes CELL delete response from scheduler
564  *
565  * @details
566  *
567  *    Function : MacProcSchCellDeleteRsp
568  *
569  *    Functionality:
570  *      Processes CELL delete from scheduler
571  *
572  * @params[in] Pst : Post structure
573  *             schCellDelRsp : Scheduler CELL delete respons
574  * @return ROK     - success
575  *         RFAILED - failure
576  *
577  * * ****************************************************************/
578 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
579 {
580    uint8_t  ret = ROK, sliceIdx = 0;
581    uint16_t cellIdx=0;
582    CellDeleteStatus status;
583    
584 #ifdef CALL_FLOW_DEBUG_LOG
585    DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_CELL_DELETE_RSP_TO_MAC\n");
586 #endif  
587
588    if(schCellDelRsp)
589    {
590       if(schCellDelRsp->rsp == RSP_OK)
591       {
592          DU_LOG("\nINFO   -->  MAC : SCH CELL Delete response for cellId[%d] is successful ", \
593          schCellDelRsp->cellId);
594          GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
595          if(macCb.macCell[cellIdx])
596          {
597             if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
598             {
599                status  = SUCCESSFUL_RSP;
600                if(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai)
601                {
602                   for(sliceIdx = 0; sliceIdx<macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.numSupportedSlice; sliceIdx++)
603                   {
604                      MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
605                   }
606                   MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.snssai, macCb.macCell[cellIdx]->macCellCfg.plmnInfoList.\
607                   numSupportedSlice * sizeof(Snssai*));
608                }
609                MAC_FREE(macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1Pdu, \
610                   macCb.macCell[cellIdx]->macCellCfg.sib1Cfg.sib1PduLen);
611                MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
612             }
613             else
614             {
615                 DU_LOG("ERROR  -->  MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
616                 status = CELL_ID_INVALID;
617                 ret = RFAILED;
618             }
619          }
620          else
621          {
622             DU_LOG("ERROR  -->  MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
623             status = CELL_ID_INVALID;
624             ret = RFAILED;
625          }
626       }
627       else
628       {
629          DU_LOG("ERROR  -->  MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
630          status = CELL_ID_INVALID;
631          ret = RFAILED;
632       }
633       if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
634       {
635          DU_LOG("\nERROR  -->  MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
636          ret = RFAILED;
637       }
638
639    }
640    else
641    {
642       DU_LOG("\nERROR  -->  MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
643       ret = RFAILED;
644    }
645    return ret;
646 }
647
648 /*******************************************************************
649  *
650  * @brief Sends Cell delete req to Scheduler
651  *
652  * @details
653  *
654  *    Function : sendCellDelReqToSch
655  *
656  *    Functionality: sends Cell delete req to Scheduler
657  *
658  * @params[in]  SchCellDelete *schCellDel
659  * @return ROK     - success
660  *         RFAILED - failure
661  *
662  * ****************************************************************/
663
664 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
665 {
666    Pst schPst;
667    FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
668    return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
669 }
670
671 /*******************************************************************
672  *
673  * @brief Handles CELL Delete requst from DU APP
674  *
675  * @details
676  *
677  *    Function : MacProcCellDeleteReq
678  *
679  *    Functionality: Handles CELL Delete requst from DU APP
680  *
681  * @params[in] Pst *pst, MacCellDelete *cellDelete
682  * @return ROK     - success
683  *         RFAILED - failure
684  *
685  *
686  * ****************************************************************/
687 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
688 {
689    uint8_t ret = ROK, cellIdx=0;
690    SchCellDelete schCellDelete;
691
692    DU_LOG("\nINFO   -->  MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
693
694    if(cellDelete)
695    {
696       GET_CELL_IDX(cellDelete->cellId, cellIdx);
697       if(macCb.macCell[cellIdx])
698       {
699          if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
700          {
701             memset(&schCellDelete, 0, sizeof(SchCellDelete));
702             schCellDelete.cellId =  cellDelete->cellId;
703             ret = sendCellDelReqToSch(&schCellDelete);
704             if(ret != ROK)
705             {
706                DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
707                ret = RFAILED;
708             }
709          }
710          else
711          {
712             DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
713             cellDelete->cellId);
714             ret = RFAILED;
715          }
716       }
717       else
718       {
719          DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
720                cellDelete->cellId);
721          ret = RFAILED;
722       }
723
724       if(ret == RFAILED)
725       {
726           DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Sending failure response to DU");
727           if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
728           {
729              DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
730              cellDelete->cellId);
731           }
732
733       }
734       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
735    }
736    else
737    {
738       DU_LOG("\nERROR  -->  MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
739       ret = RFAILED;
740    }
741    return ret;
742 }
743
744 /**
745  * @brief free the temporary slice cfg stored in macCb.
746  *
747  * @details
748  *
749  *     Function : freeMacSliceCfgReq 
750  *
751  *   free the temporary slice cfg stored in macCb
752  *
753  *  @param[in]  
754  *  @return  int
755  *      -# ROK
756  **/
757 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst)
758 {
759    uint8_t cfgIdx = 0;
760    
761    if(cfgReq)
762    {
763       if(cfgReq->numOfConfiguredSlice)
764       {
765          for(cfgIdx = 0; cfgIdx<cfgReq->numOfConfiguredSlice; cfgIdx++)
766          {
767             if(cfgReq->listOfSliceCfg[cfgIdx])
768             {
769                MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio)); 
770             }
771             MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
772          }
773          MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq->listOfSliceCfg, cfgReq->numOfConfiguredSlice * sizeof(MacSliceRrmPolicy*));
774       }
775       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cfgReq, sizeof(MacSliceCfgReq));
776    }
777 }
778 /**
779  * @brief fill Mac Slice Config Rsp
780  *
781  * @details
782  *
783  *     Function : fillMacSliceCfgRsp 
784  *
785  *     This function   fill Mac Slice Config Rsp
786  *
787  *  @param[in]  SchSliceCfgRsp *sliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp,
788  *  uint8_t *count
789  *  @return  int
790  *      -# ROK
791  **/
792 uint8_t fillMacSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp, MacSliceCfgRsp *macSliceCfgRsp)
793 {
794    
795     bool sliceFound = false;
796     uint8_t cfgIdx = 0;
797
798     macSliceCfgRsp->numSliceCfgRsp  = schSliceCfgRsp->numSliceCfgRsp;
799     MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp,  macSliceCfgRsp->numSliceCfgRsp* sizeof(MacSliceRsp*));
800     if(macSliceCfgRsp->listOfSliceCfgRsp == NULLP)
801     {
802        DU_LOG("\nERROR  -->  MAC : Memory allocation failedi in fillMacSliceCfgRsp");
803        return RFAILED;
804     }
805
806     for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
807     {
808        sliceFound = false;
809        if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
810        {
811           sliceFound = true;
812        }
813
814        MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
815        if(macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
816        {
817           DU_LOG("\nERROR  -->  MAC : Memory allocation failedi in fillMacSliceCfgRsp");
818           return RFAILED;
819        }
820
821        macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai;
822        if(sliceFound == true)
823           macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp    = MAC_DU_APP_RSP_OK;
824        else
825        {
826           macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp    = MAC_DU_APP_RSP_NOK;
827           macSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause  = SLICE_NOT_PRESENT;
828        }
829     }
830     return ROK;
831 }
832
833 /**
834  * @brief send slice cfg response to duapp.
835  *
836  * @details
837  *
838  *     Function : MacSendSliceConfigRsp
839  *
840  *   sends  slice cfg response to duapp
841  *
842  *  @param[in] MacSliceCfgRsp macSliceCfgRsp 
843  *  @return  int
844  *      -# ROK
845  **/
846 uint8_t MacSendSliceConfigRsp(MacSliceCfgRsp *macSliceCfgRsp)
847 {
848     Pst  rspPst;
849     
850     memset(&rspPst, 0, sizeof(Pst));
851     FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_CFG_RSP);
852     return (*macDuSliceCfgRspOpts[rspPst.selector])(&rspPst, macSliceCfgRsp);
853
854 }
855 /**
856  * @brief free the slice cfg rsp received from sch.
857  *
858  * @details
859  *
860  *     Function : freeSchSliceCfgRsp 
861  *
862  *     This free the slice cfg rsp received from sch
863  *
864  *  @param[in]  SchSliceCfgRsp *sliceCfgrsp
865  *  @return  int
866  *      -# ROK
867  **/
868 void freeSchSliceCfgRsp(SchSliceCfgRsp *schSliceCfgRsp)
869 {
870    uint8_t cfgIdx = 0;
871
872    if(schSliceCfgRsp)
873    {
874       if(schSliceCfgRsp->numSliceCfgRsp)
875       {
876          for(cfgIdx = 0; cfgIdx< schSliceCfgRsp->numSliceCfgRsp; cfgIdx++)
877          {
878             MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
879          }
880          MAC_FREE(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
881       }
882    }
883 }
884
885 /**
886  * @brief Mac process the slice cfg rsp received from sch.
887  *
888  * @details
889  *
890  *     Function : MacProcSchSliceCfgRsp 
891  *
892  *     This function  process the slice cfg rsp received from sch
893  *
894  *  @param[in]  Pst           *pst
895  *  @param[in]  SchSliceCfgRsp *sliceCfgrsp
896  *  @return  int
897  *      -# ROK
898  **/
899 uint8_t MacProcSchSliceCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceCfgRsp)
900 {
901    MacSliceCfgRsp *macSliceCfgRsp = NULLP;
902
903    if(schSliceCfgRsp)
904    {
905       MAC_ALLOC_SHRABL_BUF(macSliceCfgRsp, sizeof(MacSliceCfgRsp));
906       if(macSliceCfgRsp == NULLP)
907       {
908           DU_LOG("\nERROR  -->  MAC : Failed to allocate memory in MacProcSchSliceCfgRsp");
909           return RFAILED;
910       }
911       if(schSliceCfgRsp->listOfSliceCfgRsp)
912       {
913          if(fillMacSliceCfgRsp(schSliceCfgRsp, macSliceCfgRsp) != ROK)
914          {
915             DU_LOG("\nERROR  -->  MAC : Failed to fill the slice cfg response");
916             return RFAILED;
917          }
918          MacSendSliceConfigRsp(macSliceCfgRsp);
919       }
920       freeSchSliceCfgRsp(schSliceCfgRsp);
921    }
922    return ROK;
923 }
924
925 /**
926 * @brief send slice cfg response to duapp.
927 *
928 * @details
929 *
930 *     Function : MacSendSliceReconfigRsp 
931 *
932 *   sends  slice cfg response to duapp
933 *
934 *  @param[in] MacSliceCfgRsp macSliceRecfgRsp
935 *  @return  int
936 *      -# ROK
937 **/
938 uint8_t MacSendSliceReconfigRsp(MacSliceCfgRsp *macSliceRecfgRsp)
939 {
940    Pst  rspPst;
941
942    memset(&rspPst, 0, sizeof(Pst));
943    FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_SLICE_RECFG_RSP);
944    return (*macDuSliceReCfgRspOpts[rspPst.selector])(&rspPst, macSliceRecfgRsp);
945
946 }
947
948 /**
949  * @brief Mac process the slice cfg rsp received from sch.
950  *
951  * @details
952  *
953  *     Function : MacProcSchSliceReCfgRsp 
954  *
955  *     This function  process the slice cfg rsp received from sch
956  *
957  *  @param[in]  Pst           *pst
958  *  @param[in]  SchSliceCfgRsp *schSliceRecfgRsp
959  *  @return  int
960  *      -# ROK
961  **/
962 uint8_t MacProcSchSliceReCfgRsp(Pst *pst, SchSliceCfgRsp *schSliceRecfgRsp)
963 {
964    MacSliceCfgRsp *macSliceReCfgRsp = NULLP;
965
966    if(schSliceRecfgRsp)
967    {
968       MAC_ALLOC_SHRABL_BUF(macSliceReCfgRsp, sizeof(MacSliceCfgRsp));
969       if(macSliceReCfgRsp == NULLP)
970       {
971           DU_LOG("\nERROR  -->  MAC : Failed to allocate memory in MacProcSchSliceReCfgRsp");
972           return RFAILED;
973       }
974
975       if(schSliceRecfgRsp->listOfSliceCfgRsp)
976       {
977          if(fillMacSliceCfgRsp(schSliceRecfgRsp, macSliceReCfgRsp) != ROK)
978          {
979             DU_LOG("\nERROR  -->  MAC : Failed to fill the slice Recfg response");
980             return RFAILED;
981          }
982          MacSendSliceReconfigRsp(macSliceReCfgRsp);
983       }
984       freeSchSliceCfgRsp(schSliceRecfgRsp);
985    }
986    return ROK;
987 }
988
989 /**
990  * @brief Mac process the downlink pcch indication received from DUAPP
991  *
992  * @details
993  *
994  *     Function : MacProcDlPcchInd 
995  *
996  *     This function process the downlink pcch indication received from DUAPP
997  *
998  *  @param[in]  Pst           *pst
999  *  @param[in]  MacPcchInd    *pcchInd 
1000  *  @return  int
1001  *      -# ROK
1002  **/
1003 uint8_t MacProcDlPcchInd(Pst *pst, MacPcchInd *pcchInd)
1004 {
1005    uint8_t ret = RFAILED;
1006    uint16_t cellIdx = 0;
1007    Pst       schPst;
1008    SchPageInd *schPageInd = NULLP;
1009
1010    if(pcchInd)
1011    {
1012       DU_LOG("\nINFO   -->  MAC : Received DL PCCH IND from DU_APP for cellId[%d]", pcchInd->cellId);
1013       
1014       GET_CELL_IDX(pcchInd->cellId, cellIdx);
1015
1016       if(macCb.macCell[cellIdx] == NULLP || macCb.macCell[cellIdx]->cellId != pcchInd->cellId)
1017       {
1018          DU_LOG("\nERROR  -->  MAC : MacProcDlPcchInd(): CellId[%d] does not exist", pcchInd->cellId);
1019       }
1020       else
1021       {
1022          if((pcchInd->pcchPdu == NULLP) || (pcchInd->pduLen <= 0))
1023          {
1024             DU_LOG("\nERROR  -->  MAC : MacProcDlPcchInd(): Received Pcch pdu is null");
1025          }
1026          else
1027          {
1028             MAC_ALLOC(schPageInd, sizeof(SchPageInd));
1029             if(schPageInd == NULLP)
1030             {
1031                DU_LOG("\nERROR  -->  MAC : MacProcDlPcchInd(): Failed to allocate memory");
1032             }
1033             else
1034             {
1035                schPageInd->cellId = pcchInd->cellId;
1036                schPageInd->pf = pcchInd->pf;
1037                schPageInd->i_s = pcchInd->i_s;
1038                schPageInd->pduLen = pcchInd->pduLen;
1039                
1040                MAC_ALLOC(schPageInd->pagePdu, pcchInd->pduLen);
1041                if(schPageInd->pagePdu == NULLP)
1042                {
1043                   DU_LOG("\nERROR  -->  MAC : MacProcDlPcchInd(): Failed to allocate memory");
1044                   MAC_FREE(schPageInd, sizeof(SchPageInd));
1045                }
1046                else
1047                {
1048                   memcpy(schPageInd->pagePdu, pcchInd->pcchPdu, pcchInd->pduLen);
1049
1050                   FILL_PST_MAC_TO_SCH(schPst, EVENT_PAGING_IND_TO_SCH);
1051                   ret = (*macSchPagingIndOpts[schPst.selector])(&schPst, schPageInd);
1052                }
1053             }
1054          }
1055       }
1056       if((pcchInd->pcchPdu) && (pcchInd->pduLen > 0))
1057       {
1058          MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd->pcchPdu, pcchInd->pduLen);
1059       }
1060       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, pcchInd, sizeof(MacPcchInd));
1061    }
1062    else
1063    {
1064       DU_LOG("\nERROR  -->  MAC : MacProcDlPcchInd(): Received Null pointer");
1065    }
1066    return ret;
1067 }
1068 /**********************************************************************
1069   End of file
1070  **********************************************************************/