+ dlSchedInfo.msg4Alloc = msg4Alloc;
+
+ /* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */
+ memcpy(&msg4Alloc->msg4Info, cell->schDlSlotInfo[slot]->msg4Info, \
+ sizeof(Msg4Info));
+
+ /* pdcch and pdsch data is filled */
+ schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.msg4Time.slot);
+
+ /* PUCCH resource */
+ schAllocPucchResource(cell, msg4Alloc->msg4Info.crnti, dlSchedInfo.schSlotValue.msg4Time.slot);
+
+ SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, sizeof(Msg4Info));
+ cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info = NULL;
+ }
+ /* check if UL grant must be sent in this slot for a SR/BSR that had been received */
+ for(ueIdx=0; ueIdx<cell->numActvUe; ueIdx++)
+ {
+ uint32_t totDataReq = 0; /* in bytes */
+ DciInfo *dciInfo = NULLP;
+ SchUeCb *ueCb = NULLP;
+
+ ueCb = &cell->ueCb[ueIdx];
+ /* check for SR */
+ if(ueCb->srRcvd)
+ {
+ totDataReq = UL_GRANT_SIZE; /*fixing so that all control msgs can be handled in SR */
+ ueCb->srRcvd = false;
+ }
+ /* check for BSR */
+ for(lcgIdx=0; lcgIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcgIdx++)
+ {
+ totDataReq+= ueCb->bsrInfo[lcgIdx].dataVol;
+ ueCb->bsrInfo[lcgIdx].dataVol = 0;
+ }
+ if(totDataReq > 0) /* UL grant must be provided for this UE in this slot */
+ {
+ SchPuschInfo schPuschInfo;
+ memset(&schPuschInfo, 0, sizeof(SchPuschInfo));
+
+ SCH_ALLOC(dciInfo, sizeof(DciInfo));
+ if(!dciInfo)
+ {
+ DU_LOG("\nMAC: Memory Allocation failed for dciInfo alloc");
+ return RFAILED;
+ }
+ memset(dciInfo,0,sizeof(DciInfo));
+ /* update the SFN and SLOT */
+ memcpy(&dlSchedInfo.schSlotValue.ulDciTime, slotInd, sizeof(SlotIndInfo));
+ slot = dlSchedInfo.schSlotValue.ulDciTime.slot;
+ /* Update PUSCH allocation */
+ schFillPuschAlloc(ueCb, slot, totDataReq, &schPuschInfo);
+ /* Fill DCI for UL grant */
+ schFillUlDci(ueCb, schPuschInfo, dciInfo);
+ memcpy(&dciInfo->slotIndInfo, &dlSchedInfo.schSlotValue.ulDciTime, sizeof(SlotIndInfo));
+ dlSchedInfo.ulGrant = dciInfo;
+ }
+ }