+ if(dlSchedInfo->rarAlloc[ueIdx] != NULLP)
+ {
+ currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlSchedInfo->schSlotValue.rarTime.slot];
+ currDlSlot->dlInfo.rarAlloc[ueIdx] = dlSchedInfo->rarAlloc[ueIdx];
+
+ /* MUXing of RAR */
+ fillRarPdu(&currDlSlot->dlInfo.rarAlloc[ueIdx]->rarInfo);
+ }
+
+ if(dlSchedInfo->dlMsgAlloc[ueIdx] != NULLP)
+ {
+ currDlSlot = &macCb.macCell[cellIdx]->\
+ dlSlot[dlSchedInfo->schSlotValue.dlMsgTime.slot];
+ currDlSlot->dlInfo.dlMsgAlloc[ueIdx] = dlSchedInfo->dlMsgAlloc[ueIdx]; /* copy msg4 alloc pointer in MAC slot info */
+ currDlSlot->dlInfo.cellId = dlSchedInfo->cellId;
+
+ if(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgPdcchCfg && dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgPdcchCfg->coresetCfg.coreSetType == CORESET_TYPE0)
+ {
+ MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].macMsg4Status, sizeof(bool));
+ }
+
+ /* Check if the downlink pdu is msg4 */
+ if((macCb.macCell[cellIdx]->macRaCb[ueIdx].macMsg4Status))
+ {
+ GET_UE_ID(dlSchedInfo->dlMsgAlloc[ueIdx]->crnti, ueId);
+ ueIdx = ueId -1;
+ schedInfo = dlSchedInfo->dlMsgAlloc[ueIdx];
+ hqProcCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4HqInfo;
+
+ if(!dlSchedInfo->dlMsgAlloc[ueIdx]->transportBlock[0].ndi)
+ {
+ /* First transmission of MSG4 */
+ hqProcCb->procId = schedInfo->harqProcNum;
+ for(cwIdx = 0; cwIdx < schedInfo->dlMsgPdschCfg->numCodewords; cwIdx++)
+ {
+ memcpy(&hqProcCb->tbInfo[hqProcCb->numTb].txTime, &dlSchedInfo->schSlotValue.dlMsgTime, \
+ sizeof(SlotTimingInfo));
+ hqProcCb->tbInfo[hqProcCb->numTb].tbSize = schedInfo->dlMsgPdschCfg->codeword[cwIdx].tbSize;
+ hqProcCb->numTb++;
+ }
+ }
+ else
+ {
+ /* MSG4 retransmission */
+ if(hqProcCb->procId == schedInfo->harqProcNum)
+ {
+ memcpy(&hqProcCb->tbInfo[0].txTime, &dlSchedInfo->schSlotValue.dlMsgTime, \
+ sizeof(SlotTimingInfo));
+ }
+ }
+ }
+ else
+ {
+ memcpy(&currDlSlot->dlInfo.schSlotValue, &dlSchedInfo->schSlotValue, sizeof(SchSlotValue));
+
+ if(!dlSchedInfo->dlMsgAlloc[ueIdx]->transportBlock[0].ndi)
+ {
+ /* If new data transmission is scheduled, send schedule results to RLC */
+ if(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgPdschCfg)
+ {
+ sendSchedRptToRlc(currDlSlot->dlInfo, dlSchedInfo->schSlotValue.dlMsgTime, ueIdx, schInfoIdx);
+
+ /* Add HARQ Proc to DL HARQ Proc Entity in UE */
+ addDlHqProcInUe(currDlSlot->dlInfo.schSlotValue.dlMsgTime, &macCb.macCell[cellIdx]->ueCb[ueIdx], \
+ dlSchedInfo->dlMsgAlloc[ueIdx]);
+ }
+ }
+ else
+ {
+ /* For retransmission, fetch PDU to be retransmitted from DL HARQ entity and schedule on corresponding slot */
+
+ /* As of now this loop will run only once for one TB.
+ * TODO : update handling of fetched TB appropriately when support for two TB is added
+ */
+ for(cwIdx = 0; cwIdx < dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgPdschCfg->numCodewords; cwIdx++)
+ {
+ /* Fetch TB to be retransmitted */
+ txPduLen = dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgPdschCfg->codeword[cwIdx].tbSize;
+ retxTb = fetchTbfromDlHarqProc(currDlSlot->dlInfo.schSlotValue.dlMsgTime, \
+ &macCb.macCell[cellIdx]->ueCb[ueIdx], \
+ dlSchedInfo->dlMsgAlloc[ueIdx]->harqProcNum, txPduLen);
+
+ /* Store PDU in corresponding DL slot */
+ MAC_ALLOC(txPdu, txPduLen);
+ if(!txPdu)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed in MacProcDlAlloc");
+ return RFAILED;
+ }
+ memcpy(txPdu, retxTb, txPduLen);
+
+ currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPduLen = txPduLen;
+ currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdu = txPdu;
+ }
+ }
+ }
+ }