+ while(ueIdx < MAX_NUM_UE)
+ {
+ if(cell->raReq[ueIdx] == NULLP)
+ {
+ ueIdx++;
+ continue;
+ }
+
+ //puschMu = cell->cellCfg.puschMu;
+ delta = puschDeltaTable[puschMu];
+ k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2;
+
+ /* RAR will sent with a delay of RAR_DELAY */
+ rarSlot = (currTime.slot + RAR_DELAY + PHY_DELTA_DL) % cell->numSlots;
+#ifdef NR_TDD
+ for(slotIdx=0; slotIdx<cell->numSlots;slotIdx++)
+ {
+ /* Slot allocation for msg3 based on 38.214 section 6.1.2.1 */
+ msg3Slot = (rarSlot+delta+k2)%cell->numSlots;
+
+ if((schGetSlotSymbFrmt(rarSlot, cell->slotFrmtBitMap) != DL_SLOT) &&\
+ (schGetSlotSymbFrmt(msg3Slot, cell->slotFrmtBitMap) != UL_SLOT))
+ {
+ rarSlot = (rarSlot + 1) % cell->numSlots;
+ continue;
+ }
+ break;
+ }
+ if(slotIdx>=cell->numSlots)
+ {
+ DU_LOG("\nERROR --> SCH : NO Slot for Msg2 with Msg3 Grant\n");
+ return RFAILED;
+ }
+#else
+ /* Slot allocation for msg3 based on 38.214 section 6.1.2.1 */
+ msg3Slot = rarSlot + k2 + delta;
+ msg3Slot = msg3Slot % cell->numSlots;
+#endif
+
+ SchDlSlotInfo *schDlSlotInfo = cell->schDlSlotInfo[rarSlot]; /* RAR will sent in the next slot */
+
+ /* Allocate the rarInfo, this pointer will be checked at schProcessSlotInd function */
+ SCH_ALLOC(rarInfo, sizeof(RarInfo));
+ if(rarInfo == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH : Memory Allocation failed for rarInfo");
+ return RFAILED;
+ }
+
+ schDlSlotInfo->rarInfo = rarInfo;
+
+ /* create raCb at SCH */
+ createSchRaCb(cell->raReq[ueIdx]->rachInd->crnti, cell->instIdx);
+
+ /* allocate resources for msg3 */
+ msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, rarSlot, cell->raReq[ueIdx]->rachInd->crnti, msg3Slot);
+ if(msg3PuschInfo)
+ {
+ /* fill RAR info */
+ rarInfo->raRnti = cell->raReq[ueIdx]->raRnti;
+ rarInfo->tcrnti = cell->raReq[ueIdx]->rachInd->crnti;
+ rarInfo->RAPID = cell->raReq[ueIdx]->rachInd->preambleIdx;
+ rarInfo->ta = cell->raReq[ueIdx]->rachInd->timingAdv;
+ rarInfo->ulGrant.bwpSize = cell->cellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb;
+ /* Spec 38.213, section 8.2, 0 : MSG3 PUSCH will be transmitted without frequency hopping */
+ rarInfo->ulGrant.freqHopFlag = 0;
+ rarInfo->ulGrant.msg3FreqAlloc.startPrb = msg3PuschInfo->fdAlloc.startPrb;
+ rarInfo->ulGrant.msg3FreqAlloc.numPrb = msg3PuschInfo->fdAlloc.numPrb;
+ rarInfo->ulGrant.k2Index = k2Index;
+ rarInfo->ulGrant.mcs = msg3PuschInfo->tbInfo.mcs;
+ rarInfo->ulGrant.tpc = 3; /* TODO : Check appropriate value to be filled */
+ /* Spec 38.213, section 8.2 : In a contention based random access
+ * procedure, the CSI request field is reserved. */
+ rarInfo->ulGrant.csiReq = 0;
+ }
+
+ SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo));
+ SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq));
+ ueIdx++;
+
+ } /* End of while(ueIdx < MAX_NUM_UE) */
+}