pduIndex++;
numPduEncoded++;
}
-
DU_LOG("\033[1;34m");
DU_LOG("\nDEBUG --> LWR_MAC: SIB1 sent...");
DU_LOG("\033[0m");
for(schInfoIdx=0; schInfoIdx < dlInfo->dlMsgAlloc[ueIdx]->numSchedInfo; schInfoIdx++)
{
if((dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH) || \
- (dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU))
+ (dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU))
{
fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, \
&dlInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo, \
uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
uint8_t lcId, uint16_t pduLen, uint8_t *pdu);
uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx);
+uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
+ DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS]);
#endif
/**********************************************************************
End of file
uint8_t ueIdx = 0; /* Iterator for UE list */
uint8_t lcId = 0; /* LC ID of a sub pdu */
uint8_t fBit = 0; /* Value of F Bit in MAC sub-header */
- uint8_t idx = 0; /* Iterator for received PDU */
+ uint8_t rxPduIdx = 0; /* Iterator for received PDU */
uint16_t length = 0; /* Length of payload in a sub-PDU */
uint8_t *pdu = NULLP; /* Payload in sub-PDU */
uint16_t pduLen = 0; /* Length of undecoded PDU */
uint8_t ret =ROK;
GET_CELL_IDX(cellId, cellIdx);
+
+ if(rxDataIndPdu == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC: Rx Data is empty");
+ return RFAILED;
+ }
+
+ if(macCb.macCell[cellIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> CellId :%d is not created, as CellCB is empty", cellId);
+ return RFAILED;
+ }
pduLen = rxDataIndPdu->pduLength;
rxDataPdu = rxDataIndPdu->pduData;
GET_UE_IDX(rxDataIndPdu->rnti, ueIdx);
while(pduLen > 0)
{
/* MSB in 1st octet is Reserved bit. Hence not decoding it.
- 2nd MSB in 1st octet is R/F bit depending upon type of payload */
- fBit = (1 << 7) & rxDataPdu[idx];
+ 2nd MSB in 1st octet is R/F bit depending upon type of payload */
+ fBit = (1 << 7) & rxDataPdu[rxPduIdx];
/* LC id is the 6 LSB in 1st octet */
- lcId = (~((~0) << 6)) & rxDataPdu[idx];
+ lcId = (~((~0) << 6)) & rxDataPdu[rxPduIdx];
+ pdu = NULLP;
switch(lcId)
{
- case MAC_LCID_CCCH :
- {
- pduLen--;
-
- /* for UL CCCH,fixed length of MAC SDU */
- length = 6;
-
- /* Allocating sharable memory to send ul ccch msg to du app*/
- MAC_ALLOC_SHRABL_BUF(pdu, length);
- if(!pdu)
- {
- DU_LOG("\nERROR --> MAC : UL CCCH PDU memory allocation failed");
- return RFAILED;
- }
- idx++;
- memcpy(pdu, &rxDataPdu[idx], length);
- pduLen -= length;
- idx = idx + length;
-
- /* store msg3 pdu in macRaCb for CRI value */
- memcpy(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu, pdu, length);
-
- /* Send UL-CCCH Indication to DU APP */
- ret = macProcUlCcchInd(macCb.macCell[cellIdx]->cellId, rxDataIndPdu->rnti, length, pdu);
- break;
- }
-
- case MAC_LCID_MIN ... MAC_LCID_MAX :
- {
- DU_LOG("\nINFO --> MAC : PDU received for LC ID %d", lcId);
- pduLen--;
- idx++;
-
- length = rxDataPdu[idx];
- if(fBit)
- {
- pduLen--;
- idx++;
- length = (length << 8) & rxDataPdu[idx];
- }
-
- /* Copying the payload to send to RLC */
- MAC_ALLOC_SHRABL_BUF(pdu, length);
- if(!pdu)
- {
- DU_LOG("\nERROR --> MAC : Memory allocation failed while demuxing Rx Data PDU");
- return RFAILED;
- }
- pduLen--;
- idx++;
- memcpy(pdu, &rxDataPdu[idx], length);
- pduLen -= length;
- idx = idx + length;
-
- /* Delete RA cb once RRC setup complete received */
- if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == rxDataIndPdu->rnti)
- {
- MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
- macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
- MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
- macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize - TX_PAYLOAD_HDR_LEN);
- memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
- }
-
- /* Send UL Data to RLC */
- ret = macProcUlData(cellId, rxDataIndPdu->rnti, slotInfo, lcId, length, pdu);
-
- break;
- }
- case MAC_LCID_RESERVED_MIN ... MAC_LCID_RESERVED_MAX :
- break;
-
- case MAC_LCID_CCCH_48BIT :
- break;
-
- case MAC_LCID_BIT_RATE_QUERY :
- break;
-
- case MAC_LCID_MULT_PHR_FOUR_OCT :
- break;
-
- case MAC_LCID_CFG_GRANT_CFM :
- break;
-
- case MAC_LCID_MULT_PHR_ONE_OCT:
- break;
-
- case MAC_LCID_SINGLE_PHR :
- break;
-
- case MAC_LCID_CRNTI :
- break;
-
- case MAC_LCID_SHORT_TRUNC_BSR :
- break;
-
- case MAC_LCID_LONG_TRUNC_BSR :
- break;
-
- case MAC_LCID_SHORT_BSR :
- {
- uint8_t lcgId = 0;
- uint8_t bufferSizeIdx = 0;
- uint8_t crnti = 0;
- uint32_t bufferSize = 0;
-
- pduLen--;
-
- idx++;
- crnti = rxDataIndPdu->rnti;
- /* 5 LSB bits in pdu represent buffer size */
- bufferSizeIdx = (~((~0) << 5)) & rxDataPdu[idx];
- /* first 3 MSB bits in pdu represent LCGID */
- lcgId = (rxDataPdu[idx]) >> 5;
- /* determine actual number of bytes requested */
- bufferSize = shortBsrBytesTable[bufferSizeIdx];
- ret = macProcShortBsr(macCb.macCell[cellIdx]->cellId, crnti, lcgId, bufferSize);
- pduLen--;
- idx++;
-
- break;
- }
-
- case MAC_LCID_LONG_BSR :
- break;
-
- case MAC_LCID_PADDING :
- break;
-
- default:
- {
- DU_LOG("\nERROR --> MAC : Invalid LC Id %d", lcId);
- return RFAILED;
- }
+ case MAC_LCID_CCCH :
+ {
+ pduLen--;
+
+ /* for UL CCCH,fixed length of MAC SDU */
+ length = 6;
+
+ /* Allocating sharable memory to send ul ccch msg to du app*/
+ MAC_ALLOC_SHRABL_BUF(pdu, length);
+ if(!pdu)
+ {
+ DU_LOG("\nERROR --> MAC : UL CCCH PDU memory allocation failed");
+ return RFAILED;
+ }
+ rxPduIdx++;
+ memcpy(pdu, &rxDataPdu[rxPduIdx], length);
+ pduLen -= length;
+ rxPduIdx = rxPduIdx + length;
+
+ /* store msg3 pdu in macRaCb for CRI value */
+ memcpy(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu, pdu, length);
+
+ /* Send UL-CCCH Indication to DU APP */
+ ret = macProcUlCcchInd(macCb.macCell[cellIdx]->cellId, rxDataIndPdu->rnti, length, pdu);
+ break;
+ }
+
+ case MAC_LCID_MIN ... MAC_LCID_MAX :
+ {
+ DU_LOG("\nINFO --> MAC : PDU received for LC ID %d", lcId);
+ pduLen--;
+ rxPduIdx++;
+
+ length = rxDataPdu[rxPduIdx];
+ if(fBit)
+ {
+ pduLen--;
+ rxPduIdx++;
+ length = (length << 8) & rxDataPdu[rxPduIdx];
+ }
+
+ pdu = NULLP;
+ /* Copying the payload to send to RLC */
+ MAC_ALLOC_SHRABL_BUF(pdu, length);
+ if(!pdu)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed while demuxing Rx Data PDU");
+ return RFAILED;
+ }
+ pduLen--;
+ rxPduIdx++;
+ memcpy(pdu, &rxDataPdu[rxPduIdx], length);
+ pduLen -= length;
+ rxPduIdx = rxPduIdx + length;
+
+ /* Delete RA cb once RRC setup complete received */
+ if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == rxDataIndPdu->rnti)
+ {
+ MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+ MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
+ macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize - TX_PAYLOAD_HDR_LEN);
+ memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
+ }
+
+ /* Send UL Data to RLC */
+ ret = macProcUlData(cellId, rxDataIndPdu->rnti, slotInfo, lcId, length, pdu);
+
+ break;
+ }
+ case MAC_LCID_RESERVED_MIN ... MAC_LCID_RESERVED_MAX :
+ break;
+
+ case MAC_LCID_CCCH_48BIT :
+ break;
+
+ case MAC_LCID_BIT_RATE_QUERY :
+ break;
+
+ case MAC_LCID_MULT_PHR_FOUR_OCT :
+ break;
+
+ case MAC_LCID_CFG_GRANT_CFM :
+ break;
+
+ case MAC_LCID_MULT_PHR_ONE_OCT:
+ break;
+
+ case MAC_LCID_SINGLE_PHR :
+ break;
+
+ case MAC_LCID_CRNTI :
+ break;
+
+ case MAC_LCID_SHORT_TRUNC_BSR :
+ break;
+
+ case MAC_LCID_LONG_TRUNC_BSR :
+ break;
+
+ case MAC_LCID_SHORT_BSR :
+ {
+ uint8_t lcgId = 0;
+ uint8_t bufferSizeIdx = 0;
+ uint8_t crnti = 0;
+ uint32_t bufferSize = 0;
+
+ pduLen--;
+
+ rxPduIdx++;
+ crnti = rxDataIndPdu->rnti;
+ /* 5 LSB bits in pdu represent buffer size */
+ bufferSizeIdx = (~((~0) << 5)) & rxDataPdu[rxPduIdx];
+ /* first 3 MSB bits in pdu represent LCGID */
+ lcgId = (rxDataPdu[rxPduIdx]) >> 5;
+ /* determine actual number of bytes requested */
+ bufferSize = shortBsrBytesTable[bufferSizeIdx];
+ ret = macProcShortBsr(macCb.macCell[cellIdx]->cellId, crnti, lcgId, bufferSize);
+ pduLen--;
+ rxPduIdx++;
+
+ break;
+ }
+
+ case MAC_LCID_LONG_BSR :
+ {
+ DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS];
+ memset(dataVolInfo, 0,MAX_NUM_LOGICAL_CHANNEL_GROUPS * sizeof(DataVolInfo));
+ uint8_t lcgIdx = 0;
+ uint8_t crnti = 0;
+ uint8_t numLcg = 0;
+ uint8_t lcgIdxPos = 0;
+ pduLen--;
+
+ rxPduIdx++;/*To reach the Octet where lcgIdx will be present*/
+ crnti = rxDataIndPdu->rnti;
+
+ lcgIdxPos = rxPduIdx;
+
+ pduLen--;
+ rxPduIdx++;/*To reach the Octet where bsrIdx starts*/
+ for(lcgIdx = 0; lcgIdx < MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcgIdx++)
+ {
+ if(rxDataPdu[lcgIdxPos] & (1 << lcgIdx))
+ {
+ if(rxDataPdu[rxPduIdx] > 0 && rxDataPdu[rxPduIdx] < MAX_LONG_BSR_TABLE_ENTRIES)
+ {
+ dataVolInfo[numLcg].dataVol = longBsrBytesTable[rxDataPdu[rxPduIdx]];
+ dataVolInfo[numLcg].lcgId = lcgIdx;
+ numLcg++;
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC: Invalid BsrIdx:%d rcvd for lcgIdx:%d",lcgIdx,rxDataPdu[rxPduIdx]);
+ }
+ /*next byte in PDU*/
+ pduLen--;
+ rxPduIdx++;
+ }
+ }
+
+ ret = macProcLongBsr(macCb.macCell[cellIdx]->cellId, crnti, numLcg, dataVolInfo);
+
+ break;
+ }
+
+ case MAC_LCID_PADDING :
+ break;
+
+ default:
+ {
+ DU_LOG("\nERROR --> MAC : Invalid LC Id %d", lcId);
+ return RFAILED;
+ }
} /* End of switch */
if(lcId == MAC_LCID_PADDING)
{
- break;
+ break;
}
} /* End of While */
* lcg ID
* buffer size
*
+ * @return ROK - success
+ * RFAILED - failure
*
* ****************************************************************/
uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
}
+/*******************************************************************
+ *
+ * @brief Processes received short BSR
+ *
+ * @details
+ *
+ * Function : macProcShortBsr
+ *
+ * Functionality:
+ * MAC sends Short BSR to SCH
+ *
+ * @params[in] cell ID
+ * crnti
+ * lcg ID
+ * buffer size
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
+ DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
+{
+ Pst pst;
+ UlBufferStatusRptInd bsrInd;
+ uint8_t lcgIdx = 0;
+
+ memset(&pst, 0, sizeof(Pst));
+ memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
+
+ bsrInd.cellId = cellId;
+ bsrInd.crnti = crnti;
+ bsrInd.bsrType = LONG_BSR;
+ bsrInd.numLcg = numLcg;
+
+ for(lcgIdx = 0; lcgIdx < numLcg; lcgIdx++)
+ memcpy(&(bsrInd.dataVolInfo[lcgIdx]), &(dataVolInfo[lcgIdx]), sizeof(DataVolInfo));
+
+ FILL_PST_MAC_TO_SCH(pst, EVENT_LONG_BSR);
+ return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
+}
+
/*******************************************************************
*
* @brief Builds and send SR UCI Indication to SCH
#include "common_def.h"
#include "mac_utils.h"
-
+/*!< This table is the Short BSR Table
+ * * Spec 38.321, Table 6.1.3.1-1*/
uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES] = { 0, 10, 14, 20, 28, \
38, 53, 74, 102, 142, 198, 276, 384, 535, 745, 1038, 1446, 2014, 2806, 3909, \
5446, 7587, 10570, 14726, 20516, 28581, 39818, 55474, 77284, 107669, 150000, \
150001 };
+/*!< This table is the Long BSR Table
+ * * Spec 38.321, Table 6.1.3.1-2*/
+uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES] = {
+ 0,10,11,12,13,14,15,16,
+ 17,18,19,20,22,23,25,26,
+ 28,30,32,34,36,38,40,43,
+ 46,49,52,55,59,62,66,71,
+ 75,80,85,91,97,103,110,117,
+ 124,132,141,150,160,170,181,193,
+ 205,218,233,248,264,281,299,318,
+ 339,361,384,409,436,464,494,526,
+ 560,597,635,677,720,767,817,870,
+ 926,987,1051,1119,1191,1269,1351,1439,
+ 1532,1631,1737,1850,1970,2098,2234,2379,
+ 2533,2698,2873,3059,3258,3469,3694,3934,
+ 4189,4461,4751,5059,5387,5737,6109,6506,
+ 6928,7378,7857,8367,8910,9488,10104,10760,
+ 11458,12202,12994,13838,14736,15692,16711,17795,
+ 18951,20181,21491,22885,24371,25953,27638,29431,
+ 31342,33376,35543,37850,40307,42923,45709,48676,
+ 51836,55200,58784,62599,66663,70990,75598,80505,
+ 85730,91295,97221,103532,110252,117409,125030,133146,
+ 141789,150992,160793,171231,182345,194182,206786,220209,
+ 234503,249725,265935,283197,301579,321155,342002,364202,
+ 387842,413018,439827,468377,498780,531156,565634,602350,
+ 641449,683087,727427,774645,824928,878475,935498,996222,
+ 1060888,1129752,1203085,1281179,1364342,1452903,1547213,1647644,
+ 1754595,1868488,1989774,2118933,2256475,2402946,2558924,2725027,
+ 2901912,3090279,3290873,3504487,3731968,3974215,4232186,4506902,
+ 4799451,5110989,5442750,5796046,6172275,6572925,6999582,7453933,
+ 7937777,8453028,9001725,9586039,10208280,10870913,11576557,12328006,
+ 13128233,13980403,14887889,15854280,16883401,17979324,19146385,20389201,
+ 21712690,23122088,24622972,26221280,27923336,29735875,31666069,33721553,
+ 35910462,38241455,40723756,43367187,46182206,49179951,52372284,55771835,
+ 59392055,63247269,67352729,71724679,76380419,81338368,81338368,0
+ /* TODO Last Buffer Size is reserved [Now set as 0]*/
+};
+
/*******************************************************************
*
* @brief Allocates a crnti for new UE
/* Contains common utility definitions to be used at MAC */
#define MAX_SHORT_BSR_TABLE_ENTRIES 32
+#define MAX_LONG_BSR_TABLE_ENTRIES 256
#define MAC_MEM_REGION 4
#define MAC_POOL 1
/* Function declaration */
uint16_t getNewCrnti(uint8_t *crntiMap);
uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES];
+uint32_t longBsrBytesTable[MAX_LONG_BSR_TABLE_ENTRIES];
/**********************************************************************
End of file
**********************************************************************/
if(ulData->pduInfo[idx].commCh)
{
RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, cLchUlDat, \
- sizeof(RguCDatIndInfo));
- if(!cLchUlDat)
- {
- DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcProcUlData");
- ret = RFAILED;
- break;
- }
+ sizeof(RguCDatIndInfo));
+ if(!cLchUlDat)
+ {
+ DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcProcUlData");
+ ret = RFAILED;
+ break;
+ }
memset(cLchUlDat, 0, sizeof(RguCDatIndInfo));
cLchUlDat->cellId = ulData->cellId;
if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &cLchUlDat->pdu) != ROK)
{
DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcProcUlData");
- RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, cLchUlDat, \
- sizeof(RguCDatIndInfo));
+ RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, cLchUlDat, \
+ sizeof(RguCDatIndInfo));
ret = RFAILED;
- break;
+ break;
}
oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, cLchUlDat->pdu, \
- ulData->pduInfo[idx].pduLen);
+ ulData->pduInfo[idx].pduLen);
rlcProcCommLcUlData(pst, 0, cLchUlDat);
}
if(!dLchPduPres)
{
RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
- sizeof(RguDDatIndInfo));
- if(!dLchUlDat)
- {
- DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
- ret = RFAILED;
- break;
- }
+ sizeof(RguDDatIndInfo));
+ if(!dLchUlDat)
+ {
+ DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
+ ret = RFAILED;
+ break;
+ }
dLchPduPres = TRUE;
}
- /* Copy fixed buffer to message */
- lcId = ulData->pduInfo[idx].lcId;
- if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, \
- &dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]) != ROK)
- {
- DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
- for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
- {
- ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
- }
- RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
- sizeof(RguDDatIndInfo));
- ret = RFAILED;
- break;
- }
- oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
- dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
- ulData->pduInfo[idx].pduLen);
+ /* Copy fixed buffer to message */
+ lcId = ulData->pduInfo[idx].lcId;
+ if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, \
+ &dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]) != ROK)
+ {
+ DU_LOG("\nERROR --> RLC : Memory allocation failed at RlcMacProcUlData");
+ for(pduIdx=0; pduIdx < dLchData[lcId].pdu.numPdu; pduIdx++)
+ {
+ ODU_PUT_MSG_BUF(dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu]);
+ }
+ RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, dLchUlDat, \
+ sizeof(RguDDatIndInfo));
+ ret = RFAILED;
+ break;
+ }
+ oduCpyFixBufToMsg(ulData->pduInfo[idx].pduBuf, \
+ dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu],\
+ ulData->pduInfo[idx].pduLen);
dLchData[lcId].pdu.numPdu++;
}
{
if(dLchPduPres)
{
- dLchUlDat->cellId = ulData->cellId;
- GET_UE_IDX(ulData->rnti, dLchUlDat->rnti);
-
- for(idx = 0; idx < MAX_NUM_LC; idx++)
- {
- if(dLchData[idx].pdu.numPdu)
- {
- memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
- numDLch++;
- }
- }
- dLchUlDat->numLch = numDLch;
- rlcProcDedLcUlData(pst, 0, dLchUlDat);
+ dLchUlDat->cellId = ulData->cellId;
+ GET_UE_IDX(ulData->rnti, dLchUlDat->rnti);
+
+ for(idx = 0; idx < MAX_NUM_LC; idx++)
+ {
+ if(dLchData[idx].pdu.numPdu)
+ {
+ memcpy(&dLchUlDat->lchData[numDLch], &dLchData[idx], sizeof(RguLchDatInd));
+ numDLch++;
+ }
+ }
+ dLchUlDat->numLch = numDLch;
+ rlcProcDedLcUlData(pst, 0, dLchUlDat);
}
}
for(pduIdx = 0; pduIdx < ulData->numPdu; pduIdx++)
{
RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData->pduInfo[pduIdx].pduBuf, \
- ulData->pduInfo[pduIdx].pduLen);
+ ulData->pduInfo[pduIdx].pduLen);
}
RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcData));
return ROK;
RLC_ALLOC(gCb, gCb->rlcThpt.snssaiTputInfo.tputPerSnssaiList, sizeof(CmLListCp));
snssaiList = gCb->rlcThpt.snssaiTputInfo.tputPerSnssaiList;
cmLListInit(snssaiList);
- DU_LOG("\nINFO --> RLC: First SNSSAI to add in this List");
+ DU_LOG("\nINFO --> RLC: First SNSSAI to add in this List");
}
else
{
snssaiNode = (RlcTptPerSnssai *)node->node;
if(memcmp(snssaiNode->snssai, snssai, sizeof(Snssai)) == 0)
{
- DU_LOG("\nINFO --> RLC : SNSSAI found in LL");
+ DU_LOG("\nDEBUG --> RLC : SNSSAI found in LL");
found = TRUE;
break;
}
DU_LOG("\nERROR --> RLC : Allocation of SNSSAI node failed");
return NULLP;
}
- DU_LOG("\nINFO --> RLC : SNSSAI node added successfully");
+ DU_LOG("\nDEBUG --> RLC : SNSSAI node added successfully");
return (snssaiNode);
}
node = cmLListDelFrm(snssaiList, node);
RLC_FREE(gCb, node, sizeof(CmLList));
RLC_FREE(gCb, snssaiNode, sizeof(RlcTptPerSnssai));
- DU_LOG("\nINFO --> RLC : SNSSAI node found and deletion performed");
+ DU_LOG("\nDEBUG --> RLC : SNSSAI node found and deletion performed");
if(snssaiList->count == 0)
{
RLC_FREE(gCb, snssaiList, sizeof(CmLListCp));
- DU_LOG("\nINFO --> RLC : This SNSSAI was last in the list thus freeing the list also");
+ DU_LOG("\nINFO --> RLC : This SNSSAI was last in the list thus freeing the list also");
}
}
else
if(snssaiList->count == 0)
{
RLC_FREE(gCb, snssaiList, sizeof(CmLListCp));
- DU_LOG("\nINFO --> RLC : This SNSSAI was last in the list thus freeing the list also");
+ DU_LOG("\nINFO --> RLC : This SNSSAI was last in the list thus freeing the list also");
}
}
RlcCb* dlInst = rlcCb[1];
RlcCb* ulInst = rlcCb[0];
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Sent = (%ld), PdusRext = (%ld), TimeOut = (%ld), SduDiscarded = (%ld)",
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Sent = (%ld), PdusRext = (%ld), TimeOut = (%ld), SduDiscarded = (%ld)",
dlInst->genSts.pdusSent,
dlInst->genSts.pdusRetx,
dlInst->genSts.protTimeOut,
dlInst->genSts.numSduDisc);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Rcvd = (%ld), unexpPdus = (%ld), errorPdus = (%ld)",
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Rcvd = (%ld), unexpPdus = (%ld), errorPdus = (%ld)",
ulInst->genSts.pdusRecv,
ulInst->genSts.unexpPdusRecv,
ulInst->genSts.errorPdusRecv);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
"StaPduSent:%lu NacksInStaPdu:%lu BytesUnused:%lu PollTimerExpires SRB:%lu ",
gRlcStats.amRlcStats.numDLStaPduSent, gRlcStats.amRlcStats.numDLNacksInStaPdu,
gRlcStats.amRlcStats.numDLBytesUnused, gRlcStats.amRlcStats.numDLPollTimerExpiresSrb);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
"DRB:%lu MaxRetx:%lu RetransPdus:%lu",
gRlcStats.amRlcStats.numDLPollTimerExpiresDrb, gRlcStats.amRlcStats.numDLMaxRetx,
gRlcStats.amRlcStats.numDLRetransPdus);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMUL: "
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMUL: "
" PdusDiscarded:%lu ReAsmblTimerExpires:%lu StaPduRcvd:%lu NackInStaPduRcvd:%lu ",
gRlcStats.amRlcStats.numULPdusDiscarded, gRlcStats.amRlcStats.numULReAsmblTimerExpires,
gRlcStats.amRlcStats.numULStaPduRcvd, gRlcStats.amRlcStats.numULNackInStaPduRcvd);
RlcCb* ulInst = rlcCb[0];
DU_LOG ("\n ================================ RLC STATS ===========================\n");
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Sent = (%d), PdusRext = (%d), TimeOut = (%d), SduDiscarded = (%d)",
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Sent = (%d), PdusRext = (%d), TimeOut = (%d), SduDiscarded = (%d)",
dlInst->genSts.pdusSent,
dlInst->genSts.pdusRetx,
dlInst->genSts.protTimeOut,
dlInst->genSts.numSduDisc);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Rcvd = (%d), unexpPdus = (%d), errorPdus = (%d)",
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: PDUs Rcvd = (%d), unexpPdus = (%d), errorPdus = (%d)",
ulInst->genSts.pdusRecv,
ulInst->genSts.unexpPdusRecv,
ulInst->genSts.errorPdusRecv);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
"StaPduSent:%u NacksInStaPdu:%u BytesUnused:%u PollTimerExpires SRB:%u ",
gRlcStats.amRlcStats.numDLStaPduSent, gRlcStats.amRlcStats.numDLNacksInStaPdu,
gRlcStats.amRlcStats.numDLBytesUnused, gRlcStats.amRlcStats.numDLPollTimerExpiresSrb);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMDL: "
"DRB:%u MaxRetx:%u RetransPdus:%u",
gRlcStats.amRlcStats.numDLPollTimerExpiresDrb, gRlcStats.amRlcStats.numDLMaxRetx,
gRlcStats.amRlcStats.numDLRetransPdus);
- DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMUL: "
+ DU_LOG("\nINFO --> RLC_DL : RLC Stats: AMUL: "
" PdusDiscarded:%u ReAsmblTimerExpires:%u StaPduRcvd:%u NackInStaPduRcvd:%u ",
gRlcStats.amRlcStats.numULPdusDiscarded, gRlcStats.amRlcStats.numULReAsmblTimerExpires,
gRlcStats.amRlcStats.numULStaPduRcvd, gRlcStats.amRlcStats.numULNackInStaPduRcvd);
ret = RFAILED;
break;
}
- DU_LOG("\nINFO --> RLC_DL : rlcSendDedLcDlData: BO Status sent successfully for LCID:%d,BO:%d",\
+ DU_LOG("\nDEBUG --> RLC_DL : rlcSendDedLcDlData: BO Status sent successfully for LCID:%d,BO:%d",\
boStatus->lcId, boStatus->bo);
}
RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, dlData, sizeof(RlcData));
if(snssaiTputNode != NULLP)
{
snssaiTputNode->dataVol += staIndTb->lchStaInd[count].totBufSize;
- DU_LOG("\nINFO -->SCH: SNSSAI List Grant:%d, lcId:%d, total :%d",\
+ DU_LOG("\nINFO -->SCH: SNSSAI List Grant:%d, lcId:%d, total :%d",\
staIndTb->lchStaInd[count].totBufSize, staIndTb->lchStaInd[count].lcId,\
snssaiTputNode->dataVol);
}
/* Set Config done in TskInit */
schCb[inst].schInit.cfgDone = TRUE;
- DU_LOG("\nINFO --> SCH : Scheduler gen config done");
+ DU_LOG("\nINFO --> SCH : Scheduler gen config done");
return ret;
}
"pst->dstInst=%d SCH_INST_START=%d", pst->dstInst,SCH_INST_START);
return ROK;
}
- DU_LOG("\nINFO --> SCH : Received scheduler gen config");
+ DU_LOG("\nINFO --> SCH : Received scheduler gen config");
/* Fill the post structure for sending the confirmation */
memset(&cfmPst, 0 , sizeof(Pst));
SchFillCfmPst(pst, &cfmPst, cfg);
#endif
DU_LOG("\nDEBUG --> SCH : Received BSR");
+ if(bsrInd == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH : BSR Ind is empty");
+ return RFAILED;
+ }
cellCb = schCb[schInst].cells[schInst];
+ if(cellCb == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH : CellCb is empty");
+ return RFAILED;
+ }
ueCb = schGetUeCb(cellCb, bsrInd->crnti);
+ if(ueCb == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH : UeCB is empty");
+ return RFAILED;
+ }
+
ueCb->bsrRcvd = true;
/* store dataVolume per lcg in uecb */
for(lcgIdx = 0; lcgIdx < bsrInd->numLcg; lcgIdx++)
{
- ueCb->bsrInfo[lcgIdx].priority = 1; //TODO: determining LCG priority?
- ueCb->bsrInfo[lcgIdx].dataVol = bsrInd->dataVolInfo[lcgIdx].dataVol;
+ ueCb->bsrInfo[bsrInd->dataVolInfo[lcgIdx].lcgId].priority = 1; //TODO: determining LCG priority?
+ ueCb->bsrInfo[bsrInd->dataVolInfo[lcgIdx].lcgId].dataVol = bsrInd->dataVolInfo[lcgIdx].dataVol;
}
/* Adding UE Id to list of pending UEs to be scheduled */
*
* @details
*
- * Function : searchLargestFreeBlockDL
+ * Function : searchLargestFreeBlock
*
* Functionality:
* Finds the FreeBlock with MaxNum of FREE PRB considering SSB/SIB1 ocassions.
* @params[in] I/P > prbAlloc table (FreeBlock list)
* I/P > Slot timing Info
* O/P > Start PRB
+ * I/P > Direction (UL/DL)
*
*
* @return Max Number of Free PRB
*
* ********************************************************************************/
-uint16_t searchLargestFreeBlockDL(SchCellCb *cell, SlotTimingInfo slotTime,uint16_t *startPrb)
+uint16_t searchLargestFreeBlock(SchCellCb *cell, SlotTimingInfo slotTime,uint16_t *startPrb, Direction dir)
{
- uint16_t broadcastPrbStart=0, broadcastPrbEnd=0, maxFreePRB = 0;
- PduTxOccsaion ssbOccasion=0, sib1Occasion=0;
+ uint16_t reservedPrbStart=0, reservedPrbEnd=0, maxFreePRB = 0;
FreePrbBlock *freePrbBlock = NULLP;
CmLList *freePrbNode = NULLP;
+ SchPrbAlloc *prbAlloc = NULLP;
+ bool checkOccasion = FALSE;
- SchDlSlotInfo *schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot];
- SchPrbAlloc *prbAlloc = &schDlSlotInfo->prbAlloc;
-
- ssbOccasion = schCheckSsbOcc(cell, slotTime);
- sib1Occasion = schCheckSib1Occ(cell, slotTime);
+ *startPrb = 0; /*Initialize the StartPRB to zero*/
- if(ssbOccasion && sib1Occasion)
+ /*Based on Direction, Reserved Messsages will differi.e.
+ * DL >> SSB and SIB1 ocassions wheres for UL, PRACH ocassions to be checked
+ * and reserved before allocation for dedicated DL/UL msg*/
+ if(dir == DIR_DL)
{
- broadcastPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
- broadcastPrbEnd = broadcastPrbStart + SCH_SSB_NUM_PRB + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
+ SchDlSlotInfo *schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot];
+ PduTxOccsaion ssbOccasion=0, sib1Occasion=0;
+
+ prbAlloc = &schDlSlotInfo->prbAlloc;
+
+ ssbOccasion = schCheckSsbOcc(cell, slotTime);
+ sib1Occasion = schCheckSib1Occ(cell, slotTime);
+
+ checkOccasion = TRUE;
+ if(ssbOccasion && sib1Occasion)
+ {
+ reservedPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
+ reservedPrbEnd = reservedPrbStart + SCH_SSB_NUM_PRB + \
+ cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
+ }
+ else if(ssbOccasion)
+ {
+ reservedPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
+ reservedPrbEnd = reservedPrbStart + SCH_SSB_NUM_PRB -1;
+ }
+ else if(sib1Occasion)
+ {
+ reservedPrbStart = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.startPrb;
+ reservedPrbEnd = reservedPrbStart + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
+ }
+ else
+ {
+ checkOccasion = FALSE;
+ }
}
- else if(ssbOccasion)
+ else if(dir == DIR_UL)
{
- broadcastPrbStart = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
- broadcastPrbEnd = broadcastPrbStart + SCH_SSB_NUM_PRB -1;
+ prbAlloc = &cell->schUlSlotInfo[slotTime.slot]->prbAlloc;
+
+ /* Check if PRACH is also scheduled in this slot */
+ checkOccasion = schCheckPrachOcc(cell, slotTime);
+ if(checkOccasion)
+ {
+ reservedPrbStart = cell->cellCfg.schRachCfg.msg1FreqStart;
+ reservedPrbEnd = reservedPrbStart + (schCalcPrachNumRb(cell)) -1;
+ }
}
- else if(sib1Occasion)
+ else
{
- broadcastPrbStart = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.startPrb;
- broadcastPrbEnd = broadcastPrbStart + cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc.numPrb -1;
+ DU_LOG("\nERROR --> SCH: Invalid Direction!");
+ return (maxFreePRB);
}
-
freePrbNode = prbAlloc->freePrbBlockList.first;
- *startPrb = 0; /*Initialize the StartPRB to zero*/
while(freePrbNode)
{
freePrbBlock = (FreePrbBlock *)freePrbNode->node;
continue;
}
- /* If broadcast message is scheduled in this slot, then check if its PRBs belong to the current free block.
+ /* If Broadcast/Prach message is scheduled in this slot, then check if its PRBs belong to the current free block.
* Since SSB/SIB1 PRB location is fixed, these PRBs cannot be allocated to other message in same slot */
- if((ssbOccasion || sib1Occasion) &&
- ((broadcastPrbStart >= freePrbBlock->startPrb) && (broadcastPrbStart <= freePrbBlock->endPrb)) && \
- ((broadcastPrbEnd >= freePrbBlock->startPrb) && (broadcastPrbEnd <= freePrbBlock->endPrb)))
+ if(checkOccasion &&
+ ((reservedPrbStart >= freePrbBlock->startPrb) && (reservedPrbStart <= freePrbBlock->endPrb)) && \
+ ((reservedPrbEnd >= freePrbBlock->startPrb) && (reservedPrbEnd <= freePrbBlock->endPrb)))
{
/* Implmentation is done such that highest-numbered free-RB is Checked first
and freePRB in this block is greater than Max till now */
- if((freePrbBlock->endPrb > broadcastPrbEnd) && ((freePrbBlock->endPrb - broadcastPrbEnd) > maxFreePRB))
+ if((freePrbBlock->endPrb > reservedPrbEnd) && ((freePrbBlock->endPrb - reservedPrbEnd) > maxFreePRB))
{
- /* If sufficient free PRBs are available above broadcast message*/
- *startPrb = broadcastPrbEnd + 1;
- maxFreePRB = (freePrbBlock->endPrb - broadcastPrbEnd);
+ /* If sufficient free PRBs are available above reserved message*/
+ *startPrb = reservedPrbEnd + 1;
+ maxFreePRB = (freePrbBlock->endPrb - reservedPrbEnd);
}
- /*Also check the other freeBlock (i.e. Above the broadcast message) for MAX FREE PRB*/
- if((broadcastPrbStart > freePrbBlock->startPrb) && ((broadcastPrbStart - freePrbBlock->startPrb) > maxFreePRB))
+ /*Also check the other freeBlock (i.e. Above the reserved message) for MAX FREE PRB*/
+ if((reservedPrbStart > freePrbBlock->startPrb) && ((reservedPrbStart - freePrbBlock->startPrb) > maxFreePRB))
{
- /* If free PRBs are available below broadcast message*/
+ /* If free PRBs are available below reserved message*/
*startPrb = freePrbBlock->startPrb;
- maxFreePRB = (broadcastPrbStart - freePrbBlock->startPrb);
+ maxFreePRB = (reservedPrbStart - freePrbBlock->startPrb);
}
}
else //Best Block
}
return(maxFreePRB);
}
-
/**********************************************************************
End of file
**********************************************************************/
CREATE,
DELETE
}ActionTypeLcLL;
+
+typedef enum
+{
+ DIR_UL,
+ DIR_DL
+}Direction;
+
/**
* @brief
* Structure holding LTE MAC's General Configuration information.
uint16_t schAccumalateLcBoSize(SchCellCb *cell, uint16_t ueIdx);
uint8_t allocatePrbDl(SchCellCb *cell, SlotTimingInfo slotTime, uint8_t startSymbol, uint8_t symbolLength, \
uint16_t *startPrb, uint16_t numPrb);
-uint16_t searchLargestFreeBlockDL(SchCellCb *cell, SlotTimingInfo slotTime,uint16_t *startPrb);
-void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *accumalatedBOSize);
void fillDlMsgInfo(DlMsgInfo *dlMsgInfo, uint8_t crnti);
bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool dedMsg, uint8_t *pdschStartSymbol,\
uint8_t *pdschSymblLen, SlotTimingInfo *pdcchTime, SlotTimingInfo *pdschTime, SlotTimingInfo *pucchTime);
void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo prachOccasionTimingInfo);
uint16_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, uint16_t crnti);
uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo);
-uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t dataVol, uint8_t k2, uint8_t startSymb, uint8_t symbLen);
+uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbsSize, \
+ uint8_t startSymb, uint8_t symbLen, uint16_t startPrb);
uint8_t allocatePrbUl(SchCellCb *cell, SlotTimingInfo slotTime, uint8_t startSymbol, uint8_t symbolLength, \
uint16_t *startPrb, uint16_t numPrb);
bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId);
+bool schCalculateUlTbs(SchUeCb *ueCb, SlotTimingInfo puschTime, uint8_t symbLen,\
+ uint16_t *startPrb, uint32_t *totTBS);
/*Generic Functions*/
+void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, BsrInfo *bsrInfo, uint32_t *accumalatedBOSize);
+uint16_t searchLargestFreeBlock(SchCellCb *cell, SlotTimingInfo slotTime,uint16_t *startPrb, Direction dir);
LcInfo* handleLcLList(CmLListCp *lcLL, uint8_t lcId, ActionTypeLcLL action);
void prbAllocUsingRRMPolicy(CmLListCp *lcLL, bool dedicatedPRB, uint16_t mcsIdx,uint8_t numSymbols,\
- uint16_t *sharedPRB, uint16_t *reservedPRB, bool *isTxPayloadLenAdded);
+ uint16_t *sharedPRB, uint16_t *reservedPRB, bool *isTxPayloadLenAdded, bool *srRcvd);
+void updateBsrAndLcList(CmLListCp *lcLL, BsrInfo *bsrInfo, uint8_t status);
/**********************************************************************
End of file
* I/P > mcsIdx and PDSCH symbols count
* I/P & O/P > Shared PRB , reserved PRB Count
* I/P & O/P > Total TBS size accumulated
- * I/P & O/P > isTxPayloadLenAdded : Decision flag to add the TX_PAYLOAD_HDR_LEN
+ * I/P & O/P > isTxPayloadLenAdded[For DL] : Decision flag to add the TX_PAYLOAD_HDR_LEN
+ * I/P & O/P > srRcvd Flag[For UL] : Decision flag to add UL_GRANT_SIZE
*
* @return void
*
* *******************************************************************************************/
void prbAllocUsingRRMPolicy(CmLListCp *lcLL, bool isDedicatedPRB, uint16_t mcsIdx,uint8_t numSymbols,\
- uint16_t *sharedPRB, uint16_t *reservedPRB, bool *isTxPayloadLenAdded)
+ uint16_t *sharedPRB, uint16_t *reservedPRB, bool *isTxPayloadLenAdded, bool *srRcvd)
{
CmLList *node = NULLP;
LcInfo *lcNode = NULLP;
/*[Exit1]: All LCs are allocated(allocBO = 0 for fully unallocated LC)*/
if(lcNode->allocBO != 0)
{
- DU_LOG("\nWARNING --> SCH: All LC are allocated [SharedPRB:%d]",*sharedPRB);
+ DU_LOG("\nDEBUG --> SCH: All LC are allocated [SharedPRB:%d]",*sharedPRB);
return;
}
/*Loop Exit: All resources exhausted*/
if(remReservedPRB == 0 && *sharedPRB == 0)
{
- DU_LOG("\nWARNING --> SCH: Dedicated resources exhausted for LC:%d",lcNode->lcId);
+ DU_LOG("\nDEBUG --> SCH: Dedicated resources exhausted for LC:%d",lcNode->lcId);
return;
}
}
/*Loop Exit: All resources exhausted*/
if(*sharedPRB == 0)
{
- DU_LOG("\nWARNING --> SCH: Default resources exhausted for LC:%d",lcNode->lcId);
+ DU_LOG("\nDEBUG --> SCH: Default resources exhausted for LC:%d",lcNode->lcId);
return;
}
}
maxPRB = remReservedPRB + *sharedPRB;
/*[Step4]*/
- if(!(*isTxPayloadLenAdded))
+ if((isTxPayloadLenAdded != NULLP) && (*isTxPayloadLenAdded == FALSE))
{
- DU_LOG("\nINFO --> SCH: LC:%d is the First node to be allocated which includes TX_PAYLOAD_HDR_LEN",\
+ DU_LOG("\nDEBUG --> SCH: LC:%d is the First node to be allocated which includes TX_PAYLOAD_HDR_LEN",\
lcNode->lcId);
*isTxPayloadLenAdded = TRUE;
lcNode->allocBO = calculateEstimateTBSize((lcNode->reqBO + TX_PAYLOAD_HDR_LEN),\
mcsIdx, numSymbols, maxPRB, &estPrb);
lcNode->allocBO -=TX_PAYLOAD_HDR_LEN;
}
+ else if((srRcvd != NULLP) && (*srRcvd == TRUE))
+ {
+ DU_LOG("\nDEBUG --> SCH: LC:%d is the First node to be allocated which includes UL_GRANT_SIZE",\
+ lcNode->lcId);
+ *srRcvd = FALSE;
+ lcNode->reqBO += UL_GRANT_SIZE;
+ lcNode->allocBO = calculateEstimateTBSize(lcNode->reqBO, mcsIdx, numSymbols, maxPRB, &estPrb);
+ }
else
{
/*[Step4]*/
{
if(*sharedPRB <= (estPrb - remReservedPRB))
{
- DU_LOG("\nINFO --> SCH: SharedPRB is less");
+ DU_LOG("\nDEBUG --> SCH: SharedPRB is less");
*sharedPRB = 0;
}
else
* BO Report in dlMsgAlloc Pointer
*
* @params[in] I/P > lcLinkList pointer (LcInfo list)
- * I/P & O/P > dlMsgAlloc(Pending LC to be added in this context)
+ * I/P & O/P > dlMsgAlloc[for DL](Pending LC to be added in this context)
+ * I/P & O/P > BsrInfo (applicable for UL)
* I/P & O/P > accumalatedBOSize
* @return void
*
* *******************************************************************************************/
-void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *accumalatedBOSize)
+void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc,\
+ BsrInfo *bsrInfo, uint32_t *accumalatedBOSize)
{
CmLList *node = NULLP, *next = NULLP;
LcInfo *lcNode = NULLP;
return;
}
- dlMsgSchInfo = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo];
-
/*Traverse List*/
while(node)
{
lcNode = (LcInfo *)node->node;
if(lcNode != NULLP)
{
- DU_LOG("\nINFO --> SCH : LcID:%d, [reqBO, allocBO, allocPRB]:[%d,%d,%d]",\
+ DU_LOG("\nINFO --> SCH : LcID:%d, [reqBO, allocBO, allocPRB]:[%d,%d,%d]",\
lcNode->lcId, lcNode->reqBO, lcNode->allocBO, lcNode->allocPRB);
+ if(dlMsgAlloc != NULLP)
+ {
+ dlMsgSchInfo = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo];
- /*Add this LC to dlMsgAlloc so that if this LC gets allocated, BO
- * report for allocation can be sent to MAC*/
- dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].lcId = lcNode->lcId;
- dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].schBytes = lcNode->allocBO;
+ /*Add this LC to dlMsgAlloc so that if this LC gets allocated, BO
+ * report for allocation can be sent to MAC*/
+ dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].lcId = lcNode->lcId;
+ dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].schBytes = lcNode->allocBO;
- /*Calculate the Total Payload/BO size allocated*/
- *accumalatedBOSize += dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].schBytes;
+ /*Calculate the Total Payload/BO size allocated*/
+ *accumalatedBOSize += dlMsgSchInfo->lcSchInfo[dlMsgSchInfo->numLc].schBytes;
- DU_LOG("\nINFO --> SCH: Added in MAC BO report: LCID:%d,reqBO:%d,Idx:%d, TotalBO Size:%d",\
- lcNode->lcId,lcNode->reqBO, dlMsgSchInfo->numLc, *accumalatedBOSize);
+ DU_LOG("\nINFO --> SCH: Added in MAC BO report: LCID:%d,reqBO:%d,Idx:%d, TotalBO Size:%d",\
+ lcNode->lcId,lcNode->reqBO, dlMsgSchInfo->numLc, *accumalatedBOSize);
- dlMsgSchInfo->numLc++;
- /*The LC has been fully allocated, clean it*/
- if(lcNode->reqBO == 0)
+ dlMsgSchInfo->numLc++;
+ /*The LC has been fully allocated, clean it*/
+ if(lcNode->reqBO == 0)
+ {
+ handleLcLList(lcLL, lcNode->lcId, DELETE);
+ }
+ }
+ else if(bsrInfo != NULLP)
{
- handleLcLList(lcLL, lcNode->lcId, DELETE);
+ *accumalatedBOSize += lcNode->allocBO;
+ DU_LOG("\nINFO --> SCH: UL : LCID:%d,reqBO:%d, TotalBO Size:%d",\
+ lcNode->lcId,lcNode->reqBO, *accumalatedBOSize);
}
}
node = next;
return true;
}
+/*******************************************************************
+ *
+ * @brief Handler to calculate TBS size for BSR requested
+ *
+ * @details
+ *
+ * Function : schCalculateUlTbs
+ *
+ * Functionality: Function will note the required TBS for each LCGIDX and use
+ * the Priority LCG List and RRM policy to allocate the TBS size
+ *
+ * @params [in] ueCb (Pointer to UE CB)
+ * [in] puschTime (Time slot where PUSCH will be sent)
+ * [in] symbLen (No of Symbols used for PUSCH transmission)
+ * [out] startPrb(Pointer to startPRB which will be calculated while
+ * finding the best Free Block)
+ * [out] totTBS(Pointer to total TBS size)
+ *
+ * @return bool : true > Scheduling of UL grant is successful
+ * false > vice versa
+ *
+ * ****************************************************************/
+bool schCalculateUlTbs(SchUeCb *ueCb, SlotTimingInfo puschTime, uint8_t symbLen,\
+ uint16_t *startPrb, uint32_t *totTBS)
+{
+ uint16_t mcsIdx = 0;
+ CmLListCp *lcLL = NULLP;
+ uint16_t lcgIdx = 0, lcId =0, maxFreePRB = 0;
+
+ *startPrb = 0;
+ *totTBS = 0;
+
+ /* check for BSR */
+ for(lcgIdx=0; lcgIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcgIdx++)
+ {
+ if(ueCb->bsrInfo[lcgIdx].dataVol == 0)
+ {
+ continue;
+ }
+
+ /*TODO: lcgIdx and LCID has been implemented as one to one mapping.
+ * Need to check the mapping to figure out the LCID and lcgIdx once L2
+ * spec specifies any logic*/
+ lcId = lcgIdx;
+ if(ueCb->ulInfo.ulLcCtxt[lcId].isDedicated)
+ {
+ lcLL = &(ueCb->ulLcPrbEst.dedLcInfo->dedLcList);
+ }
+ else
+ {
+ lcLL = &(ueCb->ulLcPrbEst.defLcList);
+ }
+
+ /*[Step2]: Update the reqPRB and Payloadsize for this LC in the appropriate List*/
+ if(updateLcListReqPRB(lcLL, lcId, ueCb->bsrInfo[lcgIdx].dataVol) != ROK)
+ {
+ DU_LOG("\nERROR --> SCH: LcgId:%d updation failed",lcId);
+ return false;
+ }
+ }
+
+ if ((ueCb->ulLcPrbEst.defLcList.count == 0) && \
+ ((ueCb->ulLcPrbEst.dedLcInfo == NULL) || (ueCb->ulLcPrbEst.dedLcInfo->dedLcList.count == 0)))
+ {
+ if(ueCb->srRcvd)
+ {
+ *startPrb = MAX_NUM_RB;
+ *totTBS = schCalcTbSize(UL_GRANT_SIZE);
+ }
+
+ /*Returning true when NO Grant is there for UE as this is not scheduling
+ * error*/
+ return (true);
+ }
+
+ maxFreePRB = searchLargestFreeBlock(ueCb->cellCb, puschTime, startPrb, DIR_UL);
+
+ /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in
+ * the list based on RRM policy*/
+
+ /*Either this UE contains no reservedPRB pool fir dedicated S-NSSAI or
+ * Num of Free PRB available is not enough to reserve Dedicated PRBs*/
+ if(maxFreePRB != 0)
+ {
+ mcsIdx = ueCb->ueCfg.ulModInfo.mcsIndex;
+ if((ueCb->ulLcPrbEst.dedLcInfo == NULLP)
+ || ((maxFreePRB < ueCb->ulLcPrbEst.dedLcInfo->rsvdDedicatedPRB)))
+ {
+ ueCb->ulLcPrbEst.sharedNumPrb = maxFreePRB;
+ DU_LOG("\nDEBUG --> SCH : UL Only Default Slice is scheduled, sharedPRB Count:%d",\
+ ueCb->ulLcPrbEst.sharedNumPrb);
+
+ /*PRB Alloc for Default LCs*/
+ prbAllocUsingRRMPolicy(&(ueCb->ulLcPrbEst.defLcList), FALSE, mcsIdx, symbLen,\
+ &(ueCb->ulLcPrbEst.sharedNumPrb), NULLP, NULLP,&(ueCb->srRcvd));
+ }
+ else
+ {
+ ueCb->ulLcPrbEst.sharedNumPrb = maxFreePRB - ueCb->ulLcPrbEst.dedLcInfo->rsvdDedicatedPRB;
+
+ /*PRB Alloc for Dedicated LCs*/
+ prbAllocUsingRRMPolicy(&(ueCb->ulLcPrbEst.dedLcInfo->dedLcList), TRUE, mcsIdx, symbLen,\
+ &(ueCb->ulLcPrbEst.sharedNumPrb), &(ueCb->ulLcPrbEst.dedLcInfo->rsvdDedicatedPRB),\
+ NULLP,&(ueCb->srRcvd));
+
+ /*PRB Alloc for Default LCs*/
+ prbAllocUsingRRMPolicy(&(ueCb->ulLcPrbEst.defLcList), FALSE, mcsIdx, symbLen, \
+ &(ueCb->ulLcPrbEst.sharedNumPrb), &(ueCb->ulLcPrbEst.dedLcInfo->rsvdDedicatedPRB),\
+ NULLP,&(ueCb->srRcvd));
+ }
+ }
+ /*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes
+ * using allocated BO per LC and Update dlMsgAlloc(BO report for MAC*/
+ if(ueCb->ulLcPrbEst.dedLcInfo != NULLP)
+ updateGrantSizeForBoRpt(&(ueCb->ulLcPrbEst.dedLcInfo->dedLcList), NULLP, ueCb->bsrInfo, totTBS);
+
+ updateGrantSizeForBoRpt(&(ueCb->ulLcPrbEst.defLcList), NULLP, ueCb->bsrInfo, totTBS);
+
+ /*Below case will hit if NO LC(s) are allocated due to resource crunch*/
+ if (*totTBS == 0)
+ {
+ if(maxFreePRB == 0)
+ {
+ DU_LOG("\nERROR --> SCH : NO FREE PRB!!");
+ }
+ else
+ {
+ /*Schedule the LC for next slot*/
+ DU_LOG("\nDEBUG --> SCH : No LC has been scheduled");
+ }
+ return (false);
+ }
+ return (true);
+}
+
/*******************************************************************
*
* @brief sch Process pending Sr or Bsr Req
*******************************************************************/
bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId)
{
- bool k2Found = FALSE;
- uint8_t lcgIdx = 0;
+ bool k2Found = FALSE, ret = FALSE;
uint8_t startSymb = 0, symbLen = 0;
uint8_t k2TblIdx = 0, k2Index = 0, k2Val = 0;
+ uint16_t startPrb = 0;
uint32_t totDataReq = 0; /* in bytes */
SchUeCb *ueCb;
SchPuschInfo *puschInfo;
SchK2TimingInfoTbl *k2InfoTbl=NULLP;
SlotTimingInfo dciTime, puschTime;
- if(cell == NULL)
+ if(cell == NULLP)
{
DU_LOG("\nERROR --> SCH: schDlRsrcAllocMsg4() : Cell is NULL");
return false;
}
-
+
ueCb = &cell->ueCb[ueId-1];
- /* check for SR */
- if(ueCb->srRcvd)
- {
- totDataReq = UL_GRANT_SIZE; /*fixing so that all control msgs can be handled in SR */
- }
- /* check for BSR */
- if(ueCb->bsrRcvd == true)
+ if(ueCb == NULLP)
{
- for(lcgIdx=0; lcgIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcgIdx++)
- {
- totDataReq+= ueCb->bsrInfo[lcgIdx].dataVol;
- }
+ DU_LOG("\nERROR --> SCH: schDlRsrcAllocMsg4() : UE is NULL");
+ return false;
}
-
- if(totDataReq > 0)
- {
- /* Calculating time frame to send DCI for SR */
- ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA);
+ /* Calculating time frame to send DCI for SR */
+ ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA);
#ifdef NR_TDD
- if(schGetSlotSymbFrmt(dciTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
+ if(schGetSlotSymbFrmt(dciTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
#endif
- {
- if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2TblPrsnt)
- k2InfoTbl = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl;
- else
- k2InfoTbl = &cell->cellCfg.schInitialUlBwp.k2InfoTbl;
+ {
+ if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2TblPrsnt)
+ k2InfoTbl = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl;
+ else
+ k2InfoTbl = &cell->cellCfg.schInitialUlBwp.k2InfoTbl;
- for(k2TblIdx = 0; k2TblIdx < k2InfoTbl->k2TimingInfo[dciTime.slot].numK2; k2TblIdx++)
- {
- k2Index = k2InfoTbl->k2TimingInfo[dciTime.slot].k2Indexes[k2TblIdx];
+ for(k2TblIdx = 0; k2TblIdx < k2InfoTbl->k2TimingInfo[dciTime.slot].numK2; k2TblIdx++)
+ {
+ k2Index = k2InfoTbl->k2TimingInfo[dciTime.slot].k2Indexes[k2TblIdx];
- if(!ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2TblPrsnt)
- {
- k2Val = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2;
- startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol;
- symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength;
- }
- else
- {
- k2Val = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[k2Index].k2;
- startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[k2Index].startSymbol;
- symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[k2Index].symbolLength;
- }
+ if(!ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2TblPrsnt)
+ {
+ k2Val = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2;
+ startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol;
+ symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength;
+ }
+ else
+ {
+ k2Val = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[k2Index].k2;
+ startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[k2Index].startSymbol;
+ symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[k2Index].symbolLength;
+ }
- /* Calculating time frame to send PUSCH for SR */
- ADD_DELTA_TO_TIME(dciTime, puschTime, k2Val);
+ /* Calculating time frame to send PUSCH for SR */
+ ADD_DELTA_TO_TIME(dciTime, puschTime, k2Val);
#ifdef NR_TDD
- if(schGetSlotSymbFrmt(puschTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
- continue;
+ if(schGetSlotSymbFrmt(puschTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
+ continue;
#endif
- if(cell->schUlSlotInfo[puschTime.slot]->puschUe != 0)
- {
- continue;
- }
- k2Found = true;
- break;
+ if(cell->schUlSlotInfo[puschTime.slot]->puschUe != 0)
+ {
+ continue;
}
+ k2Found = true;
+ break;
}
+ }
- if(k2Found == true)
+ if(k2Found == true)
+ {
+ ret = schCalculateUlTbs(ueCb, puschTime, symbLen, &startPrb, &totDataReq);
+ if(totDataReq > 0 && ret == TRUE)
{
SCH_ALLOC(dciInfo, sizeof(DciInfo));
if(!dciInfo)
{
DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc");
+
+ if(ueCb->ulLcPrbEst.dedLcInfo != NULLP)
+ updateBsrAndLcList(&(ueCb->ulLcPrbEst.dedLcInfo->dedLcList), ueCb->bsrInfo, RFAILED);
+
+ updateBsrAndLcList(&(ueCb->ulLcPrbEst.defLcList), ueCb->bsrInfo, RFAILED);
return false;
}
cell->schDlSlotInfo[dciTime.slot]->ulGrant = dciInfo;
memset(dciInfo,0,sizeof(DciInfo));
/* Update PUSCH allocation */
- if(schFillPuschAlloc(ueCb, puschTime, totDataReq, k2Val, startSymb, symbLen) == ROK)
+ if(schFillPuschAlloc(ueCb, puschTime, totDataReq, startSymb, symbLen, startPrb) == ROK)
{
if(cell->schUlSlotInfo[puschTime.slot]->schPuschInfo)
{
memcpy(&dciInfo->slotIndInfo, &dciTime, sizeof(SlotTimingInfo));
ueCb->srRcvd = false;
ueCb->bsrRcvd = false;
- for(lcgIdx=0; lcgIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcgIdx++)
- {
- ueCb->bsrInfo[lcgIdx].dataVol = 0;
- }
-
cell->schUlSlotInfo[puschTime.slot]->puschUe = ueId;
+ if(ueCb->ulLcPrbEst.dedLcInfo != NULLP)
+ updateBsrAndLcList(&(ueCb->ulLcPrbEst.dedLcInfo->dedLcList), ueCb->bsrInfo, ROK);
+
+ updateBsrAndLcList(&(ueCb->ulLcPrbEst.defLcList), ueCb->bsrInfo, ROK);
return true;
}
}
}
+
+ if(ueCb->ulLcPrbEst.dedLcInfo != NULLP)
+ updateBsrAndLcList(&(ueCb->ulLcPrbEst.dedLcInfo->dedLcList), ueCb->bsrInfo, RFAILED);
+
+ updateBsrAndLcList(&(ueCb->ulLcPrbEst.defLcList), ueCb->bsrInfo, RFAILED);
}
}
- return false;
+ return (ret);
}
+
+
+/*******************************************************************
+ *
+ * @brief sch Process pending Sr or Bsr Req
+ *
+ * @details
+ *
+ * Function : updateBsrAndLcList
+ *
+ * Functionality:
+ * Updating the BSRInfo in UECB and Lclist
+ *
+ * @params[in] SchCellCb *cell, SlotTimingInfo currTime
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *******************************************************************/
+void updateBsrAndLcList(CmLListCp *lcLL, BsrInfo *bsrInfo, uint8_t status)
+{
+ CmLList *node = NULLP, *next = NULLP;
+ LcInfo *lcNode = NULLP;
+
+ if(lcLL == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH: LcList not present");
+ return;
+ }
+
+ if(lcLL->count)
+ {
+ node = lcLL->first;
+ }
+ else
+ {
+ /*lcLL is empty*/
+ return;
+ }
+
+ while(node)
+ {
+ next = node->next;
+ lcNode = (LcInfo *)node->node;
+ if(lcNode != NULLP)
+ {
+ /*Only when Status is OK then allocation is marked as ZERO and reqBO
+ * is updated in UE's DB. If Failure, then allocation is added to reqBO
+ * and same is updated in Ue's DB inside BSR Info structure*/
+ if(status == ROK)
+ {
+ lcNode->allocBO = 0;
+ }
+
+ lcNode->reqBO += lcNode->allocBO;
+ bsrInfo[lcNode->lcId].dataVol = lcNode->reqBO;
+ if(lcNode->reqBO == 0)
+ {
+ handleLcLList(lcLL, lcNode->lcId, DELETE);
+ }
+ }
+ node = next;
+ }
+}
/**********************************************************************
End of file
**********************************************************************/
if ((ueCb->dlLcPrbEst.defLcList.count == 0) && \
- ((ueCb->dlLcPrbEst.dedLcInfo != NULL) && (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0)))
+ ((ueCb->dlLcPrbEst.dedLcInfo == NULL) || (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0)))
{
DU_LOG("\nDEBUG --> SCH : No pending BO for any LC id\n");
- if(*(uint8_t *)cell->ueToBeScheduled.first->node == ueId)
- {
- SCH_FREE(cell->ueToBeScheduled.first->node, sizeof(uint8_t));
- deleteNodeFromLList(&cell->ueToBeScheduled, cell->ueToBeScheduled.first);
- }
UNSET_ONE_BIT(ueId, cell->boIndBitMap);
/* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
}
else
memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
- return false;
+
+ /*TRUE because this UE has nothing to be scheduled*/
+ return true;
}
/*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/
- maxFreePRB = searchLargestFreeBlockDL(cell, pdschTime, &startPrb);
+ maxFreePRB = searchLargestFreeBlock(cell, pdschTime, &startPrb, DIR_DL);
/*[Step4]: Estimation of PRB and BO which can be allocated to each LC in
* the list based on RRM policy*/
|| ((maxFreePRB < ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB)))
{
ueCb->dlLcPrbEst.sharedNumPrb = maxFreePRB;
- DU_LOG("\nWARNING --> SCH : Only Default Slice is scheduled, sharedPRB Count:%d",\
+ DU_LOG("\nDEBUG --> SCH : DL Only Default Slice is scheduled, sharedPRB Count:%d",\
ueCb->dlLcPrbEst.sharedNumPrb);
/*PRB Alloc for Default LCs*/
prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschNumSymbols,\
- &(ueCb->dlLcPrbEst.sharedNumPrb), NULLP, &isTxPayloadLenAdded);
+ &(ueCb->dlLcPrbEst.sharedNumPrb), NULLP, &isTxPayloadLenAdded, NULLP);
}
else
{
/*PRB Alloc for Dedicated LCs*/
prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), TRUE, mcsIdx, pdschNumSymbols,\
- &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded);
+ &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded, NULLP);
/*PRB Alloc for Default LCs*/
prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschNumSymbols, \
- &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded);
+ &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded, NULLP);
}
}
/*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes
* using allocated BO per LC and Update dlMsgAlloc(BO report for MAC*/
if(ueCb->dlLcPrbEst.dedLcInfo != NULLP)
- updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), dciSlotAlloc, &(accumalatedSize));
+ updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), dciSlotAlloc, NULLP, &(accumalatedSize));
- updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.defLcList), dciSlotAlloc, &(accumalatedSize));
+ updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.defLcList), dciSlotAlloc, NULLP, &(accumalatedSize));
/*Below case will hit if NO LC(s) are allocated due to resource crunch*/
if (!accumalatedSize)
* RFAILED - failure
*
* ****************************************************************/
-uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t dataVol, uint8_t k2, uint8_t startSymb, uint8_t symbLen)
+uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize,
+ uint8_t startSymb, uint8_t symbLen, uint16_t startPrb)
{
- uint16_t startRb = 0;
uint8_t numRb = 0;
- uint16_t tbSize = 0;
- uint8_t buffer = 5;
- SchCellCb *cellCb = ueCb->cellCb;
+ SchCellCb *cellCb = NULLP;
SchUlSlotInfo *schUlSlotInfo = NULLP;
SchPuschInfo puschInfo;
- startRb = MAX_NUM_RB;
- tbSize = schCalcTbSize(dataVol + buffer); /* 2 bytes header + some buffer */
+ if(ueCb == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH: UE CB is empty");
+ return RFAILED;
+ }
+
+ cellCb = ueCb->cellCb;
+ if(cellCb == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH: CELL CB is empty");
+ return RFAILED;
+ }
+
+ tbSize += UL_TX_BUFFER_SIZE; /* 2 bytes header + some buffer */
numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
- allocatePrbUl(cellCb, puschTime, startSymb, symbLen, &startRb, numRb);
+ allocatePrbUl(cellCb, puschTime, startSymb, symbLen, &startPrb, numRb);
puschInfo.crnti = ueCb->crnti;
puschInfo.harqProcId = SCH_HARQ_PROC_ID;
puschInfo.resAllocType = SCH_ALLOC_TYPE_1;
- puschInfo.fdAlloc.startPrb = startRb;
+ puschInfo.fdAlloc.startPrb = startPrb;
puschInfo.fdAlloc.numPrb = numRb;
puschInfo.tdAlloc.startSymb = startSymb;
puschInfo.tdAlloc.numSymb = symbLen;
if(lcLL == NULLP)
{
- DU_LOG("\nERROR -->SCH: LcList doesnt exist");
+ DU_LOG("\nERROR --> SCH: LcList doesnt exist");
return NULLP;
}
node = lcLL->first;
lcNode = (LcInfo *)node->node;
if(lcNode->lcId == lcId)
{
- DU_LOG("\nINFO --> SCH : LcID:%d found in LL",lcId);
found = TRUE;
break;
}
/*List is empty; Initialize the LL ControlPointer*/
if(lcLL->count == 0)
{
- DU_LOG("\nINFO --> SCH: First LC:%d to add in this List",lcId);
cmLListInit(lcLL);
}
}
else
{
- DU_LOG("\nERROR --> SCH : Allocation of List failed,lcId:%d",lcId);
+ DU_LOG("\nERROR --> SCH : Allocation of List failed,lcId:%d",lcId);
return NULLP;
}
if(addNodeToLList(lcLL, lcNode, NULLP) == RFAILED)
{
- DU_LOG("\nERROR --> SCH : failed to Add Node,lcId:%d",lcId);
+ DU_LOG("\nERROR --> SCH : failed to Add Node,lcId:%d",lcId);
SCH_FREE(lcNode, sizeof(LcInfo));
return NULLP;
}
- DU_LOG("\nINFO --> SCH : Added new Node in List for lcId:%d\n",lcId);
return lcNode;
}
{
if(!found || lcNode == NULLP)
{
- DU_LOG("\nERROR --> SCH: LCID: %d not found; thus Deletion unsuccessful",lcId);
+ DU_LOG("\nERROR --> SCH: LCID%d not found; thus Deletion unsuccessful",lcId);
}
else
{
if(deleteNodeFromLList(lcLL, node) == ROK)
SCH_FREE(lcNode, sizeof(LcInfo));
- DU_LOG("\nINFO --> SCH: LCID: %d Deleted successfully",lcId);
+ DU_LOG("\nDEBUG --> SCH: LCID%d Deleted successfully",lcId);
}
return NULLP;
}
default:
{
- DU_LOG("\nERROR --> SCH: Action type wrong: %d",action);
+ DU_LOG("\nERROR --> SCH: Action type wrong: %d",action);
break;
}
}
if(lcNode == NULLP)
{
- DU_LOG("\nERROR --> SCH : LC is neither present nor able to create in List lcId:%d",lcId);
+ DU_LOG("\nERROR --> SCH : LC is neither present nor able to create in List lcId:%d",lcId);
return RFAILED;
}
lcNode->reqBO = payloadSize;
lcNode->allocBO = 0;
lcNode->allocPRB = 0; /*Re-Initializing the AllocPRB*/
- DU_LOG("\nINFO --> SCH : LCID:%d, reqBO:%d", lcId, lcNode->reqBO);
return ROK;
}
if(lcLL == NULLP)
{
- DU_LOG("\nINFO --> SCH: LcList doesnt exist");
+ DU_LOG("\nERROR --> SCH: LcList doesnt exist");
return;
}
node = lcLL->first;
if(lcLL == NULLP)
{
- DU_LOG("\nINFO -->SCH: LcList doesnt exist");
+ DU_LOG("\nINFO --> SCH: LcList doesnt exist");
return;
}
node = lcLL->first;
lcNode = (LcInfo *)node->node;
if(lcNode)
{
- DU_LOG("\nINFO --> SCH : LcID:%d, [reqBO, allocBO, allocPRB]:[%d,%d,%d]",\
+ DU_LOG("\nINFO --> SCH : LcID:%d, [reqBO, allocBO, allocPRB]:[%d,%d,%d]",\
lcNode->lcId,lcNode->reqBO, lcNode->allocBO, lcNode->allocPRB);
}
#define EVENT_UE_DELETE_RSP_TO_MAC 16
#define EVENT_CELL_DELETE_REQ_TO_SCH 17
#define EVENT_CELL_DELETE_RSP_TO_MAC 18
+#define EVENT_LONG_BSR 19
/*macros*/
#define RAR_PAYLOAD_SIZE 10 /* As per spec 38.321, sections 6.1.5 and 6.2.3, RAR PDU is 8 bytes long and 2 bytes of padding */
#define TX_PAYLOAD_HDR_LEN 32 /* Intel L1 requires adding a 32 byte header to transmitted payload */
+#define UL_TX_BUFFER_SIZE 5
#define MAX_NUM_CONFIG_SLOTS 160 /*Max number of slots as per the numerology*/
#define MAX_NUM_K0_IDX 16 /* Max number of pdsch time domain downlink allocation */
uint8_t idx, rrcMsgType, gnbDuUeF1apId;
uint8_t ret =ROK;
InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
- DU_LOG("\nINFO --> F1AP : filling the required values in DB in procInitULRRCMsg");
+ DU_LOG("\nINFO --> F1AP : filling the required values in DB in procInitULRRCMsg");
initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
uint16_t sfnValue;
uint16_t slotValue;
+/*Mapping between LCG ID and BSR Idx*/
+typedef struct lcgBufferSize
+{
+ uint8_t lcgId; /*LCG ID for which BSR will be requested*/
+ /*BufferStatus Index. This is as per Spec 38.321, BSR will be reported as Index
+ * Refer table Table 6.1.3.1-1:Short_BSR and Table 6.1.3.1-2:Long_BSR*/
+ uint8_t bsIdx;
+}LcgBufferSize;
+
/* UE specific information */
typedef struct ueCb
{
void l1StartConsoleHandler();
void l1HdlSlotIndicaion(bool);
void GenerateTicks();
+uint8_t l1SendUlUserData(uint8_t drbId);
+uint8_t l1SendStatusPdu();
+uint16_t l1BuildAndSendSlotIndication();
+uint16_t l1BuildAndSendStopInd();
/**********************************************************************
End of file
l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn);
ueDb.numActvUe++;
}
-#if 0
/* Send RACH Ind to L2 for second UE */
if(ueDb.ueCb[UE_IDX_1].rachIndSent == false && ulTtiReq->sfn == 304 && ulTtiReq->slot == 0)
{
l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn);
ueDb.numActvUe++;
}
-#endif
MAC_FREE(msg, msgLen);
#endif
return ROK;
#endif
}
}
+
+#ifdef INTEL_FAPI
+/*******************************************************************
+ *
+ * @brief Builds and Send the BSR message to MAC
+ *
+ * @details
+ *
+ * Function : l1BuildAndSendBSR
+ *
+ * Functionality:
+ * -Send the BSR Message to MAC
+ *
+ * @params[in] BSR type
+ * array of LCGID and BSIdx
+ * @return void
+ *
+ *****************************************************************/
+uint16_t l1BuildAndSendBSR(uint8_t ueIdx, BsrType bsrType,\
+ LcgBufferSize lcgBsIdx[MAX_NUM_LOGICAL_CHANNEL_GROUPS])
+{
+ fapi_rx_data_indication_t *rxDataInd;
+ fapi_pdu_ind_info_t *pduInfo;
+ uint8_t *pdu = NULLP;
+ uint16_t byteIdx = 0;
+ uint32_t msgLen = 0;
+ uint8_t pduIdx = 0, lcgIdx = 0, lcgIdxPos = 0;
+
+ MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
+ if(!rxDataInd)
+ {
+ DU_LOG("\nERROR --> PHY_STUB: Memory allocation failed for Rx Data Indication");
+ return RFAILED;
+ }
+ memset(rxDataInd, 0, sizeof(fapi_rx_data_indication_t));
+
+ msgLen = sizeof(fapi_rx_data_indication_t) - sizeof(fapi_msg_t);
+ rxDataInd->sfn = 0;
+ rxDataInd->slot = 0;
+ rxDataInd->numPdus = 1;
+
+ pduInfo = &rxDataInd->pdus[pduIdx];
+ pduInfo->handle = (ODU_START_CRNTI + ueIdx);
+ pduInfo->rnti = (ODU_START_CRNTI + ueIdx);
+ pduInfo->harqId = 1;
+
+ /* Since status pdu size = 3bytes and 2 bytes of MAC header,
+ * setting tbsize = 24 from Table 5.1.3.2-1 spec 38.214 */
+ pduInfo->pdu_length = 24;
+ pduInfo->ul_cqi = 0;
+ pduInfo->timingAdvance = 0;
+ pduInfo->rssi = 0;
+
+ /* Filling pdu with random values for testing */
+ pduInfo->pduData = NULL;
+ MAC_ALLOC(pduInfo->pduData, pduInfo->pdu_length);
+ if(!pduInfo->pduData)
+ {
+ DU_LOG("\nERROR --> PHY_STUB: Memory allocation failed for Rx Data Pdu");
+ MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
+ return RFAILED;
+ }
+
+ /* Filling PDU */
+ pdu = (uint8_t *)pduInfo->pduData;
+
+ switch(bsrType)
+ {
+ case SHORT_BSR:
+ {
+ DU_LOG("\nDEBUG --> PHY_STUB: Forming SHORT BSR PDU ");
+
+ /* For Short BSR
+ * MAC subheader format is R/R/LcId (1Byte)
+ * LCId is 61
+ * From 38.321 section 6.1.1
+ */
+ pdu[byteIdx++] = 61; // LCID
+ pdu[byteIdx++] = (lcgBsIdx[0].lcgId << 5) | lcgBsIdx[0].bsIdx;
+ break;
+ }
+
+ case LONG_BSR:
+ {
+ DU_LOG("\nDEBUG --> PHY_STUB: Forming LONG BSR PDU ");
+
+ /* For Long BSR
+ * MAC subheader format is R/R/LcId (1Byte)
+ * LCId is 62
+ * From 38.321 section 6.1.1
+ */
+ pdu[byteIdx++] = 62; // LCID
+
+ /*Octet where lcgId bitmap will be present*/
+ lcgIdxPos = byteIdx;
+ byteIdx++;
+ for(lcgIdx = 0; lcgIdx < MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcgIdx++)
+ {
+ if(lcgBsIdx[lcgIdx].bsIdx > 0)
+ {
+ pdu[lcgIdxPos] |= 1 << lcgBsIdx[lcgIdx].lcgId;
+ pdu[byteIdx++] = lcgBsIdx[lcgIdx].bsIdx;
+ }
+ }
+
+ break;
+ }
+
+ default:
+ {
+ DU_LOG("\nERROR --> PHY_STUB: Incorrect BSR type:%d!", bsrType);
+ if(pduInfo->pdu_length)
+ MAC_FREE(pduInfo->pduData, pduInfo->pdu_length);
+ MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
+ return RFAILED;
+ }
+ }
+ /* Filling MAC SDU for Padding bytes*/
+ if(byteIdx < pduInfo->pdu_length)
+ {
+ /* For Padding
+ * MAC subheader format is R/R/LCId (1byte)
+ * LCId is 63 for padding
+ * From 38.321 section 6.1.1
+ */
+ pdu[byteIdx++] = 63;
+
+ for(; byteIdx < pduInfo->pdu_length; byteIdx++)
+ pdu[byteIdx] = 0;
+ }
+ msgLen += pduInfo->pdu_length;
+ fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, msgLen);
+
+ /* Sending Rx data indication to MAC */
+ DU_LOG("\nINFO --> PHY STUB: Sending Rx data Indication to MAC");
+ procPhyMessages(rxDataInd->header.msg_id, sizeof(fapi_rx_data_indication_t), (void *)rxDataInd);
+
+ if(pduInfo->pdu_length)
+ MAC_FREE(pduInfo->pduData, pduInfo->pdu_length);
+ MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
+ return ROK;
+}
+#endif
+
/**********************************************************************
End of file
**********************************************************************/
#include "fapi_vendor_extension.h"
#endif
#include "phy_stub.h"
+#include "mac_sch_interface.h"
-uint8_t l1SendUlUserData();
-uint8_t l1SendStatusPdu();
-uint16_t l1BuildAndSendSlotIndication();
-uint16_t l1BuildAndSendStopInd();
+extern uint16_t l1BuildAndSendBSR(uint8_t ueIdx, BsrType bsrType,\
+ LcgBufferSize lcgBsIdx[MAX_NUM_LOGICAL_CHANNEL_GROUPS]);
pthread_t thread = 0;
/*******************************************************************
* ****************************************************************/
void *l1ConsoleHandler(void *args)
{
- char ch;
- uint8_t drbIdx = 0;
+ char ch, ch1;
+ uint8_t drbIdx = 0, lcgIdx = 0, ueIdx = 0;
+ LcgBufferSize lcgBS[MAX_NUM_LOGICAL_CHANNEL_GROUPS];
while(true)
{
/* Send UL user data to DU when user enters 'd' on console */
- if((ch = getchar()) == 'd')
+ ch = getchar();
+ if(ch == 'd')
{
/* Start Pumping data from PHY stub to DU */
for(drbIdx = 0; drbIdx < NUM_DRB_TO_PUMP_DATA; drbIdx++) //Number of DRB times the loop will run
l1SendUlUserData(drbIdx);
}
}
- else if((ch = getchar()) == 'c')
+ else if(ch =='c')
{
/* Send Control PDU from PHY stub to DU */
- DU_LOG("\nDEBUG --> PHY STUB: Sending Status PDU");
- l1SendStatusPdu();
+ DU_LOG("\nDEBUG --> PHY STUB: Sending Status PDU");
+ l1SendStatusPdu();
+ }
+ else if(ch == 'b')
+ {
+ memset(lcgBS, 0, (MAX_NUM_LOGICAL_CHANNEL_GROUPS * sizeof(LcgBufferSize)));
+ /* Send Control PDU from PHY stub to DU */
+ ch1 = getchar();
+ for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
+ {
+ if(ch1 == 'l')
+ {
+ for(lcgIdx = 0; lcgIdx < NUM_DRB_TO_PUMP_DATA; lcgIdx++)
+ {
+ lcgBS[lcgIdx].lcgId = MIN_DRB_LCID + lcgIdx;
+ lcgBS[lcgIdx].bsIdx = lcgIdx + 1;
+ }
+ l1BuildAndSendBSR(ueIdx, LONG_BSR, lcgBS);
+ }
+ else if(ch1 == 's')
+ {
+ lcgIdx = 0;
+
+ lcgBS[lcgIdx].lcgId = MIN_DRB_LCID + lcgIdx;
+ lcgBS[lcgIdx].bsIdx = lcgIdx + 1;
+ l1BuildAndSendBSR(ueIdx, SHORT_BSR, lcgBS);
+ }
+ }
}
DU_LOG("\n");
continue;