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 rach handling functions
29 **********************************************************************/
32 @brief This file implements the rach handling.
34 #include "common_def.h"
40 #include "du_app_mac_inf.h"
41 #include "mac_sch_interface.h"
43 #include "sch_utils.h"
46 * @brief Checks if PRACH can be scheduled in current slot
50 * Function : schCheckPrachOcc
52 * This function checks if PRACH can be scheduled in
60 bool schCheckPrachOcc(SchCellCb *cell, SlotTimingInfo prachOccasionTimingInfo)
62 uint8_t prachCfgIdx = 0;
66 uint16_t prachSubframe = 0;
68 prachCfgIdx = cell->cellCfg.schRachCfg.prachCfgIdx;
70 /* derive the prachCfgIdx table paramters */
71 x = prachCfgIdxTable[prachCfgIdx][1];
72 y = prachCfgIdxTable[prachCfgIdx][2];
73 prachSubframe = prachCfgIdxTable[prachCfgIdx][3];
75 if((prachOccasionTimingInfo.sfn%x) == y)
77 subFrame = prachOccasionTimingInfo.slot/pow(2, cell->cellCfg.numerology);
79 /* check for subFrame number */
80 if ((1 << subFrame) & prachSubframe)
82 /* prach ocassion present in this subframe */
84 if(UL_SLOT != schGetSlotSymbFrmt(prachOccasionTimingInfo.slot % cell->numSlotsInPeriodicity,\
85 cell->slotFrmtBitMap))
87 DU_LOG("\nERROR --> SCH : PrachCfgIdx %d doesn't support UL slot", prachCfgIdx);
98 * @brief Calculate number of PRBs to be allocated for PRACH
102 * Function : schCalcPrachNumRb
104 * Calculate number of PRBs to be allocated for PRACH
106 * @param[in] SchCellCb *cell, cell cb
107 * @return Number of PRBs
109 uint8_t schCalcPrachNumRb(SchCellCb *cell)
111 uint8_t tableIdx = 0;
112 uint16_t puschScs = fetchScsValue(cell->cellCfg.schInitialUlBwp.bwp.scs);
114 for(tableIdx=0; tableIdx < MAX_RACH_NUM_RB_IDX; tableIdx++)
116 if((numRbForPrachTable[tableIdx][0] == cell->cellCfg.schRachCfg.rootSeqLen) &&
117 (numRbForPrachTable[tableIdx][1] == cell->cellCfg.schRachCfg.prachSubcSpacing) &&
118 (numRbForPrachTable[tableIdx][2] == puschScs))
120 return numRbForPrachTable[tableIdx][3];
127 * @brief resource allocation for PRACH
131 * Function : schPrachResAlloc
133 * This function handles PRACH allocation
135 * @param[in] SchCellCb *cell, cell cb
136 * @param[in] UlSchedInfo *ulSchedInfo, UL scheduling info
139 void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo prachOccasionTimingInfo)
141 uint8_t numPrachRb = 0;
143 uint8_t prachCfgIdx = 0;
144 uint8_t prachFormat = 0;
145 uint8_t prachStartSymbol = 0;
146 uint8_t prachDuration = 0;
147 uint8_t prachOcas = 0;
148 uint8_t dataType = 0;
149 uint16_t freqStart = 0;
151 /* If this slot is not a PRACH occassion, return */
152 if(!schCheckPrachOcc(cell, prachOccasionTimingInfo))
155 prachCfgIdx = cell->cellCfg.schRachCfg.prachCfgIdx;
156 prachFormat = prachCfgIdxTable[prachCfgIdx][0];
157 prachStartSymbol = prachCfgIdxTable[prachCfgIdx][4];
158 prachOcas = prachCfgIdxTable[prachCfgIdx][6];
159 prachDuration = prachCfgIdxTable[prachCfgIdx][7];
161 /* numRa determined as 𝑛 belonging {0,1,.., M − 1},
162 * where M is given by msg1Fdm */
163 numRa = (cell->cellCfg.schRachCfg.msg1Fdm - 1);
165 /* freq domain resource determination for RACH*/
166 freqStart = cell->cellCfg.schRachCfg.msg1FreqStart;
167 numPrachRb = schCalcPrachNumRb(cell);
168 /* Allocate PRACH resources from the UL resource bitmap */
169 allocatePrbUl(cell, prachOccasionTimingInfo, prachStartSymbol, prachDuration, &freqStart, numPrachRb);
172 dataType |= SCH_DATATYPE_PRACH;
173 ulSchedInfo->dataType = dataType;
174 ulSchedInfo->prachSchInfo.numPrachOcas = prachOcas;
175 ulSchedInfo->prachSchInfo.prachFormat = prachFormat;
176 ulSchedInfo->prachSchInfo.numRa = numRa;
177 ulSchedInfo->prachSchInfo.prachStartSymb = prachStartSymbol;
178 DU_LOG("\nINFO --> SCH : RACH occassion set for slot %d", prachOccasionTimingInfo.slot);
182 * @brief calculate ra-rnti function.
186 * Function : calculateRaRnti
188 * This function calculates ra-rnti
190 * @param[in] symbol index
191 * @param[in] slot index
192 * @param[in] frequency index
195 uint16_t calculateRaRnti(uint8_t symbolIdx, uint8_t slotIdx, uint8_t freqIdx)
198 uint8_t ulCarrierIdx = 0; /* Uplink carrier used for MSG1 transmission. 0:NUL carrier; 1:SUL carrier */
200 /* Refer to spec 38.321, section 5.1.3 */
201 raRnti = (1 + symbolIdx + (14*slotIdx) + (14*80*freqIdx) + (14*80*8*ulCarrierIdx));
206 * @brief create raCb function.
210 * Function : createSchRaCb
212 * This function create raCb
215 * @param[in] shed instance
218 void createSchRaCb(uint16_t tcrnti, Inst schInst)
222 GET_UE_IDX(tcrnti, ueIdx);
223 schCb[schInst].cells[schInst]->raCb[ueIdx -1].tcrnti = tcrnti;
227 * @brief resource allocation for msg3 PUSCH
231 * Function : schAllocMsg3Pusch
233 * This function handles msg3 PUSCH allocation
235 * @param[in] Inst schInst, SCH instance
236 * @param[in] slot, current slot
237 * @param[out] msg3StartRb
238 * @param[out] msg3NumRb
241 SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, SlotTimingInfo msg3SlotTime)
243 SchCellCb *cell = NULLP;
244 SchUlSlotInfo *schUlSlotInfo = NULLP;
245 uint8_t mcs = DEFAULT_MCS;
246 uint8_t startSymb = 0;
248 uint16_t startRb = 0;
252 cell = schCb[schInst].cells[schInst];
255 DU_LOG("\n\nERROR --> SCH : Failed to find cell in schAllocMsg3Pusch");
259 /* Allocate time-domain and frequency-domain resource for MSG3 PUSCH */
260 startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol;
261 symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength;
263 startRb = MAX_NUM_RB;
264 tbSize = schCalcTbSize(8); /* 6 bytes msg3 and 2 bytes header */
265 numRb = schCalcNumPrb(tbSize, mcs, symbLen);
266 numRb++; /* allocating 1 extra RB for now */
267 allocatePrbUl(cell, msg3SlotTime, startSymb, symbLen, &startRb, numRb);
269 /* Fill PUSCH scheduling details in Slot structure */
270 schUlSlotInfo = cell->schUlSlotInfo[msg3SlotTime.slot];
271 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
272 if(!schUlSlotInfo->schPuschInfo)
274 DU_LOG("\nERROR --> SCH : Memory allocation failed in schAllocMsg3Pusch");
278 tbSize = 0; /* since nPrb has been incremented, recalculating tbSize */
279 tbSize = schCalcTbSizeFromNPrb(numRb, mcs, NUM_PDSCH_SYMBOL);
280 tbSize = tbSize / 8 ; /*bits to byte conversion*/
282 schUlSlotInfo->schPuschInfo->crnti = crnti;
283 schUlSlotInfo->schPuschInfo->harqProcId = SCH_HARQ_PROC_ID;
284 schUlSlotInfo->schPuschInfo->resAllocType = SCH_ALLOC_TYPE_1;
285 schUlSlotInfo->schPuschInfo->fdAlloc.startPrb = startRb;
286 schUlSlotInfo->schPuschInfo->fdAlloc.numPrb = numRb;
287 schUlSlotInfo->schPuschInfo->tdAlloc.startSymb = startSymb;
288 schUlSlotInfo->schPuschInfo->tdAlloc.numSymb = symbLen;
289 schUlSlotInfo->schPuschInfo->tbInfo.qamOrder = QPSK_MODULATION; /* QPSK modulation */
290 schUlSlotInfo->schPuschInfo->tbInfo.mcs = mcs;
291 schUlSlotInfo->schPuschInfo->tbInfo.mcsTable = SCH_MCS_TABLE_QAM_64;
292 schUlSlotInfo->schPuschInfo->tbInfo.ndi = NEW_TRANSMISSION; /* new transmission */
293 schUlSlotInfo->schPuschInfo->tbInfo.rv = 0;
294 schUlSlotInfo->schPuschInfo->tbInfo.tbSize = tbSize;
295 schUlSlotInfo->schPuschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
296 schUlSlotInfo->schPuschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
297 schUlSlotInfo->schPuschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS;
299 return schUlSlotInfo->schPuschInfo;
303 * @brief Check if a time frame is in RA Response window
307 * Function : isInRaRspWindow
309 * Check if a time frame is in RA Response window
311 * @param[in] RA request
312 * @param[in] Time frame to check
313 * @param[in] Total number of slot per radio frame
317 RaRspWindowStatus isInRaRspWindow(SchRaReq *raReq, SlotTimingInfo frameToCheck, uint16_t numSlotsPerSystemFrame)
319 uint32_t winStartTime, winEndTime, timeToCheck;
321 winStartTime = (raReq->winStartTime.sfn * numSlotsPerSystemFrame) + raReq->winStartTime.slot;
322 winEndTime = (raReq->winEndTime.sfn * numSlotsPerSystemFrame) + raReq->winEndTime.slot;
323 timeToCheck = (frameToCheck.sfn * numSlotsPerSystemFrame) + frameToCheck.slot;
325 /* TODO : check how to handle the wrap around scenario of MAX_SFN */
326 if((timeToCheck >= winStartTime) && (timeToCheck <= winEndTime))
327 return WITHIN_WINDOW;
328 else if(timeToCheck < winStartTime)
329 return WINDOW_YET_TO_START;
331 return WINDOW_EXPIRED;
335 * @brief Processes any pending RA request
339 * Function : schProcessRaReq
341 * This function process pending RA request
343 * @param[in] Current timing of the cell
346 void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell)
348 bool k2Found = false;
349 uint8_t ueIdx = 0, k0TblIdx = 0, k2TblIdx = 0;
350 uint8_t k0Index = 0, k2Index = 0;
351 uint8_t k0 = 0, k2 = 0;
353 uint8_t msg3Delta = 0, msg3MinSchTime = 0;
355 uint8_t totalCfgSlot = 0;
357 uint16_t dciSlot = 0, rarSlot = 0;
358 SlotTimingInfo dciTime, rarTime, msg3Time;
359 RarAlloc *dciSlotAlloc = NULLP; /* Stores info for transmission of PDCCH for RAR */
360 RarAlloc *rarSlotAlloc = NULLP; /* Stores info for transmission of RAR PDSCH */
361 SchPuschInfo *msg3PuschInfo = NULLP; /* Stores MSG3 PUSCH scheduling information */
362 SchK0K1TimingInfoTbl *k0K1InfoTbl=NULLP;
363 SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP;
364 RaRspWindowStatus windowStatus=0;
366 while(ueIdx < MAX_NUM_UE)
368 if(cell->raReq[ueIdx] == NULLP)
375 totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod);
377 k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl;
378 msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl;
379 puschMu = cell->cellCfg.numerology;
380 msg3Delta = puschDeltaTable[puschMu];
381 msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology];
383 /* Calculating time frame to send DCI for RAR */
384 ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA);
385 dciSlot = dciTime.slot;
387 /* Consider this slot for sending DCI, only if it is a DL slot */
388 if(schGetSlotSymbFrmt(dciSlot, cell->slotFrmtBitMap) == DL_SLOT)
392 /* Check if this slot is within RA response window */
393 windowStatus = isInRaRspWindow(cell->raReq[ueIdx], dciTime, cell->numSlots);
394 if(windowStatus == WITHIN_WINDOW)
396 /* For all k0 values, search for a suitable k2 value to schedule MSG3.
397 * RAR DCI, RAR PDSCH and MSG3 is scheduled only if one such k0-k2 combination
398 * is found. Else no scheduling happens.
400 for(k0TblIdx = 0; k0TblIdx < k0K1InfoTbl->k0k1TimingInfo[dciSlot].numK0; k0TblIdx++)
402 k0Index = k0K1InfoTbl->k0k1TimingInfo[dciSlot].k0Indexes[k0TblIdx].k0Index;
403 k0 = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
405 /* Calculating time frame to send RAR PDSCH */
406 ADD_DELTA_TO_TIME(dciTime, rarTime, k0);
407 rarSlot = rarTime.slot;
409 for(k2TblIdx = 0; k2TblIdx < msg3K2InfoTbl->k2TimingInfo[rarSlot].numK2; k2TblIdx++)
411 k2Index = msg3K2InfoTbl->k2TimingInfo[rarSlot].k2Indexes[k2TblIdx];
412 k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2;
414 /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */
416 if(k2 >= msg3MinSchTime)
418 ADD_DELTA_TO_TIME(rarTime, msg3Time, k2);
420 if(schGetSlotSymbFrmt(msg3Time.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT)
431 else if(windowStatus == WINDOW_EXPIRED)
433 SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo));
434 SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq));
439 /* If K0-K2 combination not found, no scheduling happens */
446 /* Allocate memory for RAR PDCCH slot, pointer will be checked at schProcessSlotInd() */
447 SCH_ALLOC(dciSlotAlloc, sizeof(RarAlloc));
448 if(dciSlotAlloc == NULLP)
450 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciSlotAlloc");
453 cell->schDlSlotInfo[dciSlot]->rarAlloc = dciSlotAlloc;
455 /* Fill PDCCH and PDSCH scheduling information for RAR */
456 if((schFillRar(cell, rarTime, ueIdx, dciSlotAlloc, k0Index)) != ROK)
458 DU_LOG("\nERROR --> SCH: Scheduling of RAR failed in slot [%d]", rarSlot);
459 SCH_FREE(dciSlotAlloc, sizeof(RarAlloc));
460 cell->schDlSlotInfo[dciSlot]->rarAlloc = NULLP;
464 /* Allocate resources for msg3 */
465 msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, cell->raReq[ueIdx]->rachInd->crnti, k2Index, msg3Time);
469 dciSlotAlloc->rarInfo.raRnti = cell->raReq[ueIdx]->raRnti;
470 dciSlotAlloc->rarInfo.tcrnti = cell->raReq[ueIdx]->rachInd->crnti;
471 dciSlotAlloc->rarInfo.RAPID = cell->raReq[ueIdx]->rachInd->preambleIdx;
472 dciSlotAlloc->rarInfo.ta = cell->raReq[ueIdx]->rachInd->timingAdv;
473 dciSlotAlloc->rarInfo.ulGrant.bwpSize = cell->cellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb;
474 /* Spec 38.213, section 8.2, 0 : MSG3 PUSCH will be transmitted without frequency hopping */
475 dciSlotAlloc->rarInfo.ulGrant.freqHopFlag = 0;
476 dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.startPrb = msg3PuschInfo->fdAlloc.startPrb;
477 dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.numPrb = msg3PuschInfo->fdAlloc.numPrb;
478 dciSlotAlloc->rarInfo.ulGrant.k2Index = k2Index;
479 dciSlotAlloc->rarInfo.ulGrant.mcs = msg3PuschInfo->tbInfo.mcs;
480 dciSlotAlloc->rarInfo.ulGrant.tpc = 3; /* TODO : Check appropriate value to be filled */
481 /* Spec 38.213, section 8.2 : In a contention based random access
482 * procedure, the CSI request field is reserved. */
483 dciSlotAlloc->rarInfo.ulGrant.csiReq = 0;
486 /* Check if both DCI and RAR are sent in the same slot.
487 * If not, allocate memory RAR PDSCH slot to store RAR info
489 if(dciSlot == rarSlot)
490 dciSlotAlloc->pduPres = BOTH;
493 /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */
494 SCH_ALLOC(rarSlotAlloc, sizeof(RarAlloc));
495 if(rarSlotAlloc == NULLP)
497 DU_LOG("\nERROR --> SCH : Memory Allocation failed for rarSlotAlloc");
498 SCH_FREE(dciSlotAlloc, sizeof(RarAlloc));
499 cell->schDlSlotInfo[dciSlot]->rarAlloc = NULLP;
502 cell->schDlSlotInfo[rarSlot]->rarAlloc = rarSlotAlloc;
504 /* Copy all RAR info */
505 memcpy(rarSlotAlloc, dciSlotAlloc, sizeof(RarAlloc));
506 rarSlotAlloc->rarPdcchCfg.dci.pdschCfg = &rarSlotAlloc->rarPdschCfg;
508 /* Assign correct PDU types in corresponding slots */
509 rarSlotAlloc->pduPres = PDSCH_PDU;
510 dciSlotAlloc->pduPres = PDCCH_PDU;
511 dciSlotAlloc->pdschSlot = rarSlot;
514 /* Create raCb at SCH */
515 createSchRaCb(cell->raReq[ueIdx]->rachInd->crnti, cell->instIdx);
517 SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo));
518 SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq));
521 } /* End of while(ueIdx < MAX_NUM_UE) */
525 * @brief process rach indication function.
529 * Function : schProcessRachInd
531 * This function process rach indication
533 * @param[in] rachInd parameters
534 * @param[in] shed instance
537 uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst)
539 SchCellCb *cell = schCb[schInst].cells[schInst];
540 SchRaReq *raReq = NULLP;
547 DU_LOG("\nERROR --> SCH: Failed to find cell in schProcessRachInd");
551 /* Storing RA request in cellCb */
552 GET_UE_IDX(rachInd->crnti, ueIdx);
555 DU_LOG("\nERROR --> SCH: Invalid CRNTI [%d]", rachInd->crnti);
559 SCH_ALLOC(raReq, sizeof(SchRaReq));
562 DU_LOG("\nERROR --> SCH : Memory allocation failure in schProcessRachInd");
563 SCH_FREE(rachInd, sizeof(RachIndInfo));
567 /* calculate the ra-rnti value */
568 raReq->raRnti = calculateRaRnti(rachInd->symbolIdx, rachInd->slotIdx, rachInd->freqIdx);
569 raReq->rachInd = rachInd;
570 raReq->winStartTime.sfn = rachInd->timingInfo.sfn;
571 raReq->winStartTime.slot = rachInd->timingInfo.slot;
573 /* Converting window size from ms to number of slots */
574 slotDuration = (1 / pow(2, cell->cellCfg.numerology));
575 winNumSlots = (float)cell->cellCfg.schRachCfg.raRspWindow / slotDuration;
577 /* Adding window size to window start time to get window end time */
578 ADD_DELTA_TO_TIME(raReq->winStartTime, raReq->winEndTime, winNumSlots);
580 cell->raReq[ueIdx -1] = raReq;
586 * @brief fill RAR info function.
590 * Function : calculateRaRnti
592 * This function fills pdcch and pdsch info for RAR
594 * @param[in] rar Allocation info
597 * @param[in] offset to pointA to determine freq alloc
600 uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarAlloc *rarAlloc, uint8_t k0Index)
602 uint8_t coreset0Idx = 0;
603 uint8_t firstSymbol = 0, numSymbols = 0;
604 uint8_t mcs = DEFAULT_MCS; /* MCS fixed to 4 */
605 uint8_t dmrsStartSymbol, startSymbol, numSymbol ;
609 SchBwpDlCfg *initialBwp = &cell->cellCfg.schInitialDlBwp;
610 PdcchCfg *pdcch = &rarAlloc->rarPdcchCfg;
611 PdschCfg *pdsch = &rarAlloc->rarPdschCfg;
612 BwpCfg *bwp = &rarAlloc->bwp;
614 /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
615 coreset0Idx = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
616 numRbs = coresetIdxTable[coreset0Idx][1];
617 numSymbols = coresetIdxTable[coreset0Idx][2];
619 /* calculate time domain parameters */
620 // note: since slot value is made sl1, RAR can be sent at all slots
621 uint16_t mask = 0x2000;
622 for(firstSymbol=0; firstSymbol<MAX_SYMB_PER_SLOT; firstSymbol++)
624 if(initialBwp->pdcchCommon.commonSearchSpace.monitoringSymbol & mask)
631 bwp->freqAlloc.numPrb = initialBwp->bwp.freqAlloc.numPrb;
632 bwp->freqAlloc.startPrb = initialBwp->bwp.freqAlloc.startPrb;
633 bwp->subcarrierSpacing = initialBwp->bwp.scs;
634 bwp->cyclicPrefix = initialBwp->bwp.cyclicPrefix;
636 /* fill the PDCCH PDU */
637 pdcch->coresetCfg.startSymbolIndex = firstSymbol;
638 pdcch->coresetCfg.durationSymbols = numSymbols;
639 memcpy(pdcch->coresetCfg.freqDomainResource, \
640 cell->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
642 pdcch->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
643 pdcch->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */
644 pdcch->coresetCfg.interleaverSize = 2; /* spec-38.211 sec 7.3.2.2 */
645 pdcch->coresetCfg.coreSetType = 0;
646 pdcch->coresetCfg.coreSetSize = numRbs;
647 pdcch->coresetCfg.shiftIndex = cell->cellCfg.phyCellId;
648 pdcch->coresetCfg.precoderGranularity = 0; /* sameAsRegBundle */
650 pdcch->dci.rnti = cell->raReq[ueIdx]->raRnti; /* RA-RNTI */
651 pdcch->dci.scramblingId = cell->cellCfg.phyCellId;
652 pdcch->dci.scramblingRnti = 0;
653 pdcch->dci.cceIndex = 4; /* considering SIB1 is sent at cce 0-1-2-3 */
654 pdcch->dci.aggregLevel = 4;
655 pdcch->dci.beamPdcchInfo.numPrgs = 1;
656 pdcch->dci.beamPdcchInfo.prgSize = 1;
657 pdcch->dci.beamPdcchInfo.digBfInterfaces = 0;
658 pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0;
659 pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
660 pdcch->dci.txPdcchPower.powerValue = 0;
661 pdcch->dci.txPdcchPower.powerControlOffsetSS = 0;
662 pdcch->dci.pdschCfg = pdsch;
664 /* fill the PDSCH PDU */
666 pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
667 pdsch->rnti = cell->raReq[ueIdx]->raRnti; /* RA-RNTI */
669 pdsch->numCodewords = 1;
670 for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
672 pdsch->codeword[cwCount].targetCodeRate = 308;
673 pdsch->codeword[cwCount].qamModOrder = 2;
674 pdsch->codeword[cwCount].mcsIndex = mcs; /* mcs configured to 4 */
675 pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */
676 pdsch->codeword[cwCount].rvIndex = 0;
677 /* RAR PDU length and FAPI payload header length */
678 tbSize = schCalcTbSize(RAR_PAYLOAD_SIZE + TX_PAYLOAD_HDR_LEN);
679 pdsch->codeword[cwCount].tbSize = tbSize;
681 pdsch->dataScramblingId = cell->cellCfg.phyCellId;
682 pdsch->numLayers = 1;
683 pdsch->transmissionScheme = 0;
685 pdsch->dmrs.dlDmrsSymbPos = 4; /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */
686 pdsch->dmrs.dmrsConfigType = 0; /* type-1 */
687 pdsch->dmrs.dlDmrsScramblingId = cell->cellCfg.phyCellId;
688 pdsch->dmrs.scid = 0;
689 pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
690 pdsch->dmrs.dmrsPorts = 0;
691 pdsch->dmrs.mappingType = DMRS_MAP_TYPE_A; /* Type-A */
692 pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
693 pdsch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS;
695 pdsch->pdschTimeAlloc.timeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
696 pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
698 pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
699 pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */
700 pdsch->pdschFreqAlloc.freqAlloc.startPrb = MAX_NUM_RB;
701 pdsch->pdschFreqAlloc.freqAlloc.numPrb = \
702 schCalcNumPrb(tbSize, mcs, initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol);
704 /* Find total symbols occupied including DMRS */
705 dmrsStartSymbol = findDmrsStartSymbol(pdsch->dmrs.dlDmrsSymbPos);
706 /* If there are no DRMS symbols, findDmrsStartSymbol() returns MAX_SYMB_PER_SLOT,
707 * in that case only PDSCH symbols are marked as occupied */
708 if(dmrsStartSymbol == MAX_SYMB_PER_SLOT)
710 startSymbol = pdsch->pdschTimeAlloc.timeAlloc.startSymb;
711 numSymbol = pdsch->pdschTimeAlloc.timeAlloc.numSymb;
713 /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */
716 startSymbol = dmrsStartSymbol;
717 numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.timeAlloc.numSymb;
720 /* Allocate the number of PRBs required for RAR PDSCH */
721 if((allocatePrbDl(cell, rarTime, startSymbol, numSymbol,\
722 &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK)
724 DU_LOG("\nERROR --> SCH : allocatePrbDl() failed for RAR");
728 pdsch->beamPdschInfo.numPrgs = 1;
729 pdsch->beamPdschInfo.prgSize = 1;
730 pdsch->beamPdschInfo.digBfInterfaces = 0;
731 pdsch->beamPdschInfo.prg[0].pmIdx = 0;
732 pdsch->beamPdschInfo.prg[0].beamIdx[0] = 0;
733 pdsch->txPdschPower.powerControlOffset = 0;
734 pdsch->txPdschPower.powerControlOffsetSS = 0;
739 /**********************************************************************
741 **********************************************************************/