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;
216 SchPdschCfgCmn pdschCfg;
217 SchPucchDlDataToUlAck *dlDataToUlAck;
219 ueCb->ueCfg.cellId = ueCfg->cellId;
220 ueCb->ueCfg.crnti = ueCfg->crnti;
221 if(ueCfg->macCellGrpCfgPres == true)
223 memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg));
224 ueCb->ueCfg.macCellGrpCfgPres = true;
227 if(ueCfg->phyCellGrpCfgPres == true)
229 memcpy(&ueCb->ueCfg.phyCellGrpCfg , &ueCfg->phyCellGrpCfg, sizeof(SchPhyCellGrpCfg));
230 ueCb->ueCfg.phyCellGrpCfgPres = true;
233 if(ueCfg->spCellCfgPres == true)
235 memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
236 ueCb->ueCfg.spCellCfgPres = true;
237 dlDataToUlAck = ueCfg->spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck;
240 BuildK0K1Table(ueCb->cellCb, &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl, false, pdschCfg,\
241 ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\
242 dlDataToUlAck->dlDataToUlAckList);
246 ueCb->state = SCH_UE_STATE_ACTIVE;
249 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
250 ueCb->ueCfg.ambrCfg = ueCfg->ambrCfg;
252 memcpy(&ueCb->ueCfg.dlModInfo, &ueCfg->dlModInfo , sizeof(SchModulationInfo));
253 memcpy(&ueCb->ueCfg.ulModInfo, &ueCfg->ulModInfo , sizeof(SchModulationInfo));
255 //Updating SchUlCb and SchDlCb DB in SchUeCb
256 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
258 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD)
260 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]);
261 ueCb->ulInfo.numUlLc++;
262 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]);
263 ueCb->dlInfo.numDlLc++;
267 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod
269 if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId)
271 if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD)
273 fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
274 fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]);
277 if(ueCfg->schLcCfg[ueLcIdx].configType == CONFIG_DEL)
279 memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt));
280 ueCb->ulInfo.numUlLc--;
281 updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead
282 memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt));
283 ueCb->dlInfo.numDlLc--;
284 updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead
288 }/*End of inner for loop */
291 SCH_FREE(ueCfg->schLcCfg[lcIdx].drbQos, sizeof(SchDrbQosInfo));
292 SCH_FREE(ueCfg->schLcCfg[lcIdx].snssai, sizeof(SchSnssai));
294 }/* End of outer for loop */
298 /*******************************************************************
300 * @brief Function to get SCH Cell Cb
304 * Function : getSchCellCb
306 * Functionality: Function to get SCH Cell Cb
308 * @params[in] event, SchUeCfg pointer
309 * @return schUeCb pointer - success
312 * ****************************************************************/
314 SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
317 SchCellCb *cellCb = NULLP;
319 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
321 /* Search of cell cb */
322 for(idx = 0; idx < MAX_NUM_CELL; idx++)
324 cellCb = schCb[inst].cells[idx];
325 if(cellCb->cellId == ueCfg->cellId)
328 if(idx == MAX_NUM_CELL)
330 DU_LOG("\nERROR --> SCH : Ue create request failed. Invalid cell id %d", ueCfg->cellId);
331 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
335 /* Check if max number of UE configured */
336 if(cellCb->numActvUe > MAX_NUM_UE)
338 DU_LOG("\nERROR --> SCH : Max number of UE [%d] already configured", MAX_NUM_UE);
339 SchSendUeCfgRspToMac(srcEvent, ueCfg, inst, RSP_NOK, &cfgRsp);
346 /*******************************************************************
348 * @brief Function to Add Ue Config Request from MAC
352 * Function : MacSchAddUeConfigReq
354 * Functionality: Function to Add Ue config request from MAC
357 * @return ROK - success
360 * ****************************************************************/
361 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
363 uint8_t ueIdx, lcIdx, ret = ROK;
364 SchCellCb *cellCb = NULLP;
365 SchUeCb *ueCb = NULLP;
367 Inst inst = pst->dstInst - 1;
368 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
370 #ifdef CALL_FLOW_DEBUG_LOG
371 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_ADD_UE_CONFIG_REQ_TO_SCH\n");
376 DU_LOG("\nERROR --> SCH : Adding UE Config Request failed at MacSchAddUeConfigReq()");
379 DU_LOG("\nDEBUG --> SCH : Adding UE Config Request for CRNTI[%d]", ueCfg->crnti);
380 cellCb = getSchCellCb(pst->event, inst, ueCfg);
382 /* Search if UE already configured */
383 GET_UE_IDX(ueCfg->crnti, ueIdx);
384 ueCb = &cellCb->ueCb[ueIdx -1];
387 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
389 DU_LOG("\nDEBUG --> SCH : CRNTI %d already configured ", ueCfg->crnti);
390 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
396 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
397 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
401 /* Fill received Ue Configuration in UeCb */
402 memset(ueCb, 0, sizeof(SchUeCb));
403 GET_UE_IDX(ueCfg->crnti, ueIdx);
405 ueCb->crnti = ueCfg->crnti;
406 ueCb->state = SCH_UE_STATE_ACTIVE;
407 ret = fillSchUeCb(ueCb, ueCfg);
411 SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
412 ueCb->cellCb = cellCb;
413 ueCb->srRcvd = false;
414 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
415 ueCb->bsrInfo[lcIdx].dataVol = 0;
417 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
422 /*******************************************************************
424 * @brief Fills PUSCH UL allocation
428 * Function : schFillPuschAlloc
430 * Functionality: fills PUSCH info
433 * @return ROK - success
436 * ****************************************************************/
437 uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
439 uint16_t puschSlot = 0;
440 uint16_t startRb = 0;
445 SchCellCb *cellCb = ueCb->cellCb;
446 SchUlSlotInfo *schUlSlotInfo = NULLP;
447 uint8_t k2=0, startSymb=0 , symbLen=11;
449 if(ueCb->ueCfg.spCellCfgPres == true)
451 k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
452 startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
453 symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
455 puschSlot = (pdcchSlot + k2) % cellCb->numSlots;
457 startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
458 tbSize = schCalcTbSize(dataVol + buffer); /* 2 bytes header + some buffer */
459 numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen);
460 /* increment PUSCH PRB */
462 cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
464 puschInfo->crnti = ueCb->crnti;
465 puschInfo->harqProcId = SCH_HARQ_PROC_ID;
466 puschInfo->resAllocType = SCH_ALLOC_TYPE_1;
467 puschInfo->fdAlloc.startPrb = startRb;
468 puschInfo->fdAlloc.numPrb = numRb;
469 puschInfo->tdAlloc.startSymb = startSymb;
470 puschInfo->tdAlloc.numSymb = symbLen;
471 puschInfo->tbInfo.qamOrder = ueCb->ueCfg.ulModInfo.modOrder;
472 puschInfo->tbInfo.mcs = ueCb->ueCfg.ulModInfo.mcsIndex;
473 puschInfo->tbInfo.mcsTable = ueCb->ueCfg.ulModInfo.mcsTable;
474 puschInfo->tbInfo.ndi = 1; /* new transmission */
475 puschInfo->tbInfo.rv = 0;
476 puschInfo->tbInfo.tbSize = tbSize;
477 puschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */
478 puschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS;
479 puschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS;
481 /* Update pusch in cell */
482 for(idx=startSymb; idx<symbLen; idx++)
484 cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
487 schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
489 SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
490 if(!schUlSlotInfo->schPuschInfo)
492 DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch");
495 memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
500 /*******************************************************************
502 * @brief Fills DCI for UL grant
506 * Function : schFillUlDci
508 * Functionality: fills DCI for UL grant in response to BSR
511 * @return ROK - success
514 * ****************************************************************/
515 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
517 SchCellCb *cellCb = ueCb->cellCb;
518 SchControlRsrcSet coreset1 ;
520 memset(&coreset1, 0, sizeof(SchControlRsrcSet));
521 if(ueCb->ueCfg.spCellCfgPres == true)
523 coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
526 dciInfo->cellId = cellCb->cellId;
527 dciInfo->crnti = ueCb->crnti;
530 dciInfo->bwpCfg.subcarrierSpacing = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
531 dciInfo->bwpCfg.cyclicPrefix = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
532 dciInfo->bwpCfg.freqAlloc.startPrb = 0;
533 dciInfo->bwpCfg.freqAlloc.numPrb = MAX_NUM_RB; /* whole of BW */
535 /*fill coreset cfg */
536 //Considering number of RBs in coreset1 is same as coreset0
537 dciInfo->coresetCfg.coreSetSize = coresetIdxTable[0][1];
538 //Considering coreset1 also starts from same symbol as coreset0
539 dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
540 dciInfo->coresetCfg.durationSymbols = coreset1.duration;
541 memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
543 dciInfo->coresetCfg.cceRegMappingType = coreset1.cceRegMappingType; /* non-interleaved */
544 dciInfo->coresetCfg.regBundleSize = 6; /* must be 6 for non-interleaved */
545 dciInfo->coresetCfg.interleaverSize = 0; /* NA for non-interleaved */
546 dciInfo->coresetCfg.coreSetType = 1; /* non PBCH coreset */
547 dciInfo->coresetCfg.shiftIndex = cellCb->cellCfg.phyCellId;
548 dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
549 dciInfo->coresetCfg.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
550 dciInfo->coresetCfg.aggregationLevel = 4; /* same as for sib1 */
552 dciInfo->formatType = FORMAT0_0;
555 dciInfo->format.format0_0.resourceAllocType = puschInfo.resAllocType;
556 dciInfo->format.format0_0.freqAlloc.startPrb = puschInfo.fdAlloc.startPrb;
557 dciInfo->format.format0_0.freqAlloc.numPrb = puschInfo.fdAlloc.numPrb;
558 dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
559 dciInfo->format.format0_0.timeAlloc.numSymb = puschInfo.tdAlloc.numSymb;
560 dciInfo->format.format0_0.rowIndex = 0; /* row Index */
561 dciInfo->format.format0_0.mcs = puschInfo.tbInfo.mcs;
562 dciInfo->format.format0_0.harqProcId = puschInfo.harqProcId;
563 dciInfo->format.format0_0.puschHopFlag = FALSE; /* disabled */
564 dciInfo->format.format0_0.freqHopFlag = FALSE; /* disabled */
565 dciInfo->format.format0_0.ndi = puschInfo.tbInfo.ndi; /* new transmission */
566 dciInfo->format.format0_0.rv = puschInfo.tbInfo.rv;
567 dciInfo->format.format0_0.tpcCmd = 0; //Sphoorthi TODO: check
568 dciInfo->format.format0_0.sUlCfgd = FALSE; /* SUL not configured */
570 /* Fill DCI Structure */
571 dciInfo->dciInfo.rnti = ueCb->crnti;
572 dciInfo->dciInfo.scramblingId = cellCb->cellCfg.phyCellId;
573 dciInfo->dciInfo.scramblingRnti = 0;
574 dciInfo->dciInfo.cceIndex = 0; /* 0-3 for UL and 4-7 for DL */
575 dciInfo->dciInfo.aggregLevel = 4;
576 dciInfo->dciInfo.beamPdcchInfo.numPrgs = 1;
577 dciInfo->dciInfo.beamPdcchInfo.prgSize = 1;
578 dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces = 0;
579 dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx = 0;
580 dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0] = 0;
581 dciInfo->dciInfo.txPdcchPower.powerValue = 0;
582 dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
583 dciInfo->dciInfo.pdschCfg = NULLP; /* No DL data being sent */
588 /*******************************************************************
590 * @brief Function to Modify Ue Config request from MAC
594 * Function : MacSchModUeConfigReq
596 * Functionality: Function to modify Ue Config request from MAC
599 * @return ROK - success
602 * ****************************************************************/
603 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
605 uint8_t ueIdx, lcIdx, ret = ROK;
606 SchCellCb *cellCb = NULLP;
607 SchUeCb *ueCb = NULLP;
609 Inst inst = pst->dstInst - 1;
610 memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
612 #ifdef CALL_FLOW_DEBUG_LOG
613 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH\n");
618 DU_LOG("\nERROR --> SCH : Modifying Ue Config request failed at MacSchModUeConfigReq()");
621 DU_LOG("\nDEBUG --> SCH : Modifying Ue Config Request for CRNTI[%d]", ueCfg->crnti);
622 cellCb = getSchCellCb(pst->event, inst, ueCfg);
624 /* Search if UE already configured */
625 GET_UE_IDX(ueCfg->crnti, ueIdx);
626 ueCb = &cellCb->ueCb[ueIdx -1];
630 DU_LOG("\nERROR --> SCH : SchUeCb not found at MacSchModUeConfigReq() ");
631 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
634 if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
636 /* Found the UeCb to Reconfig */
637 ret = fillSchUeCb(ueCb, ueCfg);
640 ueCb->cellCb = cellCb;
641 ueCb->srRcvd = false;
642 for(lcIdx=0; lcIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcIdx++)
643 ueCb->bsrInfo[lcIdx].dataVol = 0;
645 SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
651 /*******************************************************************
653 * @brief Fill and send UE delete response to MAC
657 * Function : SchSendUeDeleteRspToMac
659 * Functionality: Fill and send UE delete response to MAC
661 * @params[in] Inst inst, SchUeDelete *ueDelete, SchMacRsp result,
663 * @return ROK - success
666 * ****************************************************************/
667 void SchSendUeDeleteRspToMac(Inst inst, SchUeDelete *ueDelete, SchMacRsp result, ErrorCause cause)
670 SchUeDeleteRsp delRsp;
672 memset(&delRsp, 0, sizeof(SchUeDeleteRsp));
673 delRsp.cellId = ueDelete->cellId;
674 delRsp.crnti = ueDelete->crnti;
676 delRsp.cause = cause;
678 /* Filling response post */
679 memset(&rspPst, 0, sizeof(Pst));
680 FILL_PST_SCH_TO_MAC(rspPst, inst);
681 rspPst.event = EVENT_UE_DELETE_RSP_TO_MAC;
682 SchUeDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
685 /*******************************************************************
687 * @brief Function to delete Sch Pucch ResrcCfg
691 * Function : deleteSchPucchResrcCfg
693 * Functionality: Function to delete Sch Pucch ResrcCfg
695 * @params[in] SchPucchResrcCfg *resrc
698 * ****************************************************************/
700 void deleteSchPucchResrcCfg(SchPucchResrcCfg *resrc)
703 for(rsrcIdx=0; rsrcIdx < resrc->resrcToAddModListCount; rsrcIdx++)
705 switch(resrc->resrcToAddModList[rsrcIdx].pucchFormat)
709 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format0,\
710 sizeof(SchPucchFormat0));
715 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format1,\
716 sizeof(SchPucchFormat1));
721 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format2,\
722 sizeof(SchPucchFormat2_3));
727 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format3,\
728 sizeof(SchPucchFormat2_3));
733 SCH_FREE(resrc->resrcToAddModList[rsrcIdx].SchPucchFormat.format4,\
734 sizeof(SchPucchFormat4));
741 /*******************************************************************
743 * @brief Function to delete SCH Pdsch ServCellCfg
747 * Function : deleteSchPdschServCellCfg
749 * Functionality: Function to delete SCH Pdsch ServCellCfg
751 * @params[in] SchPdschServCellCfg *pdschServCellCfg
754 * ****************************************************************/
756 void deleteSchPdschServCellCfg(SchPdschServCellCfg *pdschServCellCfg)
758 SCH_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
759 SCH_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
760 SCH_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
761 SCH_FREE(pdschServCellCfg->xOverhead, sizeof(SchPdschXOverhead));
764 /*******************************************************************
766 * @brief Function to delete SCH UeCb
770 * Function : deleteSchUeCb
772 * Functionality: Function to delete SCH UeCb
775 * @return ROK - success
778 * ****************************************************************/
779 void deleteSchUeCb(SchUeCb *ueCb)
781 uint8_t timeDomRsrcIdx;
782 SchPucchCfg *pucchCfg = NULLP;
783 SchPdschConfig *pdschCfg = NULLP;
787 SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
788 if(ueCb->ueCfg.spCellCfgPres)
790 if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
792 pdschCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg;
793 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < pdschCfg->numTimeDomRsrcAlloc; timeDomRsrcIdx++)
794 SCH_FREE(pdschCfg->timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
797 if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres == true)
799 pucchCfg = &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg;
800 SCH_FREE(pucchCfg->resrcSet,sizeof(SchPucchResrcSetCfg));
803 deleteSchPucchResrcCfg(pucchCfg->resrc);
804 SCH_FREE(pucchCfg->resrc, sizeof(SchPucchResrcCfg));
806 SCH_FREE(pucchCfg->format1, sizeof(SchPucchFormatCfg));
807 SCH_FREE(pucchCfg->format2, sizeof(SchPucchFormatCfg));
808 SCH_FREE(pucchCfg->format3, sizeof(SchPucchFormatCfg));
809 SCH_FREE(pucchCfg->format4, sizeof(SchPucchFormatCfg));
810 SCH_FREE(pucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
811 SCH_FREE(pucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
812 SCH_FREE(pucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
813 SCH_FREE(pucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
814 SCH_FREE(pucchCfg->powerControl,sizeof(SchPucchPowerControl));
816 SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.bwpInactivityTmr, sizeof(uint8_t));
817 deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg);
819 memset(ueCb, 0, sizeof(SchUeCb));
823 /*******************************************************************
825 * @brief Function for Ue Delete request from MAC to SCH
829 * Function : MacSchUeDeleteReq
831 * Functionality: Function for Ue Delete request from MAC to SCH
833 * @params[in] Pst *pst, SchUeDelete *ueDelete
834 * @return ROK - success
837 * ****************************************************************/
838 uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete)
840 uint8_t idx=0, ueIdx=0, ret=ROK;
842 SchCellCb *cellCb = NULLP;
843 Inst inst = pst->dstInst - 1;
845 #ifdef CALL_FLOW_DEBUG_LOG
846 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_UE_DELETE_REQ_TO_SCH\n");
851 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): Ue Delete request failed");
854 DU_LOG("\nDEBUG --> SCH : Ue Delete request received for crnti[%d]", ueDelete->crnti);
856 cellCb = schCb[inst].cells[idx];
858 if(cellCb->cellId != ueDelete->cellId)
860 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): cell Id is not available");
861 result = INVALID_CELLID;
865 GET_UE_IDX(ueDelete->crnti, ueIdx);
866 if(( cellCb->ueCb[ueIdx-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueIdx-1].state == SCH_UE_STATE_ACTIVE))
868 deleteSchUeCb(&cellCb->ueCb[ueIdx-1]);
870 result = NOT_APPLICABLE;
874 DU_LOG("\nERROR --> SCH : MacSchUeDeleteReq(): SchUeCb not found");
875 result = INVALID_UEIDX;
879 if(result == NOT_APPLICABLE)
881 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_OK, result);
885 SchSendUeDeleteRspToMac(inst, ueDelete, RSP_NOK, result);
891 /*******************************************************************
893 * @brief Fill and send Cell delete response to MAC
897 * Function : SchSendCellDeleteRspToMac
899 * Functionality: Fill and send Cell delete response to MAC
901 * @params[in] SchCellDelete *ueDelete, Inst inst, SchMacRsp result
902 * @return ROK - success
905 * ****************************************************************/
906 uint8_t SchSendCellDeleteRspToMac(SchCellDelete *ueDelete, Inst inst, SchMacRsp result)
911 SchCellDeleteRsp delRsp;
913 DU_LOG("\nINFO --> SCH : Filling Cell Delete response");
914 memset(&delRsp, 0, sizeof(SchCellDeleteRsp));
915 delRsp.cellId = ueDelete->cellId;
918 /* Filling response post */
919 memset(&rspPst, 0, sizeof(Pst));
920 FILL_PST_SCH_TO_MAC(rspPst, inst);
921 rspPst.event = EVENT_CELL_DELETE_RSP_TO_MAC;
922 ret = SchCellDeleteRspOpts[rspPst.selector](&rspPst, &delRsp);
925 DU_LOG("\nERROR --> SCH : SchSendCellDeleteRspToMac(): failed to send the Cell Delete response");
931 /*******************************************************************
933 * @brief Function for cellCb Deletion
937 * Function : deleteSchCellCb
939 * Functionality: Function for cellCb Deletion
941 * @params[in] SchCellDelete *cellDelete
942 * @return ROK - success
945 * ****************************************************************/
946 void deleteSchCellCb(SchCellCb *cellCb)
949 if(cellCb->schDlSlotInfo)
951 for(idx=0; idx<cellCb->numSlots; idx++)
953 if(cellCb->schDlSlotInfo[idx])
955 SCH_FREE(cellCb->schDlSlotInfo[idx], sizeof(SchDlSlotInfo));
958 SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*));
960 if(cellCb->schUlSlotInfo)
962 for(idx=0; idx<cellCb->numSlots; idx++)
964 if(cellCb->schUlSlotInfo[idx])
966 SCH_FREE(cellCb->schUlSlotInfo[idx], sizeof(SchUlSlotInfo));
969 SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*));
971 memset(cellCb, 0, sizeof(SchCellCb));
975 /*******************************************************************
977 * @brief Function for cell Delete request from MAC to SCH
981 * Function : MacSchCellDeleteReq
983 * Functionality: Function for cell Delete request from MAC to SCH
985 * @params[in] Pst *pst, SchCellDelete *cellDelete
986 * @return ROK - success
989 * ****************************************************************/
991 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete *cellDelete)
993 uint8_t cellIdx=0, ret = RFAILED;
994 Inst inst = pst->dstInst - 1;
995 SchMacRsp result= RSP_OK;
997 #ifdef CALL_FLOW_DEBUG_LOG
998 DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_CELL_DELETE_REQ_TO_SCH\n");
1003 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): Ue Delete request failed");
1007 GET_CELL_IDX(cellDelete->cellId, cellIdx);
1008 if(schCb[inst].cells[cellIdx] == NULLP)
1010 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available", cellDelete->cellId);
1015 if(schCb[inst].cells[cellIdx]->cellId == cellDelete->cellId)
1017 deleteSchCellCb(schCb[inst].cells[cellIdx]);
1020 SCH_FREE(schCb[inst].cells[cellIdx], sizeof(SchCellCb));
1021 DU_LOG("\nINFO --> SCH : Sending Cell Delete response to MAC");
1025 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): cell Id[%d] is not available",cellDelete->cellId);
1030 if(SchSendCellDeleteRspToMac(cellDelete, inst, result)!=ROK)
1032 DU_LOG("\nERROR --> SCH : MacSchCellDeleteReq(): failed to send Cell Delete response");
1040 /**********************************************************************
1042 **********************************************************************/