+/*******************************************************************
+ *
+ * @brief Fill and send Cell delete response to MAC
+ *
+ * @details
+ *
+ * Function : SchSendCellDeleteRspToMac
+ *
+ * Functionality: Fill and send Cell delete response to MAC
+ *
+ * @params[in] SchCellDelete *ueDelete, Inst inst, SchMacRsp result
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t SchSendCellDeleteRspToMac(SchCellDelete *ueDelete, Inst inst, SchMacRsp result)
+{
+ Pst rspPst;
+ uint8_t ret=0;
+
+ SchCellDeleteRsp delRsp;
+
+ DU_LOG("\nINFO --> SCH : Filling Cell Delete response");
+ memset(&delRsp, 0, sizeof(SchCellDeleteRsp));
+ delRsp.cellId = ueDelete->cellId;
+ delRsp.rsp = result;
+
+ /* Filling response post */
+ memset(&rspPst, 0, sizeof(Pst));
+ FILL_PST_SCH_TO_MAC(rspPst, inst);
+ rspPst.event = EVENT_CELL_DELETE_RSP_TO_MAC;
+ ret = SchCellDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> SCH : SchSendCellDeleteRspToMac(): failed to send the Cell Delete response");
+ return ret;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Function for cellCb Deletion
+ *
+ * @details
+ *
+ * Function : deleteSchCellCb
+ *
+ * Functionality: Function for cellCb Deletion
+ *
+ * @params[in] SchCellDelete *cellDelete
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void deleteSchCellCb(SchCellCb *cellCb)
+{
+ uint8_t sliceIdx=0, slotIdx=0;
+ CmLListCp *list=NULL;
+ CmLList *node=NULL, *next=NULL;
+ SchPageInfo *tempNode = NULLP;
+
+ if(cellCb->schDlSlotInfo)
+ {
+ for(slotIdx=0; slotIdx<cellCb->numSlots; slotIdx++)
+ {
+ list = &cellCb->schDlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList;
+ node = list->first;
+ while(node)
+ {
+ next = node->next;
+ SCH_FREE(node->node, sizeof(FreePrbBlock));
+ deleteNodeFromLList(list, node);
+ node = next;
+ }
+ SCH_FREE(cellCb->schDlSlotInfo[slotIdx], sizeof(SchDlSlotInfo));
+ }
+ SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*));
+ }
+
+ if(cellCb->schUlSlotInfo)
+ {
+ for(slotIdx=0; slotIdx<cellCb->numSlots; slotIdx++)
+ {
+ list = &cellCb->schUlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList;
+ node = list->first;
+ while(node)
+ {
+ next = node->next;
+ SCH_FREE(node->node, sizeof(FreePrbBlock));
+ deleteNodeFromLList(list, node);
+ node = next;
+ }
+ SCH_FREE(cellCb->schUlSlotInfo[slotIdx], sizeof(SchUlSlotInfo));
+ }
+ SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*));
+ }
+
+ if(cellCb->cellCfg.plmnInfoList.snssai)
+ {
+ for(sliceIdx=0; sliceIdx<cellCb->cellCfg.plmnInfoList.numSliceSupport; sliceIdx++)
+ {
+ SCH_FREE(cellCb->cellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
+ }
+ SCH_FREE(cellCb->cellCfg.plmnInfoList.snssai, cellCb->cellCfg.plmnInfoList.numSliceSupport*sizeof(Snssai*));
+ }
+
+ for(uint16_t idx =0; idx<MAX_SFN; idx++)
+ {
+ list = &cellCb->pageCb.pageIndInfoRecord[idx];
+ node = list->first;
+ while(node)
+ {
+ next = node->next;
+ if(node->node)
+ {
+ tempNode = (SchPageInfo*)(node->node);
+ SCH_FREE(tempNode->pagePdu, tempNode->msgLen);
+ SCH_FREE(node->node, sizeof(SchPageInfo));
+ }
+ deleteNodeFromLList(list, node);
+ node = next;
+ }
+ }
+
+ /* Remove all UE from ueToBeScheduled list and deallocate */
+ node = cellCb->ueToBeScheduled.first;
+ while(node)
+ {
+ next = node->next;
+ SCH_FREE(node->node, sizeof(uint8_t));
+ cmLListDelFrm(&cellCb->ueToBeScheduled, node);
+ SCH_FREE(node, sizeof(CmLList));
+ node = next;
+ }
+
+ memset(cellCb, 0, sizeof(SchCellCb));
+
+}
+
+/*******************************************************************
+ *
+ * @brief Function for cell Delete request from MAC to SCH
+ *
+ * @details
+ *
+ * Function : MacSchCellDeleteReq
+ *
+ * Functionality: Function for cell Delete request from MAC to SCH
+ *
+ * @params[in] Pst *pst, SchCellDelete *cellDelete
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete *cellDelete)
+{
+ uint8_t cellIdx=0, ret = RFAILED;
+ Inst inst = pst->dstInst - SCH_INST_START;
+ SchMacRsp result= RSP_OK;
+
+#ifdef CALL_FLOW_DEBUG_LOG
+ DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_CELL_DELETE_REQ_TO_SCH\n");
+#endif
+
+ if(!cellDelete)
+ {
+ DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): Ue Delete request failed");
+ }
+ else
+ {
+ GET_CELL_IDX(cellDelete->cellId, cellIdx);
+ if(schCb[inst].cells[cellIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available", cellDelete->cellId);
+ result = RSP_NOK;
+ }
+ else
+ {
+ if(schCb[inst].cells[cellIdx]->cellId == cellDelete->cellId)
+ {
+ deleteSchCellCb(schCb[inst].cells[cellIdx]);
+ result = RSP_OK;
+ ret = ROK;
+ SCH_FREE(schCb[inst].cells[cellIdx], sizeof(SchCellCb));
+ DU_LOG("\nINFO --> SCH : Sending Cell Delete response to MAC");
+ }
+ else
+ {
+ DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available",cellDelete->cellId);
+ result = RSP_NOK;
+ }
+ }
+
+ if(SchSendCellDeleteRspToMac(cellDelete, inst, result)!=ROK)
+ {
+ DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): failed to send Cell Delete response");
+ 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;
+ uint8_t fdbkPos = 0;
+
+ hqDlMap = ueCb->hqDlmap[slotInd->slot];
+
+ if (ueCb->cellCb->raCb[ueCb->ueId-1].raState == SCH_RA_STATE_MSG2_HANDLE)
+ {
+ return;
+ }
+ if (ueCb->cellCb->raCb[ueCb->ueId-1].raState != SCH_RA_STATE_MSG4_PENDING)
+ {
+ node = hqDlMap->hqList.first;
+ while(node)
+ {
+ hqP = (SchDlHqProcCb*)node->node;
+ node = node->next;
+ cmLListDelFrm(&hqDlMap->hqList, &hqP->ulSlotLnk);
+ /*
+ 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
+ {
+ node = hqDlMap->hqList.first;
+ hqP = (SchDlHqProcCb*)node->node;
+ cmLListDelFrm(&hqDlMap->hqList, &hqP->ulSlotLnk);
+ schMsg4FeedbackUpdate(hqP, harqPayload[fdbkPos++]);
+ }
+}