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 SchCellDeleteRspFunc SchCellDeleteRspOpts[]=
49 packSchCellDeleteRsp, /* LC */
50 MacProcSchCellDeleteRsp, /* TC */
51 packSchCellDeleteRsp /* LWLC */
53 /*******************************************************************
55 * @brief Fill and send UE cfg response to MAC
59 * Function : SchSendUeCfgRspToMac
61 * Functionality: Fill and send UE cfg response to MAC
64 * @return ROK - success
67 * ****************************************************************/
68 void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
69 SchMacRsp result, SchUeCfgRsp *cfgRsp)
73 cfgRsp->cellId = ueCfg->cellId;
74 cfgRsp->crnti = ueCfg->crnti;
75 GET_UE_IDX(ueCfg->crnti, cfgRsp->ueIdx);
78 /* Filling response post */
79 memset(&rspPst, 0, sizeof(Pst));
80 FILL_PST_SCH_TO_MAC(rspPst, inst);
81 if(event == EVENT_ADD_UE_CONFIG_REQ_TO_SCH)
83 rspPst.event = EVENT_UE_CONFIG_RSP_TO_MAC;
84 DU_LOG("\nINFO --> SCH : Sending UE Config response to MAC");
86 else if(event == EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH)
88 rspPst.event = EVENT_UE_RECONFIG_RSP_TO_MAC;
89 DU_LOG("\nINFO --> SCH : Sending UE Reconfig response to MAC");
91 SchUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp);
94 /*******************************************************************
97 * @brief Function to fill Dl Lc Context in SCH Ue Cb
101 * Function : fillSchDlLcCtxt
103 * Functionality: Function to fill Dl Lc Context in SCH Ue Cb
105 * @params[in] SchDlLcCtxt pointer,
109 * ****************************************************************/
111 void fillSchDlLcCtxt(SchDlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
113 ueCbLcCfg->lcId = lcCfg->lcId;
114 ueCbLcCfg->lcp = lcCfg->dlLcCfg.lcp;
115 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
119 /*******************************************************************
121 * @brief Function to fill Ul Lc Context in SCH Ue Cb
125 * Function : fillSchUlLcCtxt
127 * Functionality: Function to fill Ul Lc Context in SCH Ue Cb
129 * @params[in] SchUlLcCtxt pointer,
133 * ****************************************************************/
135 void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
137 ueCbLcCfg->lcId = lcCfg->lcId;
138 ueCbLcCfg->lcState = SCH_LC_STATE_ACTIVE;
139 ueCbLcCfg->priority = lcCfg->ulLcCfg.priority;
140 ueCbLcCfg->lcGroup = lcCfg->ulLcCfg.lcGroup;
141 ueCbLcCfg->schReqId = lcCfg->ulLcCfg.schReqId;
142 ueCbLcCfg->pbr = lcCfg->ulLcCfg.pbr;
143 ueCbLcCfg->bsd = lcCfg->ulLcCfg.bsd;
147 /*******************************************************************
149 * @brief Function to update Sch Ul Lc Cb
153 * Function : updateSchUlCb
155 * Functionality: Function to update SCH Ul Lc Cb
159 * ****************************************************************/
161 void updateSchUlCb(uint8_t delIdx, SchUlCb *ulInfo)
165 for(lcIdx = delIdx; lcIdx < ulInfo->numUlLc; lcIdx++)
167 memcpy(&ulInfo->ulLcCtxt[lcIdx], &ulInfo->ulLcCtxt[lcIdx+1], sizeof(SchUlLcCtxt));
168 memset(&ulInfo->ulLcCtxt[lcIdx+1], 0, sizeof(SchUlLcCtxt));
172 /*******************************************************************
174 * @brief Function to update SCH Dl Lc Cb
178 * Function : updateSchDlCb
180 * Functionality: Function to update SCH DL Lc Cb
184 * ****************************************************************/
186 void updateSchDlCb(uint8_t delIdx, SchDlCb *dlInfo)
190 for(lcIdx = delIdx; lcIdx < dlInfo->numDlLc; lcIdx++)
192 memcpy(&dlInfo->dlLcCtxt[lcIdx], &dlInfo->dlLcCtxt[lcIdx+1], sizeof(SchDlLcCtxt));
193 memset(&dlInfo->dlLcCtxt[lcIdx+1], 0, sizeof(SchDlLcCtxt));
197 /*******************************************************************
199 * @brief Function to fill SchUeCb
203 * Function : fillSchUeCb
205 * Functionality: Function to fill SchUeCb
207 * @params[in] SchUeCb pointer,
209 * @return ROK/RFAILED
211 * ****************************************************************/
213 uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
215 uint8_t lcIdx, ueLcIdx;
217 ueCb->ueCfg.cellId = ueCfg->cellId;
218 ueCb->ueCfg.crnti = ueCfg->crnti;
219 if(ueCfg->macCellGrpCfgPres == true)
221 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
222 ueCb->ueCfg.macCellGrpCfgPres = true;
225 if(ueCfg->phyCellGrpCfgPres == true)
227 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
228 ueCb->ueCfg.phyCellGrpCfgPres = true;
231 if(ueCfg->spCellCfgPres == true)
233 memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
234 ueCb->ueCfg.spCellCfgPres = true;
236 ueCb->state = SCH_UE_STATE_ACTIVE;
238 ueCb->ueCfg.ambrCfg = ueCfg->ambrCfg;
239 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
240 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
242 //Updating SchUlCb and SchDlCb DB in SchUeCb
243 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
245 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
247 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
248 ueCb->ulInfo.numUlLc++;
249 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
250 ueCb->dlInfo.numDlLc++;
254 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
256 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
258 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
260 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
261 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
264 if(ueCfg->schLcCfg[ueLcIdx].configType == CONFIG_DEL)
266 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
267 ueCb->ulInfo.numUlLc--;
268 updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead
269 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
270 ueCb->dlInfo.numDlLc--;
271 updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
275 }/*End of inner for loop */
277 }/* End of outer for loop */
281 /*******************************************************************
283 * @brief Function to get SCH Cell Cb
287 * Function : getSchCellCb
289 * Functionality: Function to get SCH Cell Cb
291 * @params[in] event, SchUeCfg pointer
292 * @return schUeCb pointer - success
295 * ****************************************************************/
297 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
300 SchCellCb *cellCb = NULLP;
302 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
304 /* Search of cell cb */
305 for(idx = 0; idx < MAX_NUM_CELL; idx++)
307 cellCb = schCb[inst].cells[idx];
308 if(cellCb->cellId == ueCfg->cellId)
311 if(idx == MAX_NUM_CELL)
313 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
314 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
318 /* Check if max number of UE configured */
319 if(cellCb->numActvUe > MAX_NUM_UE)
321 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
322 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
329 /*******************************************************************
331 * @brief Function to Add Ue Config Request from MAC
335 * Function : MacSchAddUeConfigReq
337 * Functionality: Function to Add Ue config request from MAC
340 * @return ROK - success
343 * ****************************************************************/
344 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
346 uint8_t ueIdx, lcIdx, ret = ROK;
347 SchCellCb *cellCb = NULLP;
348 SchUeCb *ueCb = NULLP;
350 Inst inst = pst->dstInst - 1;
351 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
355 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at MacSchAddUeConfigReq()");
358 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
359 cellCb = getSchCellCb(pst->event, inst, ueCfg);
361 /* Search if UE already configured */
362 GET_UE_IDX(ueCfg->crnti, ueIdx);
363 ueCb = &cellCb->ueCb[ueIdx -1];
366 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
368 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
369 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
375 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
376 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
380 /* Fill received Ue Configuration in UeCb */
381 memset(ueCb, 0, sizeof(SchUeCb));
382 GET_UE_IDX(ueCfg->crnti, ueIdx);
384 ueCb->crnti = ueCfg->crnti;
385 ueCb->state = SCH_UE_STATE_ACTIVE;
386 ret = fillSchUeCb(ueCb, ueCfg);
390 SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
391 ueCb->cellCb = cellCb;
392 ueCb->srRcvd = false;
393 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
394 ueCb->bsrInfo[lcIdx].dataVol = 0;
396 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
401 /*******************************************************************
403 * @brief Fills PUSCH UL allocation
407 * Function : schFillPuschAlloc
409 * Functionality: fills PUSCH info
412 * @return ROK - success
415 * ****************************************************************/
416 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
418 uint16_t puschSlot = 0;
419 uint16_t startRb = 0;
424 SchCellCb *cellCb = ueCb->cellCb;
425 SchUlSlotInfo *schUlSlotInfo = NULLP;
426 uint8_t k2=0, startSymb=0 , symbLen=11;
428 if(ueCb->ueCfg.spCellCfgPres == true)
430 k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
431 startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
432 symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
434 puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
436 startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
437 tbSize = schCalcTbSize(dataVol + buffer); /* 2 bytes header + some buffer */
438 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
439 /* increment PUSCH PRB */
441 cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
443 puschInfo->crnti = ueCb->crnti;
444 puschInfo->harqProcId = SCH_HARQ_PROC_ID;
445 puschInfo->resAllocType = SCH_ALLOC_TYPE_1;
446 puschInfo->fdAlloc.startPrb = startRb;
447 puschInfo->fdAlloc.numPrb = numRb;
448 puschInfo->tdAlloc.startSymb = startSymb;
449 puschInfo->tdAlloc.numSymb = symbLen;
450 puschInfo->tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
451 puschInfo->tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
452 puschInfo->tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
453 puschInfo->tbInfo.ndi = 1; /* new transmission */
454 puschInfo->tbInfo.rv = 0;
455 puschInfo->tbInfo.tbSize = tbSize;
456 puschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
457 puschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
458 puschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS;
460 /* Update pusch in cell */
461 for(idx=startSymb; idx<symbLen; idx++)
463 cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
466 schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
468 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
469 if(!schUlSlotInfo->schPuschInfo)
471 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
474 memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
479 /*******************************************************************
481 * @brief Fills DCI for UL grant
485 * Function : schFillUlDci
487 * Functionality: fills DCI for UL grant in response to BSR
490 * @return ROK - success
493 * ****************************************************************/
494 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
496 SchCellCb *cellCb = ueCb->cellCb;
497 SchControlRsrcSet coreset1 ;
499 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
500 if(ueCb->ueCfg.spCellCfgPres == true)
502 coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
505 dciInfo->cellId = cellCb->cellId;
506 dciInfo->crnti = ueCb->crnti;
509 dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
510 dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
511 dciInfo->bwpCfg.freqAlloc.startPrb = 0;
512 dciInfo->bwpCfg.freqAlloc.numPrb = MAX_NUM_RB; /* whole of BW */
514 /*fill coreset cfg */
515 //Considering number of RBs in coreset1 is same as coreset0
516 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
517 //Considering coreset1 also starts from same symbol as coreset0
518 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
519 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
520 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
522 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
523 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
524 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
525 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
526 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
527 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
528 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
529 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
531 dciInfo->formatType = FORMAT0_0;
534 dciInfo->format.format0_0.resourceAllocType = puschInfo.resAllocType;
535 dciInfo->format.format0_0.freqAlloc.startPrb = puschInfo.fdAlloc.startPrb;
536 dciInfo->format.format0_0.freqAlloc.numPrb = puschInfo.fdAlloc.numPrb;
537 dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
538 dciInfo->format.format0_0.timeAlloc.numSymb = puschInfo.tdAlloc.numSymb;
539 dciInfo->format.format0_0.rowIndex = 0; /* row Index */
540 dciInfo->format.format0_0.mcs = puschInfo.tbInfo.mcs;
541 dciInfo->format.format0_0.harqProcId = puschInfo.harqProcId;
542 dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */
543 dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */
544 dciInfo->format.format0_0.ndi = puschInfo.tbInfo.ndi; /* new transmission */
545 dciInfo->format.format0_0.rv = puschInfo.tbInfo.rv;
546 dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
547 dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */
549 /* Fill DCI Structure */
550 dciInfo->dciInfo.rnti = ueCb->crnti;
551 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
552 dciInfo->dciInfo.scramblingRnti = 0;
553 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
554 dciInfo->dciInfo.aggregLevel = 4;
555 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
556 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
557 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
558 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
559 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
560 dciInfo->dciInfo.txPdcchPower.powerValue = 0;
561 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
562 dciInfo->dciInfo.pdschCfg = NULLP; /* No DL data being sent */
567 /*******************************************************************
569 * @brief Function to Modify Ue Config request from MAC
573 * Function : MacSchModUeConfigReq
575 * Functionality: Function to modify Ue Config request from MAC
578 * @return ROK - success
581 * ****************************************************************/
582 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
584 uint8_t ueIdx, lcIdx, ret = ROK;
585 SchCellCb *cellCb = NULLP;
586 SchUeCb *ueCb = NULLP;
588 Inst inst = pst->dstInst - 1;
589 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
593 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
596 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
597 cellCb = getSchCellCb(pst->event, inst, ueCfg);
599 /* Search if UE already configured */
600 GET_UE_IDX(ueCfg->crnti, ueIdx);
601 ueCb = &cellCb->ueCb[ueIdx -1];
605 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchModUeConfigReq() ");
606 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
609 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
611 /* Found the UeCb to Reconfig */
612 ret = fillSchUeCb(ueCb, ueCfg);
615 ueCb->cellCb = cellCb;
616 ueCb->srRcvd = false;
617 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
618 ueCb->bsrInfo[lcIdx].dataVol = 0;
620 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
626 /*******************************************************************
628 * @brief Fill and send UE delete response to MAC
632 * Function : SchSendUeDeleteRspToMac
634 * Functionality: Fill and send UE delete response to MAC
636 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
638 * @return ROK - success
641 * ****************************************************************/
642 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, ErrorCause cause)
645 SchUeDeleteRsp delRsp;
647 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
648 delRsp.cellId = ueDelete->cellId;
649 delRsp.crnti = ueDelete->crnti;
651 delRsp.cause = cause;
653 /* Filling response post */
654 memset(&rspPst, 0, sizeof(Pst));
655 FILL_PST_SCH_TO_MAC(rspPst, inst);
656 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
657 SchUeDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
660 /*******************************************************************
662 * @brief Function to delete Sch Pucch ResrcCfg
666 * Function : deleteSchPucchResrcCfg
668 * Functionality: Function to delete Sch Pucch ResrcCfg
670 * @params[in] SchPucchResrcCfg *resrc
673 * ****************************************************************/
675 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
678 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
680 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
684 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
685 sizeof(SchPucchFormat0));
690 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
691 sizeof(SchPucchFormat1));
696 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
697 sizeof(SchPucchFormat2_3));
702 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
703 sizeof(SchPucchFormat2_3));
708 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
709 sizeof(SchPucchFormat4));
716 /*******************************************************************
718 * @brief Function to delete SCH Pdsch ServCellCfg
722 * Function : deleteSchPdschServCellCfg
724 * Functionality: Function to delete SCH Pdsch ServCellCfg
726 * @params[in] SchPdschServCellCfg *pdschServCellCfg
729 * ****************************************************************/
731 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
733 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
734 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
735 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
736 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
739 /*******************************************************************
741 * @brief Function to delete SCH UeCb
745 * Function : deleteSchUeCb
747 * Functionality: Function to delete SCH UeCb
750 * @return ROK - success
753 * ****************************************************************/
754 void deleteSchUeCb(SchUeCb *ueCb)
756 SchPucchCfg *pucchCfg = NULLP;
759 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
760 if(ueCb->ueCfg.spCellCfgPres)
762 if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres == true)
764 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg;
765 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
768 deleteSchPucchResrcCfg(pucchCfg->resrc);
769 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
771 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
772 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
773 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
774 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
775 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
776 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
777 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
778 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
779 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
781 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.bwpInactivityTmr, sizeof(uint8_t));
782 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg);
784 memset(ueCb, 0, sizeof(SchUeCb));
788 /*******************************************************************
790 * @brief Function for Ue Delete request from MAC to SCH
794 * Function : MacSchUeDeleteReq
796 * Functionality: Function for Ue Delete request from MAC to SCH
798 * @params[in] Pst *pst, SchUeDelete *ueDelete
799 * @return ROK - success
802 * ****************************************************************/
803 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
805 uint8_t idx=0, ueIdx=0, ret=ROK;
807 SchCellCb *cellCb = NULLP;
808 Inst inst = pst->dstInst - 1;
812 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): Ue Delete request failed");
815 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
817 cellCb = schCb[inst].cells[idx];
819 if(cellCb->cellId != ueDelete->cellId)
821 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): cell Id is not available");
822 result = INVALID_CELLID;
826 GET_UE_IDX(ueDelete->crnti, ueIdx);
827 if(( cellCb->ueCb[ueIdx-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueIdx-1].state == SCH_UE_STATE_ACTIVE))
829 deleteSchUeCb(&cellCb->ueCb[ueIdx-1]);
831 result = NOT_APPLICABLE;
835 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): SchUeCb not found");
836 result = INVALID_UEIDX;
840 if(result == NOT_APPLICABLE)
842 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, result);
846 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, result);
852 /*******************************************************************
854 * @brief Fill and send Cell delete response to MAC
858 * Function : SchSendCellDeleteRspToMac
860 * Functionality: Fill and send Cell delete response to MAC
862 * @params[in] SchCellDelete *ueDelete, Inst inst, SchMacRsp result
863 * @return ROK - success
866 * ****************************************************************/
867 uint8_t SchSendCellDeleteRspToMac(SchCellDelete *ueDelete, Inst inst, SchMacRsp result)
872 SchCellDeleteRsp delRsp;
874 DU_LOG("\nINFO --> SCH : Filling Cell Delete response");
875 memset(&delRsp, 0, sizeof(SchCellDeleteRsp));
876 delRsp.cellId = ueDelete->cellId;
879 /* Filling response post */
880 memset(&rspPst, 0, sizeof(Pst));
881 FILL_PST_SCH_TO_MAC(rspPst, inst);
882 rspPst.event = EVENT_CELL_DELETE_RSP_TO_MAC;
883 ret = SchCellDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
886 DU_LOG("\nERROR --> SCH : SchSendCellDeleteRspToMac(): failed to send the Cell Delete response");
892 /*******************************************************************
894 * @brief Function for cellCb Deletion
898 * Function : deleteSchCellCb
900 * Functionality: Function for cellCb Deletion
902 * @params[in] SchCellDelete *cellDelete
903 * @return ROK - success
906 * ****************************************************************/
907 void deleteSchCellCb(SchCellCb *cellCb)
910 if(cellCb->schDlSlotInfo)
912 for(idx=0; idx<cellCb->numSlots; idx++)
914 if(cellCb->schDlSlotInfo[idx])
916 SCH_FREE(cellCb->schDlSlotInfo[idx], sizeof(SchDlSlotInfo));
919 SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*));
921 if(cellCb->schUlSlotInfo)
923 for(idx=0; idx<cellCb->numSlots; idx++)
925 if(cellCb->schUlSlotInfo[idx])
927 SCH_FREE(cellCb->schUlSlotInfo[idx], sizeof(SchUlSlotInfo));
930 SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*));
932 memset(cellCb, 0, sizeof(SchCellCb));
936 /*******************************************************************
938 * @brief Function for cell Delete request from MAC to SCH
942 * Function : MacSchCellDeleteReq
944 * Functionality: Function for cell Delete request from MAC to SCH
946 * @params[in] Pst *pst, SchCellDelete *cellDelete
947 * @return ROK - success
950 * ****************************************************************/
952 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete *cellDelete)
954 uint8_t cellIdx=0, ret = RFAILED;
955 Inst inst = pst->dstInst - 1;
956 SchMacRsp result= RSP_OK;
960 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): Ue Delete request failed");
964 GET_CELL_IDX(cellDelete->cellId, cellIdx);
965 if(schCb[inst].cells[cellIdx] == NULLP)
967 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available", cellDelete->cellId);
972 if(schCb[inst].cells[cellIdx]->cellId == cellDelete->cellId)
974 deleteSchCellCb(schCb[inst].cells[cellIdx]);
977 SCH_FREE(schCb[inst].cells[cellIdx], sizeof(SchCellCb));
978 DU_LOG("\nINFO --> SCH : Sending Cell Delete response to MAC");
982 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available",cellDelete->cellId);
987 if(SchSendCellDeleteRspToMac(cellDelete, inst, result)!=ROK)
989 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): failed to send Cell Delete response");
997 /**********************************************************************
999 **********************************************************************/