1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file contains UE management handling functionality for SCH */
20 #include "common_def.h"
27 #include "du_app_mac_inf.h"
28 #include "mac_sch_interface.h"
30 #include "sch_utils.h"
33 SchUeCfgRspFunc SchUeCfgRspOpts[] =
35 packSchUeCfgRsp, /* LC */
36 MacProcSchUeCfgRsp, /* TC */
37 packSchUeCfgRsp /* LWLC */
40 SchUeDeleteRspFunc SchUeDeleteRspOpts[] =
42 packSchUeDeleteRsp, /* LC */
43 MacProcSchUeDeleteRsp, /* TC */
44 packSchUeDeleteRsp /* LWLC */
47 /*******************************************************************
49 * @brief Fill and send UE cfg response to MAC
53 * Function : SchSendUeCfgRspToMac
55 * Functionality: Fill and send UE cfg response to MAC
58 * @return ROK - success
61 * ****************************************************************/
62 void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
63 SchMacRsp result, SchUeCfgRsp *cfgRsp)
67 cfgRsp->cellId = ueCfg->cellId;
68 cfgRsp->crnti = ueCfg->crnti;
69 GET_UE_IDX(ueCfg->crnti, cfgRsp->ueIdx);
72 /* Filling response post */
73 memset(&rspPst, 0, sizeof(Pst));
74 FILL_PST_SCH_TO_MAC(rspPst, inst);
75 if(event == EVENT_ADD_UE_CONFIG_REQ_TO_SCH)
77 rspPst.event = EVENT_UE_CONFIG_RSP_TO_MAC;
78 DU_LOG("\nINFO --> SCH : Sending UE Config response to MAC");
80 else if(event == EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH)
82 rspPst.event = EVENT_UE_RECONFIG_RSP_TO_MAC;
83 DU_LOG("\nINFO --> SCH : Sending UE Reconfig response to MAC");
85 SchUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
88 /*******************************************************************
91 * @brief Function to fill Dl Lc Context in SCH Ue Cb
95 * Function : fillSchDlLcCtxt
97 * Functionality: Function to fill Dl Lc Context in SCH Ue Cb
99 * @params[in] SchDlLcCtxt pointer,
103 * ****************************************************************/
105 void fillSchDlLcCtxt(SchDlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
107 ueCbLcCfg->lcId = lcCfg->lcId;
108 ueCbLcCfg->lcp = lcCfg->dlLcCfg.lcp;
109 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
113 /*******************************************************************
115 * @brief Function to fill Ul Lc Context in SCH Ue Cb
119 * Function : fillSchUlLcCtxt
121 * Functionality: Function to fill Ul Lc Context in SCH Ue Cb
123 * @params[in] SchUlLcCtxt pointer,
127 * ****************************************************************/
129 void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
131 ueCbLcCfg->lcId = lcCfg->lcId;
132 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
133 ueCbLcCfg->priority = lcCfg->ulLcCfg.priority;
134 ueCbLcCfg->lcGroup = lcCfg->ulLcCfg.lcGroup;
135 ueCbLcCfg->schReqId = lcCfg->ulLcCfg.schReqId;
136 ueCbLcCfg->pbr = lcCfg->ulLcCfg.pbr;
137 ueCbLcCfg->bsd = lcCfg->ulLcCfg.bsd;
141 /*******************************************************************
143 * @brief Function to update Sch Ul Lc Cb
147 * Function : updateSchUlCb
149 * Functionality: Function to update SCH Ul Lc Cb
153 * ****************************************************************/
155 void updateSchUlCb(uint8_t delIdx, SchUlCb *ulInfo)
159 for(lcIdx = delIdx; lcIdx < ulInfo->numUlLc; lcIdx++)
161 memcpy(&ulInfo->ulLcCtxt[lcIdx], &ulInfo->ulLcCtxt[lcIdx+1], sizeof(SchUlLcCtxt));
162 memset(&ulInfo->ulLcCtxt[lcIdx+1], 0, sizeof(SchUlLcCtxt));
166 /*******************************************************************
168 * @brief Function to update SCH Dl Lc Cb
172 * Function : updateSchDlCb
174 * Functionality: Function to update SCH DL Lc Cb
178 * ****************************************************************/
180 void updateSchDlCb(uint8_t delIdx, SchDlCb *dlInfo)
184 for(lcIdx = delIdx; lcIdx < dlInfo->numDlLc; lcIdx++)
186 memcpy(&dlInfo->dlLcCtxt[lcIdx], &dlInfo->dlLcCtxt[lcIdx+1], sizeof(SchDlLcCtxt));
187 memset(&dlInfo->dlLcCtxt[lcIdx+1], 0, sizeof(SchDlLcCtxt));
191 /*******************************************************************
193 * @brief Function to fill SchUeCb
197 * Function : fillSchUeCb
199 * Functionality: Function to fill SchUeCb
201 * @params[in] SchUeCb pointer,
203 * @return ROK/RFAILED
205 * ****************************************************************/
207 uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
209 uint8_t lcIdx, ueLcIdx;
211 ueCb->ueCfg.cellId = ueCfg->cellId;
212 ueCb->ueCfg.crnti = ueCfg->crnti;
213 if(ueCfg->macCellGrpCfgPres == true)
215 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
216 ueCb->ueCfg.macCellGrpCfgPres = true;
219 if(ueCfg->phyCellGrpCfgPres == true)
221 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
222 ueCb->ueCfg.phyCellGrpCfgPres = true;
225 if(ueCfg->spCellCfgPres == true)
227 memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
228 ueCb->ueCfg.spCellCfgPres = true;
230 ueCb->state = SCH_UE_STATE_ACTIVE;
231 if(ueCfg->ambrCfg != NULLP)
233 SCH_ALLOC(ueCb->ueCfg.ambrCfg , sizeof(SchAmbrCfg));
234 memcpy(&ueCb->ueCfg.ambrCfg->ulBr , &ueCfg->ambrCfg->ulBr, sizeof(SchAmbrCfg));
237 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
238 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
240 //Updating SchUlCb and SchDlCb DB in SchUeCb
241 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
243 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
245 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
246 ueCb->ulInfo.numUlLc++;
247 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
248 ueCb->dlInfo.numDlLc++;
252 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
254 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
256 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
258 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
259 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
262 if(ueCfg->schLcCfg[ueLcIdx].configType == CONFIG_DEL)
264 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
265 ueCb->ulInfo.numUlLc--;
266 updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead
267 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
268 ueCb->dlInfo.numDlLc--;
269 updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
273 }/*End of inner for loop */
275 }/* End of outer for loop */
279 /*******************************************************************
281 * @brief Function to get SCH Cell Cb
285 * Function : getSchCellCb
287 * Functionality: Function to get SCH Cell Cb
289 * @params[in] event, SchUeCfg pointer
290 * @return schUeCb pointer - success
293 * ****************************************************************/
295 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
298 SchCellCb *cellCb = NULLP;
300 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
302 /* Search of cell cb */
303 for(idx = 0; idx < MAX_NUM_CELL; idx++)
305 cellCb = schCb[inst].cells[idx];
306 if(cellCb->cellId == ueCfg->cellId)
309 if(idx == MAX_NUM_CELL)
311 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
312 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
316 /* Check if max number of UE configured */
317 if(cellCb->numActvUe > MAX_NUM_UE)
319 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
320 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
327 /*******************************************************************
329 * @brief Function to Add Ue Config Request from MAC
333 * Function : MacSchAddUeConfigReq
335 * Functionality: Function to Add Ue config request from MAC
338 * @return ROK - success
341 * ****************************************************************/
342 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
344 uint8_t ueIdx, lcIdx, ret = ROK;
345 SchCellCb *cellCb = NULLP;
346 SchUeCb *ueCb = NULLP;
348 Inst inst = pst->dstInst - 1;
349 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
353 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at MacSchAddUeConfigReq()");
356 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
357 cellCb = getSchCellCb(pst->event, inst, ueCfg);
359 /* Search if UE already configured */
360 GET_UE_IDX(ueCfg->crnti, ueIdx);
361 ueCb = &cellCb->ueCb[ueIdx -1];
364 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
366 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
367 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
373 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
374 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
378 /* Fill received Ue Configuration in UeCb */
379 memset(ueCb, 0, sizeof(SchUeCb));
380 GET_UE_IDX(ueCfg->crnti, ueIdx);
382 ueCb->crnti = ueCfg->crnti;
383 ueCb->state = SCH_UE_STATE_ACTIVE;
384 ret = fillSchUeCb(ueCb, ueCfg);
388 SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
389 ueCb->cellCb = cellCb;
390 ueCb->srRcvd = false;
391 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
392 ueCb->bsrInfo[lcIdx].dataVol = 0;
394 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
399 /*******************************************************************
401 * @brief Fills PUSCH UL allocation
405 * Function : schFillPuschAlloc
407 * Functionality: fills PUSCH info
410 * @return ROK - success
413 * ****************************************************************/
414 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
416 uint16_t puschSlot = 0;
417 uint16_t startRb = 0;
419 uint8_t numPdschSymbols= 14;
423 SchCellCb *cellCb = ueCb->cellCb;
424 SchUlSlotInfo *schUlSlotInfo = NULLP;
425 uint8_t k2=0, startSymb=0 , symbLen=0;
427 if(ueCb->ueCfg.spCellCfgPres == true)
429 k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
430 startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
431 symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
433 puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
435 startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
436 tbSize = schCalcTbSize(dataVol + buffer); /* 2 bytes header + some buffer */
437 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, numPdschSymbols);
438 /* increment PUSCH PRB */
440 cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
442 puschInfo->crnti = ueCb->crnti;
443 puschInfo->harqProcId = SCH_HARQ_PROC_ID;
444 puschInfo->resAllocType = SCH_ALLOC_TYPE_1;
445 puschInfo->fdAlloc.startPrb = startRb;
446 puschInfo->fdAlloc.numPrb = numRb;
447 puschInfo->tdAlloc.startSymb = startSymb;
448 puschInfo->tdAlloc.numSymb = symbLen;
449 puschInfo->tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
450 puschInfo->tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
451 puschInfo->tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
452 puschInfo->tbInfo.ndi = 1; /* new transmission */
453 puschInfo->tbInfo.rv = 0;
454 puschInfo->tbInfo.tbSize = tbSize;
455 puschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
456 puschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
457 puschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS;
459 /* Update pusch in cell */
460 for(idx=startSymb; idx<symbLen; idx++)
462 cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
465 schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
467 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
468 if(!schUlSlotInfo->schPuschInfo)
470 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
473 memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
478 /*******************************************************************
480 * @brief Fills DCI for UL grant
484 * Function : schFillUlDci
486 * Functionality: fills DCI for UL grant in response to BSR
489 * @return ROK - success
492 * ****************************************************************/
493 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
495 SchCellCb *cellCb = ueCb->cellCb;
496 SchControlRsrcSet coreset1 ;
498 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
499 if(ueCb->ueCfg.spCellCfgPres == true)
501 coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
504 dciInfo->cellId = cellCb->cellId;
505 dciInfo->crnti = ueCb->crnti;
508 dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
509 dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
510 dciInfo->bwpCfg.freqAlloc.startPrb = 0;
511 dciInfo->bwpCfg.freqAlloc.numPrb = MAX_NUM_RB; /* whole of BW */
513 /*fill coreset cfg */
514 //Considering number of RBs in coreset1 is same as coreset0
515 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
516 //Considering coreset1 also starts from same symbol as coreset0
517 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
518 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
519 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
521 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
522 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
523 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
524 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
525 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
526 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
527 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
528 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
530 dciInfo->formatType = FORMAT0_0;
533 dciInfo->format.format0_0.resourceAllocType = puschInfo.resAllocType;
534 dciInfo->format.format0_0.freqAlloc.startPrb = puschInfo.fdAlloc.startPrb;
535 dciInfo->format.format0_0.freqAlloc.numPrb = puschInfo.fdAlloc.numPrb;
536 dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
537 dciInfo->format.format0_0.timeAlloc.numSymb = puschInfo.tdAlloc.numSymb;
538 dciInfo->format.format0_0.rowIndex = 0; /* row Index */
539 dciInfo->format.format0_0.mcs = puschInfo.tbInfo.mcs;
540 dciInfo->format.format0_0.harqProcId = puschInfo.harqProcId;
541 dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */
542 dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */
543 dciInfo->format.format0_0.ndi = puschInfo.tbInfo.ndi; /* new transmission */
544 dciInfo->format.format0_0.rv = puschInfo.tbInfo.rv;
545 dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
546 dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */
548 /* Fill DCI Structure */
549 dciInfo->dciInfo.rnti = ueCb->crnti;
550 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
551 dciInfo->dciInfo.scramblingRnti = 0;
552 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
553 dciInfo->dciInfo.aggregLevel = 4;
554 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
555 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
556 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
557 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
558 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
559 dciInfo->dciInfo.txPdcchPower.powerValue = 0;
560 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
561 dciInfo->dciInfo.pdschCfg = NULLP; /* No DL data being sent */
566 /*******************************************************************
568 * @brief Function to Modify Ue Config request from MAC
572 * Function : MacSchModUeConfigReq
574 * Functionality: Function to modify Ue Config request from MAC
577 * @return ROK - success
580 * ****************************************************************/
581 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
583 uint8_t ueIdx, lcIdx, ret = ROK;
584 SchCellCb *cellCb = NULLP;
585 SchUeCb *ueCb = NULLP;
587 Inst inst = pst->dstInst - 1;
588 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
592 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
595 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
596 cellCb = getSchCellCb(pst->event, inst, ueCfg);
598 /* Search if UE already configured */
599 GET_UE_IDX(ueCfg->crnti, ueIdx);
600 ueCb = &cellCb->ueCb[ueIdx -1];
604 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchModUeConfigReq() ");
605 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
608 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
610 /* Found the UeCb to Reconfig */
611 ret = fillSchUeCb(ueCb, ueCfg);
614 ueCb->cellCb = cellCb;
615 ueCb->srRcvd = false;
616 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
617 ueCb->bsrInfo[lcIdx].dataVol = 0;
619 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
624 /*******************************************************************
626 * @brief Fill and send UE delete response to MAC
630 * Function : SchSendUeDeleteRspToMac
632 * Functionality: Fill and send UE delete response to MAC
634 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
636 * @return ROK - success
639 * ****************************************************************/
640 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, ErrorCause cause)
643 SchUeDeleteRsp delRsp;
645 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
646 delRsp.cellId = ueDelete->cellId;
647 delRsp.crnti = ueDelete->crnti;
649 delRsp.cause = cause;
651 /* Filling response post */
652 memset(&rspPst, 0, sizeof(Pst));
653 FILL_PST_SCH_TO_MAC(rspPst, inst);
654 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
655 SchUeDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
657 /*******************************************************************
659 * @brief Function to delete Sch Pucch ResrcCfg
663 * Function : deleteSchPucchResrcCfg
665 * Functionality: Function to delete Sch Pucch ResrcCfg
667 * @params[in] SchPucchResrcCfg *resrc
670 * ****************************************************************/
672 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
675 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
677 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
681 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
682 sizeof(SchPucchFormat0));
687 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
688 sizeof(SchPucchFormat1));
693 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
694 sizeof(SchPucchFormat2_3));
699 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
700 sizeof(SchPucchFormat2_3));
705 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
706 sizeof(SchPucchFormat4));
712 /*******************************************************************
714 * @brief Function to delete SCH Pdsch ServCellCfg
718 * Function : deleteSchPdschServCellCfg
720 * Functionality: Function to delete SCH Pdsch ServCellCfg
722 * @params[in] SchPdschServCellCfg *pdschServCellCfg
725 * ****************************************************************/
727 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
729 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
730 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
731 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
732 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
734 /*******************************************************************
736 * @brief Function to delete SCH UeCb
740 * Function : deleteSchUeCb
742 * Functionality: Function to delete SCH UeCb
745 * @return ROK - success
748 * ****************************************************************/
749 void deleteSchUeCb(SchUeCb *ueCb)
751 SchPucchCfg *pucchCfg = NULLP;
754 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
755 if(ueCb->ueCfg.spCellCfgPres)
757 if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres == true)
759 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg;
760 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
763 deleteSchPucchResrcCfg(pucchCfg->resrc);
764 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
766 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
767 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
768 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
769 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
770 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
771 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
772 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
773 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
774 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
776 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.bwpInactivityTmr, sizeof(uint8_t));
777 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg);
779 memset(ueCb, 0, sizeof(SchUeCb));
782 /*******************************************************************
784 * @brief Function for Ue Delete request from MAC to SCH
788 * Function : MacSchUeDeleteReq
790 * Functionality: Function for Ue Delete request from MAC to SCH
792 * @params[in] Pst *pst, SchUeDelete *ueDelete
793 * @return ROK - success
796 * ****************************************************************/
797 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
799 uint8_t idx=0, ueIdx=0, ret=ROK;
801 SchCellCb *cellCb = NULLP;
803 Inst inst = pst->dstInst - 1;
807 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): Ue Delete request failed");
810 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
812 cellCb = schCb[inst].cells[idx];
814 if(cellCb->cellId != ueDelete->cellId)
816 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): cell Id is not available");
817 result = INVALID_CELLID;
821 GET_UE_IDX(ueDelete->crnti, ueIdx);
822 ueCb = cellCb->ueCb[ueIdx-1];
823 if((ueCb.crnti == ueDelete->crnti) && (ueCb.state == SCH_UE_STATE_ACTIVE))
825 deleteSchUeCb(&ueCb);
826 result = NOT_APPLICABLE;
830 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): SchUeCb not found");
831 result = INVALID_UEIDX;
835 if(result == NOT_APPLICABLE)
837 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, result);
841 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, result);
847 /**********************************************************************
849 **********************************************************************/