+ 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
+ *
+ * @details
+ *
+ * Function :
+ *
+ * Functionality:
+
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlMsgAlloc *dlMsgAlloc)
+{
+ uint8_t ueIdx, lcIdx;
+ uint16_t slot;
+ uint16_t crnti = 0;
+ uint32_t accumalatedSize = 0;
+ SchUeCb *ueCb = NULLP;
+
+ while(cell->boIndBitMap)
+ {
+ slot = dlSchedInfo->schSlotValue.dlMsgTime.slot;
+
+ GET_RIGHT_MOST_SET_BIT(cell->boIndBitMap, ueIdx);
+ GET_CRNTI(crnti,ueIdx);
+ ueCb = &cell->ueCb[ueIdx-1];
+
+ /* allocate PDCCH and PDSCH resources for the ue */
+ SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc));
+ if(!dlMsgAlloc)
+ {
+ DU_LOG("\nERROR --> SCH : Memory Allocation failed for ded DL msg alloc");
+ return RFAILED;
+ }
+ memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc));
+ dlSchedInfo->dlMsgAlloc = dlMsgAlloc;
+ dlMsgAlloc->crnti = crnti;
+
+ /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */
+ memcpy(&dlMsgAlloc->dlMsgInfo, cell->schDlSlotInfo[slot]->dlMsgInfo, \
+ sizeof(DlMsgInfo));
+
+ /* scheduled LC data fill */
+ dlMsgAlloc->numLc = 0;
+ for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++)
+ {
+ if(ueCb->dlInfo.dlLcCtxt[lcIdx].bo)
+ {
+ dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].lcId = lcIdx;
+
+ /* calculation for BO includse RLC and MAC header size */
+ dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes = \
+ ueCb->dlInfo.dlLcCtxt[lcIdx].bo + MAC_HDR_SIZE;
+ accumalatedSize += dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes;
+ dlMsgAlloc->numLc++;
+ }
+ ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0;
+ }
+
+ if (!dlMsgAlloc->numLc)
+ {
+ DU_LOG("\nDEBUG --> SCH : No bo for any lcid\n");
+ 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
+ * and Priority */
+ dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc -1].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);
+ }
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Handles slot indication at SCH
+ *
+ * @details
+ *
+ * Function : schProcessSlotInd
+ *
+ * Functionality:
+ * Handles TTI indication received from PHY
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
+{
+ uint8_t ueIdx, lcgIdx, ret = ROK;
+ uint16_t slot;
+ DlSchedInfo dlSchedInfo;
+ DlBrdcstAlloc *dlBrdcstAlloc = 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_TRANSMISSION;
+ dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION;
+
+ cell = schCb[schInst].cells[schInst];
+ if(cell == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH : Cell Does not exist");
+ return RFAILED;
+ }
+ memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo));
+ dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED;
+
+ slot = dlSchedInfo.schSlotValue.currentTime.slot;
+
+ dlSchedInfo.cellId = cell->cellId;
+
+ /* 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)
+ {
+ dlSchedInfo.isBroadcastPres = true;
+ slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
+ ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot);