+/**
+ * @brief Forming anf filling the MUX Pdu
+ * @details
+ *
+ * Function : fillMsg4Pdu
+ *
+ * Forming and filling of Msg4Pdu
+ *
+ * @param[in] DlMsgAlloc *msg4Alloc
+ * @return void
+ **/
+void fillMsg4Pdu(uint16_t cellId, DlMsgAlloc *msg4Alloc)
+{
+ uint8_t ueIdx;
+ uint16_t cellIdx;
+ MacDlData msg4DlData;
+ MacCeInfo macCeData;
+
+ GET_CELL_IDX(cellId, cellIdx);
+
+ memset(&msg4DlData, 0, sizeof(MacDlData));
+ memset(&macCeData, 0, sizeof(MacCeInfo));
+
+ GET_UE_IDX(msg4Alloc->dlMsgInfo.crnti, ueIdx);
+ ueIdx = ueIdx -1;
+ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu != NULLP)
+ {
+ MAC_ALLOC(msg4DlData.pduInfo[ueIdx].dlPdu, \
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+ if(msg4DlData.pduInfo[ueIdx].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 */
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu = NULLP;
+ MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
+ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu != NULLP)
+ {
+ memset(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, 0, \
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
+ macMuxPdu(&msg4DlData, &macCeData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu,\
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
+
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC: Failed allocating memory for msg4TxPdu");
+ }
+ /* Free memory allocated */
+ MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+ }
+ }
+
+ /* storing msg4 Pdu in macDlSlot */
+ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu)
+ {
+ msg4Alloc->dlMsgInfo.dlMsgPduLen = macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize;
+ MAC_ALLOC(msg4Alloc->dlMsgInfo.dlMsgPdu, msg4Alloc->dlMsgInfo.dlMsgPduLen);
+ if(msg4Alloc->dlMsgInfo.dlMsgPdu != NULLP)
+ {
+ memcpy(msg4Alloc->dlMsgInfo.dlMsgPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
+ msg4Alloc->dlMsgInfo.dlMsgPduLen);
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC: Failed at macMuxPdu()");
+ }
+}
+
+/**
+ * @brief Builds and Send the Muxed Pdu to Lower MAC
+ *
+ * @details
+ *
+ * Function : buildAndSendMuxPdu
+ *
+ * Build and Sends the Muxed Pdu to Lower MAC.
+ *
+ * @param[in] SlotIndInfo *slotInd
+ * @return void
+ **/
+
+void buildAndSendMuxPdu(SlotIndInfo currTimingInfo)
+{
+ uint16_t cellIdx;
+ MacDlSlot *currDlSlot = NULLP;
+ SlotIndInfo muxTimingInfo;
+ memset(&muxTimingInfo, 0, sizeof(SlotIndInfo));
+
+ GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
+
+ ADD_DELTA_TO_TIME(currTimingInfo, muxTimingInfo, PHY_DELTA_DL);
+ currDlSlot = &macCb.macCell[cellIdx]->dlSlot[muxTimingInfo.slot];
+ if(currDlSlot->dlInfo.dlMsgAlloc)
+ {
+ if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+ {
+ fillMsg4Pdu(currTimingInfo.cellId, currDlSlot->dlInfo.dlMsgAlloc);
+ currDlSlot = NULLP;
+ }
+ }
+}
+