uint8_t ret = ROK;
#ifdef INTEL_FAPI
uint16_t msgLen =0;
- char message[100];
p_fapi_api_queue_elem_t currMsg = NULLP;
#ifdef CALL_FLOW_DEBUG_LOG
+ char message[100];
+
currMsg = (p_fapi_api_queue_elem_t)msg;
while(currMsg)
{
#define MAC_LCID_CRI 62
#define MAC_LCID_PADDING 63
+/* Definitions for size of RAR PDU contents (in bits).
+ * Refer spec 38.321, sections 6.1.4, 6.2.2 and 6.2.3*/
+#define E_BIT_SIZE 1
+#define T_BIT_SIZE 1
+#define R_BIT_SIZE 1
+#define RAPID_SIZE 6
+#define LC_ID_SIZE 6
+#define TIMING_ADVANCE_SIZE 12
+#define T_CRNTI_SIZE 16
+/* UL Grant is of size = 27 bits. Refer to Spec 38.213, Table 8.2-1 for
+ * contents of UL grant in RAR */
+#define FREQ_HOP_FLAG_SIZE 1
+#define FREQ_RSRC_ALLOC_SIZE 14
+#define TIME_RSRC_ALLOC_SIZE 4
+#define MCS_SIZE 4
+#define TPC_COMMAND_SIZE 3
+#define CSI_REQUEST_SIZE 1
+
typedef struct macCellCb MacCellCb;
typedef enum
{
SchCellCfg schCellCfg;
Pst cfgPst;
- uint8_t idx=0, ret=0;
+ uint8_t ssbMaskIdx = 0, rsrcListIdx = 0, ret=0;
memset(&cfgPst, 0, sizeof(Pst));
memset(&schCellCfg, 0, sizeof(SchCellCfg));
schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
schCellCfg.ssbSchCfg.ssbPeriod = ssbPeriodicity[macCellCfg->ssbCfg.ssbPeriod];
schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
- for(uint8_t idx=0; idx<SSB_MASK_SIZE; idx++)
+ for(ssbMaskIdx=0; ssbMaskIdx<SSB_MASK_SIZE; ssbMaskIdx++)
{
- schCellCfg.ssbSchCfg.nSSBMask[idx] = macCellCfg->ssbCfg.ssbMask[idx];
+ schCellCfg.ssbSchCfg.nSSBMask[ssbMaskIdx] = macCellCfg->ssbCfg.ssbMask[ssbMaskIdx];
}
/* fill SIB1 scheduler parameters */
schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
schCellCfg.schInitialDlBwp.pdschCommon.numTimeDomAlloc = macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc;
- for(idx = 0; idx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; idx++)
+ for(rsrcListIdx = 0; rsrcListIdx<macCellCfg->initialDlBwp.pdschCommon.numTimeDomAlloc; rsrcListIdx++)
{
- schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 =
- macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0;
- schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
- macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType;
- schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
- macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol;
- schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
- macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol;
+ schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0 =
+ macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].k0;
+ schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
+ macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
+ schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
+ macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
+ schCellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol =
+ macCellCfg->initialDlBwp.pdschCommon.timeDomRsrcAllocList[rsrcListIdx].lengthSymbol;
}
/* fill initial UL BWP */
schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
schCellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc = \
macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc;
- for(idx = 0; idx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; idx++)
+ for(rsrcListIdx = 0; rsrcListIdx < macCellCfg->initialUlBwp.puschCommon.numTimeDomRsrcAlloc; rsrcListIdx++)
{
- schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[idx].k2 =
- macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[idx].k2;
- schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[idx].mappingType =
- macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[idx].mappingType;
- schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[idx].startSymbol =
- macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[idx].startSymbol;
- schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[idx].symbolLength =
- macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[idx].symbolLength;
+ schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2 =
+ macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].k2;
+ schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType =
+ macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].mappingType;
+ schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol =
+ macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].startSymbol;
+ schCellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength =
+ macCellCfg->initialUlBwp.puschCommon.timeDomRsrcAllocList[rsrcListIdx].symbolLength;
}
#ifdef NR_TDD
memcpy(&schCellCfg.tddCfg, &macCellCfg->tddCfg, sizeof(TDDCfg));
void fillRarPdu(RarInfo *rarInfo)
{
uint8_t *rarPdu = rarInfo->rarPdu;
- uint16_t bytePos= 0;
uint8_t bitPos = 0;
+ uint16_t bytePos= 0, bwpSize = 0, rbStart = 0, rbLen = 0;
+ uint8_t numHopInfoBitsInFreqAlloc = 0;
+ uint8_t actualFreqRsrcAllocSize = 0;
/* RAR subheader fields */
uint8_t EBit = 0;
uint8_t TBit = 0;
- uint8_t rapId = 0;
/* RAR payload fields */
uint8_t RBit = 0;
- uint16_t timeAdv = 0;
- uint32_t ulGrant = 0;
- uint16_t tmpCrnti = 0;
+ uint16_t msg3FreqResource = 0;
uint8_t paddingLcid = 63;
- /* Size(in bits) of RAR subheader files */
- uint8_t EBitSize = 1;
- uint8_t TBitSize = 1;
- uint8_t rapidSize = 6;
- uint8_t paddingLcidSize = 6;
+ /* Considering 2 bytes of padding in RAR PDU.
+ * 1st byte is MAC sub-header for padding
+ * 2nd byte contains padding bits
+ */
uint8_t paddingSize = 8;
-
- /* Size(in bits) of RAR payload fields */
- uint8_t RBitSize = 1;
- uint8_t timeAdvSize = 12;
- uint8_t ulGrantSize = 27;
- uint8_t tmpCrntiSize = 16;
-
/* Fill RAR pdu fields */
EBit = 0;
TBit = 1;
- rapId = rarInfo->RAPID;
-
RBit = 0;
- timeAdv = rarInfo->ta;
- ulGrant = 0; /* this will be done when implementing msg3 */
- tmpCrnti = rarInfo->tcrnti;
+
rarInfo->rarPduLen = RAR_PAYLOAD_SIZE;
/* Initialize buffer */
bitPos = 7;
/* Packing fields into RAR PDU */
- packBytes(rarPdu, &bytePos, &bitPos, EBit, EBitSize);
- packBytes(rarPdu, &bytePos, &bitPos, TBit, TBitSize);
- packBytes(rarPdu, &bytePos, &bitPos, rapId, rapidSize);
- packBytes(rarPdu, &bytePos, &bitPos, RBit, RBitSize);
- packBytes(rarPdu, &bytePos, &bitPos, timeAdv, timeAdvSize);
- packBytes(rarPdu, &bytePos, &bitPos, ulGrant, ulGrantSize);
- packBytes(rarPdu, &bytePos, &bitPos, tmpCrnti, tmpCrntiSize);
+ packBytes(rarPdu, &bytePos, &bitPos, EBit, E_BIT_SIZE);
+ packBytes(rarPdu, &bytePos, &bitPos, TBit, T_BIT_SIZE);
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->RAPID, RAPID_SIZE);
+ packBytes(rarPdu, &bytePos, &bitPos, RBit, R_BIT_SIZE);
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->ta, TIMING_ADVANCE_SIZE);
+
+ /* Packing MSG3 UL Grant in RAR */
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->ulGrant.freqHopFlag, FREQ_HOP_FLAG_SIZE);
+
+ /* Calculating freq domain resource allocation field value
+ * bwpSize = Size of BWP
+ * RBStart = Starting Resource block
+ * RBLen = length of contiguously allocted RBs
+ * Spec 38.214 Sec 6.1.2.2.2
+ */
+ bwpSize = rarInfo->ulGrant.bwpSize;
+ rbStart = rarInfo->ulGrant.msg3FreqAlloc.startPrb;
+ rbLen = rarInfo->ulGrant.msg3FreqAlloc.numPrb;
+
+ if((rbLen >=1) && (rbLen <= bwpSize - rbStart))
+ {
+ if((rbLen - 1) <= floor(bwpSize / 2))
+ msg3FreqResource = (bwpSize * (rbLen-1)) + rbStart;
+ else
+ msg3FreqResource = (bwpSize * (bwpSize - rbLen + 1)) \
+ + (bwpSize - 1 - rbStart);
+ }
+
+ /* Calculating frequency domain resource allocation field size
+ * and packing frequency domain resource allocation accordingly
+ * Spec 38.213 Sec 8.3
+ */
+ if(bwpSize < 180)
+ {
+ actualFreqRsrcAllocSize = ceil(log2(bwpSize * (bwpSize + 1) / 2));
+ packBytes(rarPdu, &bytePos, &bitPos, 0, FREQ_RSRC_ALLOC_SIZE - actualFreqRsrcAllocSize);
+ packBytes(rarPdu, &bytePos, &bitPos, msg3FreqResource, actualFreqRsrcAllocSize);
+ }
+ else
+ {
+ if(rarInfo->ulGrant.freqHopFlag == 0)
+ {
+ numHopInfoBitsInFreqAlloc = 1;
+ packBytes(rarPdu, &bytePos, &bitPos, 0, numHopInfoBitsInFreqAlloc);
+
+ actualFreqRsrcAllocSize = abs(log2(bwpSize * (bwpSize + 1) / 2));
+ packBytes(rarPdu, &bytePos, &bitPos, 0, actualFreqRsrcAllocSize - FREQ_RSRC_ALLOC_SIZE);
+ packBytes(rarPdu, &bytePos, &bitPos, msg3FreqResource, \
+ actualFreqRsrcAllocSize - numHopInfoBitsInFreqAlloc);
+ }
+ else
+ {
+ /* TODO : If frequency hopping is supported,
+ * Fetch the Number of bits to store hopping information in frequency
+ * resource allocation field and the value to be filled from Spec 38.213, Table 8.3-1.
+ * Fill the frequency resource allocation field as described in Spec 38.213 sec 8.3
+ */
+ }
+ }
+
+ /* Packing time domain resource allocation for UL grant */
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->ulGrant.k2Index, TIME_RSRC_ALLOC_SIZE);
+
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->ulGrant.mcs, MCS_SIZE);
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->ulGrant.tpc, TPC_COMMAND_SIZE);
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->ulGrant.csiReq, CSI_REQUEST_SIZE);
+
+ packBytes(rarPdu, &bytePos, &bitPos, rarInfo->tcrnti, T_CRNTI_SIZE);
/* padding of 2 bytes */
- packBytes(rarPdu, &bytePos, &bitPos, RBit, RBitSize*2);
- packBytes(rarPdu, &bytePos, &bitPos, paddingLcid, paddingLcidSize);
+ packBytes(rarPdu, &bytePos, &bitPos, RBit, R_BIT_SIZE*2);
+ packBytes(rarPdu, &bytePos, &bitPos, paddingLcid, LC_ID_SIZE);
packBytes(rarPdu, &bytePos, &bitPos, 0, paddingSize);
}
SuId rguUlSapId = 0;
SuId rguDlSapId = 0;
/* RLC SAP to allocate flowCntrlInd buffer*/
- Pst *pst ;
+ /* Commented below to resolve compilation warning */
+ //Pst *pst ;
errInfo->errCause = RGERR_CFG_CRG_CELL_CFG;
rgUpdtCellCnt(inst,RG_CFG_ADD);
errInfo->errCause = RGERR_NONE;
- pst = &rgCb[inst].rguSap[rguDlSapId].sapCfg.sapPst;
+ /* Commented below to resolve compilation warning */
+ //pst = &rgCb[inst].rguSap[rguDlSapId].sapCfg.sapPst;
/* Allocate a buffer for flowCntrlInd.*/
MAC_ALLOC(cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
if(cell->flowCntrlInd == NULLP)
)
{
- S16 ret;
-
if ((data == NULLP) || (*data == NULLP) || (size == 0))
{
return;
)
{
- S16 ret;
-
if ((data == NULLP) || (*data == NULLP) || (size == 0))
{
return;
)
{
- S16 ret;
-
if ((data == NULLP) || (*data == NULLP) || (size == 0))
{
return;
* @param[out] msg3NumRb
* @return void
**/
-uint8_t schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, \
- uint16_t *msg3StartRb, uint8_t *msg3NumRb, uint16_t msg3SlotAlloc)
+SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, uint16_t msg3SlotAlloc)
{
- SchCellCb *cell = NULLP;
- SchUlSlotInfo *schUlSlotInfo = NULLP;
+ SchCellCb *cell = NULLP;
+ SchUlSlotInfo *schUlSlotInfo = NULLP;
uint8_t startSymb = 0;
uint8_t symbLen = 0;
uint8_t startRb = 0;
if(!schUlSlotInfo->schPuschInfo)
{
DU_LOG("\nERROR --> SCH : Memory allocation failed in schAllocMsg3Pusch");
- return RFAILED;
+ return NULLP;
}
tbSize = 0; /* since nPrb has been incremented, recalculating tbSize */
tbSize = schCalcTbSizeFromNPrb(numRb, mcs, numPdschSymbols);
schUlSlotInfo->schPuschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
schUlSlotInfo->schPuschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS;
- *msg3StartRb = startRb;
- *msg3NumRb = numRb;
- return ROK;
+ return schUlSlotInfo->schPuschInfo;
}
/**
void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell)
{
uint8_t ueIdx = 0;
+ SchPuschInfo *msg3PuschInfo;
RarInfo *rarInfo = NULLP;
- uint16_t raRnti = 0;
- uint16_t rarSlot = 0;
- uint16_t msg3StartRb;
- uint8_t msg3NumRb;
- uint8_t ret = ROK;
uint8_t delta = 0;
- uint8_t k2 = 0;
+ uint8_t k2Index = 0, k2 = 0;
uint8_t puschMu = 0;
+ uint16_t rarSlot = 0;
uint16_t msg3Slot = 0;
#ifdef NR_TDD
uint16_t slotIdx = 0;
//puschMu = cell->cellCfg.puschMu;
delta = puschDeltaTable[puschMu];
- k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[0].k2;
+ k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2;
/* RAR will sent with a delay of RAR_DELAY */
rarSlot = (currTime.slot + RAR_DELAY + PHY_DELTA_DL) % cell->numSlots;
createSchRaCb(cell->raReq[ueIdx]->rachInd->crnti, cell->instIdx);
/* allocate resources for msg3 */
- ret = schAllocMsg3Pusch(cell->instIdx, rarSlot, cell->raReq[ueIdx]->rachInd->crnti, &msg3StartRb, &msg3NumRb, msg3Slot);
- if(ret == ROK)
+ msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, rarSlot, cell->raReq[ueIdx]->rachInd->crnti, msg3Slot);
+ if(msg3PuschInfo)
{
/* fill RAR info */
- rarInfo->raRnti = cell->raReq[ueIdx]->raRnti;
- rarInfo->tcrnti = cell->raReq[ueIdx]->rachInd->crnti;
- rarInfo->RAPID = cell->raReq[ueIdx]->rachInd->preambleIdx;
- rarInfo->ta = cell->raReq[ueIdx]->rachInd->timingAdv;
- rarInfo->msg3FreqAlloc.startPrb = msg3StartRb;
- rarInfo->msg3FreqAlloc.numPrb = msg3NumRb;
+ rarInfo->raRnti = cell->raReq[ueIdx]->raRnti;
+ rarInfo->tcrnti = cell->raReq[ueIdx]->rachInd->crnti;
+ rarInfo->RAPID = cell->raReq[ueIdx]->rachInd->preambleIdx;
+ rarInfo->ta = cell->raReq[ueIdx]->rachInd->timingAdv;
+ rarInfo->ulGrant.bwpSize = cell->cellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb;
+ /* Spec 38.213, section 8.2, 0 : MSG3 PUSCH will be transmitted without frequency hopping */
+ rarInfo->ulGrant.freqHopFlag = 0;
+ rarInfo->ulGrant.msg3FreqAlloc.startPrb = msg3PuschInfo->fdAlloc.startPrb;
+ rarInfo->ulGrant.msg3FreqAlloc.numPrb = msg3PuschInfo->fdAlloc.numPrb;
+ rarInfo->ulGrant.k2Index = k2Index;
+ rarInfo->ulGrant.mcs = msg3PuschInfo->tbInfo.mcs;
+ rarInfo->ulGrant.tpc = 3; /* TODO : Check appropriate value to be filled */
+ /* Spec 38.213, section 8.2 : In a contention based random access
+ * procedure, the CSI request field is reserved. */
+ rarInfo->ulGrant.csiReq = 0;
}
SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo));
Sib1AllocInfo sib1Alloc;
}DlBrdcstAlloc;
+typedef struct msg3UlGrant
+{
+ uint8_t freqHopFlag;
+ uint16_t bwpSize;
+ FreqDomainAlloc msg3FreqAlloc;
+ uint8_t k2Index;
+ uint8_t mcs;
+ uint8_t tpc;
+ uint8_t csiReq;
+}Msg3UlGrant;
+
typedef struct rarInfo
{
uint16_t raRnti;
uint8_t RAPID;
uint16_t ta;
- FreqDomainAlloc msg3FreqAlloc;
+ Msg3UlGrant ulGrant;
uint16_t tcrnti;
uint8_t rarPdu[RAR_PAYLOAD_SIZE];
uint8_t rarPduLen;