Merge "Cleanup of message sib1"
[o-du/l2.git] / src / 5gnrsch / sch.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
19 /************************************************************************
20  
21      Name:     sch.c
22   
23      Type:     C source file
24   
25      Desc:     C source code for scheduler fucntions
26   
27      File:     sch.c
28   
29 **********************************************************************/
30
31 /** @file sch.c
32 @brief This file implements the schedulers main access to MAC layer code.
33 */
34 #include "stdbool.h"
35 #include "envopt.h"        /* environment options */
36 #include "envdep.h"        /* environment dependent */
37 #include "envind.h"        /* environment independent */
38 #include "gen.h"           /* general layer */
39 #include "ssi.h"           /* system service interface */
40 #include "cm_tkns.h"       /* Common Token Defines */
41 #include "cm_llist.h"      /* Common Link List Defines */
42 #include "cm_hash.h"       /* Common Hash List Defines */
43 #include "cm_mblk.h"       /* common memory link list library */
44 #include "cm_lte.h"        /* Common LTE Defines */
45 #include "lrg.h"
46 #include "rgr.h"
47 #include "tfu.h"
48 #include "rg_sch_inf.h"
49 #include "rg_sch.h"
50 #include "gen.x"           /* general layer typedefs */
51 #include "ssi.x"           /* system services typedefs */
52 #include "cm5.x"           /* system services */
53 #include "cm_tkns.x"       /* Common Token Definitions */
54 #include "cm_llist.x"      /* Common Link List Definitions */
55 #include "cm_lib.x"        /* Common Library Definitions */
56 #include "cm_hash.x"       /* Common Hash List Definitions */
57 #include "cm_mblk.x"       /* common memory link list library */
58 #include "cm_lte.x"        /* Common LTE Defines */
59 #include "tfu.x"           /* TFU types */
60 #include "lrg.x"           /* layer management typedefs for MAC */
61 #include "rgr.x"           /* layer management typedefs for MAC */
62 #include "rg_sch_inf.x"         /* typedefs for Scheduler */
63 #include "du_app_mac_inf.h"
64 #include "mac_sch_interface.h"
65 #include "sch.h"
66 #include "sch_utils.h"
67 #include "du_log.h"
68 extern SchCb schCb[SCH_MAX_INST];
69 void SchFillCfmPst(Pst *reqPst,Pst *cfmPst,RgMngmt *cfm);
70 /* local defines */
71 SchCellCfgCfmFunc SchCellCfgCfmOpts[] = 
72 {
73         packSchCellCfgCfm,     /* LC */
74         MacProcSchCellCfgCfm,  /* TC */
75         packSchCellCfgCfm      /* LWLC */
76 };
77
78
79 /**
80  * @brief Task Initiation function. 
81  *
82  * @details
83  *
84  *     Function : schActvInit
85  *     
86  *     This function is supplied as one of parameters during MAC's 
87  *     task registration. MAC will invoke this function once, after
88  *     it creates and attaches this TAPA Task to a system task.
89  *     
90  *  @param[in]  Ent Entity, the entity ID of this task.     
91  *  @param[in]  Inst Inst, the instance ID of this task.
92  *  @param[in]  Region Region, the region ID registered for memory 
93  *              usage of this task.
94  *  @param[in]  Reason Reason.
95  *  @return  int
96  *      -# ROK
97  **/
98 int schActvInit
99 (
100 Ent    entity,            /* entity */
101 Inst   instId,             /* instance */
102 Region region,         /* region */
103 Reason reason          /* reason */
104 )
105 {
106    Inst inst = (instId  - SCH_INST_START);
107
108    /* Initialize the MAC TskInit structure to zero */
109    cmMemset ((uint8_t *)&schCb[inst], 0, sizeof(schCb));
110
111    /* Initialize the MAC TskInit with received values */
112    schCb[inst].schInit.ent = entity;
113    schCb[inst].schInit.inst = inst;
114    schCb[inst].schInit.region = region;
115    schCb[inst].schInit.pool = 0;
116    schCb[inst].schInit.reason = reason;
117    schCb[inst].schInit.cfgDone = FALSE;
118    schCb[inst].schInit.acnt = FALSE;
119    schCb[inst].schInit.usta = FALSE;
120    schCb[inst].schInit.trc = FALSE;
121    schCb[inst].schInit.procId = SFndProcId();
122
123    RETVALUE(ROK);
124 } /* schActvInit */
125
126 /**
127  * @brief Scheduler instance Configuration Handler. 
128  *
129  * @details
130  *
131  *     Function : SchInstCfg
132  *     
133  *     This function in called by HandleSchGenCfgReq(). It handles the
134  *     general configurations of the scheduler instance. Returns
135  *     reason for success/failure of this function.
136  *     
137  *  @param[in]  RgCfg *cfg, the Configuaration information 
138  *  @return  U16
139  *      -# LCM_REASON_NOT_APPL 
140  *      -# LCM_REASON_INVALID_MSGTYPE
141  *      -# LCM_REASON_MEM_NOAVAIL
142  **/
143 PUBLIC U16 SchInstCfg
144 (
145 RgCfg *cfg,            /* Configuaration information */
146 Inst  dInst
147 )
148 {
149    uint16_t ret = LCM_REASON_NOT_APPL;
150    Inst     inst = (dInst - SCH_INST_START);
151
152    printf("\nEntered SchInstCfg()");
153    /* Check if Instance Configuration is done already */
154    if (schCb[inst].schInit.cfgDone == TRUE)
155    {
156       RETVALUE(LCM_REASON_INVALID_MSGTYPE);
157    }
158    /* Update the Pst structure for LM interface */
159    cmMemcpy((U8 *)&schCb[inst].schInit.lmPst,
160             (U8 *)&cfg->s.schInstCfg.genCfg.lmPst,
161              sizeof(Pst));
162    
163    schCb[inst].schInit.inst = inst;
164    schCb[inst].schInit.lmPst.srcProcId = schCb[inst].schInit.procId;
165    schCb[inst].schInit.lmPst.srcEnt = schCb[inst].schInit.ent;
166    schCb[inst].schInit.lmPst.srcInst = schCb[inst].schInit.inst +
167    SCH_INST_START;
168    schCb[inst].schInit.lmPst.event = EVTNONE;
169
170    schCb[inst].schInit.region = cfg->s.schInstCfg.genCfg.mem.region;
171    schCb[inst].schInit.pool = cfg->s.schInstCfg.genCfg.mem.pool;
172    schCb[inst].genCfg.tmrRes = cfg->s.schInstCfg.genCfg.tmrRes;
173 #ifdef LTE_ADV
174    schCb[inst].genCfg.forceCntrlSrbBoOnPCel =  cfg->s.schInstCfg.genCfg.forceCntrlSrbBoOnPCel;
175    schCb[inst].genCfg.isSCellActDeactAlgoEnable =  cfg->s.schInstCfg.genCfg.isSCellActDeactAlgoEnable;
176 #endif
177    schCb[inst].genCfg.startCellId    = cfg->s.schInstCfg.genCfg.startCellId;
178 #if 0
179    /* Initialzie the timer queue */   
180    cmMemset((U8 *)&schCb[inst].tmrTq, 0, sizeof(CmTqType)*RGSCH_TQ_SIZE);
181    /* Initialize the timer control point */
182    cmMemset((U8 *)&schCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
183    schCb[inst].tmrTqCp.tmrLen = RGSCH_TQ_SIZE;
184
185    /* SS_MT_TMR needs to be enabled as schActvTmr needs instance information */
186    /* Timer Registration request to SSI */
187    if (SRegTmrMt(schCb[inst].schInit.ent, dInst,
188       (S16)schCb[inst].genCfg.tmrRes, schActvTmr) != ROK)
189    {
190       RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "SchInstCfg(): Failed to "
191              "register timer.");
192       RETVALUE(LCM_REASON_MEM_NOAVAIL);
193    }   
194 #endif               
195    /* Set Config done in TskInit */
196    schCb[inst].schInit.cfgDone = TRUE;
197    printf("\nScheduler gen config done");
198    
199    RETVALUE(ret);
200 }
201
202 /**
203  * @brief Layer Manager Configuration request handler. 
204  *
205  * @details
206  *
207  *     Function : HandleSchGenCfgReq
208  *     
209  *     This function handles the configuration
210  *     request received at scheduler instance from the Layer Manager.
211  *     -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
212  *        functions rgHdlGenCfg() or rgHdlSapCfg().
213  *     -# Invokes RgMiLrgSchCfgCfm() to send back the confirmation to the LM.
214  *     
215  *  @param[in]  Pst *pst, the post structure     
216  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
217  *  @return  S16
218  *      -# ROK
219  **/
220 int HandleSchGenCfgReq
221 (
222 Pst      *pst,    /* post structure  */
223 RgMngmt  *cfg     /* config structure  */
224 )
225 {
226    uint16_t       ret = LCM_PRIM_OK;
227    uint16_t       reason = LCM_REASON_NOT_APPL;
228    RgMngmt   cfm;
229    Pst       cfmPst;
230
231    if(pst->dstInst < SCH_INST_START)
232    {
233       DU_LOG("\nInvalid inst ID");
234       DU_LOG("\nHandleSchGenCfgReq(): "
235                 "pst->dstInst=%d SCH_INST_START=%d", pst->dstInst,SCH_INST_START); 
236       RETVALUE(ROK);
237    }
238    printf("\nReceived scheduler gen config");
239    /* Fill the post structure for sending the confirmation */
240         memset(&cfmPst, 0 , sizeof(Pst));
241    SchFillCfmPst(pst, &cfmPst, cfg);
242
243    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
244
245 #ifdef LMINT3
246    cfm.hdr.transId =
247       cfg->hdr.transId;
248 #endif
249
250    cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
251    switch(cfg->hdr.elmId.elmnt)
252    {
253       case STSCHINST:
254          reason = SchInstCfg(&cfg->t.cfg,pst->dstInst );
255          break;
256       default:
257          ret = LCM_PRIM_NOK;
258          reason = LCM_REASON_INVALID_ELMNT;
259          DU_LOG("\nInvalid Elmnt=%d", cfg->hdr.elmId.elmnt);
260          break;
261    }
262
263    if (reason != LCM_REASON_NOT_APPL)
264    {
265       ret = LCM_PRIM_NOK;
266    }
267
268    cfm.cfm.status = ret;
269    cfm.cfm.reason = reason;
270
271    SchSendCfgCfm(&cfmPst, &cfm);
272    /*   SPutSBuf(pst->region, pst->pool, (Data *)cfg, sizeof(RgMngmt)); */
273    
274    RETVALUE(ROK);
275 }/*-- HandleSchGenCfgReq --*/
276
277 /**
278  * @brief slot indication from MAC to SCH.
279  *
280  * @details
281  *
282  *     Function : macSchSlotInd 
283  *      
284  *      This API is invoked by PHY to indicate slot indication to Scheduler for
285  *      a cell.
286  *           
287  *  @param[in]  Pst            *pst
288  *  @param[in]  SlotIndInfo    *slotInd
289  *  @return  S16
290  *      -# ROK 
291  *      -# RFAILED 
292  **/
293 int macSchSlotInd 
294 (
295 Pst                 *pst, 
296 SlotIndInfo         *slotInd
297 )
298 {
299    Inst  inst = pst->dstInst-SCH_INST_START;
300
301    /* Now call the TOM (Tfu ownership module) primitive to process further */
302    schProcessSlotInd(slotInd, inst);
303
304    RETVALUE(ROK);
305 }  /* macSchSlotInd */
306
307 /*******************************************************************
308  *
309  * @brief Processes Rach indication from MAC 
310  *
311  * @details
312  *
313  *    Function : macSchRachInd
314  *
315  *    Functionality:
316  *      Processes Rach indication from MAC
317  *
318  * @params[in] 
319  * @return ROK     - success
320  *         RFAILED - failure
321  *
322  * ****************************************************************/
323 int macSchRachInd(Pst *pst, RachIndInfo *rachInd)
324 {
325    Inst  inst = pst->dstInst-SCH_INST_START;
326    DU_LOG("\nSCH : Received Rach indication");
327    schProcessRachInd(rachInd, inst);
328    return ROK;
329 }
330
331 /*******************************************************************
332  *
333  * @brief Processes CRC indication from MAC 
334  *
335  * @details
336  *
337  *    Function : macSchCrcInd
338  *
339  *    Functionality:
340  *      Processes CRC indication from MAC
341  *
342  * @params[in] Post structure
343  *             Crc Indication
344  * @return ROK     - success
345  *         RFAILED - failure
346  *
347  * ****************************************************************/
348 int macSchCrcInd(Pst *pst, CrcIndInfo *crcInd)
349 {
350    switch(crcInd->crcInd[0])
351         {
352       case CRC_FAILED:
353          DU_LOG("\nSCH : Received CRC indication. CRC Status [FAILURE]");
354                         break;
355       case CRC_PASSED:
356          DU_LOG("\nSCH : Received CRC indication. CRC Status [PASS]");
357                         break;
358            default:
359                         DU_LOG("\nSCH : Invalid CRC state %d", crcInd->crcInd[0]);
360                         return RFAILED;
361         }
362    return ROK;
363 }
364
365
366 /**
367  * @brief inti cellCb based on cellCfg
368  *
369  * @details
370  *
371  *     Function : InitSchCellCb 
372  *      
373  *      This API is invoked after receiving schCellCfg
374  *           
375  *  @param[in]  schCellCb *cell
376  *  @param[in]  SchCellCfg *schCellCfg
377  *  @return  int
378  *      -# ROK 
379  *      -# RFAILED 
380  **/
381 int InitSchCellCb(Inst inst, SchCellCfg *schCellCfg)
382 {
383    SchCellCb *cell;
384    SCH_ALLOC(cell, sizeof(SchCellCb));
385         if(!cell)
386         {
387       DU_LOG("\nMemory allocation failed in InitSchCellCb");
388                 return RFAILED;
389         }
390
391         cell->cellId = schCellCfg->cellId; 
392         cell->instIdx = inst;
393         switch(schCellCfg->ssbSchCfg.scsCommon)
394         {
395            case SCH_SCS_15KHZ:
396                 {
397                         cell->numSlots = SCH_NUM_SLOTS;
398                 }
399                 break;
400                 default:
401                    DU_LOG("\nSCS %d not supported", schCellCfg->ssbSchCfg.scsCommon);
402         }
403   
404    for(uint8_t idx=0; idx<SCH_NUM_SLOTS; idx++)
405         {
406                 SchDlAlloc *schDlAlloc;
407                 SchUlAlloc *schUlAlloc;
408
409       /* DL Alloc */
410                 SCH_ALLOC(schDlAlloc, sizeof(SchDlAlloc));
411                 if(!schDlAlloc)
412                 {
413                         DU_LOG("\nMemory allocation failed in InitSchCellCb");
414                         return RFAILED;
415                 }
416
417       /* UL Alloc */
418                 SCH_ALLOC(schUlAlloc, sizeof(SchUlAlloc));
419                 if(!schUlAlloc)
420                 {
421                         DU_LOG("\nMemory allocation failed in InitSchCellCb");
422                         return RFAILED;
423                 }
424
425       schDlAlloc->totalPrb = schUlAlloc->totalPrb = MAX_NUM_RB;
426
427                 for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
428                 {
429                         schDlAlloc->assignedPrb[itr] = 0;
430                         schUlAlloc->assignedPrb[itr] = 0;
431                 }
432                 schUlAlloc->schPuschInfo = NULLP;
433
434                 for(uint8_t itr=0; itr<MAX_SSB_IDX; itr++)
435                 {
436                         memset(&schDlAlloc->ssbInfo[itr], 0, sizeof(SsbInfo));
437                 }
438
439                 cell->dlAlloc[idx] = schDlAlloc;
440                 cell->ulAlloc[idx] = schUlAlloc;
441
442         }
443         schCb[inst].cells[inst] = cell;
444
445    DU_LOG("\nCell init completed for cellId:%d", cell->cellId);
446
447    return ROK;   
448 }
449
450 void fillSchSib1Cfg(
451 Inst         schInst,
452 SchSib1Cfg   *sib1SchCfg,
453 uint16_t     pci,
454 uint8_t      offsetPointA
455 )
456 {
457    uint8_t coreset0Idx = 0;
458    uint8_t searchSpace0Idx = 0;
459    //uint8_t ssbMuxPattern = 0;
460    uint8_t numRbs = 0;
461    uint8_t numSymbols = 0;
462    uint8_t offset = 0;
463    uint8_t oValue = 0;
464    //uint8_t numSearchSpacePerSlot = 0;
465    uint8_t mValue = 0;
466    uint8_t firstSymbol = 0; /* need to calculate using formula mentioned in 38.213 */
467    uint8_t slotIndex = 0;
468    uint8_t FreqDomainResource[6] = {0};
469
470    PdcchCfg *pdcch = &(sib1SchCfg->sib1PdcchCfg);
471    PdschCfg *pdsch = &(sib1SchCfg->sib1PdschCfg);
472
473    coreset0Idx     = sib1SchCfg->coresetZeroIndex;
474    searchSpace0Idx = sib1SchCfg->searchSpaceZeroIndex;
475
476    /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
477    //ssbMuxPattern = coresetIdxTable[coreset0Idx][0];
478    numRbs        = coresetIdxTable[coreset0Idx][1];
479    numSymbols    = coresetIdxTable[coreset0Idx][2];
480    offset        = coresetIdxTable[coreset0Idx][3];
481
482    /* derive the search space params from table 13-11 spec 38.213 */
483    oValue                = searchSpaceIdxTable[searchSpace0Idx][0];
484    //numSearchSpacePerSlot = searchSpaceIdxTable[searchSpace0Idx][1];
485    mValue                = searchSpaceIdxTable[searchSpace0Idx][2];
486    firstSymbol           = searchSpaceIdxTable[searchSpace0Idx][3];
487
488    /* calculate the n0, need to add the formulae, as of now the value is 0 
489     * Need to add the even and odd values of i during configuration 
490     * [(O . 2^u + i . M )  ] mod numSlotsPerSubframe 
491     * assuming u = 0, i = 0, numSlotsPerSubframe = 10
492     * Also, from this configuration, coreset0 is only on even subframe */
493    slotIndex = ((oValue * 1) + (0 * mValue)) % 10; 
494    sib1SchCfg->n0 = slotIndex;
495  
496    /* calculate the PRBs */
497    calculatePRB( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
498
499    /* fill the PDCCH PDU */
500    pdcch->pdcchBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
501    pdcch->pdcchBwpCfg.BWPStart = 0;
502    pdcch->pdcchBwpCfg.subcarrierSpacing = 0;         /* 15Khz */
503    pdcch->pdcchBwpCfg.cyclicPrefix = 0;              /* normal */
504    pdcch->coreset0Cfg.coreSet0Size = numRbs;
505    pdcch->coreset0Cfg.startSymbolIndex = firstSymbol;
506    pdcch->coreset0Cfg.durationSymbols = numSymbols;
507    memcpy(pdcch->coreset0Cfg.freqDomainResource,FreqDomainResource,6);
508    pdcch->coreset0Cfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
509    pdcch->coreset0Cfg.regBundleSize = 6;    /* spec-38.211 sec 7.3.2.2 */
510    pdcch->coreset0Cfg.interleaverSize = 2;  /* spec-38.211 sec 7.3.2.2 */
511    pdcch->coreset0Cfg.coreSetType = 0;
512    pdcch->coreset0Cfg.shiftIndex = pci;
513    pdcch->coreset0Cfg.precoderGranularity = 0; /* sameAsRegBundle */
514    pdcch->numDlDci = 1;
515    pdcch->dci.rnti = SI_RNTI;
516    pdcch->dci.scramblingId = pci;
517    pdcch->dci.scramblingRnti = 0;
518    pdcch->dci.cceIndex = 0;
519    pdcch->dci.aggregLevel = 4;
520    pdcch->dci.beamPdcchInfo.numPrgs = 1;
521    pdcch->dci.beamPdcchInfo.prgSize = 1;
522    pdcch->dci.beamPdcchInfo.digBfInterfaces = 0;
523    pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0;
524    pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
525    pdcch->dci.txPdcchPower.powerValue = 0;
526    pdcch->dci.txPdcchPower.powerControlOffsetSS = 0;
527         /* Storing pdschCfg pointer here. Required to access pdsch config while
528         fillig up pdcch pdu */
529    pdcch->dci.pdschCfg = pdsch; 
530
531    /* fill the PDSCH PDU */
532         uint8_t cwCount = 0;
533    pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
534    pdsch->rnti = 0xFFFF; /* SI-RNTI */
535    pdsch->pduIndex = 0;
536    pdsch->pdschBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
537    pdsch->pdschBwpCfg.BWPStart = 0;
538    pdsch->numCodewords = 1;
539         for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
540         {
541       pdsch->codeword[cwCount].targetCodeRate = 308;
542       pdsch->codeword[cwCount].qamModOrder = 2;
543       pdsch->codeword[cwCount].mcsIndex = sib1SchCfg->sib1Mcs;
544       pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */
545       pdsch->codeword[cwCount].rvIndex = 0;
546       pdsch->codeword[cwCount].tbSize = 768/8; /* 38.214: Table 5.1.3.2-1,
547                    devided by 8 to get the value in bytes */
548    }
549    pdsch->dataScramblingId = pci;
550    pdsch->numLayers = 1;
551    pdsch->transmissionScheme = 0;
552    pdsch->refPoint = 0;
553    pdsch->dmrs.dlDmrsSymbPos = 2;
554    pdsch->dmrs.dmrsConfigType = 0; /* type-1 */
555    pdsch->dmrs.dlDmrsScramblingId = pci;
556    pdsch->dmrs.scid = 0;
557    pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
558    pdsch->dmrs.dmrsPorts = 0;
559    pdsch->freqAlloc.resourceAlloc = 1; /* RAT type-1 RIV format */
560    pdsch->freqAlloc.rbStart = offset + SCH_SSB_PRB_DURATION; /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ 
561         /* formula used for calculation of rbSize, 38.213 section 5.1.3.2 *
562          * Ninfo = Nre . R . Qm . v                                       *
563          * Nre' = Nsc . NsymPdsch - NdmrsSymb - Noh                       *
564          * Nre = min(156,Nre') . nPrb                                     */
565    pdsch->freqAlloc.rbSize = 10; /* This value is calculated from above formulae */
566    pdsch->freqAlloc.vrbPrbMapping = 0; /* non-interleaved */
567    pdsch->timeAlloc.rowIndex = 1;
568    pdsch->timeAlloc.startSymbolIndex = 2; /* spec-38.214, Table 5.1.2.1-1 */
569    pdsch->timeAlloc.numSymbols = 12;
570    pdsch->beamPdschInfo.numPrgs = 1;
571    pdsch->beamPdschInfo.prgSize = 1;
572    pdsch->beamPdschInfo.digBfInterfaces = 0;
573    pdsch->beamPdschInfo.prg[0].pmIdx = 0;
574    pdsch->beamPdschInfo.prg[0].beamIdx[0] = 0;
575    pdsch->txPdschPower.powerControlOffset = 0;
576    pdsch->txPdschPower.powerControlOffsetSS = 0;
577
578 }
579
580 /**
581  * @brief cell config from MAC to SCH.
582  *
583  * @details
584  *
585  *     Function : macSchCellCfgReq
586  *      
587  *      This API is invoked by MAC to send cell config to SCH
588  *           
589  *  @param[in]  Pst            *pst
590  *  @param[in]  SchCellCfg     *schCellCfg
591  *  @return  int
592  *      -# ROK 
593  *      -# RFAILED 
594  **/
595 int SchHdlCellCfgReq
596 (
597 Pst                 *pst, 
598 SchCellCfg          *schCellCfg
599 )
600 {
601    int ret = ROK;
602    SchCellCb *cellCb;
603         SchCellCfgCfm schCellCfgCfm;
604         Pst rspPst;
605         Inst inst = pst->dstInst-1; 
606
607         InitSchCellCb(inst, schCellCfg);
608         cellCb = schCb[inst].cells[inst]; //cells is of MAX_CELLS, why inst
609    cellCb->macInst = pst->srcInst;
610
611    /* derive the SIB1 config parameters */
612         fillSchSib1Cfg(
613            inst,
614            &(schCellCfg->sib1SchCfg),
615                 schCellCfg->phyCellId,
616                 schCellCfg->ssbSchCfg.ssbOffsetPointA);
617    memcpy(&cellCb->cellCfg, schCellCfg, sizeof(SchCellCfg));
618
619    memset(&rspPst, 0, sizeof(Pst));
620    SCH_FILL_RSP_PST(rspPst, inst);
621         rspPst.event = EVENT_SCH_CELL_CFG_CFM;
622         schCellCfgCfm.rsp = RSP_OK;
623   
624    ret = (*SchCellCfgCfmOpts[rspPst.selector])(&rspPst, &schCellCfgCfm);
625
626    return ret;
627
628 }
629
630 /*******************************************************************
631  *
632  * @brief Processes DL RLC BO info from MAC
633  *
634  * @details
635  *
636  *    Function : macSchDlRlcBoInfo
637  *
638  *    Functionality:
639  *       Processes DL RLC BO info from MAC
640  *
641  * @params[in] 
642  * @return ROK     - success
643  *         RFAILED - failure
644  *
645  * ****************************************************************/
646 uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo)
647 {
648    uint16_t  lcIdx;
649    Inst  inst = pst->dstInst-SCH_INST_START;
650    DU_LOG("\nSCH : Received RLC BO Status indication");
651
652    SchCellCb *cell = schCb[inst].cells[inst];
653    SchDlAlloc *dlAlloc = \
654       cell->dlAlloc[(cell->slotInfo.slot + SCHED_DELTA) % SCH_NUM_SLOTS]; 
655   
656    for(lcIdx = 0; lcIdx < dlBoInfo->numLc; lcIdx++)
657         {
658            if(dlBoInfo->boInfo[lcIdx].lcId == CCCH_LCID)
659                 {
660               SCH_ALLOC(dlAlloc->msg4Info, sizeof(Msg4Info));
661               if(!dlAlloc->msg4Info)
662               {
663                  DU_LOG("\nSCH : Memory allocation failed for msg4Info");
664                       dlAlloc = NULL;
665                       return RFAILED;
666               }
667          dlAlloc->msg4Info->crnti = dlBoInfo->crnti;
668                         dlAlloc->msg4Info->ndi = 1;
669                         dlAlloc->msg4Info->harqProcNum = 0;
670                         dlAlloc->msg4Info->dlAssignIdx = 0;
671                         dlAlloc->msg4Info->pucchTpc = 0;
672                         dlAlloc->msg4Info->pucchResInd = 0;
673                         dlAlloc->msg4Info->harqFeedbackInd = 0;
674                         dlAlloc->msg4Info->dciFormatId = 1;
675            }
676    }
677
678    return ROK;
679 }
680
681 /**********************************************************************
682          End of file
683 **********************************************************************/