1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for scheduler fucntions
29 **********************************************************************/
32 @brief This file implements the schedulers main access to MAC layer code.
34 #include "common_def.h"
35 #include "du_app_mac_inf.h"
40 #include "rg_sch_inf.h"
43 #include "tfu.x" /* TFU types */
44 #include "lrg.x" /* layer management typedefs for MAC */
45 #include "rgr.x" /* layer management typedefs for MAC */
46 #include "rg_sch_inf.x" /* typedefs for Scheduler */
47 #include "mac_sch_interface.h"
49 #include "sch_utils.h"
51 void SchFillCfmPst(Pst *reqPst,Pst *cfmPst,RgMngmt *cfm);
54 SchCellCfgCfmFunc SchCellCfgCfmOpts[] =
56 packSchCellCfgCfm, /* LC */
57 MacProcSchCellCfgCfm, /* TC */
58 packSchCellCfgCfm /* LWLC */
61 SchSliceCfgRspFunc SchSliceCfgRspOpts[] =
63 packSchSliceCfgRsp, /* LC */
64 MacProcSchSliceCfgRsp, /* TC */
65 packSchSliceCfgRsp /* LWLC */
69 SchSliceRecfgRspFunc SchSliceRecfgRspOpts[] =
71 packSchSliceRecfgRsp, /* LC */
72 MacProcSchSliceRecfgRsp, /* TC */
73 packSchSliceRecfgRsp /* LWLC */
77 * @brief Task Initiation function.
81 * Function : schActvInit
83 * This function is supplied as one of parameters during MAC's
84 * task registration. MAC will invoke this function once, after
85 * it creates and attaches this TAPA Task to a system task.
87 * @param[in] Ent Entity, the entity ID of this task.
88 * @param[in] Inst Inst, the instance ID of this task.
89 * @param[in] Region Region, the region ID registered for memory
91 * @param[in] Reason Reason.
95 uint8_t schActvInit(Ent entity, Inst instId, Region region, Reason reason)
97 Inst inst = (instId - SCH_INST_START);
99 /* Initialize the MAC TskInit structure to zero */
100 memset ((uint8_t *)&schCb[inst], 0, sizeof(schCb));
102 /* Initialize the MAC TskInit with received values */
103 schCb[inst].schInit.ent = entity;
104 schCb[inst].schInit.inst = inst;
105 schCb[inst].schInit.region = region;
106 schCb[inst].schInit.pool = 0;
107 schCb[inst].schInit.reason = reason;
108 schCb[inst].schInit.cfgDone = FALSE;
109 schCb[inst].schInit.acnt = FALSE;
110 schCb[inst].schInit.usta = FALSE;
111 schCb[inst].schInit.trc = FALSE;
112 schCb[inst].schInit.procId = ODU_GET_PROCID();
118 * @brief Scheduler instance Configuration Handler.
122 * Function : SchInstCfg
124 * This function in called by SchProcGenCfgReq(). It handles the
125 * general configurations of the scheduler instance. Returns
126 * reason for success/failure of this function.
128 * @param[in] RgCfg *cfg, the Configuaration information
130 * -# LCM_REASON_NOT_APPL
131 * -# LCM_REASON_INVALID_MSGTYPE
132 * -# LCM_REASON_MEM_NOAVAIL
134 uint8_t SchInstCfg(RgCfg *cfg, Inst dInst)
136 uint16_t ret = LCM_REASON_NOT_APPL;
137 Inst inst = (dInst - SCH_INST_START);
139 DU_LOG("\nDEBUG --> SCH : Entered SchInstCfg()");
140 /* Check if Instance Configuration is done already */
141 if (schCb[inst].schInit.cfgDone == TRUE)
143 return LCM_REASON_INVALID_MSGTYPE;
145 /* Update the Pst structure for LM interface */
146 memcpy(&schCb[inst].schInit.lmPst, &cfg->s.schInstCfg.genCfg.lmPst, sizeof(Pst));
148 schCb[inst].schInit.inst = inst;
149 schCb[inst].schInit.lmPst.srcProcId = schCb[inst].schInit.procId;
150 schCb[inst].schInit.lmPst.srcEnt = schCb[inst].schInit.ent;
151 schCb[inst].schInit.lmPst.srcInst = schCb[inst].schInit.inst +
153 schCb[inst].schInit.lmPst.event = EVTNONE;
155 schCb[inst].schInit.region = cfg->s.schInstCfg.genCfg.mem.region;
156 schCb[inst].schInit.pool = cfg->s.schInstCfg.genCfg.mem.pool;
157 schCb[inst].genCfg.tmrRes = cfg->s.schInstCfg.genCfg.tmrRes;
159 schCb[inst].genCfg.forceCntrlSrbBoOnPCel = cfg->s.schInstCfg.genCfg.forceCntrlSrbBoOnPCel;
160 schCb[inst].genCfg.isSCellActDeactAlgoEnable = cfg->s.schInstCfg.genCfg.isSCellActDeactAlgoEnable;
162 schCb[inst].genCfg.startCellId = cfg->s.schInstCfg.genCfg.startCellId;
164 /* Initialzie the timer queue */
165 memset(&schCb[inst].tmrTq, 0, sizeof(CmTqType) * SCH_TQ_SIZE);
166 /* Initialize the timer control point */
167 memset(&schCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
168 schCb[inst].tmrTqCp.tmrLen = RGSCH_TQ_SIZE;
170 /* SS_MT_TMR needs to be enabled as schActvTmr needs instance information */
171 /* Timer Registration request to system services */
172 if (ODU_REG_TMR_MT(schCb[inst].schInit.ent, dInst, (int)schCb[inst].genCfg.tmrRes, schActvTmr) != ROK)
174 DU_LOG("\nERROR --> SCH : SchInstCfg(): Failed to "
176 return (LCM_REASON_MEM_NOAVAIL);
179 /* Set Config done in TskInit */
180 schCb[inst].schInit.cfgDone = TRUE;
181 DU_LOG("\nINFO --> SCH : Scheduler gen config done");
187 * @brief Layer Manager Configuration request handler.
191 * Function : SchProcGenCfgReq
193 * This function handles the configuration
194 * request received at scheduler instance from the Layer Manager.
195 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
196 * functions rgHdlGenCfg() or rgHdlSapCfg().
197 * -# Invokes RgMiLrgSchCfgCfm() to send back the confirmation to the LM.
199 * @param[in] Pst *pst, the post structure
200 * @param[in] RgMngmt *cfg, the configuration parameter's structure
204 uint8_t SchProcGenCfgReq(Pst *pst, RgMngmt *cfg)
206 uint8_t ret = LCM_PRIM_OK;
207 uint16_t reason = LCM_REASON_NOT_APPL;
211 #ifdef CALL_FLOW_DEBUG_LOG
212 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : GENERAL_CFG_REQ\n");
215 if(pst->dstInst < SCH_INST_START)
217 DU_LOG("\nERROR --> SCH : Invalid inst ID");
218 DU_LOG("\nERROR --> SCH : SchProcGenCfgReq(): "
219 "pst->dstInst=%d SCH_INST_START=%d", pst->dstInst,SCH_INST_START);
222 DU_LOG("\nINFO --> SCH : Received scheduler gen config");
223 /* Fill the post structure for sending the confirmation */
224 memset(&cfmPst, 0 , sizeof(Pst));
225 SchFillCfmPst(pst, &cfmPst, cfg);
227 memset(&cfm, 0, sizeof(RgMngmt));
234 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
235 switch(cfg->hdr.elmId.elmnt)
238 reason = SchInstCfg(&cfg->t.cfg,pst->dstInst );
242 reason = LCM_REASON_INVALID_ELMNT;
243 DU_LOG("\nERROR --> SCH : Invalid Elmnt=%d", cfg->hdr.elmId.elmnt);
247 if (reason != LCM_REASON_NOT_APPL)
252 cfm.cfm.status = ret;
253 cfm.cfm.reason = reason;
255 SchSendCfgCfm(&cfmPst, &cfm);
256 /* SCH_FREE(pst->region, pst->pool, (Data *)cfg, sizeof(RgMngmt)); */
259 }/*-- SchProcGenCfgReq --*/
262 * @brief slot indication from MAC to SCH.
266 * Function : MacSchSlotInd
268 * This API is invoked by PHY to indicate slot indication to Scheduler for
271 * @param[in] Pst *pst
272 * @param[in] SlotTimingInfo *slotInd
277 uint8_t MacSchSlotInd(Pst *pst, SlotTimingInfo *slotInd)
279 Inst inst = pst->dstInst-SCH_INST_START;
281 #ifdef CALL_FLOW_DEBUG_LOG
282 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_SLOT_IND_TO_SCH\n");
285 schProcessSlotInd(slotInd, inst);
288 } /* MacSchSlotInd */
290 /*******************************************************************
292 * @brief Processes Rach indication from MAC
296 * Function : MacSchRachInd
299 * Processes Rach indication from MAC
302 * @return ROK - success
305 * ****************************************************************/
306 uint8_t MacSchRachInd(Pst *pst, RachIndInfo *rachInd)
308 Inst inst = pst->dstInst-SCH_INST_START;
310 #ifdef CALL_FLOW_DEBUG_LOG
311 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_RACH_IND_TO_SCH\n");
314 DU_LOG("\nINFO --> SCH : Received Rach indication");
315 schProcessRachInd(rachInd, inst);
319 /*******************************************************************
321 * @brief Processes CRC indication from MAC
325 * Function : MacSchCrcInd
328 * Processes CRC indication from MAC
330 * @params[in] Post structure
332 * @return ROK - success
335 * ****************************************************************/
336 uint8_t MacSchCrcInd(Pst *pst, CrcIndInfo *crcInd)
338 Inst inst = pst->dstInst-SCH_INST_START;
339 #ifdef CALL_FLOW_DEBUG_LOG
340 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_CRC_IND_TO_SCH\n");
343 schProcessCrcInd(crcInd, inst);
349 *@brief Returns TDD periodicity in micro seconds
353 * Function : schGetPeriodicityInMsec
355 * This API retunrs TDD periodicity in micro seconds
357 * @param[in] DlUlTxPeriodicity
358 * @return periodicityInMsec
361 uint16_t schGetPeriodicityInMsec(DlUlTxPeriodicity tddPeriod)
363 uint16_t periodicityInMsec = 0;
366 case TX_PRDCTY_MS_0P5:
368 periodicityInMsec = 500;
371 case TX_PRDCTY_MS_0P625:
373 periodicityInMsec = 625;
378 periodicityInMsec = 1000;
381 case TX_PRDCTY_MS_1P25:
383 periodicityInMsec = 1250;
388 periodicityInMsec = 2000;
391 case TX_PRDCTY_MS_2P5:
393 periodicityInMsec = 2500;
398 periodicityInMsec = 5000;
401 case TX_PRDCTY_MS_10:
403 periodicityInMsec = 10000;
408 DU_LOG("\nERROR --> SCH : Invalid DlUlTxPeriodicity:%d", tddPeriod);
412 return periodicityInMsec;
417 * @brief init TDD slot config
421 * Function : schInitTddSlotCfg
423 * This API is invoked after receiving schCellCfg
425 * @param[in] schCellCb *cell
426 * @param[in] SchCellCfg *schCellCfg
429 void schInitTddSlotCfg(SchCellCb *cell, SchCellCfg *schCellCfg)
431 uint16_t periodicityInMicroSec = 0;
432 int8_t slotIdx, symbIdx;
434 periodicityInMicroSec = schGetPeriodicityInMsec(schCellCfg->tddCfg.tddPeriod);
435 cell->numSlotsInPeriodicity = (periodicityInMicroSec * pow(2, schCellCfg->numerology))/1000;
436 cell->slotFrmtBitMap = 0;
437 cell->symbFrmtBitMap = 0;
438 for(slotIdx = cell->numSlotsInPeriodicity-1; slotIdx >= 0; slotIdx--)
441 /* If the first and last symbol are the same, the entire slot is the same type */
442 if((schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx] == schCellCfg->tddCfg.slotCfg[slotIdx][MAX_SYMB_PER_SLOT-1]) &&
443 schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx] != FLEXI_SLOT)
445 switch(schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx])
449 /*BitMap to be set to 00 */
450 cell->slotFrmtBitMap = (cell->slotFrmtBitMap<<2);
455 /*BitMap to be set to 01 */
456 cell->slotFrmtBitMap = ((cell->slotFrmtBitMap<<2) | (UL_SLOT));
460 DU_LOG("\nERROR --> SCH : Invalid slot Config in schInitTddSlotCfg");
464 /* slot config is flexible. First set slotBitMap to 10 */
465 cell->slotFrmtBitMap = ((cell->slotFrmtBitMap<<2) | (FLEXI_SLOT));
467 /* Now set symbol bitmap */
468 for(symbIdx = MAX_SYMB_PER_SLOT-1; symbIdx >= 0; symbIdx--)
470 switch(schCellCfg->tddCfg.slotCfg[slotIdx][symbIdx])
474 /*symbol BitMap to be set to 00 */
475 cell->symbFrmtBitMap = (cell->symbFrmtBitMap<<2);
480 /*symbol BitMap to be set to 01 */
481 cell->symbFrmtBitMap = ((cell->symbFrmtBitMap<<2) | (UL_SLOT));
486 /*symbol BitMap to be set to 10 */
487 cell->symbFrmtBitMap = ((cell->symbFrmtBitMap<<2) | (FLEXI_SLOT));
491 DU_LOG("\nERROR --> SCH : Invalid slot Config in schInitTddSlotCfg");
499 * @brief Fill SSB start symbol
503 * Function : fillSsbStartSymb
505 * This API stores SSB start index per beam
507 * @param[in] SchCellCb *cellCb
512 void fillSsbStartSymb(SchCellCb *cellCb)
514 uint8_t cnt, scs, symbIdx, ssbStartSymbArr[SCH_MAX_SSB_BEAM];
516 scs = cellCb->cellCfg.ssbSchCfg.scsCommon;
518 memset(ssbStartSymbArr, 0, sizeof(SCH_MAX_SSB_BEAM));
520 /* Determine value of "n" based on Section 4.1 of 3GPP TS 38.213 */
525 if(cellCb->cellCfg.dlFreq <= 300000)
526 cnt = 2;/* n = 0, 1 */
528 cnt = 4; /* n = 0, 1, 2, 3 */
529 for(uint8_t idx=0; idx<cnt; idx++)
531 /* start symbol determined using {2, 8} + 14n */
532 ssbStartSymbArr[symbIdx++] = 2 + MAX_SYMB_PER_SLOT*idx;
533 ssbStartSymbArr[symbIdx++] = 8 + MAX_SYMB_PER_SLOT*idx;
539 if(cellCb->cellCfg.dlFreq <= 300000)
542 cnt = 2; /* n = 0, 1 */
543 for(uint8_t idx=0; idx<cnt; idx++)
545 /* start symbol determined using {4, 8, 16, 20} + 28n */
546 ssbStartSymbArr[symbIdx++] = 4 + MAX_SYMB_PER_SLOT*idx;
547 ssbStartSymbArr[symbIdx++] = 8 + MAX_SYMB_PER_SLOT*idx;
548 ssbStartSymbArr[symbIdx++] = 16 + MAX_SYMB_PER_SLOT*idx;
549 ssbStartSymbArr[symbIdx++] = 20 + MAX_SYMB_PER_SLOT*idx;
554 DU_LOG("\nERROR --> SCH : SCS %d is currently not supported", scs);
556 memset(cellCb->ssbStartSymbArr, 0, sizeof(SCH_MAX_SSB_BEAM));
557 memcpy(cellCb->ssbStartSymbArr, ssbStartSymbArr, SCH_MAX_SSB_BEAM);
563 * @brief init cellCb based on cellCfg
567 * Function : schInitCellCb
569 * This API is invoked after receiving schCellCfg
571 * @param[in] schCellCb *cell
572 * @param[in] SchCellCfg *schCellCfg
577 uint8_t schInitCellCb(Inst inst, SchCellCfg *schCellCfg)
579 SchCellCb *cell= NULLP;
580 SCH_ALLOC(cell, sizeof(SchCellCb));
583 DU_LOG("\nERROR --> SCH : Memory allocation failed in schInitCellCb");
587 cell->cellId = schCellCfg->cellId;
588 cell->instIdx = inst;
589 switch(schCellCfg->numerology)
591 case SCH_NUMEROLOGY_0:
593 cell->numSlots = SCH_MU0_NUM_SLOTS;
596 case SCH_NUMEROLOGY_1:
598 cell->numSlots = SCH_MU1_NUM_SLOTS;
601 case SCH_NUMEROLOGY_2:
603 cell->numSlots = SCH_MU2_NUM_SLOTS;
606 case SCH_NUMEROLOGY_3:
608 cell->numSlots = SCH_MU3_NUM_SLOTS;
611 case SCH_NUMEROLOGY_4:
613 cell->numSlots = SCH_MU4_NUM_SLOTS;
617 DU_LOG("\nERROR --> SCH : Numerology %d not supported", schCellCfg->numerology);
620 schInitTddSlotCfg(cell, schCellCfg);
623 SCH_ALLOC(cell->schDlSlotInfo, cell->numSlots * sizeof(SchDlSlotInfo*));
624 if(!cell->schDlSlotInfo)
626 DU_LOG("\nERROR --> SCH : Memory allocation failed in schInitCellCb for schDlSlotInfo");
630 SCH_ALLOC(cell->schUlSlotInfo, cell->numSlots * sizeof(SchUlSlotInfo*));
631 if(!cell->schUlSlotInfo)
633 DU_LOG("\nERROR --> SCH : Memory allocation failed in schInitCellCb for schUlSlotInfo");
637 for(uint8_t idx=0; idx<cell->numSlots; idx++)
639 SchDlSlotInfo *schDlSlotInfo;
640 SchUlSlotInfo *schUlSlotInfo;
643 SCH_ALLOC(schDlSlotInfo, sizeof(SchDlSlotInfo));
646 DU_LOG("\nERROR --> SCH : Memory allocation failed in schInitCellCb");
651 SCH_ALLOC(schUlSlotInfo, sizeof(SchUlSlotInfo));
654 DU_LOG("\nERROR --> SCH : Memory allocation failed in schInitCellCb");
658 schInitDlSlot(schDlSlotInfo);
659 schInitUlSlot(schUlSlotInfo);
661 cell->schDlSlotInfo[idx] = schDlSlotInfo;
662 cell->schUlSlotInfo[idx] = schUlSlotInfo;
665 cell->firstSsbTransmitted = false;
666 cell->firstSib1Transmitted = false;
667 fillSsbStartSymb(cell);
668 cmLListInit(&cell->ueToBeScheduled);
671 memset(cell->drxCb, 0, MAX_DRX_SIZE*sizeof(SchDrxCb));
673 schCb[inst].cells[inst] = cell;
675 DU_LOG("\nINFO --> SCH : Cell init completed for cellId:%d", cell->cellId);
681 * @brief Fill SIB1 configuration
685 * Function : fillSchSib1Cfg
687 * Fill SIB1 configuration
689 * @param[in] uint8_t bandwidth : total available bandwidth
690 * uint8_t numSlots : total slots per SFN
691 * SchSib1Cfg *sib1SchCfg : cfg to be filled
692 * uint16_t pci : physical cell Id
693 * uint8_t offsetPointA : offset
696 void fillSchSib1Cfg(uint8_t mu, uint8_t bandwidth, uint8_t numSlots, SchSib1Cfg *sib1SchCfg, uint16_t pci, uint8_t offsetPointA)
698 uint8_t coreset0Idx = 0;
699 uint8_t searchSpace0Idx = 0;
700 //uint8_t ssbMuxPattern = 0;
702 uint8_t numSymbols = 0;
705 //uint8_t numSearchSpacePerSlot = 0;
707 uint8_t firstSymbol = 0; /* need to calculate using formula mentioned in 38.213 */
708 uint8_t slotIndex = 0;
709 uint8_t FreqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
713 PdcchCfg *pdcch = &(sib1SchCfg->sib1PdcchCfg);
714 PdschCfg *pdsch = &(sib1SchCfg->sib1PdschCfg);
715 BwpCfg *bwp = &(sib1SchCfg->bwp);
717 coreset0Idx = sib1SchCfg->coresetZeroIndex;
718 searchSpace0Idx = sib1SchCfg->searchSpaceZeroIndex;
720 /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
721 //ssbMuxPattern = coresetIdxTable[coreset0Idx][0];
722 numRbs = coresetIdxTable[coreset0Idx][1];
723 numSymbols = coresetIdxTable[coreset0Idx][2];
724 offset = coresetIdxTable[coreset0Idx][3];
726 /* derive the search space params from table 13-11 spec 38.213 */
727 oValue = searchSpaceIdxTable[searchSpace0Idx][0];
728 //numSearchSpacePerSlot = searchSpaceIdxTable[searchSpace0Idx][1];
729 mValue = searchSpaceIdxTable[searchSpace0Idx][2];
730 firstSymbol = searchSpaceIdxTable[searchSpace0Idx][3];
732 /* calculate the n0, need to add the formulae, as of now the value is 0
733 * Need to add the even and odd values of i during configuration
734 * [(O . 2^u + i . M ) ] mod numSlotsPerSubframe
735 * assuming u = 0, i = 0, numSlotsPerSubframe = 10
736 * Also, from this configuration, coreset0 is only on even subframe */
737 slotIndex = (int)((oValue*pow(2, mu)) + floor(ssbIdx*mValue))%numSlots;
738 sib1SchCfg->n0 = slotIndex;
743 case BANDWIDTH_20MHZ:
745 bwp->freqAlloc.numPrb = TOTAL_PRB_20MHZ_MU0;
748 case BANDWIDTH_100MHZ:
750 bwp->freqAlloc.numPrb = TOTAL_PRB_100MHZ_MU1;
754 DU_LOG("\nERROR --> SCH : Bandwidth %d not supported", bandwidth);
757 bwp->freqAlloc.startPrb = 0;
758 bwp->subcarrierSpacing = 0; /* 15Khz */
759 bwp->cyclicPrefix = 0; /* normal */
761 /* fill the PDCCH PDU */
762 pdcch->coresetCfg.coreSetSize = numRbs;
763 pdcch->coresetCfg.startSymbolIndex = firstSymbol;
764 pdcch->coresetCfg.durationSymbols = numSymbols;
766 /* Fill Bitmap for PRBs in coreset */
767 fillCoresetFeqDomAllocMap(((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
768 covertFreqDomRsrcMapToIAPIFormat(FreqDomainResource, pdcch->coresetCfg.freqDomainResource);
770 pdcch->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
771 pdcch->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */
772 pdcch->coresetCfg.interleaverSize = 2; /* spec-38.211 sec 7.3.2.2 */
773 pdcch->coresetCfg.coreSetType = 0;
774 pdcch->coresetCfg.shiftIndex = pci;
775 pdcch->coresetCfg.precoderGranularity = 0; /* sameAsRegBundle */
777 pdcch->dci.rnti = SI_RNTI;
778 pdcch->dci.scramblingId = pci;
779 pdcch->dci.scramblingRnti = 0;
780 pdcch->dci.cceIndex = 0;
781 pdcch->dci.aggregLevel = 4;
782 pdcch->dci.beamPdcchInfo.numPrgs = 1;
783 pdcch->dci.beamPdcchInfo.prgSize = 1;
784 pdcch->dci.beamPdcchInfo.digBfInterfaces = 0;
785 pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0;
786 pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
787 pdcch->dci.txPdcchPower.powerValue = 0;
788 pdcch->dci.txPdcchPower.powerControlOffsetSS = 0;
789 /* Storing pdschCfg pointer here. Required to access pdsch config while
790 fillig up pdcch pdu */
791 pdcch->dci.pdschCfg = pdsch;
793 /* fill the PDSCH PDU */
795 pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
796 pdsch->rnti = 0xFFFF; /* SI-RNTI */
798 pdsch->numCodewords = 1;
799 for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
801 pdsch->codeword[cwCount].targetCodeRate = 308;
802 pdsch->codeword[cwCount].qamModOrder = 2;
803 pdsch->codeword[cwCount].mcsIndex = sib1SchCfg->sib1Mcs;
804 pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */
805 pdsch->codeword[cwCount].rvIndex = 0;
806 tbSize = schCalcTbSize(sib1SchCfg->sib1PduLen + TX_PAYLOAD_HDR_LEN);
807 pdsch->codeword[cwCount].tbSize = tbSize;
809 pdsch->dataScramblingId = pci;
810 pdsch->numLayers = 1;
811 pdsch->transmissionScheme = 0;
813 pdsch->dmrs.dlDmrsSymbPos = 4; /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */
814 pdsch->dmrs.dmrsConfigType = 0; /* type-1 */
815 pdsch->dmrs.dlDmrsScramblingId = pci;
816 pdsch->dmrs.scid = 0;
817 pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
818 pdsch->dmrs.dmrsPorts = 0x0001;
819 pdsch->dmrs.mappingType = DMRS_MAP_TYPE_A; /* Type-A */
820 pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
821 pdsch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS;
823 pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */
824 /* the RB numbering starts from coreset0, and PDSCH is always above SSB */
825 pdsch->pdschFreqAlloc.freqAlloc.startPrb = offsetPointA + SCH_SSB_NUM_PRB;
826 pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize,sib1SchCfg->sib1Mcs, NUM_PDSCH_SYMBOL);
827 pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
828 pdsch->pdschTimeAlloc.rowIndex = 1;
829 /* This is Intel's requirement. PDSCH should start after PDSCH DRMS symbol */
830 pdsch->pdschTimeAlloc.timeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */
831 pdsch->pdschTimeAlloc.timeAlloc.numSymb = NUM_PDSCH_SYMBOL;
832 pdsch->beamPdschInfo.numPrgs = 1;
833 pdsch->beamPdschInfo.prgSize = 1;
834 pdsch->beamPdschInfo.digBfInterfaces = 0;
835 pdsch->beamPdschInfo.prg[0].pmIdx = 0;
836 pdsch->beamPdschInfo.prg[0].beamIdx[0] = 0;
837 pdsch->txPdschPower.powerControlOffset = 0;
838 pdsch->txPdschPower.powerControlOffsetSS = 0;
843 * @brief cell config from MAC to SCH.
847 * Function : macSchCellCfgReq
849 * This API is invoked by MAC to send cell config to SCH
851 * @param[in] Pst *pst
852 * @param[in] SchCellCfg *schCellCfg
857 uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
861 SchCellCfgCfm schCellCfgCfm;
863 Inst inst = pst->dstInst - SCH_INST_START;
864 uint8_t coreset0Idx = 0;
867 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
868 SchPdschConfig pdschCfg;
870 #ifdef CALL_FLOW_DEBUG_LOG
871 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_SCH_CELL_CFG\n");
874 schInitCellCb(inst, schCellCfg);
875 cellCb = schCb[inst].cells[inst]; //cells is of MAX_CELLS, why inst
876 cellCb->macInst = pst->srcInst;
878 /* derive the SIB1 config parameters */
879 fillSchSib1Cfg(schCellCfg->numerology, schCellCfg->bandwidth, cellCb->numSlots,
880 &(schCellCfg->sib1SchCfg), schCellCfg->phyCellId,
881 schCellCfg->ssbSchCfg.ssbOffsetPointA);
884 memcpy(&cellCb->cellCfg, schCellCfg, sizeof(SchCellCfg));
885 schProcPagingCfg(cellCb);
887 /* Fill coreset frequencyDomainResource bitmap */
888 coreset0Idx = cellCb->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
889 numRbs = coresetIdxTable[coreset0Idx][1];
890 offset = coresetIdxTable[coreset0Idx][3];
891 fillCoresetFeqDomAllocMap(((cellCb->cellCfg.ssbSchCfg.ssbOffsetPointA - offset)/6), (numRbs/6), freqDomainResource);
892 covertFreqDomRsrcMapToIAPIFormat(freqDomainResource, \
893 cellCb->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc);
895 /* Fill K0 - K1 table for common cfg*/
896 BuildK0K1Table(cellCb, &cellCb->cellCfg.schInitialDlBwp.k0K1InfoTbl, true, cellCb->cellCfg.schInitialDlBwp.pdschCommon,
897 pdschCfg, DEFAULT_UL_ACK_LIST_COUNT, defaultUlAckTbl);
899 BuildK2InfoTable(cellCb, cellCb->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList,\
900 cellCb->cellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc, &cellCb->cellCfg.schInitialUlBwp.msg3K2InfoTbl, \
901 &cellCb->cellCfg.schInitialUlBwp.k2InfoTbl);
902 /* Initializing global variables */
903 cellCb->actvUeBitMap = 0;
904 cellCb->boIndBitMap = 0;
906 cellCb->cellCfg.schHqCfg.maxDlDataHqTx = SCH_MAX_NUM_DL_HQ_TX;
907 cellCb->cellCfg.schHqCfg.maxMsg4HqTx = SCH_MAX_NUM_MSG4_TX;
908 cellCb->cellCfg.schHqCfg.maxUlDataHqTx = SCH_MAX_NUM_UL_HQ_TX;
909 cellCb->cellCfg.schRachCfg.maxMsg3Tx = SCH_MAX_NUM_MSG3_TX;
911 /* Fill and send Cell config confirm */
912 memset(&rspPst, 0, sizeof(Pst));
913 FILL_PST_SCH_TO_MAC(rspPst, pst->dstInst);
914 rspPst.event = EVENT_SCH_CELL_CFG_CFM;
916 schCellCfgCfm.cellId = schCellCfg->cellId;
917 schCellCfgCfm.rsp = RSP_OK;
919 ret = (*SchCellCfgCfmOpts[rspPst.selector])(&rspPst, &schCellCfgCfm);
924 /*******************************************************************
926 * @brief Processes DL RLC BO info from MAC
930 * Function : MacSchDlRlcBoInfo
933 * Processes DL RLC BO info from MAC
936 * @return ROK - success
939 * ****************************************************************/
940 uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
944 bool isLcIdValid = false;
945 SchUeCb *ueCb = NULLP;
946 SchCellCb *cell = NULLP;
947 Inst inst = pst->dstInst-SCH_INST_START;
949 #ifdef CALL_FLOW_DEBUG_LOG
950 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_DL_RLC_BO_INFO_TO_SCH\n");
952 DU_LOG("\nDEBUG --> SCH : Received RLC BO Status indication LCId [%d] BO [%d]", dlBoInfo->lcId, dlBoInfo->dataVolume);
953 cell = schCb[inst].cells[inst];
957 DU_LOG("\nERROR --> SCH : MacSchDlRlcBoInfo(): Cell does not exists");
961 GET_UE_ID(dlBoInfo->crnti, ueId);
962 ueCb = &cell->ueCb[ueId-1];
963 if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
965 DU_LOG("INFO --> SCH : DL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
969 lcId = dlBoInfo->lcId;
970 CHECK_LCID(lcId, isLcIdValid);
971 if(isLcIdValid == FALSE)
973 DU_LOG("ERROR --> SCH: LCID:%d is not valid", lcId);
977 /*Expected when theres a case of Retransmission Failure or Resetablishment
978 *By Zero BO, the RLC is informing that previous data can be cleared out
979 *Thus clearing out the LC from the Lc priority list*/
980 if(dlBoInfo->dataVolume == 0)
982 /* TODO : Check the LC is Dedicated or default and accordingly LCList
987 if(lcId == SRB0_LCID)
989 cell->raCb[ueId -1].msg4recvd = true;
990 cell->raCb[ueId -1].dlMsgPduLen = dlBoInfo->dataVolume;
994 /* TODO : These part of changes will be corrected during DL scheduling as
996 SET_ONE_BIT(ueId, cell->boIndBitMap);
997 if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId)
999 ueCb->dlInfo.dlLcCtxt[lcId].bo = dlBoInfo->dataVolume;
1003 DU_LOG("ERROR --> SCH: LCID:%d is not configured in SCH Cb",lcId);
1007 /* Adding UE Id to list of pending UEs to be scheduled */
1008 addUeToBeScheduled(cell, ueId);
1012 /*******************************************************************
1014 * @brief Processes BSR indiation from MAC
1018 * Function : MacSchBsr
1021 * Processes DL BSR from MAC
1023 * @params[in] Pst pst
1024 * UlBufferStatusRptInd bsrInd
1025 * @return ROK - success
1028 * ****************************************************************/
1029 uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd)
1031 Inst schInst = pst->dstInst-SCH_INST_START;
1032 SchCellCb *cellCb = NULLP;
1033 SchUeCb *ueCb = NULLP;
1036 #ifdef CALL_FLOW_DEBUG_LOG
1037 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_SHORT_BSR\n");
1040 DU_LOG("\nDEBUG --> SCH : Received BSR");
1043 DU_LOG("\nERROR --> SCH : BSR Ind is empty");
1046 cellCb = schCb[schInst].cells[schInst];
1049 DU_LOG("\nERROR --> SCH : CellCb is empty");
1052 ueCb = schGetUeCb(cellCb, bsrInd->crnti);
1056 DU_LOG("\nERROR --> SCH : UeCB is empty");
1060 if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
1062 DU_LOG("\nINFO --> SCH: UL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
1066 ueCb->bsrRcvd = true;
1067 /* store dataVolume per lcg in uecb */
1068 for(lcgIdx = 0; lcgIdx < bsrInd->numLcg; lcgIdx++)
1070 ueCb->bsrInfo[bsrInd->dataVolInfo[lcgIdx].lcgId].priority = 1; //TODO: determining LCG priority?
1071 ueCb->bsrInfo[bsrInd->dataVolInfo[lcgIdx].lcgId].dataVol = bsrInd->dataVolInfo[lcgIdx].dataVol;
1074 /* Adding UE Id to list of pending UEs to be scheduled */
1075 addUeToBeScheduled(cellCb, ueCb->ueId);
1079 /*******************************************************************
1081 * @brief Processes SR UCI indication from MAC
1085 * Function : MacSchSrUciInd
1088 * Processes SR UCI indication from MAC
1090 * @params[in] Post structure
1092 * @return ROK - success
1095 * ****************************************************************/
1096 uint8_t MacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd)
1098 Inst inst = pst->dstInst-SCH_INST_START;
1101 SchCellCb *cellCb = schCb[inst].cells[inst];
1103 #ifdef CALL_FLOW_DEBUG_LOG
1104 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_UCI_IND_TO_SCH\n");
1107 DU_LOG("\nDEBUG --> SCH : Received SR");
1109 ueCb = schGetUeCb(cellCb, uciInd->crnti);
1111 if(ueCb->state == SCH_UE_STATE_INACTIVE)
1113 DU_LOG("\nERROR --> SCH : Crnti %d is inactive", uciInd->crnti);
1116 if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
1118 DU_LOG("\nINFO --> SCH: UL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
1121 if(uciInd->numSrBits)
1123 ueCb->srRcvd = true;
1124 /* Adding UE Id to list of pending UEs to be scheduled */
1125 addUeToBeScheduled(cellCb, ueCb->ueId);
1130 /*******************************************************************
1132 * @brief Processes DL HARQ indication from MAC
1136 * Function : MacSchDlHarqInd
1139 * Processes DL HARQ indication from MAC
1141 * @params[in] Post structure
1142 * DL HARQ Indication
1143 * @return ROK - success
1146 * ****************************************************************/
1147 uint8_t MacSchDlHarqInd(Pst *pst, DlHarqInd *dlHarqInd)
1149 Inst inst = pst->dstInst-SCH_INST_START;
1151 SchCellCb *cellCb = schCb[inst].cells[inst];
1153 #ifdef CALL_FLOW_DEBUG_LOG
1154 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_DL_HARQ_IND_TO_SCH\n");
1157 DU_LOG("\nDEBUG --> SCH : Received HARQ");
1159 ueCb = schGetUeCb(cellCb, dlHarqInd->crnti);
1161 if(ueCb->state == SCH_UE_STATE_INACTIVE)
1163 DU_LOG("\nERROR --> SCH : Crnti %d is inactive", dlHarqInd->crnti);
1167 schUpdateHarqFdbk(ueCb, dlHarqInd->numHarq, dlHarqInd->harqPayload, &dlHarqInd->slotInd);
1172 /*******************************************************************
1174 * @brief Allocates requested PRBs for DL
1178 * Function : allocatePrbDl
1181 * Allocates requested PRBs in DL
1182 * Keeps track of allocated PRB (using bitmap) and remaining PRBs
1184 * @params[in] prbAlloc table
1190 * @return ROK - success
1193 * ****************************************************************/
1194 uint8_t allocatePrbDl(SchCellCb *cell, SlotTimingInfo slotTime, \
1195 uint8_t startSymbol, uint8_t symbolLength, uint16_t *startPrb, uint16_t numPrb)
1198 uint16_t broadcastPrbStart=0, broadcastPrbEnd=0;
1199 FreePrbBlock *freePrbBlock = NULLP;
1200 CmLList *freePrbNode = NULLP;
1201 PduTxOccsaion ssbOccasion=0, sib1Occasion=0;
1202 SchDlSlotInfo *schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot];
1203 SchPrbAlloc *prbAlloc = &schDlSlotInfo->prbAlloc;
1205 /* If startPrb is set to MAX_NUM_RB, it means startPrb is not known currently.
1206 * Search for an appropriate location in PRB grid and allocate requested resources */
1207 if(*startPrb == MAX_NUM_RB)
1209 /* Check if SSB/SIB1 is also scheduled in this slot */
1210 ssbOccasion = schCheckSsbOcc(cell, slotTime);
1211 sib1Occasion = schCheckSib1Occ(cell, slotTime);
1213 if(ssbOccasion && sib1Occasion)
1215 broadcastPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
1216 broadcastPrbEnd = broadcastPrbStart + SCH_SSB_NUM_PRB + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
1218 else if(ssbOccasion)
1220 broadcastPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
1221 broadcastPrbEnd = broadcastPrbStart + SCH_SSB_NUM_PRB -1;
1223 else if(sib1Occasion)
1225 broadcastPrbStart = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.startPrb;
1226 broadcastPrbEnd = broadcastPrbStart + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
1229 /* Iterate through all free PRB blocks */
1230 freePrbNode = prbAlloc->freePrbBlockList.first;
1233 freePrbBlock = (FreePrbBlock *)freePrbNode->node;
1235 /* If broadcast message is scheduled in this slot, then check if its PRBs belong to the current free block.
1236 * Since SSB/SIB1 PRB location is fixed, these PRBs cannot be allocated to other message in same slot */
1237 if((ssbOccasion || sib1Occasion) &&
1238 ((broadcastPrbStart >= freePrbBlock->startPrb) && (broadcastPrbStart <= freePrbBlock->endPrb)) && \
1239 ((broadcastPrbEnd >= freePrbBlock->startPrb) && (broadcastPrbEnd <= freePrbBlock->endPrb)))
1241 /* Implmentation is done such that highest-numbered free-RB is allocated first */
1242 if((freePrbBlock->endPrb > broadcastPrbEnd) && ((freePrbBlock->endPrb - broadcastPrbEnd) >= numPrb))
1244 /* If sufficient free PRBs are available above bradcast message then,
1245 * endPrb = freePrbBlock->endPrb
1246 * startPrb = endPrb - numPrb +1;
1248 *startPrb = freePrbBlock->endPrb - numPrb +1;
1251 else if((broadcastPrbStart > freePrbBlock->startPrb) && ((broadcastPrbStart - freePrbBlock->startPrb) >= numPrb))
1253 /* If free PRBs are available below broadcast message then,
1254 * endPrb = broadcastPrbStart - 1
1255 * startPrb = endPrb - numPrb +1
1257 *startPrb = broadcastPrbStart - numPrb;
1262 freePrbNode = freePrbNode->next;
1268 /* Check if requested number of blocks can be allocated from the current block */
1269 if (freePrbBlock->numFreePrb < numPrb)
1271 freePrbNode = freePrbNode->next;
1274 *startPrb = freePrbBlock->endPrb - numPrb +1;
1279 /* If no free block can be used to allocated request number of RBs */
1280 if(*startPrb == MAX_NUM_RB)
1284 /* If startPrb is known already, check if requested PRBs are available for allocation */
1287 freePrbNode = isPrbAvailable(&prbAlloc->freePrbBlockList, *startPrb, numPrb);
1290 DU_LOG("\nERROR --> SCH: Requested DL PRB unavailable");
1295 /* Update bitmap to allocate PRBs */
1296 for(symbol=startSymbol; symbol < (startSymbol+symbolLength); symbol++)
1298 if(fillPrbBitmap(prbAlloc->prbBitMap[symbol], *startPrb, numPrb) != ROK)
1300 DU_LOG("\nERROR --> SCH: fillPrbBitmap() failed for symbol [%d] in DL", symbol);
1305 /* Update the remaining number for free PRBs */
1306 removeAllocatedPrbFromFreePrbList(&prbAlloc->freePrbBlockList, freePrbNode, *startPrb, numPrb);
1311 /*******************************************************************
1313 * @brief Allocates requested PRBs for UL
1317 * Function : allocatePrbUl
1320 * Allocates requested PRBs in UL
1321 * Keeps track of allocated PRB (using bitmap) and remaining PRBs
1323 * @params[in] prbAlloc table
1329 * @return ROK - success
1332 * ****************************************************************/
1333 uint8_t allocatePrbUl(SchCellCb *cell, SlotTimingInfo slotTime, \
1334 uint8_t startSymbol, uint8_t symbolLength, uint16_t *startPrb, uint16_t numPrb)
1337 uint16_t prachStartPrb, prachNumPrb, prachEndPrb;
1338 bool isPrachOccasion;
1339 FreePrbBlock *freePrbBlock = NULLP;
1340 CmLList *freePrbNode = NULLP;
1341 SchPrbAlloc *prbAlloc = NULLP;
1345 DU_LOG("\nERROR --> SCH : allocatePrbUl(): Received cellCb is null");
1349 prbAlloc = &cell->schUlSlotInfo[slotTime.slot]->prbAlloc;
1350 /* If startPrb is set to MAX_NUM_RB, it means startPrb is not known currently.
1351 * Search for an appropriate location in PRB grid and allocate requested resources */
1352 if(*startPrb == MAX_NUM_RB)
1354 /* Check if PRACH is also scheduled in this slot */
1355 isPrachOccasion = schCheckPrachOcc(cell, slotTime);
1358 prachStartPrb = cell->cellCfg.schRachCfg.msg1FreqStart;
1359 prachNumPrb = schCalcPrachNumRb(cell);
1360 prachEndPrb = prachStartPrb + prachNumPrb -1;
1363 /* Iterate through all free PRB blocks */
1364 freePrbNode = prbAlloc->freePrbBlockList.first;
1367 freePrbBlock = (FreePrbBlock *)freePrbNode->node;
1369 /* If PRACH is scheduled in this slot, then check if its PRBs belong to the current free block.
1370 * PRBs required for PRACH cannot be allocated to any other message */
1371 if((isPrachOccasion) &&
1372 ((prachStartPrb >= freePrbBlock->startPrb) && (prachStartPrb <= freePrbBlock->endPrb)) &&
1373 ((prachEndPrb >= freePrbBlock->startPrb) && (prachEndPrb <= freePrbBlock->endPrb)))
1375 /* Implmentation is done such that highest-numbered free-RB is allocated first */
1376 if((freePrbBlock->endPrb > prachEndPrb) && ((freePrbBlock->endPrb - prachEndPrb) >= numPrb))
1378 /* If sufficient free PRBs are available above PRACH message then,
1379 * endPrb = freePrbBlock->endPrb
1380 * startPrb = endPrb - numPrb +1;
1382 *startPrb = freePrbBlock->endPrb - numPrb +1;
1385 else if((prachStartPrb > freePrbBlock->startPrb) && ((prachStartPrb - freePrbBlock->startPrb) >= numPrb))
1387 /* If free PRBs are available below PRACH message then,
1388 * endPrb = prachStartPrb - 1
1389 * startPrb = endPrb - numPrb +1
1391 *startPrb = prachStartPrb - numPrb;
1396 freePrbNode = freePrbNode->next;
1402 /* Check if requested number of PRBs can be allocated from currect block */
1403 if(freePrbBlock->numFreePrb < numPrb)
1405 freePrbNode = freePrbNode->next;
1408 *startPrb = freePrbBlock->endPrb - numPrb +1;
1413 /* If no free block can be used to allocated requested number of RBs */
1414 if(*startPrb == MAX_NUM_RB)
1419 /* If startPrb is known already, check if requested PRBs are available for allocation */
1420 freePrbNode = isPrbAvailable(&prbAlloc->freePrbBlockList, *startPrb, numPrb);
1423 DU_LOG("\nERROR --> SCH: Requested UL PRB unavailable");
1428 /* Update bitmap to allocate PRBs */
1429 for(symbol=startSymbol; symbol < (startSymbol+symbolLength); symbol++)
1431 if(fillPrbBitmap(prbAlloc->prbBitMap[symbol], *startPrb, numPrb) != ROK)
1433 DU_LOG("\nERROR --> SCH: fillPrbBitmap() failed for symbol [%d] in UL", symbol);
1438 /* Update the remaining number for free PRBs */
1439 removeAllocatedPrbFromFreePrbList(&prbAlloc->freePrbBlockList, freePrbNode, *startPrb, numPrb);
1444 /*******************************************************************
1446 * @brief Add UE to ueToBeScheduled List
1450 * Function : addUeToBeScheduled
1453 * Search if UE entry present in the list
1455 * If no, add UE to the list
1457 * @params[in] Cell control block
1458 * Ue Idx to be added
1460 * @return ROK - success
1463 * ****************************************************************/
1464 uint8_t addUeToBeScheduled(SchCellCb *cell, uint8_t ueIdToAdd)
1469 /* Search if UE entry is already present in ueToBeScheduled list.
1470 * If yes, another entry for same UE not needed. Hence, return */
1471 node = cell->ueToBeScheduled.first;
1474 ueId = (uint8_t *)node->node;
1475 if(*ueId == ueIdToAdd)
1480 /* If UE entry not present already, add UE to the end of ueToBeScheduled list */
1481 SCH_ALLOC(ueId, sizeof(uint8_t));
1484 DU_LOG("\nERROR --> SCH : Memory allocation failure in addUeToBeScheduled");
1488 if(addNodeToLList(&cell->ueToBeScheduled, ueId, NULLP) != ROK)
1490 DU_LOG("\nERROR --> SCH : Failed to add ueId [%d] to cell->ueToBeScheduled list", *ueId);
1496 /*******************************************************************************
1498 * @brief Try to find Best Free Block with Max Num PRB
1502 * Function : searchLargestFreeBlock
1505 * Finds the FreeBlock with MaxNum of FREE PRB considering SSB/SIB1 ocassions.
1507 * @params[in] I/P > prbAlloc table (FreeBlock list)
1508 * I/P > Slot timing Info
1510 * I/P > Direction (UL/DL)
1513 * @return Max Number of Free PRB
1514 * If 0, then no Suitable Free Block
1516 * ********************************************************************************/
1518 uint16_t searchLargestFreeBlock(SchCellCb *cell, SlotTimingInfo slotTime,uint16_t *startPrb, Direction dir)
1520 uint16_t reservedPrbStart=0, reservedPrbEnd=0, maxFreePRB = 0;
1521 FreePrbBlock *freePrbBlock = NULLP;
1522 CmLList *freePrbNode = NULLP;
1523 SchPrbAlloc *prbAlloc = NULLP;
1524 bool checkOccasion = FALSE;
1526 *startPrb = 0; /*Initialize the StartPRB to zero*/
1528 /*Based on Direction, Reserved Messsages will differi.e.
1529 * DL >> SSB and SIB1 ocassions wheres for UL, PRACH ocassions to be checked
1530 * and reserved before allocation for dedicated DL/UL msg*/
1533 SchDlSlotInfo *schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot];
1534 PduTxOccsaion ssbOccasion=0, sib1Occasion=0;
1536 prbAlloc = &schDlSlotInfo->prbAlloc;
1538 ssbOccasion = schCheckSsbOcc(cell, slotTime);
1539 sib1Occasion = schCheckSib1Occ(cell, slotTime);
1541 checkOccasion = TRUE;
1542 if(ssbOccasion && sib1Occasion)
1544 reservedPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
1545 reservedPrbEnd = reservedPrbStart + SCH_SSB_NUM_PRB + \
1546 cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
1548 else if(ssbOccasion)
1550 reservedPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
1551 reservedPrbEnd = reservedPrbStart + SCH_SSB_NUM_PRB -1;
1553 else if(sib1Occasion)
1555 reservedPrbStart = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.startPrb;
1556 reservedPrbEnd = reservedPrbStart + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
1560 checkOccasion = FALSE;
1563 else if(dir == DIR_UL)
1565 prbAlloc = &cell->schUlSlotInfo[slotTime.slot]->prbAlloc;
1567 /* Check if PRACH is also scheduled in this slot */
1568 checkOccasion = schCheckPrachOcc(cell, slotTime);
1571 reservedPrbStart = cell->cellCfg.schRachCfg.msg1FreqStart;
1572 reservedPrbEnd = reservedPrbStart + (schCalcPrachNumRb(cell)) -1;
1577 DU_LOG("\nERROR --> SCH: Invalid Direction!");
1578 return (maxFreePRB);
1581 freePrbNode = prbAlloc->freePrbBlockList.first;
1584 freePrbBlock = (FreePrbBlock *)freePrbNode->node;
1586 /*For block with same numFreeBlocks, choose the one with HighestPRB range
1587 *Since FreeBLockList are arranged in Descending order of PRB range thus Skipping this block*/
1588 if(maxFreePRB >= freePrbBlock->numFreePrb)
1591 freePrbNode = freePrbNode->next;
1595 /* If Broadcast/Prach message is scheduled in this slot, then check if its PRBs belong to the current free block.
1596 * Since SSB/SIB1 PRB location is fixed, these PRBs cannot be allocated to other message in same slot */
1598 ((reservedPrbStart >= freePrbBlock->startPrb) && (reservedPrbStart <= freePrbBlock->endPrb)) && \
1599 ((reservedPrbEnd >= freePrbBlock->startPrb) && (reservedPrbEnd <= freePrbBlock->endPrb)))
1602 /* Implmentation is done such that highest-numbered free-RB is Checked first
1603 and freePRB in this block is greater than Max till now */
1604 if((freePrbBlock->endPrb > reservedPrbEnd) && ((freePrbBlock->endPrb - reservedPrbEnd) > maxFreePRB))
1606 /* If sufficient free PRBs are available above reserved message*/
1607 *startPrb = reservedPrbEnd + 1;
1608 maxFreePRB = (freePrbBlock->endPrb - reservedPrbEnd);
1610 /*Also check the other freeBlock (i.e. Above the reserved message) for MAX FREE PRB*/
1611 if((reservedPrbStart > freePrbBlock->startPrb) && ((reservedPrbStart - freePrbBlock->startPrb) > maxFreePRB))
1613 /* If free PRBs are available below reserved message*/
1614 *startPrb = freePrbBlock->startPrb;
1615 maxFreePRB = (reservedPrbStart - freePrbBlock->startPrb);
1620 if(maxFreePRB < freePrbBlock->numFreePrb)
1622 *startPrb = freePrbBlock->startPrb;
1623 maxFreePRB = freePrbBlock->numFreePrb;
1627 freePrbNode = freePrbNode->next;
1632 /*******************************************************************************
1634 * @brief This function is used to send Slice Cfg rsp to MAC
1638 * Function : SchSendSliceCfgRspToMac
1641 * function is used to send Slice Cfg rsp to MAC
1643 * @params[in] Pst *pst, SchSliceCfgRsp sliceCfgRsp
1647 * ********************************************************************************/
1648 void SchSendSliceCfgRspToMac(Inst inst, SchSliceCfgRsp sliceCfgRsp)
1652 memset(&rspPst, 0, sizeof(Pst));
1653 FILL_PST_SCH_TO_MAC(rspPst, inst);
1654 rspPst.event = EVENT_SLICE_CFG_RSP_TO_MAC;
1656 SchSliceCfgRspOpts[rspPst.selector](&rspPst, &sliceCfgRsp);
1659 /*******************************************************************************
1661 * @brief fill slice configuration response
1665 * Function : fillSliceCfgRsp
1668 * fill slice configuration response
1670 * @params[in] SchCellCb, SchSliceCfgReq, SchSliceCfgRsp,uint8_t count
1676 * ********************************************************************************/
1677 uint8_t fillSliceCfgRsp(bool sliceRecfg, SchSliceCfg *storedSliceCfg, SchCellCb *cellCb, SchSliceCfgReq *schSliceCfgReq, SchSliceCfgRsp *schSliceCfgRsp, uint8_t *count)
1679 bool sliceFound = false;
1680 uint8_t cfgIdx = 0, sliceIdx = 0;
1682 schSliceCfgRsp->numSliceCfgRsp = schSliceCfgReq->numOfConfiguredSlice;
1683 SCH_ALLOC(schSliceCfgRsp->listOfSliceCfgRsp, schSliceCfgRsp->numSliceCfgRsp * sizeof(SliceRsp*));
1684 if(schSliceCfgRsp->listOfSliceCfgRsp == NULLP)
1686 DU_LOG("\nERROR --> SCH : Memory allocation failed at fillSliceCfgRsp");
1690 for(cfgIdx = 0; cfgIdx<schSliceCfgRsp->numSliceCfgRsp ; cfgIdx++)
1693 /* Here comparing the slice cfg request with the slice stored in cellCfg */
1694 if(sliceRecfg != true)
1696 for(sliceIdx = 0; sliceIdx<cellCb->cellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
1698 if(!memcmp(&schSliceCfgReq->listOfConfirguration[cfgIdx]->snssai, cellCb->cellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai)))
1708 /* Here comparing the slice cfg request with the slice stored in SchDb */
1709 if(storedSliceCfg->listOfConfirguration)
1711 for(sliceIdx = 0; sliceIdx<storedSliceCfg->numOfSliceConfigured; sliceIdx++)
1713 if(!memcmp(&schSliceCfgReq->listOfConfirguration[cfgIdx]->snssai, &storedSliceCfg->listOfConfirguration[sliceIdx]->snssai,\
1724 SCH_ALLOC(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(SliceRsp));
1725 if(schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx] == NULLP)
1727 DU_LOG("\nERROR --> SCH : Failed to allocate memory in fillSliceCfgRsp");
1732 schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->snssai = schSliceCfgReq->listOfConfirguration[cfgIdx]->snssai;
1733 if(sliceFound == true)
1734 schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = RSP_OK;
1737 schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp = RSP_NOK;
1738 schSliceCfgRsp->listOfSliceCfgRsp[cfgIdx]->cause = SLICE_NOT_FOUND;
1744 /*******************************************************************************
1746 * @brief This function is used to store the slice configuration Sch DB
1750 * Function : addSliceCfgInSchDb
1753 * function is used to store the slice configuration Sch DB
1755 * @params[in] SchSliceCfg *storeSliceCfg, SchSliceCfgReq *cfgReq,
1756 * SchSliceCfgRsp cfgRsp, uint8_t count
1762 * ********************************************************************************/
1763 uint8_t addSliceCfgInSchDb(SchSliceCfg *storeSliceCfg, SchSliceCfgReq *cfgReq, SchSliceCfgRsp cfgRsp, uint8_t count)
1765 uint8_t cfgIdx = 0, sliceIdx = 0;
1769 storeSliceCfg->numOfSliceConfigured = count;
1770 SCH_ALLOC(storeSliceCfg->listOfConfirguration, storeSliceCfg->numOfSliceConfigured * sizeof(SchRrmPolicyOfSlice*));
1771 if(storeSliceCfg->listOfConfirguration == NULLP)
1773 DU_LOG("\nERROR --> SCH : Failed to allocate memory in addSliceCfgInSchDb");
1777 for(cfgIdx = 0; cfgIdx<storeSliceCfg->numOfSliceConfigured; cfgIdx++)
1779 if(cfgRsp.listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
1781 SCH_ALLOC(storeSliceCfg->listOfConfirguration[sliceIdx], sizeof(SchRrmPolicyOfSlice));
1782 if(storeSliceCfg->listOfConfirguration[sliceIdx] == NULLP)
1784 DU_LOG("\nERROR --> SCH : Failed to allocate memory in addSliceCfgInSchDb");
1788 SCH_ALLOC(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo, sizeof(SchRrmPolicyRatio));
1789 if(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo == NULLP)
1791 DU_LOG("\nERROR --> SCH : Failed to allocate memory in addSliceCfgInSchDb");
1795 memcpy(&storeSliceCfg->listOfConfirguration[sliceIdx]->snssai, &cfgReq->listOfConfirguration[sliceIdx]->snssai, sizeof(Snssai));
1796 memcpy(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo, cfgReq->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo,
1797 sizeof(SchRrmPolicyRatio));
1805 /*******************************************************************************
1807 * @brief This function is used to free the slice cfg and re cfg request pointer
1811 * Function : freeSchSliceCfgReq
1814 * function is used to free the slice cfg and re cfg request pointer
1816 * @params[in] Pst *pst, SchSliceCfgReq *schSliceCfgReq
1821 * ********************************************************************************/
1822 void freeSchSliceCfgReq(SchSliceCfgReq *sliceCfgReq)
1828 if(sliceCfgReq->numOfConfiguredSlice)
1830 for(cfgIdx = 0; cfgIdx<sliceCfgReq->numOfConfiguredSlice; cfgIdx++)
1832 if(sliceCfgReq->listOfConfirguration[cfgIdx])
1834 SCH_FREE(sliceCfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo, sizeof(SchRrmPolicyRatio));
1835 SCH_FREE(sliceCfgReq->listOfConfirguration[cfgIdx], sizeof(SchRrmPolicyOfSlice));
1838 SCH_FREE(sliceCfgReq->listOfConfirguration, sliceCfgReq->numOfConfiguredSlice * sizeof(SchRrmPolicyOfSlice*));
1840 SCH_FREE(sliceCfgReq, sizeof(SchSliceCfgReq));
1843 /*******************************************************************************
1845 * @brief This function is used to store the slice configuration Sch DB
1849 * Function : MacSchSliceCfgReq
1852 * function is used to store the slice configuration Sch DB
1854 * @params[in] Pst *pst, SchSliceCfgReq *schSliceCfgReq
1860 * ********************************************************************************/
1861 uint8_t MacSchSliceCfgReq(Pst *pst, SchSliceCfgReq *schSliceCfgReq)
1864 Inst inst = pst->dstInst - SCH_INST_START;
1865 SchSliceCfgRsp sliceCfgRsp;
1867 DU_LOG("\nINFO --> SCH : Received Slice Cfg request from MAC");
1870 if(schSliceCfgReq->listOfConfirguration)
1872 /* filling the slice configuration response of each slice */
1873 if(fillSliceCfgRsp(false, NULLP, schCb[inst].cells[0], schSliceCfgReq, &sliceCfgRsp, &count) != ROK)
1875 DU_LOG("\nERROR --> SCH : Failed to fill the slice cfg rsp");
1879 if(addSliceCfgInSchDb(&schCb[inst].sliceCfg, schSliceCfgReq, sliceCfgRsp, count) != ROK)
1881 DU_LOG("\nERROR --> SCH : Failed to add slice cfg in sch database");
1884 freeSchSliceCfgReq(schSliceCfgReq);
1885 SchSendSliceCfgRspToMac(inst, sliceCfgRsp);
1890 DU_LOG("\nERROR --> SCH : Received SchSliceCfgReq is NULL");
1895 /*******************************************************************************
1897 * @brief This function is used to store the slice reconfiguration Sch DB
1901 * Function : modifySliceCfgInSchDb
1904 * function is used to store the slice re configuration Sch DB
1906 * @params[in] Pst *pst, SchSliceCfgReq *schSliceCfgReq
1912 * ********************************************************************************/
1913 uint8_t modifySliceCfgInSchDb(SchSliceCfg *storeSliceCfg, SchSliceRecfgReq *recfgReq, SchSliceRecfgRsp recfgRsp, uint8_t count)
1915 uint8_t cfgIdx = 0, sliceIdx = 0;
1919 if(storeSliceCfg->listOfConfirguration == NULLP)
1921 DU_LOG("\nINFO --> SCH : Memory allocation failed in modifySliceCfgInSchDb");
1925 for(cfgIdx = 0; cfgIdx<recfgReq->numOfConfiguredSlice; cfgIdx++)
1927 if(recfgRsp.listOfSliceCfgRsp[cfgIdx]->rsp == RSP_OK)
1929 for(sliceIdx = 0; sliceIdx<storeSliceCfg->numOfSliceConfigured; sliceIdx++)
1931 if(!memcmp(&storeSliceCfg->listOfConfirguration[sliceIdx]->snssai, &recfgReq->listOfConfirguration[cfgIdx]->snssai, sizeof(Snssai)))
1933 memcpy(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo, recfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo,
1934 sizeof(SchRrmPolicyRatio));
1941 freeSchSliceCfgReq(recfgReq);
1944 /*******************************************************************************
1946 * @brief This function is used to send Slice re Cfg rsp to MAC
1950 * Function : SchSendSliceRecfgRspToMac
1953 * function is used to send Slice re Cfg rsp to MAC
1955 * @params[in] Pst *pst, SchSliceRecfgRsp schSliceRecfgRsp
1959 * ********************************************************************************/
1960 void SchSendSliceRecfgRspToMac(Inst inst, SchSliceRecfgRsp schSliceRecfgRsp)
1964 memset(&rspPst, 0, sizeof(Pst));
1965 FILL_PST_SCH_TO_MAC(rspPst, inst);
1966 rspPst.event = EVENT_SLICE_RECFG_RSP_TO_MAC;
1968 SchSliceRecfgRspOpts[rspPst.selector](&rspPst, &schSliceRecfgRsp);
1970 /*******************************************************************************
1972 * @brief This function is used to store the slice reconfiguration Sch DB
1976 * Function : MacSchSliceRecfgReq
1979 * function is used to store the slice re configuration Sch DB
1981 * @params[in] Pst *pst, SchSliceRecfgReq *schSliceRecfgReq
1987 * ********************************************************************************/
1988 uint8_t MacSchSliceRecfgReq(Pst *pst, SchSliceRecfgReq *schSliceRecfgReq)
1991 Inst inst = pst->dstInst - SCH_INST_START;
1992 SchSliceRecfgRsp schSliceRecfgRsp;
1994 DU_LOG("\nINFO --> SCH : Received Slice ReCfg request from MAC");
1995 if(schSliceRecfgReq)
1997 if(schSliceRecfgReq->listOfConfirguration)
1999 /* filling the slice configuration response of each slice */
2000 if(fillSliceCfgRsp(true, &schCb[inst].sliceCfg, NULLP, schSliceRecfgReq, &schSliceRecfgRsp, &count) != ROK)
2002 DU_LOG("\nERROR --> SCH : Failed to fill sch slice cfg response");
2006 /* Modify the slice configuration stored in schCb */
2007 if(modifySliceCfgInSchDb(&schCb[inst].sliceCfg, schSliceRecfgReq, schSliceRecfgRsp, count) != ROK)
2009 DU_LOG("\nERROR --> SCH : Failed to modify slice cfg of SchDb");
2012 SchSendSliceRecfgRspToMac(inst, schSliceRecfgRsp);
2017 DU_LOG("\nERROR --> SCH : Received SchSliceRecfgReq is NULL");
2022 /****************************************************************************
2024 * @brief Stores the Paging Configuration from DU APP in CellCb
2028 * Function : schProcPagingParam
2031 * Process the Paging Configuration when FirstPDCCHMonitoring for
2032 * Paging Ocassion is not present.
2034 * As per 38.304 Sec 7.1,
2035 * "When firstPDCCH-MonitoringOccasionOfPO is present, the
2036 * starting PDCCH monitoring occasion number of (i_s + 1)th PO is the
2037 * (i_s + 1)th value of the firstPDCCHMonitoringOccasionOfPO
2038 * parameter; otherwise, it is equal to i_s * S."
2039 * "S = number of actual transmitted SSBs determined according
2040 * to ssb-PositionsInBurst in SIB1"
2042 * @params[in] SchCellCb *cell
2046 *************************************************************************/
2047 void schProcPagingCfg(SchCellCb *cell)
2049 PageCfg *pageCfgRcvd = NULL;
2052 pageCfgRcvd = &(cell->cellCfg.sib1SchCfg.pageCfg);
2054 if(pageCfgRcvd->poPresent == TRUE)
2056 /*Fetching first Pdcch Monitoring Occasion for SFN (i_s + 1)th*/
2057 for(i_sIdx = 0; i_sIdx < pageCfgRcvd->numPO; i_sIdx++)
2059 cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot = pageCfgRcvd->pagingOcc[i_sIdx] / MAX_SYMB_PER_SLOT ;
2060 if ((pageCfgRcvd->pagingOcc[i_sIdx] % MAX_SYMB_PER_SLOT) != 0 )
2062 cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot++;
2065 cell->pageCb.pagMonOcc[i_sIdx].frameOffset = 0;
2071 schCfgPdcchMonOccOfPO(cell);
2075 /****************************************************************************
2077 * @brief Calculate PO if not present in Configuration
2081 * Function : schCfgPdcchMonOccOfPO
2083 * Functionality: In this function, PO are calculated i_s * S because
2084 * FirstPDCCHMonitoring_ForPO is not present.
2086 * @params[in] SchCellCb *cellCb
2090 *************************************************************************/
2091 void schCfgPdcchMonOccOfPO(SchCellCb *cell)
2093 uint8_t cnt = 0, incr = 1, i_sIdx = 0, frameOffSet = 0;
2094 uint8_t nsValue = cell->cellCfg.sib1SchCfg.pageCfg.numPO;
2095 uint8_t totalNumSsb = cell->cellCfg.ssbSchCfg.totNumSsb;
2096 SlotTimingInfo tmpTimingInfo, pdcchTime;
2098 /*Starting with First Sfn and slot*/
2099 tmpTimingInfo.sfn = 0;
2100 tmpTimingInfo.slot = 0;
2102 pdcchTime = tmpTimingInfo;
2104 while(i_sIdx < nsValue)
2106 /*Increment frame Offset if PO falls on next SFN*/
2107 if(pdcchTime.sfn != tmpTimingInfo.sfn)
2111 pdcchTime = tmpTimingInfo;
2112 schIncrSlot(&(tmpTimingInfo), incr, cell->numSlots);
2116 cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot = pdcchTime.slot;
2117 cell->pageCb.pagMonOcc[i_sIdx].frameOffset = frameOffSet;
2123 if((cnt == totalNumSsb) && (i_sIdx < MAX_PO_PER_PF))
2125 cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot = pdcchTime.slot;
2126 cell->pageCb.pagMonOcc[i_sIdx].frameOffset = frameOffSet;
2134 /****************************************************************************
2136 * @brief Storing the paging information in SCH database
2140 * Function : schAddPagingIndtoList
2142 * Functionality: Storing the paging information in SCH database
2144 * @params[in] CmLListCp *storedPageList, CmLList *pageIndInfo
2146 * @return ROK - sucess
2149 *************************************************************************/
2150 uint8_t schAddPagingIndtoList(CmLListCp *storedPageList,void * pageIndInfo)
2152 CmLList *firstNodeOfList = NULLP;
2153 CmLList *currentNodeInfo = NULLP;
2154 SchPageInfo *tempNode = NULLP, *recvdNode = NULLP;
2156 recvdNode = (SchPageInfo*) pageIndInfo;
2157 CM_LLIST_FIRST_NODE(storedPageList,firstNodeOfList);
2159 SCH_ALLOC(currentNodeInfo, sizeof(CmLList));
2160 if(!currentNodeInfo)
2162 DU_LOG("\nERROR --> SCH : schAddPagingIndtoList() : Memory allocation failed");
2166 currentNodeInfo->node = (PTR)pageIndInfo;
2167 while(firstNodeOfList)
2169 tempNode = (SchPageInfo*)(firstNodeOfList->node);
2170 if ((recvdNode->pageTxTime.slot < tempNode->pageTxTime.slot))
2172 cmLListInsCrnt(storedPageList, currentNodeInfo);
2175 else if ((recvdNode->pageTxTime.slot == tempNode->pageTxTime.slot))
2177 DU_LOG("\nERROR --> SCH : schAddPagingIndtoList() : Slot[%d] is already present in the list", recvdNode->pageTxTime.slot);
2182 CM_LLIST_NEXT_NODE(storedPageList, firstNodeOfList);
2186 if(!firstNodeOfList)
2188 cmLListAdd2Tail(storedPageList, currentNodeInfo);
2190 DU_LOG("\nDEBUG --> SCH : Paging information is stored successfully for PF:%d, Slot:%d",\
2191 recvdNode->pageTxTime.sfn, recvdNode->pageTxTime.slot);
2195 /****************************************************************************
2197 * @brief Process paging indication at SCH recevied form MAC
2201 * Function : MacSchPagingInd
2203 * Functionality: Process paging indication at SCH recevied form MAC
2205 * @params[in] Pst *pst, SchPageInd *pageInd
2209 *************************************************************************/
2210 uint8_t MacSchPagingInd(Pst *pst, SchPageInd *pageInd)
2212 uint8_t ret = RFAILED;
2213 uint16_t cellIdx = 0;
2214 Inst inst = pst->dstInst - SCH_INST_START;
2215 SchCellCb *cellCb = NULLP;
2216 SchPageInfo *pageInfo = NULLP;
2220 DU_LOG("\nDEBUG --> SCH : Received paging indication from MAC for cellId[%d]",\
2224 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
2226 if((schCb[inst].cells[cellIdx]) && (schCb[inst].cells[cellIdx]->cellId == pageInd->cellId))
2228 cellCb = schCb[inst].cells[cellIdx];
2234 if(pageInd->i_s > cellCb->cellCfg.sib1SchCfg.pageCfg.numPO)
2236 DU_LOG("\nERROR --> SCH : MacSchPagingInd(): i_s should not be greater than number of paging occasion");
2240 SCH_ALLOC(pageInfo, sizeof(SchPageInfo));
2243 pageInfo->pf = pageInd->pf;
2244 pageInfo->i_s = pageInd->i_s;
2245 pageInfo->pageTxTime.cellId = pageInd->cellId;
2246 pageInfo->pageTxTime.sfn = (pageInd->pf + cellCb->pageCb.pagMonOcc[pageInd->i_s].frameOffset) % MAX_SFN;
2247 pageInfo->pageTxTime.slot = cellCb->pageCb.pagMonOcc[pageInd->i_s].pagingOccSlot;
2248 pageInfo->mcs = DEFAULT_MCS;
2249 pageInfo->msgLen = pageInd->pduLen;
2250 SCH_ALLOC(pageInfo->pagePdu, pageInfo->msgLen);
2251 if(!pageInfo->pagePdu)
2253 DU_LOG("\nERROR --> SCH : MacSchPagingInd(): Failed to allocate memory");
2257 memcpy(pageInfo->pagePdu, pageInd->pagePdu, pageInfo->msgLen);
2258 ret = schAddPagingIndtoList(&cellCb->pageCb.pageIndInfoRecord[pageInfo->pageTxTime.sfn], pageInfo);
2261 DU_LOG("\nERROR --> SCH : MacSchPagingInd(): Failed to store paging record");
2267 DU_LOG("\nERROR --> SCH : MacSchPagingInd(): Failed to allocate memory");
2273 DU_LOG("\nERROR --> SCH : Cell ID [%d] not found", pageInd->cellId);
2275 SCH_FREE(pageInd->pagePdu, pageInd->pduLen);
2276 SCH_FREE(pageInd, sizeof(SchPageInd));
2280 DU_LOG("\nERROR --> SCH : MacSchPagingInd(): Received null pointer");
2284 /**********************************************************************
2286 **********************************************************************/