+
+/*******************************************************************
+*
+* @brief Function to delete Sch Pucch ResrcCfg
+*
+* @details
+*
+* Function : deleteSchPucchResrcCfg
+*
+* Functionality: Function to delete Sch Pucch ResrcCfg
+*
+* @params[in] SchPucchResrcCfg *resrc
+* @return void
+*
+* ****************************************************************/
+
+void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
+{
+ uint8_t rsrcIdx=0;
+ for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
+ {
+ switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
+ {
+ case PUCCH_FORMAT_0:
+ {
+ SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
+ sizeof(SchPucchFormat0));
+ break;
+ }
+ case PUCCH_FORMAT_1:
+ {
+ SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
+ sizeof(SchPucchFormat1));
+ break;
+ }
+ case PUCCH_FORMAT_2:
+ {
+ SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
+ sizeof(SchPucchFormat2_3));
+ break;
+ }
+ case PUCCH_FORMAT_3:
+ {
+ SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
+ sizeof(SchPucchFormat2_3));
+ break;
+ }
+ case PUCCH_FORMAT_4:
+ {
+ SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
+ sizeof(SchPucchFormat4));
+ break;
+ }
+ }
+ }
+}
+
+/*******************************************************************
+*
+* @brief Function to delete SCH Pdsch ServCellCfg
+*
+* @details
+*
+* Function : deleteSchPdschServCellCfg
+*
+* Functionality: Function to delete SCH Pdsch ServCellCfg
+*
+* @params[in] SchPdschServCellCfg *pdschServCellCfg
+* @return void
+*
+* ****************************************************************/
+
+void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
+{
+ SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
+ SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
+ SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
+ SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
+}
+
+/*******************************************************************
+*
+* @brief Function to delete SCH UeCb
+*
+* @details
+*
+* Function : deleteSchUeCb
+*
+* Functionality: Function to delete SCH UeCb
+*
+* @params[in]
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+void deleteSchUeCb(SchUeCb *ueCb)
+{
+ uint8_t timeDomRsrcIdx = 0, ueLcIdx = 0, slotIdx =0, cRSetIdx = 0;
+ SchPucchCfg *pucchCfg = NULLP;
+ SchPdschConfig *pdschCfg = NULLP;
+
+ if(ueCb)
+ {
+ if(ueCb->hqDlmap)
+ {
+ for (slotIdx = 0; slotIdx<ueCb->cellCb->numSlots; slotIdx++)
+ {
+ if(ueCb->hqDlmap[slotIdx])
+ {
+ cmLListDeleteLList(&ueCb->hqDlmap[slotIdx]->hqList);
+ SCH_FREE(ueCb->hqDlmap[slotIdx], sizeof(SchHqDlMap));
+ }
+ }
+ SCH_FREE(ueCb->hqDlmap, sizeof(SchHqDlMap*)*(ueCb->cellCb->numSlots));
+ }
+
+ if(ueCb->hqUlmap)
+ {
+ for (slotIdx = 0; slotIdx<ueCb->cellCb->numSlots; slotIdx++)
+ {
+ if(ueCb->hqUlmap[slotIdx])
+ {
+ cmLListDeleteLList(&ueCb->hqUlmap[slotIdx]->hqList);
+ SCH_FREE(ueCb->hqUlmap[slotIdx], sizeof(SchHqUlMap));
+ }
+ }
+ SCH_FREE(ueCb->hqUlmap, sizeof(SchHqUlMap*)*(ueCb->cellCb->numSlots));
+ }
+
+ schDlHqEntDelete(ueCb);
+ schUlHqEntDelete(ueCb);
+
+ SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
+ if(ueCb->ueCfg.spCellCfgPres)
+ {
+ if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfgPres == true)
+ {
+ pdschCfg = &ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg;
+ for(timeDomRsrcIdx = 0; timeDomRsrcIdx < pdschCfg->numTimeDomRsrcAlloc; timeDomRsrcIdx++)
+ SCH_FREE(pdschCfg->timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
+ }
+
+ if(ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfgPres == true)
+ {
+ pucchCfg = &ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg;
+ SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
+ if(pucchCfg->resrc)
+ {
+ deleteSchPucchResrcCfg(pucchCfg->resrc);
+ SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
+ }
+ SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
+ SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
+ SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
+ SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
+ SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
+ SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
+ SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
+ SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
+ SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
+ }
+ SCH_FREE(ueCb->ueCfg.spCellCfg.servCellRecfg.bwpInactivityTmr, sizeof(uint8_t));
+ deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellRecfg.pdschServCellCfg);
+ }
+ /*Need to Free the memory allocated for S-NSSAI*/
+ for(ueLcIdx = 0; ueLcIdx < MAX_NUM_LC; ueLcIdx++)
+ {
+ SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
+ SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai));
+ }
+#ifdef NR_DRX
+ if(ueCb->ueDrxInfoPres)
+ {
+ /* Removing all the calculated drx configuration timer list */
+ schDeleteUeDrxInfo(ueCb->cellCb, ueCb);
+ ueCb->ueDrxInfoPres = false;
+ }
+#endif
+
+ for(cRSetIdx=0; cRSetIdx < MAX_NUM_CRSET; cRSetIdx++)
+ {
+ SCH_FREE(ueCb->pdcchInfo[cRSetIdx].y, (sizeof(uint32_t) * ueCb->cellCb->numSlots));
+ }
+ memset(ueCb, 0, sizeof(SchUeCb));
+ }
+}
+
+/*******************************************************************
+*
+* @brief Fill and send UE delete response to MAC
+*
+* @details
+*
+* Function : SchSendUeDeleteRspToMac
+*
+* Functionality: Fill and send UE delete response to MAC
+*
+* @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
+* CauseOfResult cause
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, CauseOfResult cause)
+{
+ Pst rspPst;
+ SchUeDeleteRsp delRsp;
+
+ memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
+ delRsp.cellId = ueDelete->cellId;
+ delRsp.crnti = ueDelete->crnti;
+ delRsp.rsp = result;
+ delRsp.cause = cause;
+
+ /* Filling response post */
+ memset(&rspPst, 0, sizeof(Pst));
+ FILL_PST_SCH_TO_MAC(rspPst, inst);
+ rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
+ MacMessageRouter(&rspPst, (void *)&delRsp);
+}
+
+/*******************************************************************
+*
+* @brief Function for Ue Delete request from MAC to SCH
+*
+* @details
+*
+* Function : SchProcUeDeleteReq
+*
+* Functionality: Function for Ue Delete request from MAC to SCH
+*
+* @params[in] Pst *pst, SchUeDelete *ueDelete
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t SchProcUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
+{
+ uint8_t idx=0, ueId=0, ret=ROK;
+ CauseOfResult cause;
+ SchCellCb *cellCb = NULLP;
+ Inst inst = pst->dstInst - SCH_INST_START;
+
+ if(!ueDelete)
+ {
+ DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): Ue Delete request failed");
+ ret = RFAILED;
+ }
+ DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
+
+ cellCb = schCb[inst].cells[idx];
+
+ if(cellCb->cellId != ueDelete->cellId)
+ {
+ DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): cell Id is not available");
+ cause = CELLID_INVALID;
+ }
+ else
+ {
+ GET_UE_ID(ueDelete->crnti, ueId);
+ if(( cellCb->ueCb[ueId-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueId-1].state == SCH_UE_STATE_ACTIVE))
+ {
+ /* Remove UE from ueToBeScheduled list */
+ cellCb->api->SchUeDeleteReq(&cellCb->ueCb[ueId-1]);
+ deleteSchUeCb(&cellCb->ueCb[ueId-1]);
+ cellCb->numActvUe--;
+ cause = SUCCESSFUL;
+ }
+ else
+ {
+ DU_LOG("\nERROR --> SCH : SchProcUeDeleteReq(): SchUeCb not found");
+ cause = UEID_INVALID;
+ }
+ }
+
+ if(cause == SUCCESSFUL)
+ {
+ SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, cause);
+ }
+ else
+ {
+ SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, cause);
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Function updates DL HARQ Feedback
+ *
+ * @details
+ *
+ * Function : schUpdateHarqFdbk
+ *
+ * Functionality: Function updates DL HARQ feedback
+ *
+ * @params[in] SchUeCb *ueCb, UE cb struct pointer
+ * @params[in] uint8_t numHarq, number of HARQ processes in feedback
+ * @params[in] uint8_t *harqPayload, harq feedback payload received
+ * @params[in] SlotTimingInfo *slotInd, slot timing information
+ * @return void
+ *
+ * ****************************************************************/
+void schUpdateHarqFdbk(SchUeCb *ueCb, uint8_t numHarq, uint8_t *harqPayload, SlotTimingInfo *slotInd)
+{
+ SchDlHqProcCb *hqP;
+ SchHqDlMap *hqDlMap;
+ CmLList *node = NULLP;
+ uint8_t fdbkPos = 0;
+
+ hqDlMap = ueCb->hqDlmap[slotInd->slot];
+
+ if (ueCb->cellCb->raCb[ueCb->ueId-1].raState == SCH_RA_STATE_MSG2_HANDLE)
+ {
+ return;
+ }
+
+ while(fdbkPos < numHarq)
+ {
+ node = hqDlMap->hqList.first;
+ if(node == NULLP)
+ {
+ DU_LOG("\nERROR : SCH --> DL HARQ list is empty thus no need to process the dl harq feedback!");
+ return;
+ }
+ if (ueCb->cellCb->raCb[ueCb->ueId-1].raState != SCH_RA_STATE_MSG4_PENDING)
+ {
+ while(node)
+ {
+ hqP = (SchDlHqProcCb*)node->node;
+ node = node->next;
+ cmLListDelFrm(&hqDlMap->hqList, &hqP->dlSlotLnk);
+ /*
+ Decode harq feedback if needed post FAPI message decoding also or check how to decode this FAPI msg.
+ case 1 semi static harq Ack/Nack codebook //Supported
+ case 2 dynamic harq ACK/NACK codebook //Not supported
+ */
+ schDlHqFeedbackUpdate(hqP, harqPayload[fdbkPos++], HQ_TB_ACKED);//Marking 2nd TB as ACKED for now as only one TB to be used
+ }
+ }
+ else
+ {
+ hqP = (SchDlHqProcCb*)node->node;
+ cmLListDelFrm(&hqDlMap->hqList, &hqP->dlSlotLnk);
+ schMsg4FeedbackUpdate(hqP, harqPayload[fdbkPos++]);
+ }
+ }
+}