uint8_t fillMsg4TxDataReq(fapi_tx_pdu_desc_t *pduDesc, Msg4Info *msg4Info,
uint32_t *msgLen, uint16_t pduIndex)
{
+ uint16_t idx = 0;
uint32_t pduLen = 0;
uint32_t *msg4TxDataValue = NULLP;
{
return RFAILED;
}
- memcpy(msg4TxDataValue, msg4Info->msg4Pdu, msg4Info->msg4PduLen);
+ for(idx = 0; idx < msg4Info->msg4PduLen; idx++)
+ {
+ msg4TxDataValue[idx] = msg4Info->msg4Pdu[idx];
+ }
pduDesc[pduIndex].tlvs[0].value = (uint32_t)msg4TxDataValue;
/* The total length of the PDU description and PDU data */
MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc));
dlInfo->rarAlloc = NULLP;
}
- if(dlInfo->msg4Alloc != NULLP)
+ if(dlInfo->msg4Alloc != NULLP && dlInfo->msg4Alloc->msg4Info.msg4Pdu != NULLP)
{
fillMsg4TxDataReq(txDataReq->pduDesc, &dlInfo->msg4Alloc->\
msg4Info, &msgLen, pduIndex);
pduIndex++;
txDataReq->numPdus++;
-
+
+ MAC_FREE(dlInfo->msg4Alloc->msg4Info.msg4Pdu,\
+ dlInfo->msg4Alloc->msg4Info.msg4PduLen);
+ dlInfo->msg4Alloc->msg4Info.msg4Pdu = NULLP;
MAC_FREE(dlInfo->msg4Alloc,sizeof(Msg4Alloc));
dlInfo->msg4Alloc = NULLP;
}
void fillMacToSchPst(Pst *pst);
void fillRarPdu(RarInfo *rarInfo);
void createMacRaCb(uint16_t cellId, uint16_t crnti);
-void fillMsg4DlData(MacDlData *dlData);
-void fillMacCe(MacCeInfo *macCeData);
-void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize);
+void fillMsg4DlData(MacDlData *dlData, uint8_t *msg4Pdu);
+void fillMacCe(MacCeInfo *macCeData, uint8_t *msg3Pdu);
+void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize);
int unpackRxData(RxDataIndPdu *rxDataIndPdu);
uint16_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti);
+void BuildAndSendMsg4MuxPdu(Msg4Alloc *msg4Alloc);
#endif
/**********************************************************************
* @details
*
* Function : fillMsg4DlData
- * This function is a stub which sends Dl Data
+ * This function sends Dl Data
* to form MAC SDUs
*
* @param[in] MacDlData *dlData
+ * msg4Pdu pointer
************************************************/
-void fillMsg4DlData(MacDlData *dlData)
+void fillMsg4DlData(MacDlData *dlData, uint8_t *msg4Pdu)
{
uint8_t idx = 0;
uint16_t idx2;
dlData->pduInfo[idx].pduLen = macCb.macCell->macRaCb[idx].msg4PduLen;
for(idx2 = 0; idx2 < dlData->pduInfo[idx].pduLen; idx2++)
{
- dlData->pduInfo[idx].dlPdu[idx2] = \
- macCb.macCell->macRaCb[idx].msg4Pdu[idx2];
+ dlData->pduInfo[idx].dlPdu[idx2] = msg4Pdu[idx2];
}
}
* This function fills Mac ce identities
*
* @param[in] RlcMacData *dlData
+ * Msg3Pdu Data
************************************************/
-void fillMacCe(MacCeInfo *macCeInfo)
+void fillMacCe(MacCeInfo *macCeInfo, uint8_t *msg3Pdu)
{
uint8_t idx;
macCeInfo->numCes = 1;
{
macCeInfo->macCe[idx].macCeLcid = MAC_LCID_CRI;
memcpy(macCeInfo->macCe[idx].macCeValue, \
- macCb.macCell->macRaCb[idx].msg3Pdu, MAX_CRI_SIZE);
+ msg3Pdu, MAX_CRI_SIZE);
}
}
* Functionality:
* The MAC PDU will be MUXed and formed
*
- * @params[in] MacDlData *, MacCeInfo *, tbSize
+ * @params[in] MacDlData *, MacCeInfo *, msg4TxPdu *, tbSize
* @return void
- *
* ****************************************************************/
-void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize)
+void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize)
{
uint8_t bytePos = 0;
uint8_t bitPos = 7;
}
/*Storing the muxed pdu in macRaCb */
- macCb.macCell->macRaCb[0].msg4TxPdu = NULLP;
- MAC_ALLOC(macCb.macCell->macRaCb[0].msg4TxPdu, macCb.macCell->macRaCb[0].msg4TbSize);
- if(macCb.macCell->macRaCb[0].msg4TxPdu != NULLP)
+ if(msg4TxPdu != NULLP)
{
- memcpy(macCb.macCell->macRaCb[0].msg4TxPdu, macPdu,\
- macCb.macCell->macRaCb[0].msg4TbSize);
+ memcpy(msg4TxPdu, macPdu, tbSize);
}
}
if(dlSchedInfo->msg4Alloc != NULLP)
{
Msg4Alloc *msg4Alloc = NULLP;
- MacDlData msg4DlData;
- MacCeInfo macCeData;
-
currDlSlot = &macCb.macCell->dlSlot[dlSchedInfo->schSlotValue.msg4Time.slot];
currDlSlot->dlInfo.msg4Alloc = dlSchedInfo->msg4Alloc; /* copy msg4 alloc pointer in MAC slot info */
msg4Alloc = dlSchedInfo->msg4Alloc;
+ macCb.macCell->macRaCb[0].msg4TbSize = msg4Alloc->msg4PdschCfg.codeword[0].tbSize;
+ }
+ }
+ return ROK;
+}
- memset(&msg4DlData, 0, sizeof(MacDlData));
- memset(&macCeData, 0, sizeof(MacCeInfo));
+void BuildAndSendMsg4MuxPdu(Msg4Alloc *msg4Alloc)
+{
+ MacDlData msg4DlData;
+ MacCeInfo macCeData;
- macCb.macCell->macRaCb[0].msg4TbSize = msg4Alloc->msg4PdschCfg.codeword[0].tbSize;
+ memset(&msg4DlData, 0, sizeof(MacDlData));
+ memset(&macCeData, 0, sizeof(MacCeInfo));
- if(macCb.macCell->macRaCb[0].msg4Pdu != NULLP)
+ if(macCb.macCell->macRaCb[0].msg4Pdu != NULLP)
+ {
+ MAC_ALLOC(msg4DlData.pduInfo[0].dlPdu, \
+ macCb.macCell->macRaCb[0].msg4PduLen);
+ if(msg4DlData.pduInfo[0].dlPdu != NULLP)
+ {
+ fillMsg4DlData(&msg4DlData, macCb.macCell->macRaCb[0].msg4Pdu);
+ fillMacCe(&macCeData, &macCb.macCell->macRaCb[0].msg3Pdu);
+ /* Forming Mux Pdu */
+ macCb.macCell->macRaCb[0].msg4TxPdu = NULLP;
+ MAC_ALLOC(macCb.macCell->macRaCb[0].msg4TxPdu, macCb.macCell->macRaCb[0].msg4TbSize);
+ if(macCb.macCell->macRaCb[0].msg4TxPdu != NULLP)
{
- MAC_ALLOC(msg4DlData.pduInfo[0].dlPdu, \
- macCb.macCell->macRaCb[0].msg4PduLen);
- if(msg4DlData.pduInfo[0].dlPdu != NULLP)
- {
- fillMsg4DlData(&msg4DlData);
- }
- }
-
- /* MUXing for msg4 */
- fillMacCe(&macCeData);
- macMuxPdu(&msg4DlData, &macCeData, macCb.macCell->macRaCb[0].msg4TbSize);
-
- /* storing msg4 Pdu in macDlSlot */
- if(macCb.macCell->macRaCb[0].msg4TxPdu)
- {
- msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4TbSize;
- MAC_ALLOC(msg4Alloc->msg4Info.msg4Pdu, msg4Alloc->msg4Info.msg4PduLen);
- if(msg4Alloc->msg4Info.msg4Pdu != NULLP)
- {
- memcpy(msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4TxPdu, \
- msg4Alloc->msg4Info.msg4PduLen);
- }
+ memset(macCb.macCell->macRaCb[0].msg4TxPdu, 0, macCb.macCell->macRaCb[0].msg4TbSize);
+ macMuxPdu(&msg4DlData, &macCeData, macCb.macCell->macRaCb[0].msg4TxPdu,\
+ macCb.macCell->macRaCb[0].msg4TbSize);
+
}
else
{
- DU_LOG("\nMAC: Failed at macMuxPdu()");
- return RFAILED;
+ DU_LOG("\nMAC: Failed allocating memory for msg4TxPdu");
}
- /* TODO: Free all allocated memory, after the usage */
- /* MAC_FREE(macCb.macCell->macRaCb[0].msg4TxPdu, \
- macCb.macCell->macRaCb[0].msg4TbSize); // TODO: To be freed after re-transmission is successful.
- MAC_FREE(dlSchedInfo->msg4Alloc->msg4Info.msg4Pdu,\
- macCb.macCell->macRaCb[0].msg4PduLen); //TODO: To be freed after lower-mac is succesfull
- MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell->macRaCb[0].msg4PduLen);
- MAC_FREE(macCb.macCell->macRaCb[0].msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen); */
+ /* Free memory allocated */
+ MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell->macRaCb[0].msg4PduLen);
}
}
- return ROK;
+
+ /* storing msg4 Pdu in macDlSlot */
+ if(macCb.macCell->macRaCb[0].msg4TxPdu)
+ {
+ msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4TbSize;
+ MAC_ALLOC(msg4Alloc->msg4Info.msg4Pdu, msg4Alloc->msg4Info.msg4PduLen);
+ if(msg4Alloc->msg4Info.msg4Pdu != NULLP)
+ {
+ memcpy(msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4TxPdu, \
+ msg4Alloc->msg4Info.msg4PduLen);
+ }
+ }
+ else
+ {
+ DU_LOG("\nMAC: Failed at macMuxPdu()");
+ }
+ /* TODO: Free all allocated memory, after the usage */
+ /* MAC_FREE(macCb.macCell->macRaCb[0].msg4TxPdu, \
+ macCb.macCell->macRaCb[0].msg4TbSize); // TODO: To be freed after re-transmission is successful.
+ MAC_FREE(macCb.macCell->macRaCb[0].msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen); */
}
/**
}
#endif
-
+ /* Mux Pdu for Msg4 */
+ SlotIndInfo muxTimingInfo;
+ memset(&muxTimingInfo, 0, sizeof(SlotIndInfo));
+ MacDlSlot *currDlSlot = NULLP;
+ ADD_DELTA_TO_TIME(slotInd, muxTimingInfo, PHY_DELTA);
+ currDlSlot = &macCb.macCell->dlSlot[muxTimingInfo.slot];
+ if(currDlSlot->dlInfo.msg4Alloc)
+ {
+ BuildAndSendMsg4MuxPdu(currDlSlot->dlInfo.msg4Alloc);
+ currDlSlot = NULLP;
+ }
+
/* Trigger for DL TTI REQ */
handleDlTtiReq(slotInd);