X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrsch%2Fsch_slot_ind.c;h=97ea00a7dac21e1352eeed852a48c11b3566a60f;hb=9edb21c45713c87a3434d4511ef7c340de8567ea;hp=281cd2112533f8994108d80bc9d31c041bdd0d51;hpb=2dc9d6735bc5ff973a761b7d6b3f71f97e95d60e;p=o-du%2Fl2.git diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index 281cd2112..97ea00a7d 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -50,8 +50,6 @@ SchMacDlAllocFunc schMacDlAllocOpts[] = }; SchCb schCb[SCH_MAX_INST]; -int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t - offsetPointA); /******************************************************************* * @@ -75,13 +73,12 @@ uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst) memset(&pst, 0, sizeof(Pst)); FILL_PST_SCH_TO_MAC(pst, inst); - pst.event = EVENT_DL_ALLOC; + pst.event = EVENT_DL_SCH_INFO; return(*schMacDlAllocOpts[pst.selector])(&pst, dlSchedInfo); } - /******************************************************************* * * @brief Handles slot indication at SCH @@ -98,7 +95,7 @@ uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst) * RFAILED - failure * * ****************************************************************/ -void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue) +void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue) { /**************************************************************** * PHY_DELTA - the physical layer delta * @@ -119,6 +116,79 @@ void schCalcSlotValues(SlotIndInfo 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(SchCellCb *cell, SlotTimingInfo slotTime) +{ + 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(SchCellCb *cell, SlotTimingInfo slotTime) +{ + /* 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 @@ -182,24 +252,40 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM } ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0; } + + if (!dlMsgAlloc->numLc) + { + DU_LOG("\nDEBUG --> SCH : No pending BO for any LC id\n"); + /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ + SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc)); + dlSchedInfo->dlMsgAlloc = NULLP; + return ROK; + } /* pdcch and pdsch data is filled */ - schDlRsrcAllocDlMsg(dlMsgAlloc, cell, crnti, &accumalatedSize, slot); - /* Calculated TB size could be less than the total size requested. - * Hence, updated the scheduled bytes report. Following is valid only for - * one LC. - * TODO : Update the scheduling byte report for multiple LC based on QCI + if((schDlRsrcAllocDlMsg(cell, dlSchedInfo->schSlotValue.dlMsgTime, crnti, &accumalatedSize, dlMsgAlloc)) != ROK) + { + DU_LOG("\nERROR --> SCH : Scheduling of DL dedicated message failed"); + /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ + SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc)); + dlSchedInfo->dlMsgAlloc = NULLP; + return RFAILED; + + } + + /* TODO : Update the scheduling byte report for multiple LC based on QCI * and Priority */ - dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc -1].schBytes = accumalatedSize; + /* As of now, the total number of bytes scheduled for a slot is divided + * equally amongst all LC with pending data. This is avoid starving of any + * LC + * */ + accumalatedSize = accumalatedSize/dlMsgAlloc->numLc; + for(lcIdx = 0; lcIdx < dlMsgAlloc->numLc; lcIdx ++) + dlMsgAlloc->lcSchInfo[lcIdx].schBytes = accumalatedSize; /* PUCCH resource */ schAllocPucchResource(cell, dlMsgAlloc->crnti, slot); - /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ - SCH_FREE(cell->schDlSlotInfo[dlSchedInfo->schSlotValue.dlMsgTime.slot]->dlMsgInfo, \ - sizeof(DlMsgInfo)); - cell->schDlSlotInfo[dlSchedInfo->schSlotValue.dlMsgTime.slot]->dlMsgInfo = NULL; - /* after allocation is done, unset the bo bit for that ue */ UNSET_ONE_BIT(ueIdx, cell->boIndBitMap); } @@ -223,113 +309,82 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM * RFAILED - failure * * ****************************************************************/ -uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) +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]; - ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod; - memcpy(&cell->slotInfo, slotInd, sizeof(SlotIndInfo)); - dlBrdcstAlloc->ssbIdxSupported = 1; - - slot = dlSchedInfo.schSlotValue.currentTime.slot; + if(cell == NULLP) + { + DU_LOG("\nERROR --> SCH : Cell Does not exist"); + return RFAILED; + } + memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo)); + dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED; 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 */ - } + slot = dlSchedInfo.schSlotValue.broadcastTime.slot; - /* Identify SIB1 occasions */ - if((dlSchedInfo.schSlotValue.broadcastTime.sfn % SCH_SIB1_TRANS == 0) && (dlSchedInfo.schSlotValue.broadcastTime.slot ==0)) + /* Check for SSB occassion */ + dlBrdcstAlloc->ssbTrans = schCheckSsbOcc(cell, dlSchedInfo.schSlotValue.broadcastTime); + if(dlBrdcstAlloc->ssbTrans) { - 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)) + if(schBroadcastSsbAlloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK) { - dlBrdcstAlloc->sib1Trans = SIB1_REPITITION; + DU_LOG("\nERROR --> SCH : schBroadcastSsbAlloc failed"); + dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION; } - } - else - { - /* not SIB1 occassion */ - } - - - if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans) - { - dlSchedInfo.isBroadcastPres = true; - slot = dlSchedInfo.schSlotValue.broadcastTime.slot; - ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot); - if(ret != ROK) + else { - DU_LOG("\nERROR --> SCH : schBroadcastAlloc failed"); - return ret; + dlSchedInfo.isBroadcastPres = true; + if((dlBrdcstAlloc->ssbTrans == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted)) + cell->firstSsbTransmitted = true; } } - /* check for RAR */ - if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo != NULLP) + /* Check for SIB1 occassion */ + dlBrdcstAlloc->sib1Trans = schCheckSib1Occ(cell, dlSchedInfo.schSlotValue.broadcastTime); + if(dlBrdcstAlloc->sib1Trans) { - slot = dlSchedInfo.schSlotValue.rarTime.slot; - SCH_ALLOC(rarAlloc, sizeof(RarAlloc)); - if(!rarAlloc) + if(schBroadcastSib1Alloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK) { - DU_LOG("\nERROR --> SCH : Memory Allocation failed for RAR alloc"); - return RFAILED; + DU_LOG("\nERROR --> SCH : schBroadcastSib1Alloc failed"); + dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION; } + else + { + dlSchedInfo.isBroadcastPres = true; + if((dlBrdcstAlloc->sib1Trans == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted)) + cell->firstSib1Transmitted = true; + } + } - 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); + /* Check for Pending RA Requests */ + schProcessRaReq(*slotInd, cell); - SCH_FREE(cell->schDlSlotInfo[slot]->rarInfo,sizeof(RarAlloc)); - cell->schDlSlotInfo[slot]->rarInfo = NULLP; + /* Check for RAR */ + if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc != NULLP) + { + slot = dlSchedInfo.schSlotValue.rarTime.slot; + dlSchedInfo.rarAlloc = cell->schDlSlotInfo[slot]->rarAlloc; + cell->schDlSlotInfo[slot]->rarAlloc = NULLP; } - /* check for MSG4 */ + /* Check for MSG4 */ if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo != NULLP) && (cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo->isMsg4Pdu)) { @@ -349,15 +404,22 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) sizeof(DlMsgInfo)); /* pdcch and pdsch data is filled */ - schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.dlMsgTime.slot); + if((schDlRsrcAllocMsg4(cell, dlSchedInfo.schSlotValue.dlMsgTime, msg4Alloc)) != ROK) + { + DU_LOG("\nERROR --> SCH : MSG4 scheduling failed"); + SCH_FREE(msg4Alloc, sizeof(DlMsgAlloc)); + dlSchedInfo.dlMsgAlloc = NULLP; + SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo)); + return RFAILED; + } /* PUCCH resource */ schAllocPucchResource(cell, msg4Alloc->dlMsgInfo.crnti, dlSchedInfo.schSlotValue.dlMsgTime.slot); 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 */ + + /* Check if UL grant must be sent in this slot for a SR/BSR that had been received */ for(ueIdx=0; ueIdxnumActvUe; ueIdx++) { uint32_t totDataReq = 0; /* in bytes */ @@ -390,13 +452,13 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) } memset(dciInfo,0,sizeof(DciInfo)); /* update the SFN and SLOT */ - memcpy(&dlSchedInfo.schSlotValue.ulDciTime, slotInd, sizeof(SlotIndInfo)); + memcpy(&dlSchedInfo.schSlotValue.ulDciTime, slotInd, sizeof(SlotTimingInfo)); slot = dlSchedInfo.schSlotValue.ulDciTime.slot; /* Update PUSCH allocation */ schFillPuschAlloc(ueCb, slot, totDataReq, &schPuschInfo); /* Fill DCI for UL grant */ schFillUlDci(ueCb, schPuschInfo, dciInfo); - memcpy(&dciInfo->slotIndInfo, &dlSchedInfo.schSlotValue.ulDciTime, sizeof(SlotIndInfo)); + memcpy(&dciInfo->slotIndInfo, &dlSchedInfo.schSlotValue.ulDciTime, sizeof(SlotTimingInfo)); dlSchedInfo.ulGrant = dciInfo; } } @@ -405,10 +467,18 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst) if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo != NULLP) && (!cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo->isMsg4Pdu)) { - schFillBoGrantDlSchedInfo(cell, &dlSchedInfo, dlMsgAlloc); + if((schFillBoGrantDlSchedInfo(cell, &dlSchedInfo, dlMsgAlloc)) != ROK) + { + DU_LOG("\nERROR --> SCH : DL MSG scheduling failed"); + SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo)); + return RFAILED; + } + + /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ + SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo)); } - /* send msg to MAC */ + /* Send msg to MAC */ ret = sendDlAllocToMac(&dlSchedInfo, schInst); if(ret != ROK) {