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 *******************************************************************************/
19 /* This file contains UE management handling functionality for MAC */
21 /* header include files (.h) */
22 #include "common_def.h"
25 #include "du_app_mac_inf.h"
26 #include "mac_sch_interface.h"
27 #include "lwr_mac_upr_inf.h"
29 #include "mac_utils.h"
31 /* function pointers for packing slot ind from mac to sch */
32 MacSchAddUeConfigReqFunc macSchAddUeConfigReqOpts[] =
34 packMacSchAddUeConfigReq, /* packing for loosely coupled */
35 MacSchAddUeConfigReq, /* packing for tightly coupled */
36 packMacSchAddUeConfigReq /* packing for light weight loosely coupled */
39 MacDuUeCfgRspFunc macDuUeCfgRspOpts[] =
41 packDuMacUeCfgRsp, /* packing for loosely coupled */
42 DuProcMacUeCfgRsp, /* packing for tightly coupled */
43 packDuMacUeCfgRsp /* packing for light weight loosly coupled */
46 MacSchModUeConfigReqFunc macSchModUeConfigReqOpts[] =
48 packMacSchModUeConfigReq, /* packing for loosely coupled */
49 MacSchModUeConfigReq, /* packing for tightly coupled */
50 packMacSchModUeConfigReq /* packing for light weight loosely coupled */
53 MacSchUeDeleteReqFunc macSchUeDeleteReqOpts[] =
55 packMacSchUeDeleteReq, /* packing for loosely coupled */
56 MacSchUeDeleteReq, /* packing for tightly coupled */
57 packMacSchUeDeleteReq /* packing for light weight loosely coupled */
60 MacDuUeDeleteRspFunc macDuUeDeleteRspOpts[] =
62 packDuMacUeDeleteRsp, /* packing for loosely coupled */
63 DuProcMacUeDeleteRsp, /* packing for tightly coupled */
64 packDuMacUeDeleteRsp /* packing for light weight loosly coupled */
67 MacSchCellDeleteReqFunc macSchCellDeleteReqOpts[]=
69 packMacSchCellDeleteReq, /* packing for loosely coupled */
70 MacSchCellDeleteReq, /* packing for tightly coupled */
71 packMacSchCellDeleteReq /* packing for light weight loosely coupled */
74 MacDuCellDeleteRspFunc macDuCellDeleteRspOpts[] =
76 packDuMacCellDeleteRsp, /* packing for loosely coupled */
77 DuProcMacCellDeleteRsp, /* packing for tightly coupled */
78 packDuMacCellDeleteRsp /* packing for light weight loosly coupled */
81 /*******************************************************************
83 * @brief Fills mac cell group config to be sent to scheduler
87 * Function : fillMacCellGroupCfg
89 * Functionality: Fills mac cell group config to be sent to sch
91 * @params[in] macCellGrp : mac cell group config at MAC
92 * *macCellGrpCfg : mac cell group cfg to be filled
93 * @return ROK - success
96 * ****************************************************************/
97 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
100 SchSchedReqCfg *schedReqCfg;
103 /* Copy scheduling request config */
104 schedReqCfg = &macCellGrpCfg->schedReqCfg;
105 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
106 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
108 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
109 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
112 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
114 schedReqCfg->addModList[idx].schedReqId = \
115 macCellGrp.schReqCfg.addModList[idx].schedReqId;
116 schedReqCfg->addModList[idx].srProhibitTmr = \
117 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
118 schedReqCfg->addModList[idx].srTransMax = \
119 macCellGrp.schReqCfg.addModList[idx].srTransMax;
121 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
123 /* copy TAG config */
124 tagCfg = &macCellGrpCfg->tagCfg;
125 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
126 if(tagCfg->addModListCount > MAX_NUM_TAGS)
128 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
129 tagCfg->addModListCount, MAX_NUM_TAGS);
132 for(idx = 0; idx < tagCfg->addModListCount; idx++)
134 tagCfg->addModList[idx].tagId = \
135 macCellGrp.tagCfg.addModList[idx].tagId;
136 tagCfg->addModList[idx].timeAlignmentTmr = \
137 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
139 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
141 /* Copy PHR config */
142 if(macCellGrp.phrCfgSetupPres)
144 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
145 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
146 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
147 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
148 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
149 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
150 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
156 /*******************************************************************
158 * @brief Fills phy cell group config to be sent to scheduler
162 * Function : fillPhyCellGroupCfg
164 * Functionality: Fills phy cell group config to be sent to sch
166 * @params[in] macUeCfg : Phy cell group config at MAC
167 * *schPhyCellGrp : phy cell group config to be filled
168 * @return ROK - success
171 * ****************************************************************/
172 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
174 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
175 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
180 /*******************************************************************
182 * @brief Fills PDSCh serving cell config to send to scheduler
186 * Function : fillPdschServCellCfg
188 * Functionality: Fills PDSCh serving cell config to send to scheduler
190 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
191 * *schPdschCfg : Pdsch serving cell config to be filled
192 * @return ROK - success
195 * ****************************************************************/
196 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
198 if(macPdschCfg.maxMimoLayers)
200 if(!schPdschCfg->maxMimoLayers)
202 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
203 if(!schPdschCfg->maxMimoLayers)
205 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
209 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
213 schPdschCfg->maxMimoLayers = NULLP;
216 schPdschCfg->numHarqProcForPdsch = \
217 macPdschCfg.numHarqProcForPdsch;
219 if(macPdschCfg.maxCodeBlkGrpPerTb)
221 if(!schPdschCfg->maxCodeBlkGrpPerTb)
223 MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
224 if(!schPdschCfg->maxCodeBlkGrpPerTb)
226 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
230 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
234 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
237 if(macPdschCfg.codeBlkGrpFlushInd)
239 if(!schPdschCfg->codeBlkGrpFlushInd)
241 MAC_ALLOC_SHRABL_BUF(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
242 if(!schPdschCfg->codeBlkGrpFlushInd)
244 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
248 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
252 schPdschCfg->codeBlkGrpFlushInd = NULLP;
255 if(macPdschCfg.xOverhead)
257 if(!schPdschCfg->xOverhead)
259 MAC_ALLOC_SHRABL_BUF(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
260 if(!schPdschCfg->xOverhead)
262 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
266 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
270 schPdschCfg->xOverhead = NULLP;
276 /*******************************************************************
278 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
282 * Function : fillInitalUlBwpPuschCfg
285 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
287 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
288 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
289 * @return ROK - success
292 * ****************************************************************/
293 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
297 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
298 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
299 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
300 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
301 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
302 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
304 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
305 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
307 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
308 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
311 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
313 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
314 macPuschCfg.timeDomRsrcAllocList[idx].k2;
315 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
316 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
317 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
318 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
319 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
320 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
323 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
327 /*******************************************************************
329 * @brief Function to fillResrcSetList sent by DU
333 * Function : fillResrcSetList
335 * Functionality: Function to fillResrcSetList sent by DU
337 * @params[in] PucchResrcSetCfg pointer,
338 * SchPucchResrcSetCfg pointer
341 * ****************************************************************/
343 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
345 uint8_t arrIdx, rsrcListIdx;
347 /* ResrcSetToAddModList */
348 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
349 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
351 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
352 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
354 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
355 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
357 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
358 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
359 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
360 resrcListCount; rsrcListIdx++)
362 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
363 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
366 /* ResrcSetToRelList */
367 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
368 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
370 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
374 /*******************************************************************
376 * @brief Function to fillResrcList sent by DU
380 * Function : fillResrcList
382 * Functionality: Function to fillResrcList sent by DU
384 * @params[in] PucchResrcCfg pointer,
385 * SchPucchResrcCfg pointer
386 * @return ROK/RFAILED;
388 * ****************************************************************/
389 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
393 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
394 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
396 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
397 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
398 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
399 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
400 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
401 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
402 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
403 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
404 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
405 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
406 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
408 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
409 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
411 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
414 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
415 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
416 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
417 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
418 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
419 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
422 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
424 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
425 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
427 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
430 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
431 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
432 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
433 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
434 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
435 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
436 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
437 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
440 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
442 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
443 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
445 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
448 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
449 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
450 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
451 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
452 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
453 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
456 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
458 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
459 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
461 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
464 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
465 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
466 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
467 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
468 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
469 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
472 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
474 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
475 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
477 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
480 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
481 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
482 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
483 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
484 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
485 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
486 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
487 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
493 /*******************************************************************
495 * @brief Function to fillPucchFormatCfg sent by DU
499 * Function : fillPucchFormatCfg
501 * Functionality: Function to fillPucchFormatCfg
503 * @params[in] PucchFormatCfg pointer,
504 * SchPucchFormatCfg pointer
507 * ****************************************************************/
509 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
511 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
512 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
513 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
514 schFormatCfg->numSlots = macFormatCfg->numSlots;
515 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
516 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
519 /*******************************************************************
521 * @brief Function to fillPucchSchedReqCfg sent by DU
525 * Function : fillPucchSchedReqCfg
527 * Functionality: Function to fillPucchSchedReqCfg
529 * @params[in] PucchSchedReqCfg pointer,
530 * SchPucchSchedReqCfg pointer
533 * ****************************************************************/
534 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
538 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
539 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
541 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
542 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
543 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
544 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
545 schSchedReqCfg->schedAddModList[arrIdx].offset =\
546 macSchedReqCfg->schedAddModList[arrIdx].offset;
547 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
548 macSchedReqCfg->schedAddModList[arrIdx].resrc;
550 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
551 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
553 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
557 /*******************************************************************
559 * @brief Function to fillMultiCsiCfg sent by DU
563 * Function : fillMultiCsiCfg
565 * Functionality: Function to fillMultiCsiCfg
567 * @params[in] PucchMultiCsiCfg pointer,
568 * SchPucchMultiCsiCfg pointer
571 * ****************************************************************/
573 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
577 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
578 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
580 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
584 /*******************************************************************
586 * @brief Function to fillDlToUlAck sent by DU
590 * Function : fillDlToUlAck
592 * Functionality: Function to fillDlToUlAck
594 * @params[in] PucchDlDataToUlAck pointer,
595 * SchPucchDlDataToUlAck pointer
598 * ****************************************************************/
600 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
604 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
605 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
607 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
611 /*******************************************************************
613 * @brief Function to fillPucchPowerControl sent by DU
617 * Function : fillPucchPowerControl
619 * Functionality: Function to fillPucchPowerControl
621 * @params[in] PucchPowerControl pointer,
622 * SchPucchPowerControl pointer
625 * ****************************************************************/
627 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
631 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
632 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
633 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
634 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
635 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
636 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
637 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
639 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
640 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
642 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
643 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
645 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
646 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
650 /*******************************************************************
652 * @brief Function to fillOtherPucchFormatCfg sent by DU
656 * Function : fillOtherPucchFormatCfg
658 * Functionality: Function to fillOtherPucchFormatCfg
660 * @params[in] PucchFormat
661 * PucchFormatCfg pointer,
662 * SchPucchCfg pointer
665 * ****************************************************************/
667 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
676 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
677 if(schPucchCfg->format1 == NULLP)
679 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
682 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
690 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
691 if(schPucchCfg->format2 == NULLP)
693 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
696 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
704 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
705 if(schPucchCfg->format3 == NULLP)
707 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
710 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
718 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
719 if(schPucchCfg->format4 == NULLP)
721 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
724 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
729 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
735 /*******************************************************************
737 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
741 * Function : fillInitalUlBwpPucchCfg
744 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
746 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
747 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
748 * @return ROK - success
751 * ****************************************************************/
752 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
754 if(macPucchCfg->resrcSet)
756 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
757 if(schPucchCfg->resrcSet == NULLP)
759 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
762 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
763 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
766 if(macPucchCfg->resrc)
768 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
769 if(schPucchCfg->resrc == NULLP)
771 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
774 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
775 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
777 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
782 /* valid for format 1, 2, 3, 4 */
783 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
784 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
785 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
786 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
788 if(macPucchCfg->schedReq)
790 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
791 if(schPucchCfg->schedReq == NULLP)
793 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
796 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
797 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
800 if(macPucchCfg->multiCsiCfg)
802 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
803 if(schPucchCfg->multiCsiCfg == NULLP)
805 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
808 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
809 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
812 //TODO: To add the support for spatial Config
813 schPucchCfg->spatialInfo = NULLP;
815 if(macPucchCfg->dlDataToUlAck)
817 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
818 if(schPucchCfg->dlDataToUlAck == NULLP)
820 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
823 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
824 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
828 if(macPucchCfg->powerControl)
830 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
831 if(schPucchCfg->powerControl == NULLP)
833 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
836 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
837 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
843 /*******************************************************************
845 * @brief function to free Pucch Format
849 * Function : freeSchPucchFormat
852 * function to free Pucch Format
854 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
855 * SchPucchResrcInfo pointer
857 * ****************************************************************/
859 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
863 case PUCCH_FORMAT_0 :
864 if(resrcInfo->SchPucchFormat.format0)
866 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
867 resrcInfo->SchPucchFormat.format0 = NULLP;
871 case PUCCH_FORMAT_1 :
872 if(resrcInfo->SchPucchFormat.format1)
874 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
875 resrcInfo->SchPucchFormat.format1 = NULLP;
879 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
880 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
884 case PUCCH_FORMAT_2 :
885 if(resrcInfo->SchPucchFormat.format2)
887 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
888 resrcInfo->SchPucchFormat.format2 = NULLP;
892 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
893 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
897 case PUCCH_FORMAT_3 :
898 if(resrcInfo->SchPucchFormat.format3)
900 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
901 resrcInfo->SchPucchFormat.format3 = NULLP;
905 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
906 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
910 case PUCCH_FORMAT_4 :
911 if(resrcInfo->SchPucchFormat.format4)
913 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
914 resrcInfo->SchPucchFormat.format4 = NULLP;
918 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
919 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
928 /*******************************************************************
930 * @brief function to free Pucch Resrc Cfg
934 * Function : freePucchResrcCfg
937 * function to free Pucch Resrc Cfg
939 * @params[in] SchPucchResrcCfg pointer,
941 * ****************************************************************/
943 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
947 /* free Resrc To AddMod List */
948 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
950 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
951 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
952 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
954 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
955 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
958 /*******************************************************************
960 * @brief function to free Pucch Sched Req Cfg
964 * Function : freePucchSchedReqCfg
967 * function to free Pucch Sched Req Cfg
969 * @params[in] SchPucchSchedReqCfg pointer,
971 * ****************************************************************/
973 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
977 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
979 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
981 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
982 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
985 /*******************************************************************
987 * @brief function to free Ul Bwp Pucch Cfg
991 * Function : freeUlBwpPucchCfg
994 * function to free Ul Bwp Pucch Cfg
996 * @params[in] SchPucchCfg pointer,
998 * ****************************************************************/
1000 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
1002 if(schPucchCfg->resrcSet)
1004 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
1005 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
1007 if(schPucchCfg->resrc)
1009 freePucchResrcCfg(schPucchCfg->resrc);
1011 if(schPucchCfg->format1)
1013 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1015 if(schPucchCfg->format2)
1017 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1019 if(schPucchCfg->format3)
1021 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1023 if(schPucchCfg->format4)
1025 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1027 if(schPucchCfg->schedReq)
1029 freePucchSchedReqCfg(schPucchCfg->schedReq);
1031 if(schPucchCfg->spatialInfo)
1033 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1034 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1036 if(schPucchCfg->multiCsiCfg)
1038 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1039 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1041 if(schPucchCfg->dlDataToUlAck)
1043 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1044 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1046 if(schPucchCfg->powerControl)
1048 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1049 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1053 /*******************************************************************
1055 * @brief Fills initail UL BWP config to send to scheduler
1059 * Function : fillInitialUlBwp
1061 * Functionality: Fills initail UL BWP config to send to sch
1063 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1064 * schInitUlBwp : Initial UL BWP cfg to be filled
1065 * @return ROK - success
1068 * ****************************************************************/
1069 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1071 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1072 if(schInitUlBwp->pucchCfgPres)
1074 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1075 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1077 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1078 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1082 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1083 if(schInitUlBwp->puschCfgPres)
1085 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1086 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1088 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1095 /*******************************************************************
1097 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1101 * Function : fillInitDlBwpPdcchCfg
1104 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1106 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1107 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1108 * @return ROK - success
1111 * ****************************************************************/
1112 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1116 /* Fill CORESET info */
1117 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1118 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1120 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1121 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1125 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1127 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1128 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1129 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1130 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1131 schPdcchCfg->cRSetToAddModList[idx].duration = \
1132 macPdcchCfg.cRSetToAddModList[idx].duration;
1133 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1134 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1135 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1136 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1137 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1138 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1141 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1142 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1144 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1145 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1149 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1154 /* Fill Search space info */
1155 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1156 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1158 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1159 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1162 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1164 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1165 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1166 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1167 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1168 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1169 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1170 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1171 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1172 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1173 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1174 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1175 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1176 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1177 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1178 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1179 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1180 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1181 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1182 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1183 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1184 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1185 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1186 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1189 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1190 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1192 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1193 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1196 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1204 /*******************************************************************
1206 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1210 * Function : fillInitDlBwpPdschCfg
1213 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1215 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1216 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1217 * @return ROK - success
1220 * ****************************************************************/
1221 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1225 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1226 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1227 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1228 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1229 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1231 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1232 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1236 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1238 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1239 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1240 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1241 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1242 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1243 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1246 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1247 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1248 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1249 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1251 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1253 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1255 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1256 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1261 /*******************************************************************
1263 * @brief Fill Initial DL BWP for SCH UE config
1267 * Function : fillInitialDlBwp
1269 * Functionality: Fill Initial DL BWP for SCH UE config
1271 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1272 * schInitDlBwp : Inital DL BWP cfg to be filled
1273 * @return ROK - success
1276 * ****************************************************************/
1277 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1279 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1280 if(schInitDlBwp->pdcchCfgPres)
1282 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1284 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1289 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1290 if(schInitDlBwp->pdschCfgPres)
1292 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1294 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1301 /*******************************************************************
1303 * @brief Fills Sp Cell config to be sent to scheduler
1307 * Function : fillSpCellCfg
1309 * Functionality: Fills Sp Cell config to be sent to scheduler
1311 * @params[in] macSpCellCfg : SP cell cfg at MAC
1312 * schSpCellCfg : SP cell cfg to be filled
1313 * @return ROK - success
1316 * ****************************************************************/
1317 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1320 SchServCellCfgInfo *servCellCfg;
1322 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1323 servCellCfg = &schSpCellCfg->servCellCfg;
1325 /* Fill initial DL BWP */
1326 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1327 &servCellCfg->initDlBwp) != ROK )
1329 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1333 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1334 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1336 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1337 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1340 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1342 /* TODO : As of now numDlBwpToAdd = 0 */
1345 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1346 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1347 servCellCfg->bwpInactivityTmr = NULL;
1348 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1350 /* TODO : This is an optional parameter, not filled currently */
1353 /* Fill PDSCH serving cell config */
1354 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1355 &servCellCfg->pdschServCellCfg) != ROK)
1357 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1361 /* Fill Initail UL BWP */
1362 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1363 &servCellCfg->initUlBwp) != ROK)
1365 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1369 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1370 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1372 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1373 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1376 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1378 /* TODO : As of now numDlBwpToAdd = 0 */
1380 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1385 /*******************************************************************
1387 * @brief Sends UE configuration to Scheduler
1391 * Function : sendUeReqToSch
1393 * Functionality: sends UE configuration to Scheduler
1395 * @params[in] Pst and Ue configuration
1396 * @return ROK - success
1399 * ****************************************************************/
1401 uint8_t sendUeReqToSch(Pst *pst, SchUeCfg *schUeCfg)
1406 case EVENT_MAC_UE_CREATE_REQ:
1407 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1408 return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfg);
1410 case EVENT_MAC_UE_RECONFIG_REQ:
1411 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1412 return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeCfg);
1414 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1419 /*******************************************************************
1421 * @brief Fills Sch Drb Qos Information
1425 * Function : fillSchDrbQosInfo
1427 * Functionality: Fills Sch Drb Qos Information
1429 * @params[in] macLcCfg : Logical channel Cfg at MAC
1430 * schLcCfg : LC cfg to fill at scheduler
1431 * @return ROK - success
1434 * ****************************************************************/
1435 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1437 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1438 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1440 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1441 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1442 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1443 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1445 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1447 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1448 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1449 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1450 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1451 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1452 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1453 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1454 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1456 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1457 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1458 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1459 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1460 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1461 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1462 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1463 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1464 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1467 /*******************************************************************
1469 * @brief Fill SCH UL logical channel configuration
1473 * Function : fillSchUlLcCfg
1475 * Functionality: Fills Sch Ul Lc configuration
1477 * @params[in] macLcCfg : Logical channel Cfg at MAC
1478 * schLcCfg : LC cfg to fill at scheduler
1481 * ****************************************************************/
1483 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1485 schUlLcCfg->priority= macUlLcCfg->priority;
1486 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1487 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1488 schUlLcCfg->pbr = macUlLcCfg->pbr;
1489 schUlLcCfg->bsd = macUlLcCfg->bsd;
1492 /*******************************************************************
1494 * @brief Fill logical channel configuration
1498 * Function : fillLogicalChannelCfg
1500 * Functionality: Fill logical channel configuration
1502 * @params[in] macLcCfg : Logical channel Cfg at MAC
1503 * schLcCfg : LC cfg to fill at scheduler
1504 * @return ROK - success
1507 * ****************************************************************/
1508 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1512 schLcCfg->lcId = macLcCfg->lcId;
1513 schLcCfg->configType = macLcCfg->configType;
1514 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1515 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1517 if(macLcCfg->drbQos)
1519 if(!schLcCfg->drbQos)
1521 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1522 if(!schLcCfg->drbQos)
1524 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1530 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1537 schLcCfg->drbQos = NULLP;
1542 if(macLcCfg->snssai)
1544 if(!schLcCfg->snssai)
1546 MAC_ALLOC(schLcCfg->snssai, sizeof(SchSnssai));
1547 if(!schLcCfg->snssai)
1549 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1555 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1556 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1558 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1563 schLcCfg->snssai = NULLP;
1564 /*Freeing the previously allocated buffer in case of failure */
1565 if(schLcCfg->drbQos)
1567 MAC_FREE(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1568 schLcCfg->drbQos = NULLP;
1575 schLcCfg->snssai = NULLP;
1582 /*******************************************************************
1584 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1588 * Function : fillSchLcCfgList
1590 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1592 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1593 * @return ROK - success
1596 * ****************************************************************/
1598 uint8_t fillSchLcCfgList(SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1602 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1604 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1606 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1614 /*******************************************************************
1616 * @brief Fills and sends UE configuration to Scheduler
1620 * Function : fillSchUeCfg
1622 * Functionality: Fills and sends UE configuration to Scheduler
1624 * @params[in] Ue configuration from DU APP
1625 * @return ROK - success
1628 * ****************************************************************/
1629 uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1633 schUeCfg->cellId = ueCfg->cellId;
1634 schUeCfg->crnti = ueCfg->crnti;
1636 /* Copy MAC cell group config */
1637 if(ueCfg->macCellGrpCfgPres == true)
1639 schUeCfg->macCellGrpCfgPres = true;
1640 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1641 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1643 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1647 if(ueCfg->phyCellGrpCfgPres == true)
1649 schUeCfg->phyCellGrpCfgPres = true;
1650 /* Copy Physical cell group config */
1651 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1652 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1654 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1659 if(ueCfg->spCellCfgPres == true)
1661 schUeCfg->spCellCfgPres = true;
1662 /* Copy sp cell config */
1663 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1664 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1666 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1670 if(ueCfg->ambrCfg != NULLP)
1672 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1673 if(!schUeCfg->ambrCfg)
1675 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1678 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1681 schUeCfg->ambrCfg = NULLP;
1683 /* Fill DL modulation infor */
1684 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1685 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1686 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1688 /* Fill UL modulation infor */
1689 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1690 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1691 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1693 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1694 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1697 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1703 /*******************************************************************
1705 * @brief Update UeUlCb Lc List
1709 * Function : updateMacUlCb
1711 * Functionality: Update UeUlCb Lc List
1713 * @params[in] delIdx, UeUlCb pointer
1716 * ****************************************************************/
1718 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1722 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
1724 /* Moving the array element to one step ahead */
1725 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
1726 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
1730 /*******************************************************************
1732 * @brief Update UeDlCb Lc List
1736 * Function : updateMacDlCb
1738 * Functionality: Update UeDlCb Lc List
1740 * @params[in] delIdx, UeDlCb pointer
1743 * ****************************************************************/
1745 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
1749 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
1751 /* Moving the array element to one step ahead */
1752 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
1753 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
1757 /*******************************************************************
1759 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1763 * Function : fillMacLcCfgList
1765 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1767 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1768 * @return ROK - success
1771 * ****************************************************************/
1773 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
1775 uint8_t lcIdx, ueLcIdx;
1777 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1779 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
1781 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1783 /*Filling DL LC CB */
1784 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1785 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
1786 ueCb->dlInfo.numDlLc++;
1787 /*Filling UL LC CB */
1788 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1789 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1790 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
1791 ueCb->ulInfo.numUlLc++;
1792 }/*End of Add Config */
1795 //searching for Lc to be Mod
1796 for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++)
1798 if(ueCb->ulInfo.lcCb[ueLcIdx].lcId == ueCfg->lcCfgList[lcIdx].lcId)
1800 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
1802 /*Nothing to Modify in DL LC CB */
1803 /*Modify UL LC CB */
1804 ueCb->ulInfo.lcCb[ueLcIdx].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1805 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1808 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
1810 memset(&ueCb->dlInfo.lcCb[ueLcIdx], 0, sizeof(DlLcCb));
1811 (ueCb->dlInfo.numDlLc)--;
1812 updateMacDlCb(ueLcIdx, &ueCb->dlInfo);
1814 memset(&ueCb->ulInfo.lcCb[ueLcIdx], 0, sizeof(UlLcCb));
1815 (ueCb->ulInfo.numUlLc)--;
1816 updateMacUlCb(ueLcIdx, &ueCb->ulInfo);
1817 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueCfg->lcCfgList[lcIdx].lcId);
1822 }/*End of Mod Config */
1828 /*******************************************************************
1830 * @brief Fills MAC UE Cb Cfg
1834 * Function : fillMacUeCb
1836 * Functionality: Fills MAC UE Cb Cfg
1838 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1840 * @return ROK - success
1843 * ****************************************************************/
1845 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
1849 ueCb->ueIdx = ueCfg->ueIdx;
1850 ueCb->crnti = ueCfg->crnti;
1851 ueCb->cellCb = macCb.macCell[cellIdx];
1852 if(ueCfg->spCellCfgPres)
1854 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
1855 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
1857 ueCb->state = UE_STATE_ACTIVE;
1858 /*TODO: To check the bsr value during implementation */
1859 if(ueCfg->macCellGrpCfgPres)
1861 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
1862 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
1863 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
1865 ret = fillMacLcCfgList(ueCb, ueCfg);
1868 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
1873 /*******************************************************************
1875 * @brief Function to update Mac Ra Cb
1879 * Function : updateMacRaCb
1881 * Functionality: Function to update Mac Ra Cb
1883 * @params[in] cellIdx, Mac Ue Cb
1884 * @return ROK - success
1887 * ****************************************************************/
1889 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1893 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1895 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1897 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx];
1904 /*******************************************************************
1906 * @brief Function to delete Mac Ra Cb
1910 * Function : deleteMacRaCb
1912 * Functionality: Function to delete Mac Ra Cb
1914 * @params[in] cellIdx, Mac Ue Cb
1917 * ****************************************************************/
1919 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
1923 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
1925 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
1927 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
1929 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
1930 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
1932 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu)
1934 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
1935 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
1937 memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
1944 /*******************************************************************
1946 * @brief Creates UE Cb
1950 * Function : createUeCb
1952 * Functionality: Creates UE Cb
1954 * @params[in] MAC UE Configuration
1955 * @return ROK - success
1958 * ****************************************************************/
1959 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
1963 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
1964 &&(ueCb->state == UE_STATE_ACTIVE))
1966 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
1971 memset(ueCb, 0, sizeof(MacUeCb));
1972 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
1975 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
1980 macCb.macCell[cellIdx]->numActvUe++;
1981 updateMacRaCb(cellIdx, ueCb);
1989 /*******************************************************************
1991 * @brief Modify UE Cb Cfg
1995 * Function : modifyUeCb
1997 * Functionality: modify UE Cb
1999 * @params[in] MAC UE Configuration
2000 * @return ROK - success
2003 * ****************************************************************/
2004 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2008 if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti)\
2009 &&(ueCb->state == UE_STATE_ACTIVE))
2011 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueCfg->crnti);
2012 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2015 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2020 deleteMacRaCb(cellIdx, ueCb);
2028 /*******************************************************************
2030 * @brief Creates UE Cb and fills ueCfg
2034 * Function : procMacUeCfgData
2036 * Functionality: Creates UE Cb and fills ueCfg
2038 * @params[in] MAC UE Configuration
2039 * @return ROK - success
2042 * ****************************************************************/
2044 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
2048 MacUeCb *ueCb = NULLP;
2051 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2053 /* Validate cell id */
2054 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
2056 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", ueCfg->cellId);
2060 /* Check if max number of UE configured */
2061 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2063 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2067 /* Check if UE already configured */
2068 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx -1];
2071 case EVENT_UE_CONFIG_RSP_TO_MAC:
2072 ret = createUeCb(cellIdx, ueCb, ueCfg);
2074 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2076 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2077 ret = modifyUeCb(cellIdx, ueCb, ueCfg);
2079 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2088 /*******************************************************************
2090 * @brief Function to store the UeCfg Data
2094 * Function : copyToTmpData
2096 * Functionality: Function to store the UeCfg Data
2098 * @params[in] MacUeCfg pointer
2099 * @return ROK - success
2102 * ****************************************************************/
2104 uint8_t copyToTmpData(MacUeCfg *ueCfg)
2107 MacUeCfg *tmpData = NULLP;
2109 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2112 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2115 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2116 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2117 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueIdx-1] = tmpData;
2121 /*******************************************************************
2123 * @brief Handles UE create requst from DU APP
2127 * Function : MacProcUeCreateReq
2129 * Functionality: Handles UE create requst from DU APP
2132 * @return ROK - success
2135 * ****************************************************************/
2136 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2140 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2142 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2146 /*Storing received ueCfg in ueCfgTmpData */
2147 ret = copyToTmpData(ueCfg);
2150 /*Sending Cfg Req to SCH */
2151 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2153 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2156 /* Fill event and send UE create request to SCH */
2157 ret = sendUeReqToSch(pst, &schUeCfg);
2159 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2164 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2169 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2172 /* FREE shared memory */
2173 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2178 /*******************************************************************
2180 * @brief Fill and Send UE create response from MAC to DU APP
2184 * Function : MacSendUeCreateRsp
2186 * Functionality: Fill and Send UE create response from MAC to DUAPP
2188 * @params[in] MAC UE create result
2189 * SCH UE create response
2190 * @return ROK - success
2193 * ****************************************************************/
2194 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2196 MacUeCfgRsp *cfgRsp;
2199 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2202 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2206 /* Filling UE Config response */
2207 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2208 cfgRsp->cellId = schCfgRsp->cellId;
2209 cfgRsp->ueIdx = schCfgRsp->ueIdx;
2210 cfgRsp->result = result;
2212 /* Fill Post structure and send UE Create response*/
2213 memset(&rspPst, 0, sizeof(Pst));
2214 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2215 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2218 /*******************************************************************
2220 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2224 * Function : MacSendUeReconfigRsp
2226 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2228 * @params[in] MAC UE create result
2229 * SCH UE create response
2230 * @return ROK - success
2233 * ****************************************************************/
2234 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2236 MacUeCfgRsp *cfgRsp;
2239 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2242 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2246 /* Filling UE Config response */
2247 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2248 cfgRsp->cellId = schCfgRsp->cellId;
2249 cfgRsp->ueIdx = schCfgRsp->ueIdx;
2250 cfgRsp->result = result;
2252 /* Fill Post structure and send UE Create response*/
2253 memset(&rspPst, 0, sizeof(Pst));
2254 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2255 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2258 /*******************************************************************
2260 * @brief Function to return Mac Ue Cfg pointer
2264 * Function : getMacUeCfg
2267 * Function to return Mac Ue Cfg pointer
2269 * @params[in] cellIdx, ueIdx
2271 * @return MacUeCfg pointer - success
2274 * ****************************************************************/
2276 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2278 MacUeCfg *ueCfg = NULLP;
2279 if(macCb.macCell[cellIdx])
2281 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueIdx-1];
2285 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2290 /*******************************************************************
2292 * @brief Processes UE create response from scheduler
2296 * Function : MacProcSchUeCfgRsp
2299 * Processes UE create response from scheduler
2300 * Sends UE create response to DU APP
2302 * @params[in] Pst : Post structure
2303 * schCfgRsp : Scheduler UE cfg response
2304 * @return ROK - success
2307 * ****************************************************************/
2308 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2310 uint8_t result = MAC_DU_APP_RSP_NOK;
2313 MacUeCfg *ueCfg = NULLP;
2315 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2316 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueIdx);
2319 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2325 case EVENT_UE_CONFIG_RSP_TO_MAC:
2327 if(schCfgRsp->rsp != RSP_NOK)
2329 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2332 ret = procMacUeCfgData(pst, ueCfg);
2335 result = MAC_DU_APP_RSP_OK;
2341 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2343 ret = MacSendUeCreateRsp(result, schCfgRsp);
2347 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2349 if(schCfgRsp->rsp != RSP_NOK)
2351 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2354 ret = procMacUeCfgData(pst, ueCfg);
2357 result = MAC_DU_APP_RSP_OK;
2363 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2365 ret = MacSendUeReconfigRsp(result, schCfgRsp);
2372 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2378 /*******************************************************************
2380 * @brief Handles UE Reconfig requst from DU APP
2384 * Function : MacProcUeReconfigReq
2386 * Functionality: Handles UE Reconfig requst from DU APP
2389 * @return ROK - success
2392 * ****************************************************************/
2393 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
2397 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2399 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueCfg->crnti);
2403 /*Storing received ueCfg in ueCfgTmpData */
2404 ret = copyToTmpData(ueCfg);
2407 /*Sending Cfg Req to SCH */
2408 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2410 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
2413 /* Fill event and send UE create request to SCH */
2414 ret = sendUeReqToSch(pst, &schUeCfg);
2416 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
2421 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
2426 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2429 /* FREE shared memory */
2430 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2434 /*******************************************************************
2436 * @brief Fill and Send UE Delete response from MAC to DU APP
2440 * Function : MacSendUeDeleteRsp
2442 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
2444 * @params[in] MAC UE delete result
2445 * SCH UE delete response
2446 * @return ROK - success
2449 * ****************************************************************/
2451 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus result)
2453 MacUeDeleteRsp *deleteRsp;
2456 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
2459 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
2463 /* Filling UE delete response */
2464 deleteRsp->cellId = cellId;
2465 GET_UE_IDX(crnti,deleteRsp->ueIdx);
2466 deleteRsp->result = result;
2468 /* Fill Post structure and send UE delete response*/
2469 memset(&rspPst, 0, sizeof(Pst));
2470 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
2471 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
2474 /*******************************************************************
2476 * @brief freeing the Pucch Resrc Cfg
2480 * Function : deletePucchResourcesCfg
2482 * Functionality: freeing the Pucch Resrc Cfg
2484 * @params[in] PucchResrcCfg *resrcCfg
2485 * @return ROK - success
2488 * ****************************************************************/
2490 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
2493 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
2495 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
2497 case PUCCH_FORMAT_0:
2499 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
2502 case PUCCH_FORMAT_1:
2504 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
2507 case PUCCH_FORMAT_2:
2509 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
2512 case PUCCH_FORMAT_3:
2514 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
2517 case PUCCH_FORMAT_4:
2519 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
2527 /*******************************************************************
2529 * @brief Function to delete MAC Pdsch ServCellCfg
2533 * Function : deleteMacPdschServCellCfg
2535 * Functionality: Function to delete MAC Pdsch ServCellCfg
2537 * @params[in] PdschServCellCfg *pdschServCellCfg
2540 * ****************************************************************/
2542 void deleteMacPdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2544 MAC_FREE(pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2545 MAC_FREE(pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2546 MAC_FREE(pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2547 MAC_FREE(pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2550 /*******************************************************************
2552 * @brief Handles UE Delete requst from DU APP
2556 * Function : deleteMacUeCb
2558 * Functionality: Handles UE Delete requst from DU APP
2560 * @params[in] MacCellCb *cellCb,uint16_t ueIdx
2561 * @return ROK - success
2564 * ****************************************************************/
2566 void deleteMacUeCb(MacUeCb *ueCb)
2568 MacUeCfg *ueCfg = NULLP;
2569 ServCellCfgInfo *servCellCfg;
2573 MAC_FREE(ueCb->cellCb->macRaCb[ueCb->ueIdx-1].msg4Pdu, ueCb->cellCb->macRaCb[ueCb->ueIdx-1].msg4PduLen);
2574 MAC_FREE(ueCb->cellCb->macRaCb[ueCb->ueIdx-1].msg4TxPdu, ueCb->cellCb->macRaCb[ueCb->ueIdx-1].msg4TbSize);
2576 if(ueCb->cellCb->ueCfgTmpData[ueCb->ueIdx-1])
2578 ueCfg =ueCb->cellCb->ueCfgTmpData[ueCb->ueIdx-1];
2579 MAC_FREE(ueCfg->ambrCfg, sizeof(AmbrCfg));
2580 if(ueCfg->spCellCfgPres)
2582 servCellCfg = &ueCfg->spCellCfg.servCellCfg;
2583 MAC_FREE(servCellCfg->bwpInactivityTmr, sizeof(uint8_t));
2585 if(servCellCfg->initUlBwp.pucchPresent)
2587 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.resrcSet, sizeof(PucchResrcSetCfg));
2589 if(servCellCfg->initUlBwp.pucchCfg.resrc)
2591 deletePucchResourcesCfg(servCellCfg->initUlBwp.pucchCfg.resrc);
2592 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.resrc, sizeof(PucchResrcCfg));
2594 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.format1, sizeof(PucchFormatCfg));
2595 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.format2, sizeof(PucchFormatCfg));
2596 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.format3, sizeof(PucchFormatCfg));
2597 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.format4, sizeof(PucchFormatCfg));
2598 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.schedReq, sizeof(PucchSchedReqCfg));
2599 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.multiCsiCfg, sizeof(PucchMultiCsiCfg));
2600 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.spatialInfo, sizeof(PucchSpatialCfg));
2601 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.dlDataToUlAck , sizeof(PucchDlDataToUlAck));
2602 MAC_FREE(servCellCfg->initUlBwp.pucchCfg.powerControl, sizeof(PucchPowerControl));
2603 deleteMacPdschServCellCfg(&servCellCfg->pdschServCellCfg);
2606 for(uint8_t idx=0 ;idx < ueCfg->numLcs; idx++)
2608 MAC_FREE(ueCfg->lcCfgList[idx].drbQos, sizeof(DrbQosInfo));
2609 MAC_FREE(ueCfg->lcCfgList[idx].snssai, sizeof(Snssai));
2611 MAC_FREE(ueCb->cellCb->ueCfgTmpData[ueCb->ueIdx-1],sizeof(MacUeCfg));
2614 memset(ueCb, 0, sizeof(MacUeCb));
2617 /*******************************************************************
2619 * @brief Processes UE delete response from scheduler
2623 * Function : MacProcSchUeCfgRsp
2626 * Processes UE create delete from scheduler
2628 * @params[in] Pst : Post structure
2629 * schUeDelRsp : Scheduler UE delete respons
2630 * @return ROK - success
2633 * ****************************************************************/
2635 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
2639 uint8_t ret = RFAILED;
2640 UeDeleteStatus result;
2644 if(schUeDelRsp->rsp == RSP_OK)
2646 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
2647 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
2648 if(macCb.macCell[cellIdx])
2650 GET_UE_IDX(schUeDelRsp->crnti, ueIdx);
2651 if(macCb.macCell[cellIdx]->ueCb[ueIdx -1].crnti == schUeDelRsp->crnti)
2653 deleteMacUeCb(&macCb.macCell[cellIdx]->ueCb[ueIdx -1]);
2654 macCb.macCell[cellIdx]->numActvUe--;
2660 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
2661 result = UEIDX_INVALID;
2666 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
2667 result = CELLID_INVALID;
2672 result = (schUeDelRsp->cause == INVALID_CELLID) ? CELLID_INVALID : UEIDX_INVALID;
2674 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, result) != ROK)
2676 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
2681 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
2687 /*******************************************************************
2689 * @brief Sends UE delete req to Scheduler
2693 * Function : sendUeDelReqToSch
2695 * Functionality: sends UE delete req to Scheduler
2697 * @params[in] Pst *pst, MacUeDelete *ueDelete
2698 * @return ROK - success
2701 * ****************************************************************/
2703 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
2705 if(ueDelete != NULLP)
2708 SchUeDelete schUeDel;
2710 memset(&schUeDel, 0, sizeof(SchUeDelete));
2711 schUeDel.cellId = ueDelete->cellId;
2712 schUeDel.crnti = ueDelete->crnti;
2713 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2714 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
2715 return(*macSchUeDeleteReqOpts[schPst.selector])(&schPst, &schUeDel);
2719 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
2725 /*******************************************************************
2727 * @brief Handles UE Delete requst from DU APP
2731 * Function : MacProcUeDeleteReq
2733 * Functionality: Handles UE Delete requst from DU APP
2735 * @params[in] Pst *pst, MacUeDelete *ueDelete
2736 * @return ROK - success
2739 * ****************************************************************/
2741 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
2745 UeDeleteStatus result=SUCCESS;
2746 MacUeCb *ueCb = NULLP;
2747 MacCellCb *cellCb = NULLP;
2749 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueIdx[%d]", ueDelete->ueIdx);
2753 GET_CELL_IDX(ueDelete->cellId, cellIdx);
2754 cellCb = macCb.macCell[cellIdx];
2757 ueCb = &cellCb->ueCb[ueDelete->ueIdx-1];
2758 if(ueCb->crnti == ueDelete->crnti)
2760 ret = sendUeDelReqToSch(pst, ueDelete);
2763 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
2769 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
2770 result = UEIDX_INVALID;
2775 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeIdx = %d",ueDelete->ueIdx);
2776 result = CELLID_INVALID;
2779 if(result != SUCCESS)
2781 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, result);
2782 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2788 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
2794 /*******************************************************************
2796 * @brief Fill and Send Cell Delete response from MAC to DU APP
2800 * Function : MacSendCellDeleteRsp
2802 * Functionality: Fill and Send Cell Delete response from MAC to DUAPP
2804 * @params[in] MAC Cell delete result
2805 * SCH Cell delete response
2806 * @return ROK - success
2809 * ****************************************************************/
2810 uint8_t MacSendCellDeleteRsp(CellDeleteStatus result, uint8_t cellId)
2812 MacCellDeleteRsp *deleteRsp=NULLP;
2815 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacCellDeleteRsp));
2818 DU_LOG("\nERROR --> MAC : MacSendCellDeleteRsp(): Memory allocation for Cell delete response failed");
2822 /* Filling CELL delete response */
2823 deleteRsp->cellId = cellId;
2824 deleteRsp->result = result;
2826 /* Fill Post structure and send CELL delete response*/
2827 memset(&rspPst, 0, sizeof(Pst));
2828 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_CELL_DELETE_RSP);
2829 return (*macDuCellDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
2832 /*******************************************************************
2834 * @brief delete MAC CellCb information
2838 * Function : deleteMacCellCb
2841 * delete MAC CellCb information
2843 * @params[in] MacCellCb * cellCb
2845 * @return ROK - success
2848 * ****************************************************************/
2849 void deleteMacCellCb(MacCellCb * cellCb)
2852 for(idx=0; idx<MAX_SLOTS; idx++)
2854 MAC_FREE(cellCb->dlSlot[idx].dlInfo.rarAlloc, sizeof(RarAlloc));
2855 if(cellCb->dlSlot[idx].dlInfo.ulGrant)
2857 MAC_FREE(cellCb->dlSlot[idx].dlInfo.ulGrant->dciInfo.pdschCfg, sizeof(PdschCfg));
2858 MAC_FREE(cellCb->dlSlot[idx].dlInfo.ulGrant, sizeof(DciInfo));
2860 if(cellCb->dlSlot[idx].dlInfo.dlMsgAlloc)
2862 MAC_FREE(cellCb->dlSlot[idx].dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu,\
2863 cellCb->dlSlot[idx].dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPduLen);
2864 MAC_FREE(cellCb->dlSlot[idx].dlInfo.dlMsgAlloc, sizeof(DlMsgAlloc));
2868 memset(cellCb, 0, sizeof(MacCellCb));
2871 /*******************************************************************
2873 * @brief Processes CELL delete response from scheduler
2877 * Function : MacProcSchCellDeleteRsp
2880 * Processes CELL delete from scheduler
2882 * @params[in] Pst : Post structure
2883 * schCellDelRsp : Scheduler CELL delete respons
2884 * @return ROK - success
2887 * * ****************************************************************/
2888 uint8_t MacProcSchCellDeleteRsp(Pst *pst, SchCellDeleteRsp *schCellDelRsp)
2892 CellDeleteStatus status;
2896 if(schCellDelRsp->rsp == RSP_OK)
2898 DU_LOG("\nINFO --> MAC : SCH CELL Delete response for cellId[%d] is successful ", \
2899 schCellDelRsp->cellId);
2900 GET_CELL_IDX(schCellDelRsp->cellId, cellIdx);
2901 if(macCb.macCell[cellIdx])
2903 if(macCb.macCell[cellIdx]->cellId == schCellDelRsp->cellId)
2905 deleteMacCellCb(macCb.macCell[cellIdx]);
2906 status = SUCCESSFUL_RSP;
2907 MAC_FREE(macCb.macCell[cellIdx], sizeof(MacCellCb));
2911 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
2912 status = CELL_ID_INVALID;
2918 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
2919 status = CELL_ID_INVALID;
2925 DU_LOG("ERROR --> MAC : MacProcSchCellDeleteRsp(): CellId[%d] does not exists", schCellDelRsp->cellId);
2926 status = CELL_ID_INVALID;
2929 if(MacSendCellDeleteRsp(status, schCellDelRsp->cellId) != ROK)
2931 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): Failed to send CELL delete response");
2938 DU_LOG("\nERROR --> MAC: MacProcSchCellDeleteRsp(): schCellDelRsp is NULL");
2944 /*******************************************************************
2946 * @brief Sends Cell delete req to Scheduler
2950 * Function : sendCellDelReqToSch
2952 * Functionality: sends Cell delete req to Scheduler
2954 * @params[in] SchCellDelete *schCellDel
2955 * @return ROK - success
2958 * ****************************************************************/
2960 uint8_t sendCellDelReqToSch(SchCellDelete *schCellDel)
2963 FILL_PST_MAC_TO_SCH(schPst, EVENT_CELL_DELETE_REQ_TO_SCH);
2964 return(*macSchCellDeleteReqOpts[schPst.selector])(&schPst, schCellDel);
2967 /*******************************************************************
2969 * @brief Handles CELL Delete requst from DU APP
2973 * Function : MacProcCellDeleteReq
2975 * Functionality: Handles CELL Delete requst from DU APP
2977 * @params[in] Pst *pst, MacCellDelete *cellDelete
2978 * @return ROK - success
2982 * ****************************************************************/
2983 uint8_t MacProcCellDeleteReq(Pst *pst, MacCellDelete *cellDelete)
2985 uint8_t ret = ROK, cellIdx=0;
2986 SchCellDelete schCellDelete;
2988 DU_LOG("\nINFO --> MAC : Cell Delete Request received for cellId[%d]", cellDelete->cellId);
2992 GET_CELL_IDX(cellDelete->cellId, cellIdx);
2993 if(macCb.macCell[cellIdx])
2995 if(macCb.macCell[cellIdx]->cellId == cellDelete->cellId)
2997 memset(&schCellDelete, 0, sizeof(SchCellDelete));
2998 schCellDelete.cellId = cellDelete->cellId;
2999 ret = sendCellDelReqToSch(&schCellDelete);
3002 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to send UE Delete Request to SCH");
3008 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
3009 cellDelete->cellId);
3015 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Failed to find the MacUeCb of CellId = %d",\
3016 cellDelete->cellId);
3022 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Sending failure response to DU");
3023 if(MacSendCellDeleteRsp(CELL_ID_INVALID, cellDelete->cellId) != ROK)
3025 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): failed to send cell delete rsp for cellID[%d]",\
3026 cellDelete->cellId);
3030 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellDelete, sizeof(MacCellDelete));
3034 DU_LOG("\nERROR --> MAC : MacProcCellDeleteReq(): Received MacCellDelete is NULL");
3040 /**********************************************************************
3042 **********************************************************************/