+/**
+ * @brief process DL Paging allocation from scheduler
+ *
+ * @details
+ *
+ * Function : MacProcDlPageAlloc
+ *
+ * This function copied dl Pag info in the mac slot info
+ *
+ * @param[in] Pst *pst
+ * @param[in] DL Paging allocation from scheduler
+ * @return
+ * -# ROK
+ * -# RFAILED
+ **/
+uint8_t MacProcDlPageAlloc(Pst *pst, DlPageAlloc *dlPageAlloc)
+{
+ uint16_t cellIdx = 0;
+ MacDlSlot *currDlSlot = NULLP;
+
+#ifdef CALL_FLOW_DEBUG_LOG
+ DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_DL_PAGING_ALLOC\n");
+#endif
+ if(dlPageAlloc != NULLP)
+ {
+ GET_CELL_IDX(dlPageAlloc->cellId, cellIdx);
+
+ currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlPageAlloc->dlPageTime.slot];
+ MAC_ALLOC(currDlSlot->pageAllocInfo, sizeof(DlPageAlloc));
+ if(currDlSlot->pageAllocInfo == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : MacProcDlPageAlloc : Memory Allocation is failed!");
+ return RFAILED;
+ }
+ memcpy(currDlSlot->pageAllocInfo, dlPageAlloc, sizeof(DlPageAlloc));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : DL Paging Allocation is failed!");
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/**
+ * @brief Forming and filling the MUX Pdu
+ * @details
+ *
+ * Function : fillMsg4Pdu
+ *
+ * Forming and filling of Msg4Pdu
+ *
+ * @param[in] DlMsgAlloc *msg4Alloc
+ * @return void
+ **/
+void fillMsg4Pdu(uint16_t cellId, DlMsgSchInfo *msg4SchInfo)
+{
+ uint8_t ueId = 0, ueIdx = 0;
+ uint16_t cellIdx;
+ uint16_t msg4TxPduLen;
+ MacDlData msg4DlData;
+ MacCeInfo macCeData;
+ DlHarqProcCb *hqProcCb;
+
+ GET_CELL_IDX(cellId, cellIdx);
+
+ memset(&msg4DlData, 0, sizeof(MacDlData));
+ memset(&macCeData, 0, sizeof(MacCeInfo));
+
+ GET_UE_ID(msg4SchInfo->crnti, ueId);
+ ueIdx = ueId -1;
+
+ if(macCb.macCell[cellIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC: Cell Id[%d] not found", cellId);
+ return;
+ }
+
+ hqProcCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4HqInfo;
+ msg4TxPduLen = hqProcCb->tbInfo[0].tbSize - TX_PAYLOAD_HDR_LEN;
+
+ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu != NULLP)
+ {
+ MAC_ALLOC(msg4DlData.pduInfo[msg4DlData.numPdu].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+ if(msg4DlData.pduInfo[msg4DlData.numPdu].dlPdu != NULLP)
+ {
+ fillMsg4DlData(&msg4DlData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen, \
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu);
+ fillMacCe(&macCeData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu);
+
+ /* Forming Mux Pdu */
+ hqProcCb->tbInfo[0].tb = NULLP;
+ MAC_ALLOC(hqProcCb->tbInfo[0].tb, msg4TxPduLen);
+ if(hqProcCb->tbInfo[0].tb != NULLP)
+ {
+ memset(hqProcCb->tbInfo[0].tb, 0, msg4TxPduLen);
+ macMuxPdu(&msg4DlData, &macCeData, hqProcCb->tbInfo[0].tb, msg4TxPduLen);
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC: Failed allocating memory for msg4TxPdu");
+ }
+ /* Free memory allocated */
+ MAC_FREE(msg4DlData.pduInfo[msg4DlData.numPdu-1].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+ MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu = NULLP;
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = 0;
+ msg4DlData.numPdu--;
+
+ }
+ }
+
+ /* storing msg4 Pdu in macDlSlot */
+ if(hqProcCb->tbInfo[0].tb)
+ {
+ msg4SchInfo->dlMsgPduLen = msg4TxPduLen;
+ MAC_ALLOC(msg4SchInfo->dlMsgPdu, msg4SchInfo->dlMsgPduLen);
+ if(msg4SchInfo->dlMsgPdu != NULLP)
+ {
+ memcpy(msg4SchInfo->dlMsgPdu, hqProcCb->tbInfo[0].tb, \
+ msg4SchInfo->dlMsgPduLen);
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC: Failed at fillMsg4Pdu()");
+ }
+}
+
+/**
+ * @brief Builds and Send the Muxed Pdu to Lower MAC
+ *
+ * @details
+ *
+ * Function : buildAndSendMuxPdu
+ *
+ * Build and Sends the Muxed Pdu to Lower MAC.
+ *
+ * @param[in] SlotTimingInfo *slotInd
+ * @return void
+ **/
+
+void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo)
+{
+ uint8_t ueIdx;
+ uint16_t cellIdx;
+ MacDlSlot *currDlSlot = NULLP;
+ SlotTimingInfo muxTimingInfo;
+ memset(&muxTimingInfo, 0, sizeof(SlotTimingInfo));
+
+ GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
+
+ ADD_DELTA_TO_TIME(currTimingInfo, muxTimingInfo, PHY_DELTA_DL, macCb.macCell[cellIdx]->numOfSlots);
+ currDlSlot = &macCb.macCell[cellIdx]->dlSlot[muxTimingInfo.slot];
+
+ for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
+ {
+ if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx])
+ {
+ if((macCb.macCell[cellIdx]->macRaCb[ueIdx].macMsg4Status)&& (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg))
+ {
+ fillMsg4Pdu(currTimingInfo.cellId, currDlSlot->dlInfo.dlMsgAlloc[ueIdx]);
+ }
+ }
+ }
+}
+