From: lal.harshita Date: Mon, 30 Aug 2021 10:17:49 +0000 (+0530) Subject: RAR and MSG3 scheduling in TDD [Issue-ID: ODUHIGH-342] X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=7fb274708be5434e1573315b106c554d5562ac42;p=o-du%2Fl2.git RAR and MSG3 scheduling in TDD [Issue-ID: ODUHIGH-342] Change-Id: Iae7e79e48feb8c0a0b0f66becd33c39696b7b5f7 Signed-off-by: lal.harshita --- diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 5b787a346..6f4f8a8c2 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -3100,7 +3100,10 @@ uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo) if(dlInfo->rarAlloc != NULLP) { /* PDCCH and PDSCH PDU is filled */ - count += 2; + if(dlInfo->rarAlloc->pduPres == BOTH) + count += 2; + else + count += 1; } if(dlInfo->dlMsgAlloc != NULLP) { @@ -3424,6 +3427,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) DU_LOG("\nDEBUG --> LWR_MAC: MIB sent.."); DU_LOG("\033[0m"); } + if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans) { /* Filling SIB1 param */ @@ -3447,24 +3451,34 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) DU_LOG("\033[0m"); } } + if(currDlSlot->dlInfo.rarAlloc != NULLP) { /* Filling RAR param */ rntiType = RA_RNTI_TYPE; - fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \ - &currDlSlot->dlInfo, rntiType, CORESET_TYPE0); - numPduEncoded++; - fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], - &currDlSlot->dlInfo.rarAlloc->rarPdschCfg, - currDlSlot->dlInfo.rarAlloc->bwp, - pduIndex); - numPduEncoded++; - pduIndex++; + if((currDlSlot->dlInfo.rarAlloc->pduPres == BOTH) || \ + (currDlSlot->dlInfo.rarAlloc->pduPres == PDCCH_PDU)) + { + fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \ + &currDlSlot->dlInfo, rntiType, CORESET_TYPE0); + numPduEncoded++; + } + if((currDlSlot->dlInfo.rarAlloc->pduPres == BOTH) || \ + (currDlSlot->dlInfo.rarAlloc->pduPres == PDSCH_PDU)) + { + fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], + &currDlSlot->dlInfo.rarAlloc->rarPdschCfg, + currDlSlot->dlInfo.rarAlloc->bwp, + pduIndex); + numPduEncoded++; + pduIndex++; - DU_LOG("\033[1;32m"); - DU_LOG("\nDEBUG --> LWR_MAC: RAR sent..."); - DU_LOG("\033[0m"); + DU_LOG("\033[1;32m"); + DU_LOG("\nDEBUG --> LWR_MAC: RAR sent..."); + DU_LOG("\033[0m"); + } } + if(currDlSlot->dlInfo.dlMsgAlloc != NULLP) { if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu != NULLP) @@ -3629,16 +3643,19 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap pduIndex++; txDataReq->num_pdus++; } + if(dlInfo->rarAlloc != NULLP) { - fillRarTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->rarAlloc->rarInfo,\ - dlInfo->rarAlloc->rarPdschCfg); - pduIndex++; - txDataReq->num_pdus++; - - MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc)); - dlInfo->rarAlloc = NULLP; + if((dlInfo->rarAlloc->pduPres == BOTH) || (dlInfo->rarAlloc->pduPres == PDSCH_PDU)) + { + fillRarTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->rarAlloc->rarInfo,\ + dlInfo->rarAlloc->rarPdschCfg); + pduIndex++; + txDataReq->num_pdus++; + } + MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc)); } + if(dlInfo->dlMsgAlloc != NULLP) { fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->dlMsgAlloc->dlMsgInfo,\ @@ -3650,7 +3667,6 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPduLen); dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu = NULLP; MAC_FREE(dlInfo->dlMsgAlloc, sizeof(DlMsgAlloc)); - dlInfo->dlMsgAlloc = NULLP; } /* Fill message header */ diff --git a/src/5gnrsch/sch.c b/src/5gnrsch/sch.c index 1191492cf..056842fb1 100644 --- a/src/5gnrsch/sch.c +++ b/src/5gnrsch/sch.c @@ -877,7 +877,8 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg) pdschCfg, DEFAULT_UL_ACK_LIST_COUNT, defaultUlAckTbl); BuildK2InfoTable(cellCb, cellCb->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList,\ - cellCb->cellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc, &cellCb->cellCfg.schInitialUlBwp.k2InfoTbl); + cellCb->cellCfg.schInitialUlBwp.puschCommon.numTimeDomRsrcAlloc, &cellCb->cellCfg.schInitialUlBwp.msg3K2InfoTbl, \ + &cellCb->cellCfg.schInitialUlBwp.k2InfoTbl); /* Initializing global variables */ cellCb->actvUeBitMap = 0; cellCb->boIndBitMap = 0; diff --git a/src/5gnrsch/sch.h b/src/5gnrsch/sch.h index 27f4aa9e1..5ca4170f5 100644 --- a/src/5gnrsch/sch.h +++ b/src/5gnrsch/sch.h @@ -51,6 +51,7 @@ #define DMRS_ADDITIONAL_POS 0 #define SCH_DEFAULT_K1 1 #define SCH_TQ_SIZE 10 +#define SSB_IDX_SUPPORTED 1 #define CRC_FAILED 0 #define CRC_PASSED 1 @@ -82,6 +83,13 @@ typedef enum SCH_LC_STATE_ACTIVE }SchLcState; +typedef enum +{ + WINDOW_YET_TO_START, + WITHIN_WINDOW, + WINDOW_EXPIRED +}RaRspWindowStatus; + /** * @brief * Structure holding LTE MAC's General Configuration information. @@ -111,8 +119,8 @@ typedef struct schDlSlotInfo uint8_t ssbIdxSupported; /*!< Max SSB index */ SsbInfo ssbInfo[MAX_SSB_IDX]; /*!< SSB info */ bool sib1Pres; /*!< Flag to determine if SIB1 is present in this slot */ - RarInfo *rarInfo; /*!< RAR info */ - DlMsgInfo *dlMsgInfo; /*!< DL dedicated Msg info */ + RarAlloc *rarAlloc; /*!< RAR allocation */ + DlMsgInfo *dlMsgInfo; /*!< DL dedicated Msg info */ }SchDlSlotInfo; typedef struct schRaCb @@ -286,12 +294,18 @@ uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, S uint8_t schDlRsrcAllocDlMsg(DlMsgAlloc *dlMsgAlloc, SchCellCb *cell, uint16_t crnti, uint32_t *accumalatedSize, uint16_t slot); uint16_t schAccumalateLcBoSize(SchCellCb *cell, uint16_t ueIdx); -uint8_t schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t offsetPointA, bool ssbPresent, bool sib1Present); -void BuildK0K1Table(SchCellCb *cell, SchK0K1TimingInfoTbl *k0K1InfoTbl, bool pdschCfgCmnPres, SchPdschCfgCmn pdschCmnCfg,\ -SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl); +uint8_t schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t offsetPointA, \ + uint8_t k0Index, bool ssbPresent, bool sib1Present); void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cellCb); -void BuildK2InfoTable(SchCellCb *cell, SchPuschTimeDomRsrcAlloc timeDomRsrcAllocList[], uint16_t puschSymTblSize,\ -SchK2TimingInfoTbl *k2InfoTbl); + +void BuildK0K1Table(SchCellCb *cell, SchK0K1TimingInfoTbl *k0K1InfoTbl, bool pdschCfgCmnPres, \ +SchPdschCfgCmn pdschCmnCfg,SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl); +void BuildK2InfoTable(SchCellCb *cell, SchPuschTimeDomRsrcAlloc timeDomRsrcAllocList[], \ +uint16_t puschSymTblSize, SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl); + +PduTxOccsaion schCheckSsbOcc(SlotTimingInfo slotTime, SchCellCb *cell); +PduTxOccsaion schCheckSib1Occ(SlotTimingInfo slotTime, SchCellCb *cell); + /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrsch/sch_common.c b/src/5gnrsch/sch_common.c index fea12b3f6..ebd6f7a5e 100644 --- a/src/5gnrsch/sch_common.c +++ b/src/5gnrsch/sch_common.c @@ -47,6 +47,7 @@ SchCb schCb[SCH_MAX_INST]; uint16_t prachCfgIdxTable[MAX_PRACH_CONFIG_IDX][8]; uint16_t numRbForPrachTable[MAX_RACH_NUM_RB_IDX][5]; uint8_t pucchResourceSet[MAX_PUCCH_RES_SET_IDX][4]; +uint8_t puschDeltaTable[MAX_MU_PUSCH]; SchMacUlSchInfoFunc schMacUlSchInfoOpts[] = { @@ -1136,13 +1137,15 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) * * ****************************************************************/ void BuildK2InfoTableForFdd(SchCellCb *cell, SchPuschTimeDomRsrcAlloc timeDomRsrcAllocList[], uint16_t puschSymTblSize,\ -SchK2TimingInfoTbl *k2InfoTbl) +SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) { - uint16_t slotIdx=0, k2Index=0, k2TmpVal=0; + uint16_t slotIdx=0, k2Index=0, k2TmpIdx=0, msg3K2TmpIdx=0; /* Initialization the structure and storing the total slot values. */ memset(k2InfoTbl, 0, sizeof(SchK2TimingInfoTbl)); k2InfoTbl->tblSize = cell->numSlots; + if(msg3K2InfoTbl) + msg3K2InfoTbl->tblSize = cell->numSlots; /* Checking all possible indexes for K2. */ for(slotIdx = 0; slotIdx < cell->numSlots; slotIdx++) @@ -1150,9 +1153,17 @@ SchK2TimingInfoTbl *k2InfoTbl) /* Storing K2 values. */ for(k2Index = 0; ((k2Index < puschSymTblSize) && (k2Index < MAX_NUM_K2_IDX)); k2Index++) { - k2TmpVal= k2InfoTbl->k2TimingInfo[slotIdx].numK2; - k2InfoTbl->k2TimingInfo[slotIdx].k2Indexes[k2TmpVal] = k2Index; + k2TmpIdx= k2InfoTbl->k2TimingInfo[slotIdx].numK2; + k2InfoTbl->k2TimingInfo[slotIdx].k2Indexes[k2TmpIdx] = k2Index; k2InfoTbl->k2TimingInfo[slotIdx].numK2++; + + /* Updating K2 values for MSG3 */ + if(msg3K2InfoTbl) + { + msg3K2TmpIdx = msg3K2InfoTbl->k2TimingInfo[slotIdx].numK2; + msg3K2InfoTbl->k2TimingInfo[slotIdx].k2Indexes[msg3K2TmpIdx] = k2Index; + msg3K2InfoTbl->k2TimingInfo[slotIdx].numK2++; + } } } } @@ -1175,19 +1186,19 @@ SchK2TimingInfoTbl *k2InfoTbl) * * ****************************************************************/ void BuildK2InfoTable(SchCellCb *cell, SchPuschTimeDomRsrcAlloc timeDomRsrcAllocList[], uint16_t puschSymTblSize,\ -SchK2TimingInfoTbl *k2InfoTbl) +SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) { #ifdef NR_TDD bool dlSymbolPresent = false; - uint8_t slotIdx=0, k2Index=0, k2TmpVal=0, numK2 =0, currentSymbol =0; + uint8_t slotIdx=0, k2Index=0, k2Val=0, k2TmpVal=0, msg3K2TmpVal=0, msg3Delta=0, numK2 =0, currentSymbol =0; uint8_t startSymbol =0, endSymbol =0, checkSymbol=0, totalCfgSlot=0, slotCfg=0; SlotConfig currentSlot; #endif if(cell->cellCfg.dupMode == DUPLEX_MODE_FDD) { - BuildK2InfoTableForFdd(cell, timeDomRsrcAllocList, puschSymTblSize, k2InfoTbl); + BuildK2InfoTableForFdd(cell, timeDomRsrcAllocList, puschSymTblSize, msg3K2InfoTbl, k2InfoTbl); } else { @@ -1196,10 +1207,12 @@ SchK2TimingInfoTbl *k2InfoTbl) /* Initialization the structure and storing the total slot values. */ memset(k2InfoTbl, 0, sizeof(SchK2TimingInfoTbl)); k2InfoTbl->tblSize = cell->numSlots; + if(msg3K2InfoTbl) + msg3K2InfoTbl->tblSize = cell->numSlots; totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); /* Checking all possible indexes for K2. */ - for(slotIdx = 0; slotIdx < k2InfoTbl->tblSize; slotIdx++) + for(slotIdx = 0; slotIdx < cell->numSlots; slotIdx++) { currentSlot = schGetSlotSymbFrmt(slotIdx % totalCfgSlot, cell->slotFrmtBitMap); @@ -1211,22 +1224,22 @@ SchK2TimingInfoTbl *k2InfoTbl) /* Storing k2, startSymbol, endSymbol information for further processing. * If k2 is absent then fill the default values given in spec 38.331 * PUSCH-TimeDomainResourceAllocationList field descriptions */ - k2TmpVal = timeDomRsrcAllocList[k2Index].k2; - if(!k2TmpVal) + k2Val = timeDomRsrcAllocList[k2Index].k2; + if(!k2Val) { switch(cell->cellCfg.ssbSchCfg.scsCommon) { case SCS_15KHZ: - k2TmpVal = DEFAULT_K2_VALUE_FOR_SCS15; + k2Val = DEFAULT_K2_VALUE_FOR_SCS15; break; case SCS_30KHZ: - k2TmpVal = DEFAULT_K2_VALUE_FOR_SCS30; + k2Val = DEFAULT_K2_VALUE_FOR_SCS30; break; case SCS_60KHZ: - k2TmpVal = DEFAULT_K2_VALUE_FOR_SCS60; + k2Val = DEFAULT_K2_VALUE_FOR_SCS60; break; case SCS_120KHZ: - k2TmpVal = DEFAULT_K2_VALUE_FOR_SCS120; + k2Val = DEFAULT_K2_VALUE_FOR_SCS120; break; } } @@ -1234,33 +1247,69 @@ SchK2TimingInfoTbl *k2InfoTbl) /* Current slot + k2 should be either UL or FLEXI slot. * If slot is FLEXI then check all the symbols of that slot, * it should not contain any DL or FLEXI slot */ - k2TmpVal = (slotIdx + k2TmpVal) % totalCfgSlot; + k2TmpVal = (slotIdx + k2Val) % totalCfgSlot; slotCfg = schGetSlotSymbFrmt(k2TmpVal, cell->slotFrmtBitMap); - if(slotCfg == DL_SLOT) - { - continue; - } - if(slotCfg == FLEXI_SLOT) + if(slotCfg != DL_SLOT) { - startSymbol = timeDomRsrcAllocList[k2Index].startSymbol; - endSymbol = startSymbol+ timeDomRsrcAllocList[k2Index].symbolLength; - dlSymbolPresent = false; - for(checkSymbol= startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[k2TmpVal][checkSymbol]; - if(currentSymbol == DL_SLOT || currentSymbol == FLEXI_SLOT) + startSymbol = timeDomRsrcAllocList[k2Index].startSymbol; + endSymbol = startSymbol+ timeDomRsrcAllocList[k2Index].symbolLength; + dlSymbolPresent = false; + for(checkSymbol= startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[k2TmpVal][checkSymbol]; + if(currentSymbol == DL_SLOT || currentSymbol == FLEXI_SLOT) + { + dlSymbolPresent = true; + break; + } } } + /* Store all the values if all condition satisfies. */ + if(dlSymbolPresent != true || slotCfg == UL_SLOT) + { + numK2 = k2InfoTbl->k2TimingInfo[slotIdx].numK2; + k2InfoTbl->k2TimingInfo[slotIdx].k2Indexes[numK2] = k2Index; + k2InfoTbl->k2TimingInfo[slotIdx].numK2++; + } } - /* Store all the values if all condition satisfies. */ - if(dlSymbolPresent != true || slotCfg == UL_SLOT) + + if(msg3K2InfoTbl) { - numK2 = k2InfoTbl->k2TimingInfo[slotIdx].numK2; - k2InfoTbl->k2TimingInfo[slotIdx].k2Indexes[numK2] = k2Index; - k2InfoTbl->k2TimingInfo[slotIdx].numK2++; + msg3Delta = puschDeltaTable[cell->cellCfg.numerology]; + + /* Check for K2 for MSG3 */ + /* Current slot + k2 should be either UL or FLEXI slot. + * If slot is FLEXI then check all the symbols of that slot, + * it should not contain any DL or FLEXI slot */ + msg3K2TmpVal = (slotIdx + k2Val + msg3Delta) % totalCfgSlot; + slotCfg = schGetSlotSymbFrmt(msg3K2TmpVal, cell->slotFrmtBitMap); + if(slotCfg != DL_SLOT) + { + if(slotCfg == FLEXI_SLOT) + { + startSymbol = timeDomRsrcAllocList[k2Index].startSymbol; + endSymbol = startSymbol+ timeDomRsrcAllocList[k2Index].symbolLength; + dlSymbolPresent = false; + for(checkSymbol= startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[msg3K2TmpVal][checkSymbol]; + if(currentSymbol == DL_SLOT || currentSymbol == FLEXI_SLOT) + { + dlSymbolPresent = true; + break; + } + } + } + /* Store all the values if all condition satisfies. */ + if(dlSymbolPresent != true || slotCfg == UL_SLOT) + { + numK2 = msg3K2InfoTbl->k2TimingInfo[slotIdx].numK2; + msg3K2InfoTbl->k2TimingInfo[slotIdx].k2Indexes[numK2] = k2Index; + msg3K2InfoTbl->k2TimingInfo[slotIdx].numK2++; + } + } } } } diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c index 77e736f1b..9f37d1cef 100644 --- a/src/5gnrsch/sch_rach.c +++ b/src/5gnrsch/sch_rach.c @@ -105,7 +105,7 @@ void createSchRaCb(uint16_t tcrnti, Inst schInst) * @param[out] msg3NumRb * @return void **/ -SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, uint16_t msg3SlotAlloc) +SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, uint16_t msg3Slot) { SchCellCb *cell = NULLP; SchUlSlotInfo *schUlSlotInfo = NULLP; @@ -115,27 +115,33 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, uin uint8_t numRb = 0; uint8_t idx = 0; uint8_t mcs = 4; - uint8_t numPdschSymbols= 14; + uint8_t numPdschSymbols= 11; uint16_t tbSize = 0; cell = schCb[schInst].cells[schInst]; - startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[0].startSymbol; - symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength; + if(cell == NULL) + { + DU_LOG("\n\nERROR --> SCH : Failed to find cell in schAllocMsg3Pusch"); + return RFAILED; + } + + startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; + symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; - startRb = cell->schUlSlotInfo[msg3SlotAlloc]->puschCurrentPrb; + startRb = cell->schUlSlotInfo[msg3Slot]->puschCurrentPrb; tbSize = schCalcTbSize(8); /* 6 bytes msg3 and 2 bytes header */ numRb = schCalcNumPrb(tbSize, mcs, numPdschSymbols); /* allocating 1 extra RB for now */ numRb++; /* increment PUSCH PRB */ - cell->schUlSlotInfo[msg3SlotAlloc]->puschCurrentPrb += numRb; + cell->schUlSlotInfo[msg3Slot]->puschCurrentPrb += numRb; for(idx=startSymb; idxschUlSlotInfo[msg3SlotAlloc]->assignedPrb[idx] = startRb + numRb; + cell->schUlSlotInfo[msg3Slot]->assignedPrb[idx] = startRb + numRb; } - schUlSlotInfo = cell->schUlSlotInfo[msg3SlotAlloc]; + schUlSlotInfo = cell->schUlSlotInfo[msg3Slot]; SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo)); if(!schUlSlotInfo->schPuschInfo) @@ -145,7 +151,7 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, uin } tbSize = 0; /* since nPrb has been incremented, recalculating tbSize */ tbSize = schCalcTbSizeFromNPrb(numRb, mcs, numPdschSymbols); - tbSize = tbSize/8;/*bits to byte conversion*/ + tbSize = tbSize / 8 ; /*bits to byte conversion*/ schUlSlotInfo->schPuschInfo->crnti = crnti; schUlSlotInfo->schPuschInfo->harqProcId = SCH_HARQ_PROC_ID; schUlSlotInfo->schPuschInfo->resAllocType = SCH_ALLOC_TYPE_1; @@ -153,11 +159,11 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, uin schUlSlotInfo->schPuschInfo->fdAlloc.numPrb = numRb; schUlSlotInfo->schPuschInfo->tdAlloc.startSymb = startSymb; schUlSlotInfo->schPuschInfo->tdAlloc.numSymb = symbLen; - schUlSlotInfo->schPuschInfo->tbInfo.qamOrder = 2; /* QPSK modulation */ - schUlSlotInfo->schPuschInfo->tbInfo.mcs = mcs; + schUlSlotInfo->schPuschInfo->tbInfo.qamOrder = QPSK_MODULATION; /* QPSK modulation */ + schUlSlotInfo->schPuschInfo->tbInfo.mcs = mcs; schUlSlotInfo->schPuschInfo->tbInfo.mcsTable = SCH_MCS_TABLE_QAM_64; - schUlSlotInfo->schPuschInfo->tbInfo.ndi = 1; /* new transmission */ - schUlSlotInfo->schPuschInfo->tbInfo.rv = 0; + schUlSlotInfo->schPuschInfo->tbInfo.ndi = NEW_TRANSMISSION; /* new transmission */ + schUlSlotInfo->schPuschInfo->tbInfo.rv = 0; schUlSlotInfo->schPuschInfo->tbInfo.tbSize = tbSize; /*Considering 2 PRBs */ schUlSlotInfo->schPuschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */ schUlSlotInfo->schPuschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; @@ -166,6 +172,38 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, uin return schUlSlotInfo->schPuschInfo; } +/** + * @brief Check if a time frame is in RA Response window + * + * @details + * + * Function : isInRaRspWindow + * + * Check if a time frame is in RA Response window + * + * @param[in] RA request + * @param[in] Time frame to check + * @param[in] Total number of slot per radio frame + * @return true + * @return false + **/ +RaRspWindowStatus isInRaRspWindow(SchRaReq *raReq, SlotTimingInfo frameToCheck, uint16_t numSlotsPerSystemFrame) +{ + uint32_t winStartTime, winEndTime, timeToCheck; + + winStartTime = (raReq->winStartTime.sfn * numSlotsPerSystemFrame) + raReq->winStartTime.slot; + winEndTime = (raReq->winEndTime.sfn * numSlotsPerSystemFrame) + raReq->winEndTime.slot; + timeToCheck = (frameToCheck.sfn * numSlotsPerSystemFrame) + frameToCheck.slot; + + /* TODO : check how to handle the wrap around scenario of MAX_SFN */ + if((timeToCheck >= winStartTime) && (timeToCheck <= winEndTime)) + return WITHIN_WINDOW; + else if(timeToCheck < winStartTime) + return WINDOW_YET_TO_START; + + return WINDOW_EXPIRED; +} + /** * @brief Processes any pending RA request * @@ -180,17 +218,24 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t crnti, uin **/ void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell) { - uint8_t ueIdx = 0; - SchPuschInfo *msg3PuschInfo; - RarInfo *rarInfo = NULLP; - uint8_t delta = 0; - uint8_t k2Index = 0, k2 = 0; - uint8_t puschMu = 0; - uint16_t rarSlot = 0; - uint16_t msg3Slot = 0; + bool k2Found = false; + uint8_t ueIdx = 0, k0TblIdx = 0, k2TblIdx = 0; + uint8_t k0Index = 0, k2Index = 0; + uint8_t k0 = 0, k2 = 0; + uint8_t puschMu = 0; + uint8_t msg3Delta = 0, msg3MinSchTime = 0; #ifdef NR_TDD - uint16_t slotIdx = 0; + uint8_t totalCfgSlot = 0; #endif + uint16_t dciSlot = 0, rarSlot = 0, msg3Slot = 0; + SlotTimingInfo dciTime, rarTime; + RarAlloc *dciSlotAlloc = NULLP; /* Stores info for transmission of PDCCH for RAR */ + RarAlloc *rarSlotAlloc = NULLP; /* Stores info for transmission of RAR PDSCH */ + SchPuschInfo *msg3PuschInfo = NULLP; /* Stores MSG3 PUSCH scheduling information */ + PduTxOccsaion ssbOccasion=0, sib1Occasion=0; + SchK0K1TimingInfoTbl *k0K1InfoTbl=NULLP; + SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP; + RaRspWindowStatus windowStatus=0; while(ueIdx < MAX_NUM_UE) { @@ -200,78 +245,152 @@ void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell) continue; } - //puschMu = cell->cellCfg.puschMu; - delta = puschDeltaTable[puschMu]; - 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; #ifdef NR_TDD - for(slotIdx=0; slotIdxnumSlots;slotIdx++) + totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); +#endif + k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl; + msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl; + puschMu = cell->cellCfg.numerology; + msg3Delta = puschDeltaTable[puschMu]; + msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology]; + + /* Calculating time frame to send DCI for RAR */ + ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA); + dciSlot = dciTime.slot; +#ifdef NR_TDD + /* Consider this slot for sending DCI, only if it is a DL slot */ + if(schGetSlotSymbFrmt(dciSlot, cell->slotFrmtBitMap) == DL_SLOT) +#endif { - /* Slot allocation for msg3 based on 38.214 section 6.1.2.1 */ - msg3Slot = (rarSlot+delta+k2)%cell->numSlots; + + /* Check if this slot is within RA response window */ + windowStatus = isInRaRspWindow(cell->raReq[ueIdx], dciTime, cell->numSlots); + if(windowStatus == WITHIN_WINDOW) + { + /* For all k0 values, search for a suitable k2 value to schedule MSG3. + * RAR DCI, RAR PDSCH and MSG3 is scheduled only if one such k0-k2 combination + * is found. Else no scheduling happens. + */ + for(k0TblIdx = 0; k0TblIdx < k0K1InfoTbl->k0k1TimingInfo[dciSlot].numK0; k0TblIdx++) + { + k0Index = k0K1InfoTbl->k0k1TimingInfo[dciSlot].k0Indexes[k0TblIdx].k0Index; + k0 = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0; + + /* Calculating time frame to send RAR PDSCH */ + ADD_DELTA_TO_TIME(dciTime, rarTime, k0); + rarSlot = rarTime.slot; + + for(k2TblIdx = 0; k2TblIdx < msg3K2InfoTbl->k2TimingInfo[rarSlot].numK2; k2TblIdx++) + { + k2Index = msg3K2InfoTbl->k2TimingInfo[rarSlot].k2Indexes[k2TblIdx]; + k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; + + /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */ + k2 = k2 + msg3Delta; + if(k2 >= msg3MinSchTime) + { + msg3Slot = (rarSlot + k2) % cell->numSlots; +#ifdef NR_TDD + if(schGetSlotSymbFrmt(msg3Slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT) + continue; +#endif + k2Found = true; + break; + } + } + if(k2Found) + break; + } + } + else if(windowStatus == WINDOW_EXPIRED) + { + SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo)); + SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq)); + ueIdx++; + continue; + } - if((schGetSlotSymbFrmt(rarSlot, cell->slotFrmtBitMap) != DL_SLOT) &&\ - (schGetSlotSymbFrmt(msg3Slot, cell->slotFrmtBitMap) != UL_SLOT)) + /* If K0-K2 combination not found, no scheduling happens */ + if(!k2Found) { - rarSlot = (rarSlot + 1) % cell->numSlots; + ueIdx++; continue; } - break; - } - if(slotIdx>=cell->numSlots) - { - DU_LOG("\nERROR --> SCH : NO Slot for Msg2 with Msg3 Grant\n"); - return RFAILED; - } -#else - /* Slot allocation for msg3 based on 38.214 section 6.1.2.1 */ - msg3Slot = rarSlot + k2 + delta; - msg3Slot = msg3Slot % cell->numSlots; -#endif - SchDlSlotInfo *schDlSlotInfo = cell->schDlSlotInfo[rarSlot]; /* RAR will sent in the next slot */ + /* Allocate memory for RAR PDCCH slot, pointer will be checked at schProcessSlotInd() */ + SCH_ALLOC(dciSlotAlloc, sizeof(RarAlloc)); + if(dciSlotAlloc == NULLP) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciSlotAlloc"); + return; + } + cell->schDlSlotInfo[dciSlot]->rarAlloc = dciSlotAlloc; - /* Allocate the rarInfo, this pointer will be checked at schProcessSlotInd function */ - SCH_ALLOC(rarInfo, sizeof(RarInfo)); - if(rarInfo == NULLP) - { - DU_LOG("\nERROR --> SCH : Memory Allocation failed for rarInfo"); - return RFAILED; - } + /* Check if RAR PDSCH occasion same as SSB and SIB1 occasion */ + ssbOccasion = schCheckSsbOcc(rarTime, cell); + sib1Occasion = schCheckSib1Occ(rarTime, cell); - schDlSlotInfo->rarInfo = rarInfo; + /* Fill PDCCH and PDSCH scheduling information for RAR */ + schFillRar(dciSlotAlloc, cell->raReq[ueIdx]->raRnti, + cell->cellCfg.phyCellId, cell->cellCfg.ssbSchCfg.ssbOffsetPointA, k0Index, + ssbOccasion, sib1Occasion); - /* create raCb at SCH */ - createSchRaCb(cell->raReq[ueIdx]->rachInd->crnti, cell->instIdx); + /* Allocate resources for msg3 */ + msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, cell->raReq[ueIdx]->rachInd->crnti, k2Index, msg3Slot); + if(msg3PuschInfo) + { + /* Fill RAR info */ + dciSlotAlloc->rarInfo.raRnti = cell->raReq[ueIdx]->raRnti; + dciSlotAlloc->rarInfo.tcrnti = cell->raReq[ueIdx]->rachInd->crnti; + dciSlotAlloc->rarInfo.RAPID = cell->raReq[ueIdx]->rachInd->preambleIdx; + dciSlotAlloc->rarInfo.ta = cell->raReq[ueIdx]->rachInd->timingAdv; + dciSlotAlloc->rarInfo.ulGrant.bwpSize = cell->cellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb; + /* Spec 38.213, section 8.2, 0 : MSG3 PUSCH will be transmitted without frequency hopping */ + dciSlotAlloc->rarInfo.ulGrant.freqHopFlag = 0; + dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.startPrb = msg3PuschInfo->fdAlloc.startPrb; + dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.numPrb = msg3PuschInfo->fdAlloc.numPrb; + dciSlotAlloc->rarInfo.ulGrant.k2Index = k2Index; + dciSlotAlloc->rarInfo.ulGrant.mcs = msg3PuschInfo->tbInfo.mcs; + dciSlotAlloc->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. */ + dciSlotAlloc->rarInfo.ulGrant.csiReq = 0; + } - /* allocate resources for msg3 */ - 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->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; - } + /* Check if both DCI and RAR are sent in the same slot. + * If not, allocate memory RAR PDSCH slot to store RAR info + */ + if(dciSlot == rarSlot) + dciSlotAlloc->pduPres = BOTH; + else + { + /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */ + SCH_ALLOC(rarSlotAlloc, sizeof(RarAlloc)); + if(rarSlotAlloc == NULLP) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for rarSlotAlloc"); + SCH_FREE(dciSlotAlloc, sizeof(RarAlloc)); + return; + } + cell->schDlSlotInfo[rarSlot]->rarAlloc = rarSlotAlloc; + + /* Copy all RAR info */ + memcpy(rarSlotAlloc, dciSlotAlloc, sizeof(RarAlloc)); + rarSlotAlloc->rarPdcchCfg.dci.pdschCfg = &rarSlotAlloc->rarPdschCfg; + + /* Assign correct PDU types in corresponding slots */ + rarSlotAlloc->pduPres = PDSCH_PDU; + dciSlotAlloc->pduPres = PDCCH_PDU; + dciSlotAlloc->pdschSlot = rarSlot; + } - SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo)); - SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq)); - ueIdx++; + /* Create raCb at SCH */ + createSchRaCb(cell->raReq[ueIdx]->rachInd->crnti, cell->instIdx); + SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo)); + SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq)); + } + ueIdx++; } /* End of while(ueIdx < MAX_NUM_UE) */ } @@ -296,6 +415,20 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst) uint8_t winNumSlots; uint8_t ueIdx; + if(cell == NULLP) + { + DU_LOG("\nERROR --> SCH: Failed to find cell in schProcessRachInd"); + return RFAILED; + } + + /* Storing RA request in cellCb */ + GET_UE_IDX(rachInd->crnti, ueIdx); + if(ueIdx <= 0) + { + DU_LOG("\nERROR --> SCH: Invalid CRNTI [%d]", rachInd->crnti); + return RFAILED; + } + SCH_ALLOC(raReq, sizeof(SchRaReq)); if(!raReq) { @@ -317,9 +450,7 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst) /* Adding window size to window start time to get window end time */ ADD_DELTA_TO_TIME(raReq->winStartTime, raReq->winEndTime, winNumSlots); - /* Storing RA request in cellCb */ - GET_UE_IDX(rachInd->crnti, ueIdx); - cell->raReq[ueIdx] = raReq; + cell->raReq[ueIdx -1] = raReq; return ROK; } @@ -340,7 +471,7 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst) * @return ROK **/ uint8_t schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t offsetPointA, \ -bool ssbPresent, bool sib1Present) +uint8_t k0Index, bool ssbPresent, bool sib1Present) { Inst inst = 0; uint8_t coreset0Idx = 0; @@ -352,6 +483,12 @@ bool ssbPresent, bool sib1Present) uint16_t tbSize = 0; uint8_t mcs = 4; /* MCS fixed to 4 */ + if(schCb[inst].cells[inst] == NULL) + { + DU_LOG("\nERROR --> SCH: Cell not found"); + return RFAILED; + } + SchBwpDlCfg *initialBwp = &schCb[inst].cells[inst]->cellCfg.schInitialDlBwp; PdcchCfg *pdcch = &rarAlloc->rarPdcchCfg; PdschCfg *pdsch = &rarAlloc->rarPdschCfg; @@ -455,10 +592,10 @@ bool ssbPresent, bool sib1Present) pdsch->pdschFreqAlloc.freqAlloc.startPrb = sib1PdschFreqAlloc->startPrb + sib1PdschFreqAlloc->numPrb + 1; } pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, \ - initialBwp->pdschCommon.timeDomRsrcAllocList[0].lengthSymbol); + initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol); pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ - pdsch->pdschTimeAlloc.timeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[0].startSymbol; - pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[0].lengthSymbol; + pdsch->pdschTimeAlloc.timeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol; + pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol; pdsch->beamPdschInfo.numPrgs = 1; pdsch->beamPdschInfo.prgSize = 1; pdsch->beamPdschInfo.digBfInterfaces = 0; diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index 59501bc78..3542bd018 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -79,7 +79,6 @@ uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst) } - /******************************************************************* * * @brief Handles slot indication at SCH @@ -117,6 +116,79 @@ void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue) ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, PHY_DELTA_DL + SCHED_DELTA); } +/******************************************************************* + * + * @brief Checks if a slot is to be scheduled for SSB transmission + * + * @details + * + * Function : schCheckSsbOcc + * + * Functionality: + * Checks if a slot is to be scheduled for SSB transmission + * + * @params[in] SlotTimingInfo slotTime + * SchCellCb *cell + * @return Pdu transmission + * + * ****************************************************************/ +PduTxOccsaion schCheckSsbOcc(SlotTimingInfo slotTime, SchCellCb *cell) +{ + uint8_t ssb_rep; + + ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod; + + /* Identify SSB ocassion*/ + if ((slotTime.sfn % SCH_MIB_TRANS == 0) && (slotTime.slot ==0)) + { + return NEW_TRANSMISSION; + } + else if(cell->firstSsbTransmitted) + { + if((ssb_rep == 5) && ((slotTime.slot == 0 || slotTime.slot == 10))) + return REPEATITION; + else if((slotTime.sfn % (ssb_rep/10) == 0) && slotTime.slot == 0) + return REPEATITION; + } + /* not SSB occassion */ + return NO_TRANSMISSION; +} + +/******************************************************************* + * + * @brief Checks if a slot is to be scheduled for SIB1 transmission + * + * @details + * + * Function : schCheckSib1Occ + * + * Functionality: + * Checks if a slot is to be scheduled for SIB1 transmission + * + * @params[in] SlotTimingInfo slotTime + * SchCellCb *cell + * @return Pdu transmission + * + * ****************************************************************/ +PduTxOccsaion schCheckSib1Occ(SlotTimingInfo slotTime, SchCellCb *cell) +{ + /* Identify SIB1 occasions */ + if((slotTime.sfn % SCH_SIB1_TRANS == 0) && (slotTime.slot ==0)) + { + return NEW_TRANSMISSION; + } + else if(cell->firstSib1Transmitted) + { + if((slotTime.sfn % (cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod/10) == 0) && + (slotTime.slot == 0)) + { + return REPEATITION; + } + } + /* not SIB1 occassion */ + return NO_TRANSMISSION; +} + /******************************************************************* * * @brief @@ -229,22 +301,20 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM * ****************************************************************/ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst) { - uint8_t ssb_rep, ueIdx, lcgIdx, ret = ROK; + uint8_t ueIdx, lcgIdx, ret = ROK; uint16_t slot; DlSchedInfo dlSchedInfo; DlBrdcstAlloc *dlBrdcstAlloc = NULLP; - RarAlloc *rarAlloc = NULLP; DlMsgAlloc *msg4Alloc = NULLP; DlMsgAlloc *dlMsgAlloc = NULLP; SchCellCb *cell = NULLP; - memset(&dlSchedInfo,0,sizeof(DlSchedInfo)); dlSchedInfo.dlMsgAlloc = NULLP; schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue); dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc; - dlBrdcstAlloc->ssbTrans = NO_SSB; - dlBrdcstAlloc->sib1Trans = NO_SIB1; + dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION; + dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION; cell = schCb[schInst].cells[schInst]; if(cell == NULLP) @@ -252,53 +322,22 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst) DU_LOG("\nERROR --> SCH : Cell Does not exist"); return RFAILED; } - ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod; memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo)); - dlBrdcstAlloc->ssbIdxSupported = 1; + dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED; slot = dlSchedInfo.schSlotValue.currentTime.slot; dlSchedInfo.cellId = cell->cellId; - /* Identify SSB ocassion*/ - if ((dlSchedInfo.schSlotValue.broadcastTime.sfn % SCH_MIB_TRANS == 0) && (dlSchedInfo.schSlotValue.broadcastTime.slot ==0)) - { - dlBrdcstAlloc->ssbTrans = SSB_TRANSMISSION; - if(!cell->firstSsbTransmitted) - cell->firstSsbTransmitted = true; - } - else if (cell->firstSsbTransmitted) - { - if((ssb_rep == 5) && ((dlSchedInfo.schSlotValue.broadcastTime.slot == 0 || dlSchedInfo.schSlotValue.broadcastTime.slot == 10))) - dlBrdcstAlloc->ssbTrans = SSB_REPEAT; - else if((dlSchedInfo.schSlotValue.broadcastTime.sfn % (ssb_rep/10) == 0) && dlSchedInfo.schSlotValue.broadcastTime.slot == 0) - dlBrdcstAlloc->ssbTrans = SSB_REPEAT; - } - else - { - /* not SSB occassion */ - } - - /* Identify SIB1 occasions */ - if((dlSchedInfo.schSlotValue.broadcastTime.sfn % SCH_SIB1_TRANS == 0) && (dlSchedInfo.schSlotValue.broadcastTime.slot ==0)) - { - dlBrdcstAlloc->sib1Trans = SIB1_TRANSMISSION; - if(!cell->firstSib1Transmitted) - cell->firstSib1Transmitted = true; - } - else if (cell->firstSib1Transmitted) - { - if((dlSchedInfo.schSlotValue.broadcastTime.sfn % (cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod/10) == 0) && - (dlSchedInfo.schSlotValue.broadcastTime.slot == 0)) - { - dlBrdcstAlloc->sib1Trans = SIB1_REPITITION; - } - } - else - { - /* not SIB1 occassion */ - } + /* Check if this slot is SSB occassion */ + dlBrdcstAlloc->ssbTrans = schCheckSsbOcc(dlSchedInfo.schSlotValue.broadcastTime, cell); + if((dlBrdcstAlloc->ssbTrans == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted)) + cell->firstSsbTransmitted = true; + /* Check if this slot is SIB1 occassion */ + dlBrdcstAlloc->sib1Trans = schCheckSib1Occ(dlSchedInfo.schSlotValue.broadcastTime, cell); + if((dlBrdcstAlloc->sib1Trans == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted)) + cell->firstSib1Transmitted = true; if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans) { @@ -316,31 +355,11 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst) schProcessRaReq(*slotInd, cell); /* check for RAR */ - if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo != NULLP) + if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc != NULLP) { slot = dlSchedInfo.schSlotValue.rarTime.slot; - SCH_ALLOC(rarAlloc, sizeof(RarAlloc)); - if(!rarAlloc) - { - DU_LOG("\nERROR --> SCH : Memory Allocation failed for RAR alloc"); - return RFAILED; - } - - dlSchedInfo.rarAlloc = rarAlloc; - - /* RAR info is copied, this was earlier filled in schProcessRachInd */ - memcpy(&rarAlloc->rarInfo,cell->schDlSlotInfo[slot]->rarInfo, sizeof(RarInfo)); - - /* pdcch and pdsch data is filled */ - schFillRar(rarAlloc, - cell->schDlSlotInfo[slot]->rarInfo->raRnti, - cell->cellCfg.phyCellId, - cell->cellCfg.ssbSchCfg.ssbOffsetPointA, - dlBrdcstAlloc->ssbTrans, - dlBrdcstAlloc->sib1Trans); - - SCH_FREE(cell->schDlSlotInfo[slot]->rarInfo,sizeof(RarInfo)); - cell->schDlSlotInfo[slot]->rarInfo = NULLP; + dlSchedInfo.rarAlloc = cell->schDlSlotInfo[slot]->rarAlloc; + cell->schDlSlotInfo[slot]->rarAlloc = NULLP; } /* check for MSG4 */ @@ -371,6 +390,7 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst) SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo)); cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo = NULL; } + /* check if UL grant must be sent in this slot for a SR/BSR that had been received */ for(ueIdx=0; ueIdxnumActvUe; ueIdx++) { diff --git a/src/5gnrsch/sch_ue_mgr.c b/src/5gnrsch/sch_ue_mgr.c index 62a1abe4f..769c79378 100644 --- a/src/5gnrsch/sch_ue_mgr.c +++ b/src/5gnrsch/sch_ue_mgr.c @@ -244,7 +244,7 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg) dlDataToUlAck->dlDataToUlAckList); BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\ ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\ - &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl); + NULLP, &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl); } } } diff --git a/src/5gnrsch/sch_utils.c b/src/5gnrsch/sch_utils.c index 600297da8..333191554 100644 --- a/src/5gnrsch/sch_utils.c +++ b/src/5gnrsch/sch_utils.c @@ -765,6 +765,12 @@ uint8_t pucchResourceSet[MAX_PUCCH_RES_SET_IDX][4] = { { 1, 0, 14, 0 }, /* index 15 */ }; +/* Minimum Msg3 scheduling time should be calculated based on N1+N2+NTAmax+0.5 + * ms formula. + * Refer spec 38.213 section 8.3. + * Harcoding the minimum msg3 scheduling for now */ +uint8_t minMsg3SchTime[MAX_NUM_MU] = {6, 6, 6, 6}; + uint8_t defaultUlAckTbl[DEFAULT_UL_ACK_LIST_COUNT]= {1, 2, 3 , 4, 5, 6, 7, 8}; /** * @brief frequency domain allocation function. @@ -1096,6 +1102,7 @@ uint8_t calculateSlotPatternLength(uint8_t scs, uint8_t periodicity) } return slotPatternLength; } + #endif /********************************************************************** End of file diff --git a/src/5gnrsch/sch_utils.h b/src/5gnrsch/sch_utils.h index fb1bb2c1e..bc88c620b 100644 --- a/src/5gnrsch/sch_utils.h +++ b/src/5gnrsch/sch_utils.h @@ -99,6 +99,7 @@ int8_t coresetIdxTable[MAX_CORESET_INDEX][4]; int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4]; uint8_t defaultUlAckTbl[DEFAULT_UL_ACK_LIST_COUNT]; +uint8_t minMsg3SchTime[MAX_NUM_MU]; /* functions declarations */ void freqDomRscAllocType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain); diff --git a/src/cm/common_def.h b/src/cm/common_def.h index 0350c6f7e..77e0c9979 100644 --- a/src/cm/common_def.h +++ b/src/cm/common_def.h @@ -56,6 +56,7 @@ #define RADIO_FRAME_DURATION 10 /* Time duration of a radio frame in ms */ /* MAX values */ #define MAX_NUM_CELL 1 +#define MAX_NUM_MU 4 #define MAX_NUM_UE 2 #define MAX_NUM_UE_PER_TTI 1 #define MAX_NUM_LC 11 diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index 506902e47..8cf9301bb 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -38,16 +38,9 @@ /*macros*/ -#define NO_SSB 0 -#define SSB_TRANSMISSION 1 -#define SSB_REPEAT 2 #define MAX_SSB_IDX 1 /* forcing it as 1 for now. Right value is 64 */ #define SCH_SSB_MASK_SIZE 1 -#define NO_SIB1 0 -#define SIB1_TRANSMISSION 1 -#define SIB1_REPITITION 2 - #define MAX_NUM_PRG 1 /* max value should be later 275 */ #define MAX_DIG_BF_INTERFACES 0 /* max value should be later 255 */ #define MAX_CODEWORDS 1 /* max should be 2 */ @@ -91,6 +84,7 @@ #define MAX_NUM_PATH_LOSS_REF_RS 4 #define MAX_NUM_DL_DATA_TO_UL_ACK 15 #define SD_SIZE 3 +#define QPSK_MODULATION 2 #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 */ @@ -124,6 +118,13 @@ } \ } +typedef enum +{ + NO_TRANSMISSION, + NEW_TRANSMISSION, + REPEATITION +}PduTxOccsaion; + typedef enum { UNSPECIFIED_CAUSE, @@ -401,6 +402,13 @@ typedef enum SCH_MCS_TABLE_QAM_64_LOW_SE }SchMcsTable; +typedef enum +{ + PDCCH_PDU, + PDSCH_PDU, + BOTH +}DlPduType; + /*structures*/ typedef struct timeDomainAlloc { @@ -705,6 +713,7 @@ typedef struct schBwpUlCfg SchBwpParams bwp; SchPucchCfgCmn pucchCommon; SchPuschCfgCmn puschCommon; + SchK2TimingInfoTbl msg3K2InfoTbl; SchK2TimingInfoTbl k2InfoTbl; }SchBwpUlCfg; @@ -797,6 +806,8 @@ typedef struct rarInfo typedef struct rarAlloc { + DlPduType pduPres; + uint8_t pdschSlot; RarInfo rarInfo; BwpCfg bwp; PdcchCfg rarPdcchCfg; diff --git a/src/du_app/du_cfg.c b/src/du_app/du_cfg.c index ac754e4a8..5b41aacf5 100644 --- a/src/du_app/du_cfg.c +++ b/src/du_app/du_cfg.c @@ -312,6 +312,7 @@ uint8_t readMacCfg() PDSCH_START_SYMBOL; duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol = PDSCH_LENGTH_SYMBOL; + idx++; duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2; duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = @@ -490,6 +491,7 @@ uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm) pdschCfg.timeDomAlloc[0].mapType = \ PDSCH_TimeDomainResourceAllocation__mappingType_typeA; pdschCfg.timeDomAlloc[0].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL); + pdschCfg.timeDomAlloc[1].k0 = PDSCH_K0_CFG2; pdschCfg.timeDomAlloc[1].mapType = \ PDSCH_TimeDomainResourceAllocation__mappingType_typeA; @@ -530,7 +532,7 @@ uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm) rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR; rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200; rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2; - rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20; + rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl10; rachCfg.numRaPreamble = NUM_RA_PREAMBLE; rachCfg.ssbPerRachOccPresent = \ RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one; diff --git a/src/du_app/du_cfg.h b/src/du_app/du_cfg.h index fabeaaf29..419cfe0a1 100644 --- a/src/du_app/du_cfg.h +++ b/src/du_app/du_cfg.h @@ -121,7 +121,7 @@ #define RSS_MEASUREMENT_UNIT DONT_REPORT_RSSI #define RA_CONT_RES_TIMER 64 -#define RA_RSP_WINDOW 180 +#define RA_RSP_WINDOW 10 #define PRACH_RESTRICTED_SET 0 /* Unrestricted */ #define ROOT_SEQ_LEN 139 diff --git a/src/phy_stub/phy_stub_thread_hdl.c b/src/phy_stub/phy_stub_thread_hdl.c index 4bdea8106..8028b0f1a 100644 --- a/src/phy_stub/phy_stub_thread_hdl.c +++ b/src/phy_stub/phy_stub_thread_hdl.c @@ -50,9 +50,9 @@ pthread_t thread = 0; void GenerateTicks() { #ifdef NR_TDD - int milisec = 0.5; /* 0.5ms */ + float milisec = 0.5; /* 0.5ms */ #else - int milisec = 1; /* 1ms */ + float milisec = 1; /* 1ms */ #endif struct timespec req = {0};