+ else
+ {
+ /* First transmission of MSG4 */
+ if(cell->raCb[ueId-1].msg4recvd)
+ {
+ isMsg4Pending = true;
+ if(schProcessMsg4Req(cell, *slotInd, ueId, FALSE, &cell->ueCb[ueId-1].msg4Proc) == ROK)
+ isMsg4Scheduled = true;
+
+ /* If MSG4 scheduling failed, free the newly assigned HARQ process */
+ if(!isMsg4Scheduled)
+ schDlReleaseHqProcess(cell->ueCb[ueId-1].msg4Proc);
+ }
+ }
+
+ if(isRarPending || isMsg4Pending)
+ {
+ /* If RAR or MSG is successfully scheduled then
+ * remove UE from linked list since no pending msgs for this UE */
+ if(isRarScheduled || isMsg4Scheduled)
+ {
+ SCH_FREE(pendingUeNode->node, sizeof(uint8_t));
+ deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
+ }
+ /* If RAR/MSG4 is pending but couldnt be scheduled then,
+ * put this UE at the end of linked list to be scheduled later */
+ else
+ {
+ cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
+ }
+ }
+
+#ifdef NR_DRX
+ if((cell->ueCb[ueId-1].ueDrxInfoPres == true) && (cell->ueCb[ueId-1].drxUeCb.drxDlUeActiveStatus != true))
+ {
+ if(pendingUeNode->node)
+ {
+ cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
+ }
+ }
+ else
+#endif
+ {
+
+ /* DL Data */
+ node = cell->ueCb[ueId-1].dlRetxHqList.first;
+ if(node != NULLP)
+ {
+ /* DL Data ReTransmisson */
+ isDlMsgPending = true;
+ isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId, TRUE, ((SchDlHqProcCb**) &(node->node)));
+ if(isDlMsgScheduled)
+ {
+#ifdef NR_DRX
+ schDrxStopDlHqRetxTmr(cell, &cell->ueCb[ueId-1], ((SchDlHqProcCb**) &(node->node)));
+#endif
+ cmLListDelFrm(&cell->ueCb[ueId-1].dlRetxHqList, node);
+ }
+ }
+ else
+ {
+ /* DL Data new transmission */
+ if((cell->boIndBitMap) & (1<<ueId))
+ {
+ isDlMsgPending = true;
+ isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId, FALSE, &hqP);
+
+ /* If DL scheduling failed, free the newly assigned HARQ process */
+ if(!isDlMsgScheduled)
+ schDlReleaseHqProcess(hqP);
+ else
+ {
+#ifdef NR_DRX
+ schHdlDrxInActvStrtTmr(cell, &cell->ueCb[ueId-1], PHY_DELTA_DL + SCHED_DELTA);
+#endif
+ }
+ }
+ }
+
+ /* Scheduling of UL grant */
+ node = cell->ueCb[ueId-1].ulRetxHqList.first;
+ if(node != NULLP)
+ {
+ /* UL Data ReTransmisson */
+ isUlGrantPending = true;
+ isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, TRUE, (SchUlHqProcCb**) &(node->node));
+ if(isUlGrantScheduled)
+ {
+#ifdef NR_DRX
+ schDrxStopUlHqRetxTmr(cell, &cell->ueCb[ueId-1], ((SchUlHqProcCb**) &(node->node)));
+#endif
+ cmLListDelFrm(&cell->ueCb[ueId-1].ulRetxHqList, node);
+ }
+ }
+ else
+ {
+ /* UL Data new transmission */
+ if(cell->ueCb[ueId-1].srRcvd || cell->ueCb[ueId-1].bsrRcvd)
+ {
+ isUlGrantPending = true;
+ isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, FALSE, &ulHqP);
+ if(!isUlGrantScheduled)
+ schUlReleaseHqProcess(ulHqP, FALSE);
+ else
+ {
+#ifdef NR_DRX
+ schHdlDrxInActvStrtTmr(cell, &cell->ueCb[ueId-1], PHY_DELTA_UL + SCHED_DELTA);
+#endif
+ }
+ }
+ }
+
+ if(!isUlGrantPending && !isDlMsgPending)
+ {
+ /* No action required */
+ }
+ else if((isUlGrantPending && !isUlGrantScheduled) || (isDlMsgPending && !isDlMsgScheduled))
+ {
+ cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
+ }
+ else
+ {
+ SCH_FREE(ueNode, sizeof(uint8_t));
+ deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
+ }
+ }
+ }
+ }
+
+ /* Check if any PDU is scheduled at this slot for any UE */
+ for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
+ {
+ /* If RAR PDCCH/PDSCH is scheduled for a UE at this slot, fill RAR specific interface
+ * structure to send to MAC */
+ if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc[ueIdx] != NULLP)
+ {
+ slot = dlSchedInfo.schSlotValue.rarTime.slot;
+ dlSchedInfo.rarAlloc[ueIdx] = cell->schDlSlotInfo[slot]->rarAlloc[ueIdx];
+ cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP;
+ }
+
+ /* If DL-Msg PDCCH/PDSCH is scheduled for a UE at this slot, fill
+ * specific interface structure to send to MAC */
+ if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx] != NULLP)
+ {
+ slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
+ dlSchedInfo.dlMsgAlloc[ueIdx] = cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx];
+ cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx] = NULLP;