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 /*******************************************************************
69 * @brief Fills mac cell group config to be sent to scheduler
73 * Function : fillMacCellGroupCfg
75 * Functionality: Fills mac cell group config to be sent to sch
77 * @params[in] macCellGrp : mac cell group config at MAC
78 * *macCellGrpCfg : mac cell group cfg to be filled
79 * @return ROK - success
82 * ****************************************************************/
83 uint8_t fillMacCellGroupCfg(MacCellGrpCfg macCellGrp, SchMacCellGrpCfg *macCellGrpCfg)
86 SchSchedReqCfg *schedReqCfg;
89 /* Copy scheduling request config */
90 schedReqCfg = &macCellGrpCfg->schedReqCfg;
91 schedReqCfg->addModListCount = macCellGrp.schReqCfg.addModListCount;
92 if(schedReqCfg->addModListCount > MAX_NUM_SR_CFG_PER_CELL_GRP)
94 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
95 schedReqCfg->addModListCount, MAX_NUM_SR_CFG_PER_CELL_GRP);
98 for(idx = 0; idx < schedReqCfg->addModListCount; idx++)
100 schedReqCfg->addModList[idx].schedReqId = \
101 macCellGrp.schReqCfg.addModList[idx].schedReqId;
102 schedReqCfg->addModList[idx].srProhibitTmr = \
103 macCellGrp.schReqCfg.addModList[idx].srProhibitTmr;
104 schedReqCfg->addModList[idx].srTransMax = \
105 macCellGrp.schReqCfg.addModList[idx].srTransMax;
107 schedReqCfg->relListCount = macCellGrp.schReqCfg.relListCount;
109 /* copy TAG config */
110 tagCfg = &macCellGrpCfg->tagCfg;
111 tagCfg->addModListCount = macCellGrp.tagCfg.addModListCount;
112 if(tagCfg->addModListCount > MAX_NUM_TAGS)
114 DU_LOG("\nERROR --> MAC : Scheduling Request Add/Mod Count %d exceeds max limit %d", \
115 tagCfg->addModListCount, MAX_NUM_TAGS);
118 for(idx = 0; idx < tagCfg->addModListCount; idx++)
120 tagCfg->addModList[idx].tagId = \
121 macCellGrp.tagCfg.addModList[idx].tagId;
122 tagCfg->addModList[idx].timeAlignmentTmr = \
123 macCellGrp.tagCfg.addModList[idx].timeAlignTimer;
125 tagCfg->relListCount = macCellGrp.tagCfg.relListCount;
127 /* Copy PHR config */
128 if(macCellGrp.phrCfgSetupPres)
130 macCellGrpCfg->phrCfg.periodicTmr = macCellGrp.phrCfg.periodicTimer;
131 macCellGrpCfg->phrCfg.prohibitTmr = macCellGrp.phrCfg.prohibitTimer;
132 macCellGrpCfg->phrCfg.txpowerFactorChange = macCellGrp.phrCfg.txPowerFactor;
133 macCellGrpCfg->phrCfg.multiplePhr = macCellGrp.phrCfg.multiplePHR;
134 macCellGrpCfg->phrCfg.dummy = macCellGrp.phrCfg.dummy;
135 macCellGrpCfg->phrCfg.type2OtherCell = macCellGrp.phrCfg.phrType2OtherCell;
136 macCellGrpCfg->phrCfg.modeOtherCG = macCellGrp.phrCfg.phrOtherCG;
142 /*******************************************************************
144 * @brief Fills phy cell group config to be sent to scheduler
148 * Function : fillPhyCellGroupCfg
150 * Functionality: Fills phy cell group config to be sent to sch
152 * @params[in] macUeCfg : Phy cell group config at MAC
153 * *schPhyCellGrp : phy cell group config to be filled
154 * @return ROK - success
157 * ****************************************************************/
158 uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCellGrp)
160 schPhyCellGrp->pdschHarqAckCodebook = macUeCfg.pdschHarqAckCodebook;
161 schPhyCellGrp->pNrFr1 = macUeCfg.pNrFr1;
166 /*******************************************************************
168 * @brief Fills PDSCh serving cell config to send to scheduler
172 * Function : fillPdschServCellCfg
174 * Functionality: Fills PDSCh serving cell config to send to scheduler
176 * @params[in] macPdschCfg : Pdsch serving cell config at MAC
177 * *schPdschCfg : Pdsch serving cell config to be filled
178 * @return ROK - success
181 * ****************************************************************/
182 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg)
184 if(macPdschCfg.maxMimoLayers)
186 if(!schPdschCfg->maxMimoLayers)
188 MAC_ALLOC(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
189 if(!schPdschCfg->maxMimoLayers)
191 DU_LOG("\nERROR --> MAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
195 *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
199 schPdschCfg->maxMimoLayers = NULLP;
202 schPdschCfg->numHarqProcForPdsch = \
203 macPdschCfg.numHarqProcForPdsch;
205 if(macPdschCfg.maxCodeBlkGrpPerTb)
207 if(!schPdschCfg->maxCodeBlkGrpPerTb)
209 MAC_ALLOC(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
210 if(!schPdschCfg->maxCodeBlkGrpPerTb)
212 DU_LOG("\nERROR --> MAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
216 *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
220 schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
223 if(macPdschCfg.codeBlkGrpFlushInd)
225 if(!schPdschCfg->codeBlkGrpFlushInd)
227 MAC_ALLOC(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
228 if(!schPdschCfg->codeBlkGrpFlushInd)
230 DU_LOG("\nERROR --> MAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
234 *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
238 schPdschCfg->codeBlkGrpFlushInd = NULLP;
241 if(macPdschCfg.xOverhead)
243 if(!schPdschCfg->xOverhead)
245 MAC_ALLOC(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
246 if(!schPdschCfg->xOverhead)
248 DU_LOG("\nERROR --> MAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
252 *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
256 schPdschCfg->xOverhead = NULLP;
262 /*******************************************************************
264 * @brief Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
268 * Function : fillInitalUlBwpPuschCfg
271 * Fills PUSCH cofig in initial UL BWP config for SCH UE Cfg
273 * @params[in] macPuschCfg : Initial UL-BWP PUSCH cfg at MAC
274 * schPuschCfg : Initial UL-BWP PUSCH cfg to be filled
275 * @return ROK - success
278 * ****************************************************************/
279 uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
283 schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
284 schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
285 macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
286 schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
287 macPuschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0;
288 schPuschCfg->resourceAllocType = macPuschCfg.resourceAllocType;
290 schPuschCfg->numTimeDomRsrcAlloc = macPuschCfg.numTimeDomRsrcAlloc;
291 if(schPuschCfg->numTimeDomRsrcAlloc > MAX_NUM_UL_ALLOC)
293 DU_LOG("\nERROR --> MAC : Number of Time domain resource allocation [%d] exceeds max limit [%d]",\
294 schPuschCfg->numTimeDomRsrcAlloc, MAX_NUM_UL_ALLOC);
297 for(idx = 0; idx < schPuschCfg->numTimeDomRsrcAlloc; idx++)
299 schPuschCfg->timeDomRsrcAllocList[idx].k2 = \
300 macPuschCfg.timeDomRsrcAllocList[idx].k2;
301 schPuschCfg->timeDomRsrcAllocList[idx].mappingType = \
302 macPuschCfg.timeDomRsrcAllocList[idx].mappingType;
303 schPuschCfg->timeDomRsrcAllocList[idx].startSymbol = \
304 macPuschCfg.timeDomRsrcAllocList[idx].startSymbol;
305 schPuschCfg->timeDomRsrcAllocList[idx].symbolLength = \
306 macPuschCfg.timeDomRsrcAllocList[idx].symbolLength;
309 schPuschCfg->transformPrecoder = macPuschCfg.transformPrecoder;
313 /*******************************************************************
315 * @brief Function to fillResrcSetList sent by DU
319 * Function : fillResrcSetList
321 * Functionality: Function to fillResrcSetList sent by DU
323 * @params[in] PucchResrcSetCfg pointer,
324 * SchPucchResrcSetCfg pointer
327 * ****************************************************************/
329 void fillResrcSetList(PucchResrcSetCfg *macRsrcSetList, SchPucchResrcSetCfg *schRsrcSetList)
331 uint8_t arrIdx, rsrcListIdx;
333 /* ResrcSetToAddModList */
334 schRsrcSetList->resrcSetToAddModListCount = macRsrcSetList->resrcSetToAddModListCount;
335 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
337 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
338 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId;
340 schRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
341 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize;
343 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
344 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount;
345 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].\
346 resrcListCount; rsrcListIdx++)
348 schRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
349 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx];
352 /* ResrcSetToRelList */
353 schRsrcSetList->resrcSetToRelListCount = macRsrcSetList->resrcSetToRelListCount;
354 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToRelListCount; arrIdx++)
356 schRsrcSetList->resrcSetToRelList[arrIdx] = macRsrcSetList->resrcSetToRelList[arrIdx];
360 /*******************************************************************
362 * @brief Function to fillResrcList sent by DU
366 * Function : fillResrcList
368 * Functionality: Function to fillResrcList sent by DU
370 * @params[in] PucchResrcCfg pointer,
371 * SchPucchResrcCfg pointer
372 * @return ROK/RFAILED;
374 * ****************************************************************/
375 uint8_t fillResrcList(PucchResrcCfg *macResrcCfg, SchPucchResrcCfg *schResrcCfg)
379 schResrcCfg->resrcToAddModListCount = macResrcCfg->resrcToAddModListCount;
380 for(arrIdx=0; arrIdx < macResrcCfg->resrcToAddModListCount; arrIdx++)
382 schResrcCfg->resrcToAddModList[arrIdx].resrcId =\
383 macResrcCfg->resrcToAddModList[arrIdx].resrcId;
384 schResrcCfg->resrcToAddModList[arrIdx].startPrb =\
385 macResrcCfg->resrcToAddModList[arrIdx].startPrb;
386 schResrcCfg->resrcToAddModList[arrIdx].intraFreqHop =\
387 macResrcCfg->resrcToAddModList[arrIdx].intraFreqHop;
388 schResrcCfg->resrcToAddModList[arrIdx].secondPrbHop =\
389 macResrcCfg->resrcToAddModList[arrIdx].secondPrbHop;
390 schResrcCfg->resrcToAddModList[arrIdx].pucchFormat =\
391 macResrcCfg->resrcToAddModList[arrIdx].pucchFormat;
392 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0)
394 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0, sizeof(SchPucchFormat0));
395 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0 == NULLP)
397 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format0 in fillResrcList()");
400 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->initialCyclicShift =\
401 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift;
402 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->numSymbols =\
403 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols;
404 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format0->startSymbolIdx =\
405 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx;
408 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1)
410 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1, sizeof(SchPucchFormat1));
411 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1 == NULLP)
413 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format1 in fillResrcList()");
416 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->initialCyclicShift =\
417 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift;
418 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->numSymbols =\
419 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols;
420 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->startSymbolIdx =\
421 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx;
422 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format1->timeDomOCC =\
423 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC;
426 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2)
428 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
429 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2 == NULLP)
431 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format2 in fillResrcList()");
434 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numPrbs =\
435 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs;
436 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->numSymbols =\
437 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols;
438 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format2->startSymbolIdx =\
439 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx;
442 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3)
444 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
445 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3 == NULLP)
447 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format3 in fillResrcList()");
450 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numPrbs =\
451 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs;
452 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->numSymbols =\
453 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols;
454 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format3->startSymbolIdx =\
455 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx;
458 if(macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4)
460 MAC_ALLOC(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4, sizeof(SchPucchFormat4));
461 if(schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4 == NULLP)
463 DU_LOG("\nERROR --> MAC : Failed to allocate memory for Format4 in fillResrcList()");
466 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->numSymbols =\
467 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols;
468 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->startSymbolIdx =\
469 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx;
470 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occLen =\
471 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occLen;
472 schResrcCfg->resrcToAddModList[arrIdx].SchPucchFormat.format4->occIdx =\
473 macResrcCfg->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx;
479 /*******************************************************************
481 * @brief Function to fillPucchFormatCfg sent by DU
485 * Function : fillPucchFormatCfg
487 * Functionality: Function to fillPucchFormatCfg
489 * @params[in] PucchFormatCfg pointer,
490 * SchPucchFormatCfg pointer
493 * ****************************************************************/
495 void fillPucchFormatCfg(PucchFormatCfg *macFormatCfg, SchPucchFormatCfg *schFormatCfg)
497 schFormatCfg->interSlotFreqHop = macFormatCfg->interSlotFreqHop;
498 schFormatCfg->addDmrs = macFormatCfg->addDmrs;
499 schFormatCfg->maxCodeRate = macFormatCfg->maxCodeRate;
500 schFormatCfg->numSlots = macFormatCfg->numSlots;
501 schFormatCfg->pi2BPSK = macFormatCfg->pi2BPSK;
502 schFormatCfg->harqAckCSI = macFormatCfg->harqAckCSI;
505 /*******************************************************************
507 * @brief Function to fillPucchSchedReqCfg sent by DU
511 * Function : fillPucchSchedReqCfg
513 * Functionality: Function to fillPucchSchedReqCfg
515 * @params[in] PucchSchedReqCfg pointer,
516 * SchPucchSchedReqCfg pointer
519 * ****************************************************************/
520 void fillPucchSchedReqCfg(PucchSchedReqCfg *macSchedReqCfg, SchPucchSchedReqCfg *schSchedReqCfg)
524 schSchedReqCfg->schedAddModListCount = macSchedReqCfg->schedAddModListCount;
525 for(arrIdx=0; arrIdx < schSchedReqCfg->schedAddModListCount; arrIdx++)
527 schSchedReqCfg->schedAddModList[arrIdx].resrcId = macSchedReqCfg->schedAddModList[arrIdx].resrcId;
528 schSchedReqCfg->schedAddModList[arrIdx].requestId = macSchedReqCfg->schedAddModList[arrIdx].requestId;
529 schSchedReqCfg->schedAddModList[arrIdx].periodicity =\
530 macSchedReqCfg->schedAddModList[arrIdx].periodicity;
531 schSchedReqCfg->schedAddModList[arrIdx].offset =\
532 macSchedReqCfg->schedAddModList[arrIdx].offset;
533 schSchedReqCfg->schedAddModList[arrIdx].resrc =\
534 macSchedReqCfg->schedAddModList[arrIdx].resrc;
536 schSchedReqCfg->schedRelListCount = macSchedReqCfg->schedRelListCount;
537 for(arrIdx=0; arrIdx < schSchedReqCfg->schedRelListCount; arrIdx++)
539 schSchedReqCfg->schedRelList[arrIdx] = macSchedReqCfg->schedRelList[arrIdx];
543 /*******************************************************************
545 * @brief Function to fillMultiCsiCfg sent by DU
549 * Function : fillMultiCsiCfg
551 * Functionality: Function to fillMultiCsiCfg
553 * @params[in] PucchMultiCsiCfg pointer,
554 * SchPucchMultiCsiCfg pointer
557 * ****************************************************************/
559 void fillMultiCsiCfg(PucchMultiCsiCfg *macCsiCfg, SchPucchMultiCsiCfg *schCsiCfg)
563 schCsiCfg->multiCsiResrcListCount = macCsiCfg->multiCsiResrcListCount;
564 for(arrIdx =0; arrIdx < schCsiCfg->multiCsiResrcListCount; arrIdx++)
566 schCsiCfg->multiCsiResrcList[arrIdx] = macCsiCfg->multiCsiResrcList[arrIdx];
570 /*******************************************************************
572 * @brief Function to fillDlToUlAck sent by DU
576 * Function : fillDlToUlAck
578 * Functionality: Function to fillDlToUlAck
580 * @params[in] PucchDlDataToUlAck pointer,
581 * SchPucchDlDataToUlAck pointer
584 * ****************************************************************/
586 void fillDlToUlAck(PucchDlDataToUlAck *macUlAck, SchPucchDlDataToUlAck *schUlAck)
590 schUlAck->dlDataToUlAckListCount = macUlAck->dlDataToUlAckListCount;
591 for(arrIdx =0; arrIdx < macUlAck->dlDataToUlAckListCount; arrIdx++)
593 schUlAck->dlDataToUlAckList[arrIdx] = macUlAck->dlDataToUlAckList[arrIdx];
597 /*******************************************************************
599 * @brief Function to fillPucchPowerControl sent by DU
603 * Function : fillPucchPowerControl
605 * Functionality: Function to fillPucchPowerControl
607 * @params[in] PucchPowerControl pointer,
608 * SchPucchPowerControl pointer
611 * ****************************************************************/
613 void fillPucchPowerControl(PucchPowerControl *macPwrCtrl, SchPucchPowerControl *schPwrCtrl)
617 schPwrCtrl->deltaF_Format0 = macPwrCtrl->deltaF_Format0;
618 schPwrCtrl->deltaF_Format1 = macPwrCtrl->deltaF_Format1;
619 schPwrCtrl->deltaF_Format2 = macPwrCtrl->deltaF_Format2;
620 schPwrCtrl->deltaF_Format3 = macPwrCtrl->deltaF_Format3;
621 schPwrCtrl->deltaF_Format4 = macPwrCtrl->deltaF_Format4;
622 schPwrCtrl->p0SetCount = macPwrCtrl->p0SetCount;
623 for(arrIdx =0; arrIdx < macPwrCtrl->p0SetCount; arrIdx++)
625 schPwrCtrl->p0Set[arrIdx].p0PucchId = macPwrCtrl->p0Set[arrIdx].p0PucchId;
626 schPwrCtrl->p0Set[arrIdx].p0PucchVal = macPwrCtrl->p0Set[arrIdx].p0PucchVal;
628 schPwrCtrl->pathLossRefRSListCount = macPwrCtrl->pathLossRefRSListCount;
629 for(arrIdx = 0; arrIdx < macPwrCtrl->pathLossRefRSListCount; arrIdx++)
631 schPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
632 macPwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId;
636 /*******************************************************************
638 * @brief Function to fillOtherPucchFormatCfg sent by DU
642 * Function : fillOtherPucchFormatCfg
644 * Functionality: Function to fillOtherPucchFormatCfg
646 * @params[in] PucchFormat
647 * PucchFormatCfg pointer,
648 * SchPucchCfg pointer
651 * ****************************************************************/
653 uint8_t fillOtherPucchFormatCfg(uint8_t pucchFormat, PucchFormatCfg *macFormatCfg, SchPucchCfg *schPucchCfg)
662 MAC_ALLOC(schPucchCfg->format1, sizeof(SchPucchFormatCfg));
663 if(schPucchCfg->format1 == NULLP)
665 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 1 in fillOtherPucchFormatCfg()");
668 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format1);
676 MAC_ALLOC(schPucchCfg->format2, sizeof(SchPucchFormatCfg));
677 if(schPucchCfg->format2 == NULLP)
679 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 2 in fillOtherPucchFormatCfg()");
682 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format2);
690 MAC_ALLOC(schPucchCfg->format3, sizeof(SchPucchFormatCfg));
691 if(schPucchCfg->format3 == NULLP)
693 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 3 in fillOtherPucchFormatCfg()");
696 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format3);
704 MAC_ALLOC(schPucchCfg->format4, sizeof(SchPucchFormatCfg));
705 if(schPucchCfg->format4 == NULLP)
707 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Format 4 in fillOtherPucchFormatCfg()");
710 fillPucchFormatCfg(macFormatCfg, schPucchCfg->format4);
715 DU_LOG("\nERROR --> MAC : Invalid Format Cfg %d in fillInitialUlBwpPucchCfg()", pucchFormat);
721 /*******************************************************************
723 * @brief Fills PUCCH config in initial UL BWP config for SCH UE Cfg
727 * Function : fillInitalUlBwpPucchCfg
730 * Fills PUCCH cofig in initial UL BWP config for SCH UE Cfg
732 * @params[in] macPucchCfg : Initial UL-BWP PUCCH cfg at MAC
733 * schPucchCfg : Initial UL-BWP PUCCH cfg to be filled
734 * @return ROK - success
737 * ****************************************************************/
738 uint8_t fillInitialUlBwpPucchCfg(PucchCfg *macPucchCfg, SchPucchCfg *schPucchCfg)
740 if(macPucchCfg->resrcSet)
742 MAC_ALLOC(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
743 if(schPucchCfg->resrcSet == NULLP)
745 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc set List in fillInitialUlBwpPucchCfg()");
748 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
749 fillResrcSetList(macPucchCfg->resrcSet, schPucchCfg->resrcSet);
752 if(macPucchCfg->resrc)
754 MAC_ALLOC(schPucchCfg->resrc, sizeof(SchPucchResrcCfg));
755 if(schPucchCfg->resrc == NULLP)
757 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for Resrc List in fillInitialUlBwpPucchCfg()");
760 memset(schPucchCfg->resrc, 0, sizeof(SchPucchResrcCfg));
761 if((fillResrcList(macPucchCfg->resrc, schPucchCfg->resrc)) != ROK)
763 DU_LOG("\nERROR --> MAC : Failed in fillResrcList() at fillInitialUlBwpPucchCfg()");
768 /* valid for format 1, 2, 3, 4 */
769 fillOtherPucchFormatCfg(PUCCH_FORMAT_1, macPucchCfg->format1, schPucchCfg);
770 fillOtherPucchFormatCfg(PUCCH_FORMAT_2, macPucchCfg->format2, schPucchCfg);
771 fillOtherPucchFormatCfg(PUCCH_FORMAT_3, macPucchCfg->format3, schPucchCfg);
772 fillOtherPucchFormatCfg(PUCCH_FORMAT_4, macPucchCfg->format4, schPucchCfg);
774 if(macPucchCfg->schedReq)
776 MAC_ALLOC(schPucchCfg->schedReq, sizeof(SchPucchSchedReqCfg));
777 if(schPucchCfg->schedReq == NULLP)
779 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for PucchSchedReqCfg in fillInitialUlBwpPucchCfg()");
782 memset(schPucchCfg->schedReq, 0, sizeof(SchPucchSchedReqCfg));
783 fillPucchSchedReqCfg(macPucchCfg->schedReq, schPucchCfg->schedReq);
786 if(macPucchCfg->multiCsiCfg)
788 MAC_ALLOC(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
789 if(schPucchCfg->multiCsiCfg == NULLP)
791 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for multiCsiCfg in fillInitialUlBwpPucchCfg()");
794 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
795 fillMultiCsiCfg(macPucchCfg->multiCsiCfg, schPucchCfg->multiCsiCfg);
798 //TODO: To add the support for spatial Config
799 schPucchCfg->spatialInfo = NULLP;
801 if(macPucchCfg->dlDataToUlAck)
803 MAC_ALLOC(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
804 if(schPucchCfg->dlDataToUlAck == NULLP)
806 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for dlDataToUlAck in fillInitialUlBwpPucchCfg()");
809 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
810 fillDlToUlAck(macPucchCfg->dlDataToUlAck, schPucchCfg->dlDataToUlAck);
814 if(macPucchCfg->powerControl)
816 MAC_ALLOC(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
817 if(schPucchCfg->powerControl == NULLP)
819 DU_LOG("\nERROR --> MAC : Failed to allocate Mem for powerControl in fillInitialUlBwpPucchCfg()");
822 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
823 fillPucchPowerControl(macPucchCfg->powerControl, schPucchCfg->powerControl);
829 /*******************************************************************
831 * @brief function to free Pucch Format
835 * Function : freeSchPucchFormat
838 * function to free Pucch Format
840 * @params[in] pucchFormat, SchPucchResrcInfo Pointer,
841 * SchPucchResrcInfo pointer
843 * ****************************************************************/
845 void freeSchPucchFormat(uint8_t pucchFormat, SchPucchResrcInfo *resrcInfo, SchPucchFormatCfg *formatCfg)
849 case PUCCH_FORMAT_0 :
850 if(resrcInfo->SchPucchFormat.format0)
852 MAC_FREE(resrcInfo->SchPucchFormat.format0, sizeof(SchPucchFormat0));
853 resrcInfo->SchPucchFormat.format0 = NULLP;
857 case PUCCH_FORMAT_1 :
858 if(resrcInfo->SchPucchFormat.format1)
860 MAC_FREE(resrcInfo->SchPucchFormat.format1, sizeof(SchPucchFormat1));
861 resrcInfo->SchPucchFormat.format1 = NULLP;
865 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
866 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
870 case PUCCH_FORMAT_2 :
871 if(resrcInfo->SchPucchFormat.format2)
873 MAC_FREE(resrcInfo->SchPucchFormat.format2, sizeof(SchPucchFormat2_3));
874 resrcInfo->SchPucchFormat.format2 = NULLP;
878 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
879 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
883 case PUCCH_FORMAT_3 :
884 if(resrcInfo->SchPucchFormat.format3)
886 MAC_FREE(resrcInfo->SchPucchFormat.format3, sizeof(SchPucchFormat2_3));
887 resrcInfo->SchPucchFormat.format3 = NULLP;
891 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
892 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
896 case PUCCH_FORMAT_4 :
897 if(resrcInfo->SchPucchFormat.format4)
899 MAC_FREE(resrcInfo->SchPucchFormat.format4, sizeof(SchPucchFormat4));
900 resrcInfo->SchPucchFormat.format4 = NULLP;
904 memset(formatCfg, 0, sizeof(SchPucchFormatCfg));
905 MAC_FREE(formatCfg, sizeof(SchPucchFormatCfg));
914 /*******************************************************************
916 * @brief function to free Pucch Resrc Cfg
920 * Function : freePucchResrcCfg
923 * function to free Pucch Resrc Cfg
925 * @params[in] SchPucchResrcCfg pointer,
927 * ****************************************************************/
929 void freePucchResrcCfg(SchPucchResrcCfg *schRsrcList)
933 /* free Resrc To AddMod List */
934 for(resrcIdx = 0; resrcIdx < schRsrcList->resrcToAddModListCount; resrcIdx++)
936 freeSchPucchFormat(schRsrcList->resrcToAddModList[resrcIdx].pucchFormat,
937 &schRsrcList->resrcToAddModList[resrcIdx], NULLP);
938 memset(&schRsrcList->resrcToAddModList[resrcIdx], 0, sizeof(SchPucchResrcInfo));
940 memset(schRsrcList, 0, sizeof(SchPucchResrcCfg));
941 MAC_FREE(schRsrcList, sizeof(SchPucchResrcCfg));
944 /*******************************************************************
946 * @brief function to free Pucch Sched Req Cfg
950 * Function : freePucchSchedReqCfg
953 * function to free Pucch Sched Req Cfg
955 * @params[in] SchPucchSchedReqCfg pointer,
957 * ****************************************************************/
959 void freePucchSchedReqCfg(SchPucchSchedReqCfg *schedReqCfg)
963 for(schedReqIdx = 0; schedReqIdx < schedReqCfg->schedAddModListCount; schedReqIdx++)
965 memset(&schedReqCfg->schedAddModList[schedReqIdx], 0, sizeof(SchSchedReqResrcInfo));
967 memset(schedReqCfg, 0, sizeof(SchPucchSchedReqCfg));
968 MAC_FREE(schedReqCfg, sizeof(SchPucchSchedReqCfg));
971 /*******************************************************************
973 * @brief function to free Ul Bwp Pucch Cfg
977 * Function : freeUlBwpPucchCfg
980 * function to free Ul Bwp Pucch Cfg
982 * @params[in] SchPucchCfg pointer,
984 * ****************************************************************/
986 void freeUlBwpPucchCfg(SchPucchCfg *schPucchCfg)
988 if(schPucchCfg->resrcSet)
990 memset(schPucchCfg->resrcSet, 0, sizeof(SchPucchResrcSetCfg));
991 MAC_FREE(schPucchCfg->resrcSet, sizeof(SchPucchResrcSetCfg));
993 if(schPucchCfg->resrc)
995 freePucchResrcCfg(schPucchCfg->resrc);
997 if(schPucchCfg->format1)
999 freeSchPucchFormat(PUCCH_FORMAT_1, NULLP, schPucchCfg->format1);
1001 if(schPucchCfg->format2)
1003 freeSchPucchFormat(PUCCH_FORMAT_2, NULLP, schPucchCfg->format2);
1005 if(schPucchCfg->format3)
1007 freeSchPucchFormat(PUCCH_FORMAT_3, NULLP, schPucchCfg->format3);
1009 if(schPucchCfg->format4)
1011 freeSchPucchFormat(PUCCH_FORMAT_4, NULLP, schPucchCfg->format4);
1013 if(schPucchCfg->schedReq)
1015 freePucchSchedReqCfg(schPucchCfg->schedReq);
1017 if(schPucchCfg->spatialInfo)
1019 memset(schPucchCfg->spatialInfo, 0, sizeof(SchPucchSpatialCfg));
1020 MAC_FREE(schPucchCfg->spatialInfo, sizeof(SchPucchSpatialCfg));
1022 if(schPucchCfg->multiCsiCfg)
1024 memset(schPucchCfg->multiCsiCfg, 0, sizeof(SchPucchMultiCsiCfg));
1025 MAC_FREE(schPucchCfg->multiCsiCfg, sizeof(SchPucchMultiCsiCfg));
1027 if(schPucchCfg->dlDataToUlAck)
1029 memset(schPucchCfg->dlDataToUlAck, 0, sizeof(SchPucchDlDataToUlAck));
1030 MAC_FREE(schPucchCfg->dlDataToUlAck, sizeof(SchPucchDlDataToUlAck));
1032 if(schPucchCfg->powerControl)
1034 memset(schPucchCfg->powerControl, 0, sizeof(SchPucchPowerControl));
1035 MAC_FREE(schPucchCfg->powerControl, sizeof(SchPucchPowerControl));
1039 /*******************************************************************
1041 * @brief Fills initail UL BWP config to send to scheduler
1045 * Function : fillInitialUlBwp
1047 * Functionality: Fills initail UL BWP config to send to sch
1049 * @params[in] macInitUlBwp : Initial UL BWP cfg at MAC
1050 * schInitUlBwp : Initial UL BWP cfg to be filled
1051 * @return ROK - success
1054 * ****************************************************************/
1055 uint8_t fillInitialUlBwp(InitialUlBwp macInitUlBwp, SchInitialUlBwp *schInitUlBwp)
1057 schInitUlBwp->pucchCfgPres = macInitUlBwp.pucchPresent;
1058 if(schInitUlBwp->pucchCfgPres)
1060 memset(&schInitUlBwp->pucchCfg, 0, sizeof(SchPucchCfg));
1061 if(fillInitialUlBwpPucchCfg(&macInitUlBwp.pucchCfg, &schInitUlBwp->pucchCfg) != ROK)
1063 DU_LOG("\nERROR --> MAC : Failed to fill Pucch Cfg in fillInitialUlBwpPucchCfg()");
1064 freeUlBwpPucchCfg(&schInitUlBwp->pucchCfg);
1068 schInitUlBwp->puschCfgPres = macInitUlBwp.puschPresent;
1069 if(schInitUlBwp->puschCfgPres)
1071 memset(&schInitUlBwp->puschCfg, 0, sizeof(SchPuschCfg));
1072 if(fillInitalUlBwpPuschCfg(macInitUlBwp.puschCfg, &schInitUlBwp->puschCfg) != ROK)
1074 DU_LOG("\nERROR --> MAC : Failed to fill Pusch Cfg in fillInitalUlBwpPuschCfg()");
1081 /*******************************************************************
1083 * @brief Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1087 * Function : fillInitDlBwpPdcchCfg
1090 * Fill PDCCH cfg in Initial DL BWP for UE Cfg in Scheduler
1092 * @params[in] macPdcchCfg : Inital DL BWP PDCCH cfg in MAC
1093 * schPdcchCfg : Inital DL BWP PDCCH cfg to be filled
1094 * @return ROK - success
1097 * ****************************************************************/
1098 uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchCfg)
1102 /* Fill CORESET info */
1103 schPdcchCfg->numCRsetToAddMod = macPdcchCfg.numCRsetToAddMod;
1104 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1106 DU_LOG("\nERROR --> MAC : Number of CORESET to ADD/MOD [%d] exceeds max limit [%d]",\
1107 schPdcchCfg->numCRsetToAddMod, MAX_NUM_CRSET);
1111 for(idx = 0; idx < schPdcchCfg->numCRsetToAddMod; idx++)
1113 schPdcchCfg->cRSetToAddModList[idx].cRSetId = \
1114 macPdcchCfg.cRSetToAddModList[idx].cRSetId;
1115 memcpy(&schPdcchCfg->cRSetToAddModList[idx].freqDomainRsrc,\
1116 &macPdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
1117 schPdcchCfg->cRSetToAddModList[idx].duration = \
1118 macPdcchCfg.cRSetToAddModList[idx].duration;
1119 schPdcchCfg->cRSetToAddModList[idx].cceRegMappingType = \
1120 macPdcchCfg.cRSetToAddModList[idx].cceRegMappingType;
1121 schPdcchCfg->cRSetToAddModList[idx].precoderGranularity = \
1122 macPdcchCfg.cRSetToAddModList[idx].precoderGranularity;
1123 schPdcchCfg->cRSetToAddModList[idx].dmrsScramblingId = \
1124 macPdcchCfg.cRSetToAddModList[idx].dmrsScramblingId;
1127 schPdcchCfg->numCRsetToRel = macPdcchCfg.numCRsetToRel;
1128 if(schPdcchCfg->numCRsetToAddMod > MAX_NUM_CRSET)
1130 DU_LOG("\nERROR --> MAC : Number of CORESET to release [%d] exceeds max limit [%d]",\
1131 schPdcchCfg->numCRsetToRel, MAX_NUM_CRSET);
1135 for(idx = 0; idx < schPdcchCfg->numCRsetToRel; idx++)
1140 /* Fill Search space info */
1141 schPdcchCfg->numSearchSpcToAddMod = macPdcchCfg.numSearchSpcToAddMod;
1142 if(schPdcchCfg->numSearchSpcToAddMod > MAX_NUM_SEARCH_SPC)
1144 DU_LOG("\nERROR --> MAC : Number of search space to ADD/MOD [%d] exceeds max [%d]", \
1145 schPdcchCfg->numSearchSpcToAddMod, MAX_NUM_SEARCH_SPC);
1148 for(idx = 0; idx < schPdcchCfg->numSearchSpcToAddMod; idx++)
1150 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceId = \
1151 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
1152 schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
1153 macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
1154 schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
1155 macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
1156 memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
1157 &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
1158 MONITORING_SYMB_WITHIN_SLOT_SIZE);
1159 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1 = \
1160 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1;
1161 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2 = \
1162 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2;
1163 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4 = \
1164 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4;
1165 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8 = \
1166 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8;
1167 schPdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16 = \
1168 macPdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16;
1169 schPdcchCfg->searchSpcToAddModList[idx].searchSpaceType = \
1170 macPdcchCfg.searchSpcToAddModList[idx].searchSpaceType;
1171 schPdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat = \
1172 macPdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat;
1175 schPdcchCfg->numSearchSpcToRel = macPdcchCfg.numSearchSpcToRel;
1176 if(schPdcchCfg->numSearchSpcToRel > MAX_NUM_SEARCH_SPC)
1178 DU_LOG("\nERROR --> MAC : Number of search space to release [%d] exceeds max [%d]", \
1179 schPdcchCfg->numSearchSpcToRel, MAX_NUM_SEARCH_SPC);
1182 for(idx = 0; idx < schPdcchCfg->numSearchSpcToRel; idx++)
1190 /*******************************************************************
1192 * @brief Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1196 * Function : fillInitDlBwpPdschCfg
1199 * Fill PDSCH cfg in Initial DL BWP for UE Cfg in Scheduler
1201 * @params[in] macPdschCfg : Inital DL BWP PDSCH cfg at MAC
1202 * schPdschCfg : Inital DL BWP PDSCH cfg to be filled
1203 * @return ROK - success
1206 * ****************************************************************/
1207 uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschCfg)
1211 schPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
1212 macPdschCfg.dmrsDlCfgForPdschMapTypeA.addPos;
1213 schPdschCfg->resourceAllocType = macPdschCfg.resourceAllocType;
1214 schPdschCfg->numTimeDomRsrcAlloc = macPdschCfg.numTimeDomRsrcAlloc;
1215 if(schPdschCfg->numTimeDomRsrcAlloc > MAX_NUM_DL_ALLOC)
1217 DU_LOG("\nERROR --> MAC : Number of time domain resource allocation [%d], exceeds\
1218 max limit [%d]", schPdschCfg->numTimeDomRsrcAlloc, MAX_NUM_DL_ALLOC);
1222 for(idx = 0; idx < schPdschCfg->numTimeDomRsrcAlloc; idx++)
1224 if(macPdschCfg.timeDomRsrcAllociList[idx].k0)
1226 MAC_ALLOC(schPdschCfg->timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
1227 if(!schPdschCfg->timeDomRsrcAllociList[idx].k0)
1229 DU_LOG("\nERROR --> MAC : Memory allocation failed for K0 in fillInitDlBwpPdschCfg()");
1232 *(schPdschCfg->timeDomRsrcAllociList[idx].k0) = *(macPdschCfg.timeDomRsrcAllociList[idx].k0);
1234 schPdschCfg->timeDomRsrcAllociList[idx].mappingType = \
1235 macPdschCfg.timeDomRsrcAllociList[idx].mappingType;
1236 schPdschCfg->timeDomRsrcAllociList[idx].startSymbol = \
1237 macPdschCfg.timeDomRsrcAllociList[idx].startSymbol;
1238 schPdschCfg->timeDomRsrcAllociList[idx].symbolLength = \
1239 macPdschCfg.timeDomRsrcAllociList[idx].symbolLength;
1242 schPdschCfg->rbgSize = macPdschCfg.rbgSize;
1243 schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
1244 schPdschCfg->bundlingType = macPdschCfg.bundlingType;
1245 if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
1247 schPdschCfg->bundlingInfo.SchStaticBundling.size = macPdschCfg.bundlingInfo.StaticBundling.size;
1249 else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
1251 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
1252 schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
1257 /*******************************************************************
1259 * @brief Fill Initial DL BWP for SCH UE config
1263 * Function : fillInitialDlBwp
1265 * Functionality: Fill Initial DL BWP for SCH UE config
1267 * @params[in] macInitDlBwp : Inital DL BWP cfg at MAC
1268 * schInitDlBwp : Inital DL BWP cfg to be filled
1269 * @return ROK - success
1272 * ****************************************************************/
1273 uint8_t fillInitialDlBwp(InitialDlBwp macInitDlBwp, SchInitalDlBwp *schInitDlBwp)
1275 schInitDlBwp->pdcchCfgPres = macInitDlBwp.pdcchPresent;
1276 if(schInitDlBwp->pdcchCfgPres)
1278 if(fillInitDlBwpPdcchCfg(macInitDlBwp.pdcchCfg, &schInitDlBwp->pdcchCfg) != ROK)
1280 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdcchCfg() failed");
1285 schInitDlBwp->pdschCfgPres = macInitDlBwp.pdschPresent;
1286 if(schInitDlBwp->pdschCfgPres)
1288 if(fillInitDlBwpPdschCfg(macInitDlBwp.pdschCfg,&schInitDlBwp->pdschCfg) != ROK)
1290 DU_LOG("\nERROR --> MAC : fillInitDlBwpPdschCfg() failed");
1297 /*******************************************************************
1299 * @brief Fills Sp Cell config to be sent to scheduler
1303 * Function : fillSpCellCfg
1305 * Functionality: Fills Sp Cell config to be sent to scheduler
1307 * @params[in] macSpCellCfg : SP cell cfg at MAC
1308 * schSpCellCfg : SP cell cfg to be filled
1309 * @return ROK - success
1312 * ****************************************************************/
1313 uint8_t fillSpCellCfg(SpCellCfg macSpCellCfg, SchSpCellCfg *schSpCellCfg)
1316 SchServCellCfgInfo *servCellCfg;
1318 schSpCellCfg->servCellIdx = macSpCellCfg.servCellIdx;
1319 servCellCfg = &schSpCellCfg->servCellCfg;
1321 /* Fill initial DL BWP */
1322 if(fillInitialDlBwp(macSpCellCfg.servCellCfg.initDlBwp, \
1323 &servCellCfg->initDlBwp) != ROK )
1325 DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
1329 servCellCfg->numDlBwpToAdd = macSpCellCfg.servCellCfg.numDlBwpToAdd;
1330 if(servCellCfg->numDlBwpToAdd > MAX_NUM_BWP)
1332 DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1333 servCellCfg->numDlBwpToAdd, MAX_NUM_BWP);
1336 for(idx = 0; idx < servCellCfg->numDlBwpToAdd; idx++)
1338 /* TODO : As of now numDlBwpToAdd = 0 */
1341 servCellCfg->firstActvDlBwpId = macSpCellCfg.servCellCfg.firstActvDlBwpId;
1342 servCellCfg->defaultDlBwpId = macSpCellCfg.servCellCfg.defaultDlBwpId;
1343 servCellCfg->bwpInactivityTmr = NULL;
1344 if(macSpCellCfg.servCellCfg.bwpInactivityTmr)
1346 /* TODO : This is an optional parameter, not filled currently */
1349 /* Fill PDSCH serving cell config */
1350 if(fillPdschServCellCfg(macSpCellCfg.servCellCfg.pdschServCellCfg, \
1351 &servCellCfg->pdschServCellCfg) != ROK)
1353 DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
1357 /* Fill Initail UL BWP */
1358 if(fillInitialUlBwp(macSpCellCfg.servCellCfg.initUlBwp, \
1359 &servCellCfg->initUlBwp) != ROK)
1361 DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
1365 servCellCfg->numUlBwpToAdd = macSpCellCfg.servCellCfg.numUlBwpToAdd;
1366 if(servCellCfg->numUlBwpToAdd > MAX_NUM_BWP)
1368 DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
1369 servCellCfg->numUlBwpToAdd, MAX_NUM_BWP);
1372 for(idx = 0; idx < servCellCfg->numUlBwpToAdd; idx++)
1374 /* TODO : As of now numDlBwpToAdd = 0 */
1376 servCellCfg->firstActvUlBwpId = macSpCellCfg.servCellCfg.firstActvUlBwpId;
1381 /*******************************************************************
1383 * @brief Sends UE configuration to Scheduler
1387 * Function : sendUeReqToSch
1389 * Functionality: sends UE configuration to Scheduler
1391 * @params[in] Pst and Ue configuration
1392 * @return ROK - success
1395 * ****************************************************************/
1397 uint8_t sendUeReqToSch(Pst *pst, SchUeCfg *schUeCfg)
1402 case EVENT_MAC_UE_CREATE_REQ:
1403 FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
1404 return(*macSchAddUeConfigReqOpts[schPst.selector])(&schPst, schUeCfg);
1406 case EVENT_MAC_UE_RECONFIG_REQ:
1407 FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
1408 return(*macSchModUeConfigReqOpts[schPst.selector])(&schPst,schUeCfg);
1410 DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
1415 /*******************************************************************
1417 * @brief Fills Sch Drb Qos Information
1421 * Function : fillSchDrbQosInfo
1423 * Functionality: Fills Sch Drb Qos Information
1425 * @params[in] macLcCfg : Logical channel Cfg at MAC
1426 * schLcCfg : LC cfg to fill at scheduler
1427 * @return ROK - success
1430 * ****************************************************************/
1431 void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
1433 schDrbQos->fiveQiType = macDrbQos->fiveQiType;
1434 if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
1436 schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
1437 schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
1438 schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
1439 schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
1441 else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
1443 schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
1444 schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
1445 schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
1446 schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
1447 schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
1448 schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
1449 schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
1450 schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
1452 schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
1453 schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
1454 schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
1455 schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
1456 schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
1457 schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
1458 schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
1459 schDrbQos->pduSessionId = macDrbQos->pduSessionId;
1460 schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
1463 /*******************************************************************
1465 * @brief Fill SCH UL logical channel configuration
1469 * Function : fillSchUlLcCfg
1471 * Functionality: Fills Sch Ul Lc configuration
1473 * @params[in] macLcCfg : Logical channel Cfg at MAC
1474 * schLcCfg : LC cfg to fill at scheduler
1477 * ****************************************************************/
1479 void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
1481 schUlLcCfg->priority= macUlLcCfg->priority;
1482 schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
1483 schUlLcCfg->schReqId= macUlLcCfg->schReqId;
1484 schUlLcCfg->pbr = macUlLcCfg->pbr;
1485 schUlLcCfg->bsd = macUlLcCfg->bsd;
1488 /*******************************************************************
1490 * @brief Fill logical channel configuration
1494 * Function : fillLogicalChannelCfg
1496 * Functionality: Fill logical channel configuration
1498 * @params[in] macLcCfg : Logical channel Cfg at MAC
1499 * schLcCfg : LC cfg to fill at scheduler
1500 * @return ROK - success
1503 * ****************************************************************/
1504 uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
1508 schLcCfg->lcId = macLcCfg->lcId;
1509 schLcCfg->configType = macLcCfg->configType;
1510 schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
1511 fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
1513 if(macLcCfg->drbQos)
1515 if(!schLcCfg->drbQos)
1517 MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
1518 if(!schLcCfg->drbQos)
1520 DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
1526 fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
1533 schLcCfg->drbQos = NULLP;
1538 if(macLcCfg->snssai)
1540 if(!schLcCfg->snssai)
1542 MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
1543 if(!schLcCfg->snssai)
1545 DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
1551 schLcCfg->snssai->sst = macLcCfg->snssai->sst;
1552 for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
1554 schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
1560 schLcCfg->snssai = NULLP;
1567 /*******************************************************************
1569 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1573 * Function : fillSchLcCfgList
1575 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1577 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1578 * @return ROK - success
1581 * ****************************************************************/
1583 uint8_t fillSchLcCfgList(SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1587 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1589 if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
1591 DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
1599 /*******************************************************************
1601 * @brief Fills and sends UE configuration to Scheduler
1605 * Function : fillSchUeCfg
1607 * Functionality: Fills and sends UE configuration to Scheduler
1609 * @params[in] Ue configuration from DU APP
1610 * @return ROK - success
1613 * ****************************************************************/
1614 uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
1618 schUeCfg->cellId = ueCfg->cellId;
1619 schUeCfg->ueId = ueCfg->ueId;
1620 schUeCfg->crnti = ueCfg->crnti;
1621 schUeCfg->dataTransmissionInfo = ueCfg->transmissionAction;
1622 /* Copy MAC cell group config */
1623 if(ueCfg->macCellGrpCfgPres == true)
1625 schUeCfg->macCellGrpCfgPres = true;
1626 memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
1627 if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
1629 DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
1633 if(ueCfg->phyCellGrpCfgPres == true)
1635 schUeCfg->phyCellGrpCfgPres = true;
1636 /* Copy Physical cell group config */
1637 memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
1638 if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
1640 DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
1645 if(ueCfg->spCellCfgPres == true)
1647 schUeCfg->spCellCfgPres = true;
1648 /* Copy sp cell config */
1649 memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
1650 if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
1652 DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
1656 if(ueCfg->ambrCfg != NULLP)
1658 MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
1659 if(!schUeCfg->ambrCfg)
1661 DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
1664 schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
1668 schUeCfg->ambrCfg = NULLP;
1670 /* Fill DL modulation infor */
1671 schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
1672 schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
1673 schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
1675 /* Fill UL modulation infor */
1676 schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
1677 schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
1678 schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
1680 /* Fill sch Lc Cfg to Add/ Mod/ Del */
1681 ret = fillSchLcCfgList(schUeCfg, ueCfg);
1684 DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
1690 /*******************************************************************
1692 * @brief Update UeUlCb Lc List
1696 * Function : updateMacUlCb
1698 * Functionality: Update UeUlCb Lc List
1700 * @params[in] delIdx, UeUlCb pointer
1703 * ****************************************************************/
1705 void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
1709 for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
1711 /* Moving the array element to one step ahead */
1712 memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
1713 memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
1715 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1717 /*Checking the Memory Leakage of Last Index*/
1718 if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
1720 DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
1722 MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
1726 DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
1732 /*******************************************************************
1734 * @brief Update UeDlCb Lc List
1738 * Function : updateMacDlCb
1740 * Functionality: Update UeDlCb Lc List
1742 * @params[in] delIdx, UeDlCb pointer
1745 * ****************************************************************/
1747 void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
1751 for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
1753 /* Moving the array element to one step ahead */
1754 memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
1755 memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
1757 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1759 /*Checking the Memory Leakage of Last Index*/
1760 if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
1762 DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
1764 MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
1768 DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
1774 /*******************************************************************
1776 * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
1780 * Function : updateMacUlLcCtxt
1782 * Functionality: Update UeUlCb Lc List
1784 * @params[in] UeUlCb pointer, ueLcCfg(received from DUAPP)
1787 * ****************************************************************/
1788 void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg)
1790 uint8_t ueLcIdx = 0;
1792 /*Traversing UL LC to be updated/Deleted*/
1793 for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
1795 if(ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId)
1797 if(ueLcCfg->configType == CONFIG_MOD)
1799 /*Modify UL LC CB */
1800 ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
1802 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1804 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
1807 ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
1811 if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
1813 MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
1816 memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
1819 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
1820 ueLcCfg->lcId,ueLcIdx);
1823 if(ueLcCfg->configType == CONFIG_DEL)
1825 memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
1826 (ulInfo->numUlLc)--;
1827 updateMacUlCb(ueLcIdx, ulInfo);
1828 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueLcCfg->lcId);
1835 /*******************************************************************
1837 * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
1841 * Function : updateMacDlLcCtxt
1843 * Functionality: Update UeDlCb Lc List
1845 * @params[in] UeDlCb pointer, ueLcCfg(received from DUAPP)
1848 * ****************************************************************/
1849 void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg)
1851 uint8_t ueLcIdx = 0;
1853 /*Traversing DL LC to be updated/Deleted*/
1854 for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
1856 if(dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId)
1858 if(ueLcCfg->configType == CONFIG_MOD)
1860 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1862 /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
1865 dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
1869 if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
1871 MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
1874 memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
1877 DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
1878 ueLcCfg->lcId,ueLcIdx);
1881 if(ueLcCfg->configType == CONFIG_DEL)
1883 memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
1884 (dlInfo->numDlLc)--;
1885 updateMacDlCb(ueLcIdx, dlInfo);
1886 DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", ueLcCfg->lcId);
1892 /*******************************************************************
1894 * @brief Fills Logical channel Cfg List to Add/Mod/Del
1898 * Function : fillMacLcCfgList
1900 * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
1902 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1903 * @return ROK - success
1906 * ****************************************************************/
1908 uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
1912 for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
1914 if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
1916 if(ueCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1918 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
1920 /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
1921 if(ueCfg->lcCfgList[lcIdx].drbQos)
1923 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
1924 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
1926 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
1927 ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
1929 if(ueCfg->lcCfgList[lcIdx].snssai)
1931 if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
1933 MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
1935 if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
1937 MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
1940 memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
1941 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
1943 memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
1944 ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
1948 /*Filling DL LC CB */
1949 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1950 ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
1951 ueCb->dlInfo.numDlLc++;
1952 /*Filling UL LC CB */
1953 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
1954 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
1955 ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
1956 ueCb->ulInfo.numUlLc++;
1957 }/*End of Add Config */
1960 updateMacUlLcCtxt(&ueCb->ulInfo, &ueCfg->lcCfgList[lcIdx]);
1961 updateMacDlLcCtxt(&ueCb->dlInfo, &ueCfg->lcCfgList[lcIdx]);
1962 }/*End of Mod Config */
1968 /*******************************************************************
1970 * @brief Fills MAC UE Cb Cfg
1974 * Function : fillMacUeCb
1976 * Functionality: Fills MAC UE Cb Cfg
1978 * @params[in] MAC UE Cb Cfg , MAC UE Configuration
1980 * @return ROK - success
1983 * ****************************************************************/
1985 uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
1989 ueCb->ueId = ueCfg->ueId;
1990 ueCb->crnti = ueCfg->crnti;
1991 ueCb->cellCb = macCb.macCell[cellIdx];
1992 if(ueCfg->spCellCfgPres)
1994 ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
1995 ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
1998 /*TODO: To check the bsr value during implementation */
1999 if(ueCfg->macCellGrpCfgPres)
2001 ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
2002 ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
2003 ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
2005 ret = fillMacLcCfgList(ueCb, ueCfg);
2008 DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
2010 ueCb->transmissionAction = ueCfg->transmissionAction;
2015 /*******************************************************************
2017 * @brief Function to update Mac Ra Cb
2021 * Function : updateMacRaCb
2023 * Functionality: Function to update Mac Ra Cb
2025 * @params[in] cellIdx, Mac Ue Cb
2026 * @return ROK - success
2029 * ****************************************************************/
2031 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2034 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2036 ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
2040 DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
2046 /*******************************************************************
2048 * @brief Function to delete Mac Ra Cb
2052 * Function : deleteMacRaCb
2054 * Functionality: Function to delete Mac Ra Cb
2056 * @params[in] cellIdx, Mac Ue Cb
2059 * ****************************************************************/
2061 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
2064 MacRaCbInfo *raCb = ueCb->raCb;
2065 DlHarqProcCb *hqProcCb;
2067 if(raCb && (raCb->crnti == ueCb->crnti))
2069 hqProcCb = &raCb->msg4HqInfo;
2070 MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
2071 for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
2073 MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
2074 raCb->msg4HqInfo.tbInfo[tbIdx].tbSize);
2076 memset(raCb, 0, sizeof(MacRaCbInfo));
2080 /*******************************************************************
2082 * @brief Creates UE Cb
2086 * Function : createUeCb
2088 * Functionality: Creates UE Cb
2090 * @params[in] MAC UE Configuration
2091 * @return ROK - success
2094 * ****************************************************************/
2095 uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2098 uint8_t hqProcIdx = 0;
2100 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2101 &&(ueCb->state == UE_STATE_ACTIVE))
2103 DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
2108 memset(ueCb, 0, sizeof(MacUeCb));
2109 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2112 DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
2117 /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
2118 for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
2120 ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
2123 /* If UE has not requested for RACH yet, it means UE context is created for a
2125 if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
2127 ueCb->state = UE_STATE_ACTIVE;
2128 macCb.macCell[cellIdx]->numActvUe++;
2129 updateMacRaCb(cellIdx, ueCb);
2132 ueCb->state = UE_HANDIN_IN_PROGRESS;
2140 /*******************************************************************
2142 * @brief Modify UE Cb Cfg
2146 * Function : modifyUeCb
2148 * Functionality: modify UE Cb
2150 * @params[in] MAC UE Configuration
2151 * @return ROK - success
2154 * ****************************************************************/
2155 uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
2159 if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
2160 &&(ueCb->state == UE_STATE_ACTIVE))
2162 DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueCfg->crnti);
2163 ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
2166 DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
2178 /*******************************************************************
2180 * @brief Creates UE Cb and fills ueCfg
2184 * Function : procMacUeCfgData
2186 * Functionality: Creates UE Cb and fills ueCfg
2188 * @params[in] MAC UE Configuration
2189 * @return ROK - success
2192 * ****************************************************************/
2194 uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
2198 MacUeCb *ueCb = NULLP;
2201 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2203 /* Validate cell id */
2204 if(macCb.macCell[cellIdx]->cellId != ueCfg->cellId)
2206 DU_LOG("\nERROR --> MAC : Cell Id %d not configured", ueCfg->cellId);
2210 /* Check if max number of UE configured */
2211 if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
2213 DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
2217 /* Check if UE already configured */
2218 ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueId -1];
2222 case EVENT_UE_CONFIG_RSP_TO_MAC:
2224 ret = createUeCb(cellIdx, ueCb, ueCfg);
2226 DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
2230 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2232 ret = modifyUeCb(cellIdx, ueCb, ueCfg);
2234 DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
2245 /*******************************************************************
2247 * @brief Function to store the UeCfg Data
2251 * Function : copyToTmpData
2253 * Functionality: Function to store the UeCfg Data
2255 * @params[in] MacUeCfg pointer
2256 * @return ROK - success
2259 * ****************************************************************/
2261 uint8_t copyToTmpData(MacUeCfg *ueCfg)
2264 MacUeCfg *tmpData = NULLP;
2266 MAC_ALLOC(tmpData, sizeof(MacUeCfg));
2269 DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
2272 memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
2273 GET_CELL_IDX(ueCfg->cellId, cellIdx);
2274 macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
2278 /*******************************************************************
2280 * @brief Handles UE create requst from DU APP
2284 * Function : MacProcUeCreateReq
2286 * Functionality: Handles UE create requst from DU APP
2289 * @return ROK - success
2292 * ****************************************************************/
2293 uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
2297 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2299 DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
2303 /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
2304 * case of UE in handover */
2305 if(ueCfg->crnti == 0)
2307 GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
2310 /*Storing received ueCfg in ueCfgTmpData */
2311 ret = copyToTmpData(ueCfg);
2314 /*Sending Cfg Req to SCH */
2315 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2317 DU_LOG("\nERROR --> MAC : Failed to fill Sch Ue Cfg at MacProcUeCreateReq()");
2320 /* Fill event and send UE create request to SCH */
2321 ret = sendUeReqToSch(pst, &schUeCfg);
2323 DU_LOG("\nERROR --> MAC : Failed to send UE Create request to SCH");
2328 DU_LOG("\nERROR --> MAC : Failed to store MAC UE CFG ");
2333 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2336 /* FREE shared memory */
2337 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2342 /*******************************************************************
2344 * @brief Fill and Send UE create response from MAC to DU APP
2348 * Function : MacSendUeCreateRsp
2350 * Functionality: Fill and Send UE create response from MAC to DUAPP
2352 * @params[in] MAC UE create result
2353 * SCH UE create response
2354 * @return ROK - success
2357 * ****************************************************************/
2358 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2360 MacUeCfgRsp *cfgRsp;
2363 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2366 DU_LOG("\nERROR --> MAC: Memory allocation for UE config response failed");
2370 /* Filling UE Config response */
2371 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2372 cfgRsp->cellId = schCfgRsp->cellId;
2373 cfgRsp->ueId = schCfgRsp->ueId;
2374 cfgRsp->result = result;
2376 /* Fill Post structure and send UE Create response*/
2377 memset(&rspPst, 0, sizeof(Pst));
2378 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
2379 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2382 /*******************************************************************
2384 * @brief Fill and Send UE Reconfig response from MAC to DU APP
2388 * Function : MacSendUeReconfigRsp
2390 * Functionality: Fill and Send UE Reconfig response from MAC to DUAPP
2392 * @params[in] MAC UE create result
2393 * SCH UE create response
2394 * @return ROK - success
2397 * ****************************************************************/
2398 uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
2400 MacUeCfgRsp *cfgRsp;
2403 MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
2406 DU_LOG("\nERROR --> MAC: Memory allocation for UE Reconfig response failed");
2410 /* Filling UE Config response */
2411 memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
2412 cfgRsp->cellId = schCfgRsp->cellId;
2413 cfgRsp->ueId = schCfgRsp->ueId;
2414 cfgRsp->result = result;
2416 /* Fill Post structure and send UE Create response*/
2417 memset(&rspPst, 0, sizeof(Pst));
2418 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_RECONFIG_RSP);
2419 return (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp);
2422 /*******************************************************************
2424 * @brief Function to return Mac Ue Cfg pointer
2428 * Function : getMacUeCfg
2431 * Function to return Mac Ue Cfg pointer
2433 * @params[in] cellIdx, ueId
2435 * @return MacUeCfg pointer - success
2438 * ****************************************************************/
2440 MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
2442 MacUeCfg *ueCfg = NULLP;
2443 if(macCb.macCell[cellIdx])
2445 ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
2449 DU_LOG("\nERROR --> MAC: Failed to get macCellCb in getMacUeCfg()");
2454 /*******************************************************************
2456 * @brief Processes UE create response from scheduler
2460 * Function : MacProcSchUeCfgRsp
2463 * Processes UE create response from scheduler
2464 * Sends UE create response to DU APP
2466 * @params[in] Pst : Post structure
2467 * schCfgRsp : Scheduler UE cfg response
2468 * @return ROK - success
2471 * ****************************************************************/
2472 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
2474 uint8_t result = MAC_DU_APP_RSP_NOK;
2477 MacUeCfg *ueCfg = NULLP;
2479 #ifdef CALL_FLOW_DEBUG_LOG
2482 case EVENT_UE_CONFIG_RSP_TO_MAC:
2483 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_CONFIG_RSP_TO_MAC\n");
2485 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2486 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_RECONFIG_RSP_TO_MAC\n");
2489 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : Invalid Event\n");
2494 GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
2495 ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
2498 DU_LOG("\nERROR --> MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
2504 case EVENT_UE_CONFIG_RSP_TO_MAC:
2506 if(schCfgRsp->rsp != RSP_NOK)
2508 DU_LOG("\nINFO --> MAC: SCH UeConfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2511 ret = procMacUeCfgData(pst, ueCfg);
2514 result = MAC_DU_APP_RSP_OK;
2520 DU_LOG("\nERROR --> MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
2522 ret = MacSendUeCreateRsp(result, schCfgRsp);
2526 case EVENT_UE_RECONFIG_RSP_TO_MAC:
2529 if(schCfgRsp->rsp != RSP_NOK)
2531 DU_LOG("\nINFO --> MAC: SCH UeReconfigRsp for CRNTI[%d] is success in MacProcSchUeCfgRsp()",\
2535 ret = procMacUeCfgData(pst, ueCfg);
2538 result = MAC_DU_APP_RSP_OK;
2544 DU_LOG("\nERROR --> MAC: SCH UeReconfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()",\
2547 ret = MacSendUeReconfigRsp(result, schCfgRsp);
2551 MAC_FREE(ueCfg, sizeof(MacUeCfg));
2556 /*******************************************************************
2558 * @brief Handles UE Reconfig requst from DU APP
2562 * Function : MacProcUeReconfigReq
2564 * Functionality: Handles UE Reconfig requst from DU APP
2567 * @return ROK - success
2570 * ****************************************************************/
2571 uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
2575 memset(&schUeCfg, 0, sizeof(SchUeCfg));
2577 DU_LOG("\nINFO --> MAC : UE Reconfig Request for CRNTI[%d]", ueCfg->crnti);
2581 /*Storing received ueCfg in ueCfgTmpData */
2582 ret = copyToTmpData(ueCfg);
2585 /*Sending Cfg Req to SCH */
2586 ret = fillSchUeCfg(pst, &schUeCfg, ueCfg);
2588 DU_LOG("\nERROR --> MAC : Failed to fill sch Ue Cfg at MacProcUeReconfigReq()");
2591 /* Fill event and send UE create request to SCH */
2592 ret = sendUeReqToSch(pst, &schUeCfg);
2594 DU_LOG("\nERROR --> MAC : Failed to send UE Reconfig Request to SCH");
2599 DU_LOG("\nERROR --> MAC : Failed to store MAC UE Cb ");
2604 DU_LOG("\nERROR --> MAC : MAC UE Create request processing failed");
2607 /* FREE shared memory */
2608 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
2612 /*******************************************************************
2614 * @brief Fill and Send UE Delete response from MAC to DU APP
2618 * Function : MacSendUeDeleteRsp
2620 * Functionality: Fill and Send UE Delete response from MAC to DUAPP
2622 * @params[in] MAC UE delete result
2623 * SCH UE delete response
2624 * @return ROK - success
2627 * ****************************************************************/
2629 uint8_t MacSendUeDeleteRsp(uint16_t cellId, uint16_t crnti, UeDeleteStatus result)
2631 MacUeDeleteRsp *deleteRsp;
2634 MAC_ALLOC_SHRABL_BUF(deleteRsp, sizeof(MacUeDeleteRsp));
2637 DU_LOG("\nERROR --> MAC : Memory allocation for UE delete response failed");
2641 /* Filling UE delete response */
2642 deleteRsp->cellId = cellId;
2643 GET_UE_ID(crnti, deleteRsp->ueId);
2644 deleteRsp->result = result;
2646 /* Fill Post structure and send UE delete response*/
2647 memset(&rspPst, 0, sizeof(Pst));
2648 FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_DELETE_RSP);
2649 return (*macDuUeDeleteRspOpts[rspPst.selector])(&rspPst, deleteRsp);
2652 /*******************************************************************
2654 * @brief freeing the Pucch Resrc Cfg
2658 * Function : deletePucchResourcesCfg
2660 * Functionality: freeing the Pucch Resrc Cfg
2662 * @params[in] PucchResrcCfg *resrcCfg
2663 * @return ROK - success
2666 * ****************************************************************/
2668 void deletePucchResourcesCfg(PucchResrcCfg *resrcCfg)
2671 for(resrcIdx =0; resrcIdx< resrcCfg->resrcToAddModListCount;resrcIdx++)
2673 switch(resrcCfg->resrcToAddModList[resrcIdx].pucchFormat)
2675 case PUCCH_FORMAT_0:
2677 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format0, sizeof(PucchFormat0));
2680 case PUCCH_FORMAT_1:
2682 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format1, sizeof(PucchFormat1));
2685 case PUCCH_FORMAT_2:
2687 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
2690 case PUCCH_FORMAT_3:
2692 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
2695 case PUCCH_FORMAT_4:
2697 MAC_FREE(resrcCfg->resrcToAddModList[resrcIdx].PucchFormat.format4, sizeof(PucchFormat4));
2705 /*******************************************************************
2707 * @brief Processes UE delete response from scheduler
2711 * Function : MacProcSchUeCfgRsp
2714 * Processes UE create delete from scheduler
2716 * @params[in] Pst : Post structure
2717 * schUeDelRsp : Scheduler UE delete respons
2718 * @return ROK - success
2721 * ****************************************************************/
2723 uint8_t MacProcSchUeDeleteRsp(Pst *pst, SchUeDeleteRsp *schUeDelRsp)
2725 uint8_t ueId =0, isCrntiValid = 0;
2727 uint8_t ret = RFAILED;
2728 UeDeleteStatus result;
2730 #ifdef CALL_FLOW_DEBUG_LOG
2731 DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_UE_DELETE_RSP_TO_MAC\n");
2736 if(schUeDelRsp->rsp == RSP_OK)
2738 DU_LOG("\nINFO --> MAC : SCH UE Delete response for CRNTI[%d] is successful", schUeDelRsp->crnti);
2739 GET_CELL_IDX(schUeDelRsp->cellId, cellIdx);
2740 if(macCb.macCell[cellIdx])
2742 CHECK_CRNTI(schUeDelRsp->crnti, isCrntiValid);
2745 /*C-RNTI value is out of Acceptable range*/
2746 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): Invalid crnti[%d] ",schUeDelRsp->crnti);
2747 result = UEID_INVALID;
2751 GET_UE_ID(schUeDelRsp->crnti, ueId);
2752 if(macCb.macCell[cellIdx]->ueCb[ueId -1].crnti == schUeDelRsp->crnti)
2755 /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
2757 /*Looping around LCs to free S-NSSAI memory*/
2758 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.numUlLc); lcIdx++)
2760 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].ulInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
2762 for(lcIdx = 0; lcIdx < (macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.numDlLc); lcIdx++)
2764 MAC_FREE(macCb.macCell[cellIdx]->ueCb[ueId -1].dlInfo.lcCb[lcIdx].snssai, sizeof(Snssai));
2767 memset(&macCb.macCell[cellIdx]->ueCb[ueId -1], 0, sizeof(MacUeCb));
2768 macCb.macCell[cellIdx]->numActvUe--;
2774 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): crnti[%d] does not exist ",schUeDelRsp->crnti);
2775 result = UEID_INVALID;
2781 DU_LOG("\nERROR --> MAC : MacProcSchUeDeleteRsp(): cellId[%d] does not exist ",schUeDelRsp->cellId);
2782 result = CELLID_INVALID;
2787 result = (schUeDelRsp->cause == INVALID_CELLID) ? CELLID_INVALID : UEID_INVALID;
2789 if(MacSendUeDeleteRsp(schUeDelRsp->cellId, schUeDelRsp->crnti, result) != ROK)
2791 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to send UE delete response");
2796 DU_LOG("\nERROR --> MAC: MacProcSchUeDeleteRsp(): Failed to receive UE delete response by SCH");
2802 /*******************************************************************
2804 * @brief Sends UE delete req to Scheduler
2808 * Function : sendUeDelReqToSch
2810 * Functionality: sends UE delete req to Scheduler
2812 * @params[in] Pst *pst, MacUeDelete *ueDelete
2813 * @return ROK - success
2816 * ****************************************************************/
2818 uint8_t sendUeDelReqToSch(Pst *pst, MacUeDelete *ueDelete)
2820 if(ueDelete != NULLP)
2823 SchUeDelete schUeDel;
2825 memset(&schUeDel, 0, sizeof(SchUeDelete));
2826 schUeDel.cellId = ueDelete->cellId;
2827 schUeDel.crnti = ueDelete->crnti;
2828 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2829 FILL_PST_MAC_TO_SCH(schPst, EVENT_UE_DELETE_REQ_TO_SCH);
2830 return(*macSchUeDeleteReqOpts[schPst.selector])(&schPst, &schUeDel);
2834 DU_LOG("\nERROR --> SCH: sendUeDelReqToSch():MAC Ue Delete is NULL");
2840 /*******************************************************************
2842 * @brief Handles UE Delete requst from DU APP
2846 * Function : MacProcUeDeleteReq
2848 * Functionality: Handles UE Delete requst from DU APP
2850 * @params[in] Pst *pst, MacUeDelete *ueDelete
2851 * @return ROK - success
2854 * ****************************************************************/
2856 uint8_t MacProcUeDeleteReq(Pst *pst, MacUeDelete *ueDelete)
2860 UeDeleteStatus result=SUCCESS;
2861 MacUeCb *ueCb = NULLP;
2862 MacCellCb *cellCb = NULLP;
2864 DU_LOG("\nINFO --> MAC : UE Delete Request received for ueId[%d]", ueDelete->ueId);
2868 GET_CELL_IDX(ueDelete->cellId, cellIdx);
2869 cellCb = macCb.macCell[cellIdx];
2872 ueCb = &cellCb->ueCb[ueDelete->ueId-1];
2873 if(ueCb->crnti == ueDelete->crnti)
2875 ret = sendUeDelReqToSch(pst, ueDelete);
2878 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to send UE Delete Request to SCH");
2884 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): CRNTI is not matched");
2885 result = UEID_INVALID;
2890 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): Failed to find the MacUeCb of UeId = %d",ueDelete->ueId);
2891 result = CELLID_INVALID;
2894 if(result != SUCCESS)
2896 MacSendUeDeleteRsp(ueDelete->cellId, ueDelete->crnti, result);
2897 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueDelete, sizeof(MacUeDelete));
2903 DU_LOG("\nERROR --> MAC : MacProcUeDeleteReq(): MAC UE delete request processing failed");
2909 /**********************************************************************
2911 **********************************************************************/